Commands.cpp 367 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include "Commands.h"
  18. #include "../ClientPacketFunctions.h"
  19. #include "../../common/version.h"
  20. #include "../../common/seperator.h"
  21. #include "../../common/servertalk.h"
  22. #include "../WorldDatabase.h"
  23. #include "../World.h"
  24. #include "../../common/ConfigReader.h"
  25. #include "../VisualStates.h"
  26. #include "../../common/debug.h"
  27. #include "../LuaInterface.h"
  28. #include "../Quests.h"
  29. #include "../client.h"
  30. #include "../NPC.h"
  31. #include "../Guilds/Guild.h"
  32. #include "../SpellProcess.h"
  33. #include "../Tradeskills/Tradeskills.h"
  34. #include "../../common/Log.h"
  35. #include "../../common/MiscFunctions.h"
  36. #include "../Languages.h"
  37. #include "../IRC/IRC.h"
  38. #include "../Traits/Traits.h"
  39. #include "../Chat/Chat.h"
  40. #include "../Rules/Rules.h"
  41. #include "../AltAdvancement/AltAdvancement.h"
  42. #include "../RaceTypes/RaceTypes.h"
  43. #include "../classes.h"
  44. #include "../Transmute.h"
  45. #include "../Zone/SPGrid.h"
  46. extern WorldDatabase database;
  47. extern MasterSpellList master_spell_list;
  48. extern MasterTraitList master_trait_list;
  49. extern MasterRecipeList master_recipe_list;
  50. extern MasterRecipeBookList master_recipebook_list;
  51. extern World world;
  52. extern ClientList client_list;
  53. extern ConfigReader configReader;
  54. extern VisualStates visual_states;
  55. extern ZoneList zone_list;
  56. extern LuaInterface* lua_interface;
  57. extern MasterQuestList master_quest_list;
  58. extern MasterCollectionList master_collection_list;
  59. extern MasterSkillList master_skill_list;
  60. extern MasterFactionList master_faction_list;
  61. extern GuildList guild_list;
  62. extern MasterLanguagesList master_languages_list;
  63. extern IRC irc;
  64. extern Chat chat;
  65. extern RuleManager rule_manager;
  66. extern MasterAAList master_aa_list;
  67. extern MasterRaceTypeList race_types_list;
  68. extern Classes classes;
  69. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  70. #if defined(__GNUC__)
  71. #define stricmp strcasecmp
  72. #define strnicmp strncasecmp
  73. #endif
  74. EQ2Packet* RemoteCommands::serialize(){
  75. buffer.clear();
  76. vector<EQ2_RemoteCommandString>::iterator command_list;
  77. buffer.append((char*)&num_commands, sizeof(int16));
  78. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  79. AddDataCommand(&(*command_list));
  80. }
  81. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  82. return app;
  83. }
  84. Commands::Commands(){
  85. remote_commands = new RemoteCommands();
  86. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  87. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  88. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  89. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  90. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  91. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  92. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  93. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  94. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  95. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  96. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  97. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  98. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  99. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  100. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  101. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  102. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  103. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  104. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  105. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  106. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  107. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  108. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  109. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  110. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  111. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  112. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  113. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  114. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  115. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  116. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  117. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  118. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  119. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  120. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  121. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  122. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  123. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  124. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  125. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  126. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  127. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  128. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  129. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  130. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  131. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  132. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  133. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  134. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  135. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  136. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  137. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  138. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  139. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  140. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  141. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  142. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  143. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  144. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  145. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  146. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  147. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  148. spawn_set_values["skin_color"] = SPAWN_SET_SKIN_COLOR;
  149. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  150. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  151. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  152. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  153. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  154. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  155. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  156. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  157. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  158. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  159. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  160. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  161. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  162. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  163. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  164. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  165. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  166. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  167. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  168. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  169. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  170. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  171. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  172. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  173. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  174. }
  175. Commands::~Commands() {
  176. safe_delete(remote_commands);
  177. }
  178. int32 Commands::GetSpawnSetType(string val){
  179. if(spawn_set_values.count(val) > 0)
  180. return spawn_set_values[val];
  181. return 0xFFFFFFFF;
  182. }
  183. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  184. if(!target)
  185. return false;
  186. int32 val = 0;
  187. try{
  188. if(type != SPAWN_SET_VALUE_NAME &&
  189. !(type >= SPAWN_SET_VALUE_SPAWN_SCRIPT && type <= SPAWN_SET_VALUE_SUB_TITLE) && !(type >= SPAWN_SET_VALUE_PREFIX && type <= SPAWN_SET_VALUE_EXPANSION_FLAG || type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  190. && type != SPAWN_SET_SKIN_COLOR)
  191. val = atoul(value);
  192. }
  193. catch(...){
  194. if(client)
  195. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  196. return false;
  197. }
  198. if(temporary){
  199. char tmp[128] = {0};
  200. switch(type){
  201. case SPAWN_SET_VALUE_NAME:{
  202. sprintf(tmp, "%s", target->GetName());
  203. target->SetName(value);
  204. client->GetCurrentZone()->SendUpdateTitles(target);
  205. break;
  206. }
  207. case SPAWN_SET_VALUE_X_OFFSET:
  208. {
  209. sprintf(tmp, "%f", target->GetXOffset());
  210. target->SetXOffset(float(val));
  211. break;
  212. }
  213. case SPAWN_SET_VALUE_Y_OFFSET:
  214. {
  215. sprintf(tmp, "%f", target->GetYOffset());
  216. target->SetYOffset(float(val));
  217. break;
  218. }
  219. case SPAWN_SET_VALUE_Z_OFFSET:
  220. {
  221. sprintf(tmp, "%f", target->GetZOffset());
  222. target->SetZOffset(float(val));
  223. break;
  224. }
  225. case SPAWN_SET_VALUE_EXPIRE: {
  226. sprintf(tmp, "%u", target->GetExpireTime());
  227. target->SetExpireTime(val);
  228. break;
  229. }
  230. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  231. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  232. target->SetExpireOffsetTime(val);
  233. break;
  234. }
  235. case SPAWN_SET_VALUE_SUB_TITLE: {
  236. sprintf(tmp, "%s", target->GetSubTitle());
  237. target->SetSubTitle(value);
  238. client->GetCurrentZone()->SendUpdateTitles(target);
  239. break;
  240. }
  241. case SPAWN_SET_VALUE_LEVEL:{
  242. sprintf(tmp, "%i", target->GetLevel());
  243. target->SetLevel(val, send_update);
  244. break;
  245. }
  246. case SPAWN_SET_VALUE_DIFFICULTY:{
  247. sprintf(tmp, "%i", target->GetEncounterLevel());
  248. target->SetEncounterLevel(val, send_update);
  249. break;
  250. }
  251. case SPAWN_SET_VALUE_MODEL_TYPE:{
  252. sprintf(tmp, "%i", target->GetModelType());
  253. target->SetModelType(val, send_update);
  254. break;
  255. }
  256. case SPAWN_SET_VALUE_CLASS:{
  257. sprintf(tmp, "%i", target->GetAdventureClass());
  258. target->SetAdventureClass(val, send_update);
  259. break;
  260. }
  261. case SPAWN_SET_VALUE_GENDER:{
  262. sprintf(tmp, "%i", target->GetGender());
  263. target->SetGender(val, send_update);
  264. break;
  265. }
  266. case SPAWN_SET_VALUE_SHOW_NAME:{
  267. sprintf(tmp, "%i", target->GetShowName());
  268. target->SetShowName(val, send_update);
  269. break;
  270. }
  271. case SPAWN_SET_VALUE_ATTACKABLE:{
  272. sprintf(tmp, "%i", target->GetAttackable());
  273. target->SetAttackable(val, send_update);
  274. break;
  275. }
  276. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  277. sprintf(tmp, "%i", target->GetShowLevel());
  278. target->SetShowLevel(val, send_update);
  279. break;
  280. }
  281. case SPAWN_SET_VALUE_TARGETABLE:{
  282. sprintf(tmp, "%i", target->GetTargetable());
  283. target->SetTargetable(val, send_update);
  284. break;
  285. }
  286. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  287. sprintf(tmp, "%i", target->GetShowCommandIcon());
  288. target->SetShowCommandIcon(val, send_update);
  289. break;
  290. }
  291. case SPAWN_SET_VALUE_HAND_ICON:{
  292. sprintf(tmp, "%i", target->GetShowHandIcon());
  293. target->SetShowHandIcon(val, send_update);
  294. break;
  295. }
  296. case SPAWN_SET_VALUE_HAIR_TYPE:{
  297. if(target->IsEntity()){
  298. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  299. ((Entity*)target)->SetHairType(val, send_update);
  300. }
  301. break;
  302. }
  303. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  304. if(target->IsEntity()){
  305. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  306. ((Entity*)target)->SetHairType(val, send_update);
  307. }
  308. break;
  309. }
  310. case SPAWN_SET_VALUE_WING_TYPE:{
  311. if(target->IsEntity()){
  312. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  313. ((Entity*)target)->SetWingType(val, send_update);
  314. }
  315. break;
  316. }
  317. case SPAWN_SET_VALUE_CHEST_TYPE:{
  318. if(target->IsEntity()){
  319. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  320. ((Entity*)target)->SetChestType(val, send_update);
  321. }
  322. break;
  323. }
  324. case SPAWN_SET_VALUE_LEGS_TYPE:{
  325. if(target->IsEntity()){
  326. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  327. ((Entity*)target)->SetLegsType(val, send_update);
  328. }
  329. break;
  330. }
  331. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  332. if(target->IsEntity()){
  333. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  334. ((Entity*)target)->SetSogaHairType(val, send_update);
  335. }
  336. break;
  337. }
  338. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  339. if(target->IsEntity()){
  340. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  341. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  342. }
  343. break;
  344. }
  345. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  346. sprintf(tmp, "%i", target->GetSogaModelType());
  347. target->SetSogaModelType(val, send_update);
  348. break;
  349. }
  350. case SPAWN_SET_VALUE_SIZE:{
  351. sprintf(tmp, "%i", target->GetSize());
  352. target->SetSize(val, send_update);
  353. break;
  354. }
  355. case SPAWN_SET_VALUE_HP:{
  356. sprintf(tmp, "%i", target->GetHP());
  357. target->SetHP(val, send_update);
  358. break;
  359. }
  360. case SPAWN_SET_VALUE_POWER:{
  361. sprintf(tmp, "%i", target->GetPower());
  362. target->SetPower(val, send_update);
  363. break;
  364. }
  365. case SPAWN_SET_VALUE_HEROIC:{
  366. sprintf(tmp, "%i", target->GetHeroic());
  367. target->SetHeroic(val, send_update);
  368. break;
  369. }
  370. case SPAWN_SET_VALUE_RESPAWN:{
  371. sprintf(tmp, "%u", target->GetRespawnTime());
  372. target->SetRespawnTime(val);
  373. break;
  374. }
  375. case SPAWN_SET_VALUE_X:{
  376. sprintf(tmp, "%f", target->GetX());
  377. target->SetX(atof(value), send_update);
  378. break;
  379. }
  380. case SPAWN_SET_VALUE_Y:{
  381. sprintf(tmp, "%f", target->GetY());
  382. target->SetY(atof(value), send_update);
  383. break;
  384. }
  385. case SPAWN_SET_VALUE_Z:{
  386. sprintf(tmp, "%f", target->GetZ());
  387. target->SetZ(atof(value), send_update);
  388. break;
  389. }
  390. case SPAWN_SET_VALUE_HEADING:{
  391. sprintf(tmp, "%f", target->GetHeading());
  392. target->SetHeading(atof(value) + 360, send_update);
  393. break;
  394. }
  395. case SPAWN_SET_VALUE_VISUAL_STATE:{
  396. sprintf(tmp, "%i", target->GetVisualState());
  397. target->SetVisualState(val, send_update);
  398. break;
  399. }
  400. case SPAWN_SET_VALUE_ACTION_STATE:{
  401. sprintf(tmp, "%i", target->GetActionState());
  402. target->SetActionState(val, send_update);
  403. break;
  404. }
  405. case SPAWN_SET_VALUE_MOOD_STATE:{
  406. sprintf(tmp, "%i", target->GetMoodState());
  407. target->SetMoodState(val, send_update);
  408. break;
  409. }
  410. case SPAWN_SET_VALUE_INITIAL_STATE:{
  411. sprintf(tmp, "%i", target->GetInitialState());
  412. target->SetInitialState(val, send_update);
  413. break;
  414. }
  415. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  416. sprintf(tmp, "%i", target->GetActivityStatus());
  417. target->SetActivityStatus(val, send_update);
  418. break;
  419. }
  420. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  421. sprintf(tmp, "%i", target->GetCollisionRadius());
  422. target->SetCollisionRadius(val, send_update);
  423. break;
  424. }
  425. case SPAWN_SET_VALUE_DEVICE_ID: {
  426. if (target->IsObject()) {
  427. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  428. ((Object*)target)->SetDeviceID(val);
  429. }
  430. break;
  431. }
  432. case SPAWN_SET_VALUE_PITCH: {
  433. sprintf(tmp, "%f", target->GetPitch());
  434. target->SetPitch(atof(value), send_update);
  435. break;
  436. }
  437. case SPAWN_SET_VALUE_ROLL: {
  438. sprintf(tmp, "%f", target->GetRoll());
  439. target->SetRoll(atof(value), send_update);
  440. break;
  441. }
  442. case SPAWN_SET_VALUE_HIDE_HOOD: {
  443. sprintf(tmp, "%i", target->appearance.hide_hood);
  444. target->SetHideHood(val);
  445. break;
  446. }
  447. case SPAWN_SET_VALUE_EMOTE_STATE: {
  448. sprintf(tmp, "%i", target->appearance.emote_state);
  449. target->SetEmoteState(val);
  450. break;
  451. }
  452. case SPAWN_SET_VALUE_ICON: {
  453. sprintf(tmp, "%i", target->GetIconValue());
  454. target->SetIcon(val);
  455. break;
  456. }
  457. case SPAWN_SET_VALUE_PREFIX: {
  458. sprintf(tmp, "%s", target->GetPrefixTitle());
  459. target->SetPrefixTitle(value);
  460. client->GetCurrentZone()->SendUpdateTitles(target);
  461. break;
  462. }
  463. case SPAWN_SET_VALUE_SUFFIX: {
  464. sprintf(tmp, "%s", target->GetSuffixTitle());
  465. target->SetSuffixTitle(value);
  466. client->GetCurrentZone()->SendUpdateTitles(target);
  467. break;
  468. }
  469. case SPAWN_SET_VALUE_LASTNAME: {
  470. sprintf(tmp, "%s", target->GetLastName());
  471. target->SetLastName(value);
  472. client->GetCurrentZone()->SendUpdateTitles(target);
  473. break;
  474. }
  475. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  476. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  477. // nothing to do must reload spawns
  478. break;
  479. }
  480. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  481. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  482. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  483. break;
  484. }
  485. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  486. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  487. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  488. break;
  489. }
  490. case SPAWN_SET_SKIN_COLOR: {
  491. if (target->IsNPC())
  492. {
  493. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  494. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  495. {
  496. EQ2_Color clr;
  497. clr.red = atoul(skinsep->arg[0]);
  498. clr.green = atoul(skinsep->arg[1]);
  499. clr.blue = atoul(skinsep->arg[2]);
  500. ((Entity*)target)->SetSkinColor(clr);
  501. }
  502. safe_delete(skinsep);
  503. }
  504. break;
  505. }
  506. if(temp_value)
  507. *temp_value = string(tmp);
  508. }
  509. }
  510. else{
  511. switch(type){
  512. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  513. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  514. break;
  515. }
  516. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  517. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  518. break;
  519. }
  520. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  521. if (target->GetDatabaseID() > 0)
  522. {
  523. char query[256];
  524. snprintf(query, 256, "update spawn set expansion_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  525. if (database.RunQuery(query, strnlen(query, 256)))
  526. {
  527. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  528. }
  529. }
  530. break;
  531. }
  532. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  533. if (target->GetDatabaseID() > 0)
  534. {
  535. char query[256];
  536. snprintf(query, 256, "update spawn set holiday_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  537. if (database.RunQuery(query, strnlen(query, 256)))
  538. {
  539. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  540. }
  541. }
  542. break;
  543. }
  544. case SPAWN_SET_VALUE_NAME:{
  545. target->SetName(value);
  546. client->GetCurrentZone()->SendUpdateTitles(target);
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_SUB_TITLE: {
  550. target->SetSubTitle(value);
  551. client->GetCurrentZone()->SendUpdateTitles(target);
  552. break;
  553. }
  554. case SPAWN_SET_VALUE_X_OFFSET:
  555. {
  556. target->SetXOffset(atof(value));
  557. break;
  558. }
  559. case SPAWN_SET_VALUE_Y_OFFSET:
  560. {
  561. target->SetYOffset(atof(value));
  562. break;
  563. }
  564. case SPAWN_SET_VALUE_Z_OFFSET:
  565. {
  566. target->SetZOffset(atof(value));
  567. break;
  568. }
  569. case SPAWN_SET_VALUE_EXPIRE: {
  570. target->SetExpireTime(val);
  571. break;
  572. }
  573. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  574. target->SetExpireOffsetTime(val);
  575. break;
  576. }
  577. case SPAWN_SET_VALUE_LEVEL:{
  578. target->SetLevel(val, send_update);
  579. break;
  580. }
  581. case SPAWN_SET_VALUE_DIFFICULTY:{
  582. target->SetEncounterLevel(val, send_update);
  583. break;
  584. }
  585. case SPAWN_SET_VALUE_MODEL_TYPE:{
  586. target->SetModelType(val, send_update);
  587. break;
  588. }
  589. case SPAWN_SET_VALUE_CLASS:{
  590. target->SetAdventureClass(val, send_update);
  591. break;
  592. }
  593. case SPAWN_SET_VALUE_GENDER:{
  594. target->SetGender(val, send_update);
  595. break;
  596. }
  597. case SPAWN_SET_VALUE_SHOW_NAME:{
  598. target->SetShowName(val, send_update);
  599. break;
  600. }
  601. case SPAWN_SET_VALUE_ATTACKABLE:{
  602. target->SetAttackable(val, send_update);
  603. break;
  604. }
  605. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  606. target->SetShowLevel(val, send_update);
  607. break;
  608. }
  609. case SPAWN_SET_VALUE_TARGETABLE:{
  610. target->SetTargetable(val, send_update);
  611. break;
  612. }
  613. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  614. target->SetShowCommandIcon(val, send_update);
  615. break;
  616. }
  617. case SPAWN_SET_VALUE_HAND_ICON:{
  618. target->SetShowHandIcon(val, send_update);
  619. break;
  620. }
  621. case SPAWN_SET_VALUE_HAIR_TYPE:{
  622. if(target->IsEntity())
  623. ((Entity*)target)->SetHairType(val, send_update);
  624. break;
  625. }
  626. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  627. if(target->IsEntity())
  628. ((Entity*)target)->SetHairType(val, send_update);
  629. break;
  630. }
  631. case SPAWN_SET_VALUE_WING_TYPE:{
  632. if(target->IsEntity())
  633. ((Entity*)target)->SetWingType(val, send_update);
  634. break;
  635. }
  636. case SPAWN_SET_VALUE_CHEST_TYPE:{
  637. if(target->IsEntity())
  638. ((Entity*)target)->SetChestType(val, send_update);
  639. break;
  640. }
  641. case SPAWN_SET_VALUE_LEGS_TYPE:{
  642. if(target->IsEntity())
  643. ((Entity*)target)->SetLegsType(val, send_update);
  644. break;
  645. }
  646. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  647. if(target->IsEntity())
  648. ((Entity*)target)->SetSogaHairType(val, send_update);
  649. break;
  650. }
  651. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  652. if(target->IsEntity())
  653. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  654. break;
  655. }
  656. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  657. target->SetSogaModelType(val, send_update);
  658. break;
  659. }
  660. case SPAWN_SET_VALUE_SIZE:{
  661. target->SetSize(val, send_update);
  662. break;
  663. }
  664. case SPAWN_SET_VALUE_HP:{
  665. target->SetHP(val, send_update);
  666. break;
  667. }
  668. case SPAWN_SET_VALUE_POWER:{
  669. target->SetPower(val, send_update);
  670. break;
  671. }
  672. case SPAWN_SET_VALUE_HEROIC:{
  673. target->SetHeroic(val, send_update);
  674. break;
  675. }
  676. case SPAWN_SET_VALUE_RESPAWN:{
  677. target->SetRespawnTime(val);
  678. break;
  679. }
  680. case SPAWN_SET_VALUE_X:{
  681. target->SetX(atof(value), send_update);
  682. target->SetSpawnOrigX(target->GetX());
  683. break;
  684. }
  685. case SPAWN_SET_VALUE_Y:{
  686. target->SetY(atof(value), send_update);
  687. target->SetSpawnOrigY(target->GetY());
  688. break;
  689. }
  690. case SPAWN_SET_VALUE_Z:{
  691. target->SetZ(atof(value), send_update);
  692. target->SetSpawnOrigZ(target->GetZ());
  693. break;
  694. }
  695. case SPAWN_SET_VALUE_HEADING:{
  696. target->SetHeading(atof(value), send_update);
  697. target->SetSpawnOrigHeading(target->GetHeading());
  698. break;
  699. }
  700. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  701. ZoneServer* zone = target->GetZone();
  702. if (!zone)
  703. zone = client->GetCurrentZone();
  704. if(zone->GetEntityCommandList(val))
  705. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  706. target->primary_command_list_id = val;
  707. break;
  708. }
  709. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  710. ZoneServer* zone = target->GetZone();
  711. if (!zone)
  712. zone = client->GetCurrentZone();
  713. if (zone->GetEntityCommandList(val))
  714. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  715. target->secondary_command_list_id = val;
  716. break;
  717. }
  718. case SPAWN_SET_VALUE_VISUAL_STATE:{
  719. target->SetVisualState(val, send_update);
  720. break;
  721. }
  722. case SPAWN_SET_VALUE_ACTION_STATE:{
  723. target->SetActionState(val, send_update);
  724. break;
  725. }
  726. case SPAWN_SET_VALUE_MOOD_STATE:{
  727. target->SetMoodState(val, send_update);
  728. break;
  729. }
  730. case SPAWN_SET_VALUE_INITIAL_STATE:{
  731. target->SetInitialState(val, send_update);
  732. break;
  733. }
  734. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  735. target->SetActivityStatus(val, send_update);
  736. break;
  737. }
  738. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  739. target->SetCollisionRadius(val, send_update);
  740. break;
  741. }
  742. case SPAWN_SET_VALUE_FACTION:{
  743. ZoneServer* zone = target->GetZone();
  744. if (!zone)
  745. zone = client->GetCurrentZone();
  746. target->faction_id = val;
  747. zone->RemoveDeadEnemyList(target);
  748. if(target->IsNPC())
  749. zone->AddEnemyList((NPC*)target);
  750. break;
  751. }
  752. case SPAWN_SET_VALUE_DEVICE_ID:{
  753. if (target->IsObject())
  754. ((Object*)target)->SetDeviceID(val);
  755. break;
  756. }
  757. case SPAWN_SET_VALUE_PITCH: {
  758. target->SetPitch(atof(value), send_update);
  759. target->SetSpawnOrigPitch(atof(value));
  760. break;
  761. }
  762. case SPAWN_SET_VALUE_ROLL: {
  763. target->SetRoll(atof(value), send_update);
  764. target->SetSpawnOrigRoll(atof(value));
  765. break;
  766. }
  767. case SPAWN_SET_VALUE_HIDE_HOOD: {
  768. target->SetHideHood(val);
  769. break;
  770. }
  771. case SPAWN_SET_VALUE_EMOTE_STATE: {
  772. target->SetEmoteState(val);
  773. break;
  774. }
  775. case SPAWN_SET_VALUE_ICON: {
  776. target->SetIcon(val);
  777. break;
  778. }
  779. case SPAWN_SET_VALUE_PREFIX: {
  780. target->SetPrefixTitle(value);
  781. client->GetCurrentZone()->SendUpdateTitles(target);
  782. break;
  783. }
  784. case SPAWN_SET_VALUE_SUFFIX: {
  785. target->SetSuffixTitle(value);
  786. client->GetCurrentZone()->SendUpdateTitles(target);
  787. break;
  788. }
  789. case SPAWN_SET_VALUE_LASTNAME: {
  790. target->SetLastName(value);
  791. client->GetCurrentZone()->SendUpdateTitles(target);
  792. break;
  793. }
  794. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  795. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  796. if(client){
  797. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  798. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  799. }
  800. return false;
  801. }
  802. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  803. return false;
  804. else{
  805. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  806. target->SetSpawnScript(value);
  807. }
  808. break;
  809. }
  810. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  811. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  812. if(client){
  813. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  814. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  815. }
  816. return false;
  817. }
  818. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  819. return false;
  820. else{
  821. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  822. target->SetSpawnScript(value);
  823. }
  824. break;
  825. }
  826. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  827. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  828. if(client){
  829. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  830. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  831. }
  832. return false;
  833. }
  834. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  835. return false;
  836. else
  837. target->SetSpawnScript(value);
  838. break;
  839. }
  840. case SPAWN_SET_SKIN_COLOR: {
  841. if (target->IsNPC())
  842. {
  843. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  844. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  845. {
  846. EQ2_Color clr;
  847. clr.red = atoul(skinsep->arg[0]);
  848. clr.green = atoul(skinsep->arg[1]);
  849. clr.blue = atoul(skinsep->arg[2]);
  850. ((Entity*)target)->SetSkinColor(clr);
  851. Query replaceSkinQuery;
  852. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='skin_color'", target->GetDatabaseID());
  853. replaceSkinQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into npc_appearance set spawn_id=%u, type='skin_color', red=%u, green=%u, blue=%u", target->GetDatabaseID(), clr.red, clr.green, clr.blue);
  854. }
  855. safe_delete(skinsep);
  856. }
  857. break;
  858. }
  859. }
  860. }
  861. return true;
  862. }
  863. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  864. the database fields always and also update the zone in memory if it's running. */
  865. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  866. if (client && zone_id > 0 && type > 0 && value) {
  867. sint32 int_value = 0;
  868. float float_value = 0;
  869. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  870. try {
  871. float_value = atof(value);
  872. }
  873. catch (...) {
  874. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  875. return false;
  876. }
  877. }
  878. else if (type != ZONE_SET_VALUE_NAME && type != ZONE_SET_VALUE_FILE && type != ZONE_SET_VALUE_DESCRIPTION && type != ZONE_SET_VALUE_ZONE_TYPE && type != ZONE_SET_VALUE_LUA_SCRIPT && type != ZONE_SET_VALUE_ZONE_MOTD) {
  879. try {
  880. int_value = atoi(value);
  881. }
  882. catch (...) {
  883. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  884. return false;
  885. }
  886. }
  887. switch (type) {
  888. case ZONE_SET_VALUE_EXPANSION_ID: {
  889. break;
  890. }
  891. case ZONE_SET_VALUE_NAME: {
  892. if (zone)
  893. zone->SetZoneName(const_cast<char*>(value));
  894. database.SaveZoneInfo(zone_id, "name", value);
  895. break;
  896. }
  897. case ZONE_SET_VALUE_FILE: {
  898. if (zone)
  899. zone->SetZoneFile(const_cast<char*>(value));
  900. database.SaveZoneInfo(zone_id, "file", value);
  901. break;
  902. }
  903. case ZONE_SET_VALUE_DESCRIPTION: {
  904. if (zone)
  905. zone->SetZoneDescription(const_cast<char*>(value));
  906. database.SaveZoneInfo(zone_id, "description", value);
  907. break;
  908. }
  909. case ZONE_SET_VALUE_SAFE_X: {
  910. if (zone)
  911. zone->SetSafeX(float_value);
  912. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  913. break;
  914. }
  915. case ZONE_SET_VALUE_SAFE_Y: {
  916. if (zone)
  917. zone->SetSafeY(float_value);
  918. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  919. break;
  920. }
  921. case ZONE_SET_VALUE_SAFE_Z: {
  922. if (zone)
  923. zone->SetSafeZ(float_value);
  924. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  925. break;
  926. }
  927. case ZONE_SET_VALUE_UNDERWORLD: {
  928. if (zone)
  929. zone->SetUnderWorld(float_value);
  930. database.SaveZoneInfo(zone_id, "underworld", float_value);
  931. break;
  932. }
  933. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  934. break;
  935. }
  936. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  937. break;
  938. }
  939. case ZONE_SET_VALUE_ZONE_TYPE: {
  940. break;
  941. }
  942. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  943. if (zone)
  944. zone->SetAlwaysLoaded(int_value == 1);
  945. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  946. break;
  947. }
  948. case ZONE_SET_VALUE_CITY_ZONE: {
  949. if (zone)
  950. zone->SetCityZone(int_value == 1);
  951. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  952. break;
  953. }
  954. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  955. if (zone)
  956. zone->SetWeatherAllowed(int_value == 1);
  957. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  958. break;
  959. }
  960. case ZONE_SET_VALUE_MIN_STATUS: {
  961. if (zone)
  962. zone->SetMinimumStatus(int_value);
  963. database.SaveZoneInfo(zone_id, "min_status", int_value);
  964. break;
  965. }
  966. case ZONE_SET_VALUE_MIN_LEVEL: {
  967. if (zone)
  968. zone->SetMinimumLevel(int_value);
  969. database.SaveZoneInfo(zone_id, "min_level", int_value);
  970. break;
  971. }
  972. case ZONE_SET_VALUE_MAX_LEVEL: {
  973. if (zone)
  974. zone->SetMaximumLevel(int_value);
  975. database.SaveZoneInfo(zone_id, "max_level", int_value);
  976. break;
  977. }
  978. case ZONE_SET_VALUE_START_ZONE: {
  979. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  980. break;
  981. }
  982. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  983. if (zone)
  984. zone->SetInstanceType(int_value);
  985. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  986. break;
  987. }
  988. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  989. if (zone)
  990. zone->SetDefaultReenterTime(int_value);
  991. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  992. break;
  993. }
  994. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  995. if (zone)
  996. zone->SetDefaultResetTime(int_value);
  997. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  998. break;
  999. }
  1000. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1001. if (zone)
  1002. zone->SetDefaultLockoutTime(int_value);
  1003. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1004. break;
  1005. }
  1006. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1007. if (zone)
  1008. zone->SetForceGroupZoneOption(int_value);
  1009. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1010. break;
  1011. }
  1012. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1013. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1014. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1015. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1016. return false;
  1017. }
  1018. else {
  1019. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1020. database.SaveZoneInfo(zone_id, "lua_script", value);
  1021. }
  1022. break;
  1023. }
  1024. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1025. if (zone)
  1026. zone->SetShutdownTimer(int_value);
  1027. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1028. break;
  1029. }
  1030. case ZONE_SET_VALUE_ZONE_MOTD: {
  1031. if (zone)
  1032. zone->SetZoneMOTD(string(value));
  1033. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1034. break;
  1035. }
  1036. default: {
  1037. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1038. return false;
  1039. }
  1040. }
  1041. }
  1042. else {
  1043. if (client)
  1044. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1045. return false;
  1046. }
  1047. return true;
  1048. }
  1049. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1050. if (index >= remote_commands->commands.size()) {
  1051. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1052. return;
  1053. }
  1054. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1055. EQ2_RemoteCommandString* parent_command = 0;
  1056. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1057. Seperator* sep = 0;
  1058. if (command_parms->size > 0) {
  1059. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1060. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1061. parent_command = command;
  1062. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1063. safe_delete(sep);
  1064. if (command_parms->data.length() > (command->command.data.length() + 1))
  1065. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1066. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1067. }
  1068. else
  1069. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1070. }
  1071. int ndx = 0;
  1072. if (command->required_status > client->GetAdminStatus())
  1073. {
  1074. LogWrite(COMMAND__ERROR, 0, "Command", "Player '%s' (%u) needs status %i to use command: %s", client->GetPlayer()->GetName(), client->GetAccountID(), command->required_status, command->command.data.c_str());
  1075. safe_delete(sep);
  1076. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1077. return;
  1078. }
  1079. Player* player = client->GetPlayer();
  1080. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1081. switch (command->handler) {
  1082. case COMMAND_RELOAD: {
  1083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1084. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1085. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1086. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1087. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1088. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1089. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1090. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1091. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1093. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1094. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1095. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1096. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1097. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1098. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1099. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1100. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1101. break;
  1102. }
  1103. case COMMAND_RELOADSTRUCTS: {
  1104. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1105. configReader.ReloadStructs();
  1106. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1107. break;
  1108. }
  1109. case COMMAND_RELOAD_QUESTS: {
  1110. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1111. master_quest_list.Reload();
  1112. client_list.ReloadQuests();
  1113. zone_list.ReloadClientQuests();
  1114. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1115. break;
  1116. }
  1117. case COMMAND_RELOAD_SPAWNS: {
  1118. client->GetCurrentZone()->ReloadSpawns();
  1119. break;
  1120. }
  1121. case COMMAND_RELOAD_SPELLS: {
  1122. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1123. zone_list.DeleteSpellProcess();
  1124. master_spell_list.Reload();
  1125. if (lua_interface)
  1126. lua_interface->ReloadSpells();
  1127. zone_list.LoadSpellProcess();
  1128. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1129. break;
  1130. }
  1131. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1132. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1133. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1134. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1135. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1136. break;
  1137. }
  1138. case COMMAND_RELOAD_ZONESCRIPTS: {
  1139. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1140. world.ResetZoneScripts();
  1141. database.LoadZoneScriptData();
  1142. if (lua_interface)
  1143. lua_interface->DestroyZoneScripts();
  1144. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1145. break;
  1146. }
  1147. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1148. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1149. client->GetCurrentZone()->ClearEntityCommands();
  1150. database.LoadEntityCommands(client->GetCurrentZone());
  1151. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1152. break;
  1153. }
  1154. case COMMAND_RELOAD_FACTIONS: {
  1155. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1156. master_faction_list.Clear();
  1157. database.LoadFactionList();
  1158. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1159. break;
  1160. }
  1161. case COMMAND_RELOAD_MAIL: {
  1162. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1163. zone_list.ReloadMail();
  1164. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1165. break;
  1166. }
  1167. case COMMAND_RELOAD_GUILDS: {
  1168. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1169. world.ReloadGuilds();
  1170. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1171. break;
  1172. }
  1173. case COMMAND_RELOAD_LOCATIONS: {
  1174. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1175. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1176. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1177. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1178. break;
  1179. }
  1180. case COMMAND_RELOAD_RULES: {
  1181. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1182. database.LoadRuleSets(true);
  1183. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1184. break;
  1185. }
  1186. case COMMAND_RELOAD_TRANSPORTERS: {
  1187. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1188. database.LoadTransporters(client->GetCurrentZone());
  1189. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1190. break;
  1191. }
  1192. case COMMAND_RELOAD_STARTABILITIES: {
  1193. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1194. world.PurgeStartingLists();
  1195. world.LoadStartingLists();
  1196. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1197. break;
  1198. }
  1199. case COMMAND_READ: {
  1200. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1201. if (strcmp(sep->arg[0], "read") == 0) {
  1202. int32 item_index = atol(sep->arg[1]);
  1203. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1204. if (item) {
  1205. Spawn* spawn = cmdTarget;
  1206. client->SendShowBook(client->GetPlayer(), item->name, item->book_pages);
  1207. break;
  1208. }
  1209. }
  1210. }
  1211. break;
  1212. }
  1213. case COMMAND_USEABILITY:{
  1214. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1215. if (client->GetPlayer()->GetHP() == 0) {
  1216. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1217. }
  1218. else {
  1219. int32 spell_id = atoul(sep->arg[0]);
  1220. int8 spell_tier = 0;
  1221. if (sep->arg[1][0] && sep->IsNumber(1))
  1222. spell_tier = atoi(sep->arg[1]);
  1223. else
  1224. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1225. if (!spell_tier)
  1226. spell_tier = 1;
  1227. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1228. if (spell) {
  1229. 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)
  1230. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1231. else
  1232. {
  1233. if (cmdTarget)
  1234. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1235. else
  1236. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1237. }
  1238. }
  1239. }
  1240. }
  1241. else if (cmdTarget && cmdTarget->IsWidget())
  1242. {
  1243. Widget* widget = (Widget*)cmdTarget;
  1244. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1245. }
  1246. else
  1247. {
  1248. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1249. }
  1250. break;
  1251. }
  1252. case COMMAND_INFO:{
  1253. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1254. if(strcmp(sep->arg[0], "inventory") == 0){
  1255. int32 item_index = atol(sep->arg[1]);
  1256. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1257. if(item){
  1258. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1259. break;
  1260. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1261. //DumpPacket(app);
  1262. client->QueuePacket(app);
  1263. if(item->GetItemScript() && lua_interface)
  1264. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1265. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1266. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id);
  1267. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1268. client->AddPendingQuest(quest);
  1269. }
  1270. }
  1271. else
  1272. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1273. }
  1274. else if(strcmp(sep->arg[0], "equipment") == 0){
  1275. int32 item_index = atol(sep->arg[1]);
  1276. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1277. if(item){
  1278. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1279. client->QueuePacket(app);
  1280. if(item->GetItemScript() && lua_interface)
  1281. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1282. }
  1283. else
  1284. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1285. }
  1286. 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){
  1287. int32 item_id = atoul(sep->arg[1]);
  1288. Item* item = master_item_list.GetItem(item_id);
  1289. if(item){
  1290. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1291. client->QueuePacket(app);
  1292. }
  1293. else
  1294. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1295. }
  1296. else if (strcmp(sep->arg[0], "spell") == 0) {
  1297. sint32 spell_id = atol(sep->arg[1]);
  1298. int8 tier = atoi(sep->arg[3]);
  1299. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1300. if (outapp)
  1301. client->QueuePacket(outapp);
  1302. else
  1303. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1304. }
  1305. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1306. sint32 spell_id = atol(sep->arg[2]);
  1307. int8 group = atoi(sep->arg[1]);
  1308. AltAdvanceData* data = 0;
  1309. SpellBookEntry* spellentry = 0;
  1310. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1311. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1312. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1313. if (outapp)
  1314. client->QueuePacket(outapp);
  1315. else
  1316. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1317. }
  1318. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1319. sint32 spell_id = atol(sep->arg[1]);
  1320. int8 tier = atoi(sep->arg[2]);
  1321. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1322. if (outapp)
  1323. client->QueuePacket(outapp);
  1324. else
  1325. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1326. }
  1327. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1328. sint32 recipe_id = atol(sep->arg[1]);
  1329. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1330. if(outapp)
  1331. client->QueuePacket(outapp);
  1332. else
  1333. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1334. }
  1335. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1336. int32 slot = atol(sep->arg[1]);
  1337. int32 spell_id = atol(sep->arg[2]);
  1338. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1339. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1340. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1341. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1342. if(outapp)
  1343. client->QueuePacket(outapp);
  1344. else
  1345. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1346. }
  1347. else if (strcmp(sep->arg[0], "effect") == 0) {
  1348. int32 spell_id = atol(sep->arg[1]);
  1349. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1350. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1351. int8 type = 0;
  1352. if (client->GetVersion() <= 283)
  1353. type = 1;
  1354. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  1355. if (outapp){
  1356. client->QueuePacket(outapp);
  1357. }
  1358. else
  1359. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1360. }
  1361. }
  1362. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1363. Item* item = player->item_list.GetOverflowItem();
  1364. if(item) {
  1365. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1366. client->QueuePacket(app);
  1367. }
  1368. else
  1369. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1370. }
  1371. else
  1372. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1373. break;
  1374. }
  1375. case COMMAND_USE_EQUIPPED_ITEM:{
  1376. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1377. int32 slot_id = atoul(sep->arg[0]);
  1378. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1379. if (item && item->generic_info.usable && item->GetItemScript())
  1380. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1381. }
  1382. break;
  1383. }
  1384. case COMMAND_USE_ITEM: {
  1385. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1386. int32 item_index = atoul(sep->arg[0]);
  1387. Item* item = player->item_list.GetItemFromIndex(item_index);
  1388. if (item && item->GetItemScript()) {
  1389. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1390. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1391. else {
  1392. if (item->generic_info.display_charges > 0) {
  1393. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1394. item->generic_info.display_charges -= 1;
  1395. item->save_needed = true;
  1396. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1397. }
  1398. else
  1399. LogWrite(PLAYER__ERROR, 0, "Command", "%s: Item %s (%i) attempted to be used, however display_charges is 0.", client->GetPlayer()->GetName(), item->name.c_str(), item->details.item_id);
  1400. }
  1401. }
  1402. }
  1403. break;
  1404. }
  1405. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1406. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1407. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1408. if (item) {
  1409. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1410. if(item->generic_info.item_type == 6) {
  1411. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1412. int8 old_slot = 0;
  1413. if (spell) {
  1414. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1415. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1416. player->RemoveSpellBookEntry(spell->GetSpellID());
  1417. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1418. player->UnlockSpell(spell);
  1419. client->SendSpellUpdate(spell);
  1420. database.DeleteItem(client->GetCharacterID(), item, 0);
  1421. player->item_list.RemoveItem(item, true);
  1422. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1423. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1424. }
  1425. }
  1426. else
  1427. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1428. }
  1429. else if(item->generic_info.item_type == 7){
  1430. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1431. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1432. // if valid recipe book and the player doesn't have it
  1433. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1434. client->Message(CHANNEL_NARRATIVE, "Your tradeskill level is not high enough to scribe this book.");
  1435. safe_delete(recipe_book);
  1436. }
  1437. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1438. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1439. // Add recipe book to the players list
  1440. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1441. // Get a list of all recipes this book contains
  1442. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1443. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1444. // Create the packet to send to update the players recipe list
  1445. PacketStruct* packet = 0;
  1446. if (client->GetRecipeListSent()) {
  1447. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1448. if (packet)
  1449. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1450. }
  1451. // loop through the list
  1452. vector<Recipe*>::iterator itr;
  1453. int16 i = 0;
  1454. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1455. // check to see if the player already has this recipe some how
  1456. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1457. // Player doesn't already have this recipe so lets add it
  1458. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1459. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1460. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1461. client->Message(CHANNEL_NARRATIVE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1462. if (packet && client->GetRecipeListSent()) {
  1463. packet->setArrayDataByName("id", recipe->GetID(), i);
  1464. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1465. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1466. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1467. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1468. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1469. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1470. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1471. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1472. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1473. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1474. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1475. i++;
  1476. }
  1477. }
  1478. }
  1479. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1480. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1481. database.DeleteItem(client->GetCharacterID(), item, 0);
  1482. client->GetPlayer()->item_list.RemoveItem(item, true);
  1483. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1484. if (packet && client->GetRecipeListSent())
  1485. client->QueuePacket(packet->serialize());
  1486. safe_delete(packet);
  1487. }
  1488. else {
  1489. if (recipe_book)
  1490. client->Message(CHANNEL_NARRATIVE, "You have already learned all you can from this item.");
  1491. safe_delete(recipe_book);
  1492. }
  1493. }
  1494. }
  1495. else
  1496. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1497. }
  1498. break;
  1499. }
  1500. case COMMAND_SUMMONITEM: {
  1501. if (sep && sep->IsNumber(0)) {
  1502. int32 item_id = atol(sep->arg[0]);
  1503. int32 quantity = 1;
  1504. if (sep->arg[1] && sep->IsNumber(1))
  1505. quantity = atoi(sep->arg[1]);
  1506. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1507. client->AddItemToBank(item_id,quantity);
  1508. }
  1509. else {
  1510. client->AddItem(item_id, quantity);
  1511. }
  1512. }
  1513. else {
  1514. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1515. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1516. }
  1517. break;
  1518. }
  1519. case COMMAND_COLLECTION_ADDITEM: {
  1520. // takes 2 params: collection_id, slot
  1521. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1522. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1523. if (item)
  1524. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1525. else
  1526. 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]));
  1527. }
  1528. else
  1529. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1530. break;
  1531. }
  1532. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1533. // takes 1 param: slot
  1534. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1535. int i = 0;
  1536. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1537. printf("\t%u: %s\n", i, sep->arg[i]);
  1538. i++;
  1539. }
  1540. break;
  1541. }
  1542. case COMMAND_WHO:{
  1543. const char* who = 0;
  1544. if(sep && sep->arg[0]){
  1545. //cout << "Who query: \n";
  1546. who = sep->argplus[0];
  1547. //cout << who << endl;
  1548. }
  1549. zone_list.ProcessWhoQuery(who, client);
  1550. break;
  1551. }
  1552. case COMMAND_SELECT_JUNCTION:{
  1553. 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__);
  1554. int32 choice = 0;
  1555. if(sep && sep->arg[0] && sep->IsNumber(0))
  1556. choice = atoul(sep->arg[0]);
  1557. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1558. client->HandlePlayerRevive(choice);
  1559. }
  1560. break;
  1561. }
  1562. case COMMAND_SPAWN_MOVE: {
  1563. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  1564. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1565. if (packet) {
  1566. float unknown2_3 = 0;
  1567. int8 placement_mode = 0;
  1568. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1569. if (sep && sep->arg[0][0]) {
  1570. if (strcmp(sep->arg[0], "wall") == 0) {
  1571. placement_mode = 2;
  1572. unknown2_3 = 150;
  1573. }
  1574. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1575. placement_mode = 1;
  1576. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1577. {
  1578. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1579. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1580. }
  1581. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1582. {
  1583. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1584. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1585. }
  1586. else if (strcmp(sep->arg[0], "myloc") == 0)
  1587. {
  1588. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1589. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1590. safe_delete(packet);
  1591. break;
  1592. }
  1593. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1594. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1595. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1596. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1597. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1598. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1599. safe_delete(packet);
  1600. break;
  1601. }
  1602. }
  1603. packet->setDataByName("placement_mode", placement_mode);
  1604. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1605. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1606. packet->setDataByName("unknown", 1); //size
  1607. packet->setDataByName("unknown2", 1); //size 2
  1608. packet->setDataByName("unknown2", .5, 1); //size 3
  1609. packet->setDataByName("unknown2", 3, 2);
  1610. packet->setDataByName("unknown2", unknown2_3, 3);
  1611. packet->setDataByName("max_distance", 500);
  1612. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1613. client->QueuePacket(packet->serialize());
  1614. safe_delete(packet);
  1615. }
  1616. }
  1617. else {
  1618. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1619. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1620. }
  1621. break;
  1622. }
  1623. case COMMAND_HAIL:{
  1624. Spawn* spawn = cmdTarget;
  1625. if(spawn && spawn->GetTargetable())
  1626. {
  1627. char tmp[75] = {0};
  1628. sprintf(tmp, "Hail, %s", spawn->GetName());
  1629. bool show_bubble = true;
  1630. if (spawn->IsNPC())
  1631. show_bubble = false;
  1632. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1633. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < 30){
  1634. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1635. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1636. else
  1637. spawn->ProcessMovement();
  1638. LogWrite(MISC__TODO, 0, "Check", "ProcessMovement has been called");
  1639. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer());
  1640. }
  1641. }
  1642. else {
  1643. string tmp = "Hail";
  1644. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1645. }
  1646. break;
  1647. }
  1648. case COMMAND_SAY:{
  1649. if (sep && sep->arg[0][0]) {
  1650. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1651. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1652. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1653. }
  1654. else
  1655. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1656. break;
  1657. }
  1658. case COMMAND_TELL:{
  1659. if(sep && sep->arg[0] && sep->argplus[1]){
  1660. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1]))
  1661. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1662. }else
  1663. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1664. break;
  1665. }
  1666. case COMMAND_SHOUT:{
  1667. if(sep && sep->arg[0][0])
  1668. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1669. else
  1670. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1671. break;
  1672. }
  1673. case COMMAND_AUCTION:{
  1674. if(sep && sep->arg[0][0])
  1675. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1676. else
  1677. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1678. break;
  1679. }
  1680. case COMMAND_OOC:{
  1681. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  1682. if(sep && sep->arg[0][0])
  1683. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0]);
  1684. else
  1685. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  1686. break;
  1687. }
  1688. case COMMAND_EMOTE:{
  1689. if(sep && sep->arg[0][0])
  1690. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  1691. else
  1692. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  1693. break;
  1694. }
  1695. case COMMAND_RACE:{
  1696. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  1697. if(sep->arg[1][0] && sep->IsNumber(1)){
  1698. client->GetPlayer()->GetInfoStruct()->race = atoi(sep->arg[1]);
  1699. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  1700. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  1701. client->GetPlayer()->SetCharSheetChanged(true);
  1702. }
  1703. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  1704. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  1705. //client->QueuePacket(outapp);
  1706. }
  1707. else{
  1708. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  1709. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  1710. }
  1711. break;
  1712. }
  1713. case COMMAND_BANK_DEPOSIT:{
  1714. if(client->GetBanker() && sep && sep->arg[0]){
  1715. int64 amount = 0;
  1716. string deposit = string(sep->arg[0]);
  1717. amount = atoi64(deposit.c_str());
  1718. client->BankDeposit(amount);
  1719. }
  1720. break;
  1721. }
  1722. case COMMAND_BANK_WITHDRAWAL:{
  1723. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  1724. int64 amount = 0;
  1725. string deposit = string(sep->arg[0]);
  1726. amount = atoi64(deposit.c_str());
  1727. client->BankWithdrawal(amount);
  1728. }
  1729. break;
  1730. }
  1731. case COMMAND_BANK_CANCEL:{
  1732. Spawn* banker = cmdTarget;
  1733. client->Bank(banker, true);
  1734. break;
  1735. }
  1736. case COMMAND_BANK:{
  1737. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  1738. Spawn* banker = cmdTarget;
  1739. client->Bank(banker);
  1740. break;
  1741. }
  1742. case COMMAND_GUILD_BANK:{
  1743. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  1744. //Spawn* banker = client->GetPlayer()->GetTarget();
  1745. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  1746. break;
  1747. }
  1748. case COMMAND_START_MAIL: {
  1749. client->SetMailTransaction(cmdTarget);
  1750. client->SendMailList();
  1751. break;
  1752. }
  1753. case COMMAND_CANCEL_MAIL: {
  1754. client->SetMailTransaction(0);
  1755. break;
  1756. }
  1757. case COMMAND_GET_MAIL_MESSAGE: {
  1758. if (sep && sep->arg[0] && sep->IsNumber(0))
  1759. client->DisplayMailMessage(atoul(sep->arg[0]));
  1760. break;
  1761. }
  1762. case COMMAND_ADD_MAIL_PLAT: {
  1763. if (sep && sep->arg[0] && sep->IsNumber(0))
  1764. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1765. break;
  1766. }
  1767. case COMMAND_ADD_MAIL_GOLD: {
  1768. if (sep && sep->arg[0] && sep->IsNumber(0))
  1769. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  1770. break;
  1771. }
  1772. case COMMAND_ADD_MAIL_SILVER: {
  1773. if (sep && sep->arg[0] && sep->IsNumber(0))
  1774. client->AddMailCoin(0, atoul(sep->arg[0]));
  1775. break;
  1776. }
  1777. case COMMAND_ADD_MAIL_COPPER: {
  1778. if (sep && sep->arg[0] && sep->IsNumber(0))
  1779. client->AddMailCoin(atoul(sep->arg[0]));
  1780. break;
  1781. }
  1782. case COMMAND_SET_MAIL_ITEM: {
  1783. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1784. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1785. break;
  1786. }
  1787. case COMMAND_REMOVE_MAIL_PLAT: {
  1788. if (sep && sep->arg[0] && sep->IsNumber(0))
  1789. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1790. break;
  1791. }
  1792. case COMMAND_REMOVE_MAIL_GOLD: {
  1793. if (sep && sep->arg[0] && sep->IsNumber(0))
  1794. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  1795. break;
  1796. }
  1797. case COMMAND_REMOVE_MAIL_SILVER: {
  1798. if (sep && sep->arg[0] && sep->IsNumber(0))
  1799. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  1800. break;
  1801. }
  1802. case COMMAND_REMOVE_MAIL_COPPER: {
  1803. if (sep && sep->arg[0] && sep->IsNumber(0))
  1804. client->RemoveMailCoin(atoul(sep->arg[0]));
  1805. break;
  1806. }
  1807. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  1808. if (sep && sep->arg[0] && sep->IsNumber(0))
  1809. client->TakeMailAttachments(atoul(sep->arg[0]));
  1810. break;
  1811. }
  1812. case COMMAND_CANCEL_SEND_MAIL: {
  1813. client->CancelSendMail();
  1814. break;
  1815. }
  1816. case COMMAND_DELETE_MAIL_MESSAGE: {
  1817. if (sep && sep->arg[0] && sep->IsNumber(0))
  1818. client->DeleteMail(atoul(sep->arg[0]), true);
  1819. break;
  1820. }
  1821. case COMMAND_REPORT_SPAM: {
  1822. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1823. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1824. break;
  1825. }
  1826. case COMMAND_KILL:{
  1827. Spawn* dead = 0;
  1828. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  1829. dead=client->GetPlayer();
  1830. client->GetPlayer()->SetHP(0);
  1831. client->GetPlayer()->KillSpawn(dead);
  1832. }else{
  1833. dead= cmdTarget;
  1834. if(dead && dead->IsPlayer() == false){
  1835. dead->SetHP(0);
  1836. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  1837. client->GetCurrentZone()->RemoveSpawn(false, dead, true);
  1838. else
  1839. client->GetPlayer()->KillSpawn(dead);
  1840. }else{
  1841. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  1842. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  1843. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  1844. }
  1845. }
  1846. break;
  1847. }
  1848. case COMMAND_LEVEL:{
  1849. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  1850. int16 new_level = atoi(sep->arg[ndx]);
  1851. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  1852. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  1853. else {
  1854. if (new_level < 1)
  1855. new_level = 1;
  1856. if (new_level > 255)
  1857. new_level = 255;
  1858. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  1859. client->GetPlayer()->SetXP(1);
  1860. client->GetPlayer()->SetNeededXP();
  1861. }
  1862. }else
  1863. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  1864. break;
  1865. }
  1866. case COMMAND_SIT: {
  1867. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1868. if(client->GetPlayer()->GetHP() > 0){
  1869. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  1870. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  1871. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  1872. }
  1873. break;
  1874. }
  1875. case COMMAND_STAND: {
  1876. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1877. if(client->GetPlayer()->GetHP() > 0){
  1878. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  1879. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  1880. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  1881. }
  1882. break;
  1883. }
  1884. case COMMAND_CLASS:{
  1885. if(sep && sep->arg[ndx][0]){
  1886. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  1887. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  1888. }else
  1889. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  1890. break;
  1891. }
  1892. case COMMAND_GENDER:{
  1893. if(sep && sep->arg[ndx][0]){
  1894. client->GetPlayer()->GetInfoStruct()->gender = atoi(sep->arg[ndx]);
  1895. client->GetPlayer()->SetCharSheetChanged(true);
  1896. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  1897. }else{
  1898. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  1899. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  1900. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  1901. }
  1902. break;
  1903. }
  1904. case COMMAND_FLYMODE:{
  1905. if(sep && sep->arg[0] && sep->IsNumber(0)){
  1906. PrintSep(sep, "COMMAND_FLYMODE");
  1907. int8 val = atoi(sep->arg[0]);
  1908. ClientPacketFunctions::SendFlyMode(client, val);
  1909. }
  1910. else{
  1911. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  1912. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  1913. }
  1914. break;
  1915. }
  1916. case COMMAND_LOOT_LIST:{
  1917. Spawn* spawn = cmdTarget;
  1918. if(spawn && spawn->IsEntity()){
  1919. if (sep && sep->arg[0]) {
  1920. if (!spawn->GetDatabaseID())
  1921. {
  1922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  1923. break;
  1924. }
  1925. else if (!spawn->IsNPC())
  1926. {
  1927. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  1928. break;
  1929. }
  1930. bool reloadLoot = false;
  1931. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  1932. {
  1933. int32 loottable_id = atoul(sep->arg[1]);
  1934. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  1935. {
  1936. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  1937. reloadLoot = true;
  1938. }
  1939. else
  1940. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  1941. }
  1942. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  1943. {
  1944. int32 loottable_id = atoul(sep->arg[1]);
  1945. if (loottable_id > 0)
  1946. {
  1947. database.AddLootTableToSpawn(spawn, loottable_id);
  1948. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  1949. reloadLoot = true;
  1950. }
  1951. else
  1952. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  1953. }
  1954. else if (!stricmp(sep->arg[0], "clearall"))
  1955. {
  1956. if (database.RemoveSpawnLootTable(spawn, 0))
  1957. {
  1958. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  1959. reloadLoot = true;
  1960. }
  1961. else
  1962. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  1963. }
  1964. else
  1965. {
  1966. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  1967. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  1968. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  1969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  1970. break;
  1971. }
  1972. if (reloadLoot)
  1973. {
  1974. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  1975. if (spawn->IsNPC())
  1976. {
  1977. Entity* ent = (Entity*)spawn;
  1978. ent->SetLootCoins(0);
  1979. ent->ClearLootList();
  1980. spawn->GetZone()->AddLoot((NPC*)spawn);
  1981. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  1982. }
  1983. }
  1984. break; // nothing further this is the end of these sub commands
  1985. }
  1986. else
  1987. {
  1988. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  1989. if (loot_list.size() > 0) {
  1990. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  1991. vector<int32>::iterator list_itr;
  1992. LootTable* table = 0;
  1993. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  1994. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  1995. if (table)
  1996. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  1997. }
  1998. }
  1999. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2000. vector<Item*>* items = spawn->GetLootItems();
  2001. if (items) {
  2002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2003. vector<Item*>::iterator itr;
  2004. Item* item = 0;
  2005. for (itr = items->begin(); itr != items->end(); itr++) {
  2006. item = *itr;
  2007. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2008. }
  2009. }
  2010. else
  2011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2012. }
  2013. }
  2014. break;
  2015. }
  2016. case COMMAND_LOOT_SETCOIN:{
  2017. Spawn* spawn = cmdTarget;
  2018. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2019. spawn->SetLootCoins(atoul(sep->arg[0]));
  2020. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2021. }
  2022. else
  2023. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2024. break;
  2025. }
  2026. case COMMAND_LOOT_ADDITEM:{
  2027. Spawn* spawn = cmdTarget;
  2028. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2029. int16 charges = 1;
  2030. if(sep->arg[1] && sep->IsNumber(1))
  2031. charges = atoi(sep->arg[1]);
  2032. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2033. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2034. }
  2035. else
  2036. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2037. break;
  2038. }
  2039. case COMMAND_LOOT_REMOVEITEM:{
  2040. Spawn* spawn = cmdTarget;
  2041. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2042. spawn->LootItem(atoul(sep->arg[0]));
  2043. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2044. }
  2045. else
  2046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2047. break;
  2048. }
  2049. case COMMAND_LOOT_CORPSE:
  2050. case COMMAND_DISARM:
  2051. case COMMAND_LOOT:{
  2052. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2053. {
  2054. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2055. break;
  2056. }
  2057. if(cmdTarget && cmdTarget->IsEntity()){
  2058. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2059. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2060. client->OpenChest(cmdTarget, true);
  2061. else
  2062. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2063. if (!(cmdTarget)->HasLoot()){
  2064. if (((Entity*)cmdTarget)->IsNPC())
  2065. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2066. }
  2067. }
  2068. else
  2069. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2070. }
  2071. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2072. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2073. break;
  2074. }
  2075. case COMMAND_RELOADSPAWNSCRIPTS:{
  2076. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2077. if (lua_interface)
  2078. lua_interface->SetSpawnScriptsReloading(true);
  2079. world.ResetSpawnScripts();
  2080. database.LoadSpawnScriptData();
  2081. if(lua_interface) {
  2082. lua_interface->DestroySpawnScripts();
  2083. lua_interface->SetSpawnScriptsReloading(false);
  2084. }
  2085. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2086. break;
  2087. }
  2088. case COMMAND_RELOADLUASYSTEM:{
  2089. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2090. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2091. safe_delete(lua_interface);
  2092. lua_interface = new LuaInterface();
  2093. if(lua_interface)
  2094. lua_interface->SetSpawnScriptsReloading(true);
  2095. if(lua_interface && debug_clients.size() > 0){
  2096. map<Client*, int32>::iterator itr;
  2097. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2098. if(lua_interface)
  2099. lua_interface->UpdateDebugClients(itr->first);
  2100. }
  2101. }
  2102. world.ResetSpawnScripts();
  2103. database.LoadSpawnScriptData();
  2104. world.ResetZoneScripts();
  2105. database.LoadZoneScriptData();
  2106. int32 quest_count = database.LoadQuests();
  2107. zone_list.DeleteSpellProcess();
  2108. master_spell_list.Reload();
  2109. int32 spell_count = 0;
  2110. if(lua_interface) {
  2111. lua_interface->DestroySpawnScripts();
  2112. lua_interface->DestroySpells();
  2113. spell_count = database.LoadSpellScriptData();
  2114. lua_interface->SetSpawnScriptsReloading(false);
  2115. }
  2116. zone_list.LoadSpellProcess();
  2117. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2118. break;
  2119. }
  2120. case COMMAND_DECLINE_QUEST:{
  2121. int32 quest_id = 0;
  2122. if(sep && sep->arg[0] && sep->IsNumber(0))
  2123. quest_id = atoul(sep->arg[0]);
  2124. if(quest_id > 0){
  2125. Quest* quest = client->GetPendingQuest(quest_id);
  2126. if(quest){
  2127. client->RemovePendingQuest(quest);
  2128. if(lua_interface)
  2129. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2130. safe_delete(quest);
  2131. client->GetCurrentZone()->SendQuestUpdates(client);
  2132. }
  2133. }
  2134. break;
  2135. }
  2136. case COMMAND_DELETE_QUEST:{
  2137. int32 quest_id = 0;
  2138. if(sep && sep->arg[0] && sep->IsNumber(0))
  2139. quest_id = atoul(sep->arg[0]);
  2140. if(quest_id > 0){
  2141. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2142. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2143. if (quest)
  2144. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2145. }
  2146. client->RemovePlayerQuest(quest_id);
  2147. client->GetCurrentZone()->SendQuestUpdates(client);
  2148. }
  2149. break;
  2150. }
  2151. case COMMAND_ACCEPT_QUEST:{
  2152. int32 quest_id = 0;
  2153. if(sep && sep->arg[0] && sep->IsNumber(0))
  2154. quest_id = atoul(sep->arg[0]);
  2155. if(quest_id > 0){
  2156. client->AcceptQuest(quest_id);
  2157. }
  2158. break;
  2159. }
  2160. case COMMAND_NAME:{
  2161. if(sep && sep->arg[ndx][0]){
  2162. memset(client->GetPlayer()->GetInfoStruct()->name, 0, 40);
  2163. strncpy(client->GetPlayer()->GetInfoStruct()->name, sep->arg[ndx], 39);
  2164. client->GetPlayer()->SetCharSheetChanged(true);
  2165. }else
  2166. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2167. break;
  2168. }
  2169. case COMMAND_GROUPSAY:{
  2170. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2171. if(sep && sep->arg[0] && gmi)
  2172. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2173. break;
  2174. }
  2175. case COMMAND_GROUPINVITE: {
  2176. Entity* target = 0;
  2177. Client* target_client = 0;
  2178. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2179. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2180. return;
  2181. }
  2182. // name provided with command so it has to be a player, npc not supported here
  2183. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2184. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2185. if (target_client) {
  2186. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2187. target = 0;
  2188. else
  2189. target = target_client->GetPlayer();
  2190. }
  2191. }
  2192. // if name was not provided use the players target, npc or player supported here
  2193. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2194. target = (Entity*)client->GetPlayer()->GetTarget();
  2195. if (target->IsPlayer()) {
  2196. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2197. }
  2198. }
  2199. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2200. if (result == 0) {
  2201. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2202. if (target_client) {
  2203. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2204. if (packet) {
  2205. packet->setDataByName("type", 1);
  2206. packet->setDataByName("name", client->GetPlayer()->GetName());
  2207. packet->setDataByName("unknown2", 1);
  2208. target_client->QueuePacket(packet->serialize());
  2209. safe_delete(packet);
  2210. }
  2211. }
  2212. }
  2213. else if (result == 1)
  2214. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2215. else if (result == 2)
  2216. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2217. else if (result == 3)
  2218. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2219. else if (result == 4)
  2220. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2221. else if (result == 5)
  2222. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2223. else if (result == 6)
  2224. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2225. else
  2226. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2227. break;
  2228. }
  2229. case COMMAND_GROUPDISBAND: {
  2230. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2231. if (gmi) { // TODO: Leader check
  2232. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2233. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2234. }
  2235. break;
  2236. }
  2237. case COMMAND_GROUP_LEAVE: {
  2238. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2239. if (gmi) {
  2240. int32 group_id = gmi->group_id;
  2241. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2242. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2243. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2244. }
  2245. else {
  2246. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2247. }
  2248. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  2249. }
  2250. break;
  2251. }
  2252. case COMMAND_FRIEND_ADD:{
  2253. string name = "";
  2254. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2255. name = database.GetPlayerName(sep->arg[0]);
  2256. else if(cmdTarget && cmdTarget->IsPlayer())
  2257. name = string(cmdTarget->GetName());
  2258. if(name.length() > 0){
  2259. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2260. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2261. client->GetPlayer()->RemoveIgnore(name.c_str());
  2262. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2263. client->SendChatRelationship(3, name.c_str());
  2264. }
  2265. client->GetPlayer()->AddFriend(name.c_str(), true);
  2266. client->SendChatRelationship(0, name.c_str());
  2267. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2268. if(zone_list.GetClientByCharName(name))
  2269. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2270. }
  2271. else
  2272. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2273. }
  2274. else
  2275. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2276. break;
  2277. }
  2278. case COMMAND_FRIEND_REMOVE:{
  2279. string name = "";
  2280. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2281. name = database.GetPlayerName(sep->arg[0]);
  2282. else if(cmdTarget && cmdTarget->IsPlayer())
  2283. name = string(cmdTarget->GetName());
  2284. if(name.length() > 0){
  2285. client->GetPlayer()->RemoveFriend(name.c_str());
  2286. client->SendChatRelationship(1, name.c_str());
  2287. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2288. }
  2289. else
  2290. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2291. break;
  2292. }
  2293. case COMMAND_FRIENDS:{
  2294. break;
  2295. }
  2296. case COMMAND_IGNORE_ADD:{
  2297. string name = "";
  2298. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2299. name = database.GetPlayerName(sep->arg[0]);
  2300. else if(cmdTarget && cmdTarget->IsPlayer())
  2301. name = string(cmdTarget->GetName());
  2302. if(name.length() > 0){
  2303. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2304. if(client->GetPlayer()->IsFriend(name.c_str())){
  2305. client->GetPlayer()->RemoveFriend(name.c_str());
  2306. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2307. client->SendChatRelationship(1, name.c_str());
  2308. }
  2309. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2310. client->SendChatRelationship(2, name.c_str());
  2311. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2312. }
  2313. else
  2314. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2315. }
  2316. else
  2317. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2318. break;
  2319. }
  2320. case COMMAND_IGNORE_REMOVE:{
  2321. string name = "";
  2322. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2323. name = database.GetPlayerName(sep->arg[0]);
  2324. else if(cmdTarget && cmdTarget->IsPlayer())
  2325. name = string(cmdTarget->GetName());
  2326. if(name.length() > 0){
  2327. client->GetPlayer()->RemoveIgnore(name.c_str());
  2328. client->SendChatRelationship(3, name.c_str());
  2329. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2330. }
  2331. break;
  2332. }
  2333. case COMMAND_IGNORES:{
  2334. break;
  2335. }
  2336. case COMMAND_GROUP_KICK:{
  2337. Entity* kicked = 0;
  2338. Client* kicked_client = 0;
  2339. int32 group_id = 0;
  2340. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2341. return;
  2342. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2343. if (sep && sep->arg[0]) {
  2344. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2345. if (kicked_client)
  2346. kicked = kicked_client->GetPlayer();
  2347. }
  2348. else if (cmdTarget && cmdTarget->IsEntity()) {
  2349. kicked = (Entity*)cmdTarget;
  2350. }
  2351. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2352. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2353. if (kicked)
  2354. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2355. if(send_kicked_message)
  2356. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2357. else
  2358. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  2359. if (kicked_client)
  2360. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  2361. break;
  2362. }
  2363. case COMMAND_GROUP_MAKE_LEADER:{
  2364. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2365. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2366. return;
  2367. }
  2368. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2369. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2370. if (new_leader) {
  2371. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2372. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2373. }
  2374. }
  2375. else
  2376. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2377. }
  2378. else if (cmdTarget && cmdTarget->IsPlayer())
  2379. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2380. else
  2381. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2382. break;
  2383. }
  2384. case COMMAND_GROUP_ACCEPT_INVITE: {
  2385. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2386. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2387. if (result == 0)
  2388. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  2389. else if (result == 1)
  2390. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  2391. else if (result == 2)
  2392. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  2393. else
  2394. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  2395. }
  2396. break;
  2397. }
  2398. case COMMAND_GROUP_DECLINE_INVITE: {
  2399. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2400. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2401. }
  2402. break;
  2403. }
  2404. case COMMAND_SUMMON:{
  2405. char* search_name = 0;
  2406. if(sep && sep->arg[0][0])
  2407. search_name = sep->arg[0];
  2408. if(!search_name && !cmdTarget){
  2409. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2410. 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.");
  2411. }
  2412. else{
  2413. if(!client->Summon(search_name))
  2414. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2415. }
  2416. break;
  2417. }
  2418. case COMMAND_GOTO:{
  2419. const char* search_name = 0;
  2420. if(sep && sep->arg[0][0])
  2421. search_name = sep->argplus[0];
  2422. if(!search_name && !cmdTarget){
  2423. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2424. 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.");
  2425. }
  2426. else{
  2427. if(!client->GotoSpawn(search_name))
  2428. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2429. }
  2430. break;
  2431. }
  2432. case COMMAND_MOVE:{
  2433. bool success = false;
  2434. try{
  2435. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2436. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2437. if(app){
  2438. client->QueuePacket(app);
  2439. success = true;
  2440. }
  2441. }
  2442. }
  2443. catch(...){}
  2444. if(!success){
  2445. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2446. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2447. }
  2448. break;
  2449. }
  2450. case COMMAND_SETTIME:{
  2451. if(sep && sep->arg[0]){
  2452. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2453. if(sep->arg[1] && sep->IsNumber(1))
  2454. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2455. if(sep->arg[2] && sep->IsNumber(2))
  2456. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2457. if(sep->arg[3] && sep->IsNumber(3))
  2458. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2459. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2460. }
  2461. else{
  2462. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2463. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2464. }
  2465. break;
  2466. }
  2467. case COMMAND_VERSION:{
  2468. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2469. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2470. break;
  2471. }
  2472. case COMMAND_ZONE:{
  2473. string* zonename = 0;
  2474. int32 instanceID = 0;
  2475. const char* zone = 0;
  2476. int32 zone_id = 0;
  2477. bool listSearch = false;
  2478. bool isInstance = false;
  2479. ZoneServer* zsZone = 0;
  2480. if(sep && sep->arg[0][0])
  2481. {
  2482. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2483. listSearch = true;
  2484. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2485. {
  2486. zone_list.SendZoneList(client);
  2487. break;
  2488. }
  2489. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2490. {
  2491. if(sep->IsNumber(1))
  2492. instanceID = atol(sep->arg[1]);
  2493. }
  2494. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2495. {
  2496. PrintSep(sep, "ZONE LOCK");
  2497. if(sep->IsNumber(1))
  2498. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2499. else
  2500. zsZone = zone_list.Get(sep->arg[1], false);
  2501. if( zsZone )
  2502. {
  2503. zsZone->SetZoneLockState(true);
  2504. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2505. }
  2506. else
  2507. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2508. break;
  2509. }
  2510. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2511. {
  2512. PrintSep(sep, "ZONE UNLOCK");
  2513. if(sep->IsNumber(1))
  2514. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2515. else
  2516. zsZone = zone_list.Get(sep->arg[1], false);
  2517. if( zsZone )
  2518. {
  2519. zsZone->SetZoneLockState(false);
  2520. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2521. }
  2522. else
  2523. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2524. break;
  2525. }
  2526. else
  2527. {
  2528. if(sep->IsNumber(0))
  2529. {
  2530. zone_id = atoul(sep->arg[0]);
  2531. zonename = database.GetZoneName(zone_id);
  2532. if(zonename)
  2533. zone = zonename->c_str();
  2534. }
  2535. else
  2536. zone = sep->arg[0];
  2537. }
  2538. if(instanceID > 0)
  2539. {
  2540. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2541. if(zsInstance != NULL)
  2542. {
  2543. instanceID = zsInstance->GetInstanceID();
  2544. zone = zsInstance->GetZoneName();
  2545. zone_id = zsInstance->GetZoneID();
  2546. isInstance = true;
  2547. }
  2548. }
  2549. }
  2550. if(!listSearch)
  2551. {
  2552. if(!zone)
  2553. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2554. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2555. zone_id != client->GetCurrentZone()->GetZoneID())
  2556. {
  2557. if(database.VerifyZone(zone))
  2558. {
  2559. if(client->CheckZoneAccess(zone))
  2560. {
  2561. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zone);
  2562. if(isInstance)
  2563. client->Zone(instanceID,true,true);
  2564. else
  2565. client->Zone(zone);
  2566. }
  2567. }
  2568. else
  2569. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zone);
  2570. }
  2571. else
  2572. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2573. }
  2574. else
  2575. {
  2576. const char* name = 0;
  2577. if(sep && sep->arg[1][0])
  2578. {
  2579. map<int32, string>* zone_names;
  2580. name = sep->argplus[1];
  2581. sint16 status = client->GetAdminStatus();
  2582. if( status > 0 )
  2583. {
  2584. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2585. zone_names = database.GetZoneList(name, true);
  2586. }
  2587. else
  2588. zone_names = database.GetZoneList(name);
  2589. if(!zone_names)
  2590. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2591. else
  2592. {
  2593. map<int32, string>::iterator itr;
  2594. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2595. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2596. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2597. safe_delete(zone_names);
  2598. }
  2599. }
  2600. else
  2601. {
  2602. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2603. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2604. }
  2605. }
  2606. safe_delete(zonename);
  2607. break;
  2608. }
  2609. case COMMAND_USE: {
  2610. Spawn* target = cmdTarget;
  2611. if (target->IsWidget())
  2612. ((Widget*)target)->HandleUse(client, "use");
  2613. break;
  2614. }
  2615. case COMMAND_OPEN: {
  2616. Spawn* target = cmdTarget;
  2617. if (target->IsWidget())
  2618. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2619. break;
  2620. }
  2621. case COMMAND_CASTSPELL: {
  2622. if (sep && sep->arg[0] && sep->IsNumber(0))
  2623. {
  2624. int8 tier = 1;
  2625. if (sep->arg[1] && sep->IsNumber(1))
  2626. tier = atoul(sep->arg[1]);
  2627. int32 spellid = atoul(sep->arg[0]);
  2628. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2629. if (spell)
  2630. {
  2631. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2632. SpellProcess* spellProcess = 0;
  2633. // Get the current zones spell process
  2634. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2635. spellProcess->CastInstant(spell, (Entity*)client->GetPlayer(), (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2636. }
  2637. else
  2638. {
  2639. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2640. }
  2641. }
  2642. else if (sep && sep->arg[0])
  2643. {
  2644. database.FindSpell(client, (char*)sep->argplus[0]);
  2645. }
  2646. else
  2647. {
  2648. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2649. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2650. }
  2651. break;
  2652. }
  2653. case COMMAND_KNOWLEDGEWINDOWSORT: {
  2654. if (client->GetVersion() <= 546)
  2655. break;
  2656. if (sep && sep->GetArgNumber() == 4)
  2657. {
  2658. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  2659. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  2660. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  2661. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  2662. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  2663. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  2664. ClientPacketFunctions::SendSkillSlotMappings(client);
  2665. }
  2666. else
  2667. {
  2668. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  2669. }
  2670. break;
  2671. }
  2672. case COMMAND_MOVE_ITEM:
  2673. {
  2674. int32 id = 0;
  2675. if (sep->IsNumber(0))
  2676. id = atoul(sep->arg[0]);
  2677. Spawn* spawn = 0;
  2678. if (id == 0)
  2679. {
  2680. spawn = cmdTarget;
  2681. }
  2682. else
  2683. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2684. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2685. break;
  2686. client->SendMoveObjectMode(spawn, 0);
  2687. break;
  2688. }
  2689. case COMMAND_PICKUP:
  2690. {
  2691. int32 id = 0;
  2692. if (sep->IsNumber(0))
  2693. id = atoul(sep->arg[0]);
  2694. Spawn* spawn = 0;
  2695. if (id == 0)
  2696. {
  2697. spawn = cmdTarget;
  2698. }
  2699. else
  2700. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2701. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2702. break;
  2703. client->AddItem(spawn->GetPickupItemID(), 1);
  2704. Query query;
  2705. 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());
  2706. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  2707. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, true);
  2708. }
  2709. // we had a UI Window displayed, update the house items
  2710. if ( id > 0 )
  2711. client->GetCurrentZone()->SendHouseItems(client);
  2712. break;
  2713. }
  2714. case COMMAND_HOUSE_DEPOSIT:
  2715. {
  2716. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  2717. // arg0 = ??? (set to 3)
  2718. // arg1 = coin (in copper)
  2719. // arg2 = status? (not implemented yet)
  2720. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2721. if (ph && sep && sep->IsNumber(1))
  2722. {
  2723. int64 outVal = strtoull(sep->arg[1], NULL, 0);
  2724. if (client->GetPlayer()->RemoveCoins(outVal))
  2725. {
  2726. char query[256];
  2727. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  2728. if (itr != ph->depositsMap.end())
  2729. {
  2730. 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());
  2731. }
  2732. else
  2733. 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);
  2734. if (database.RunQuery(query, strnlen(query, 256)))
  2735. {
  2736. ph->escrow_coins += outVal;
  2737. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins);
  2738. database.LoadDeposits(ph);
  2739. client->PlaySound("coin_cha_ching");
  2740. HouseZone* hz = world.GetHouseZone(ph->house_id);
  2741. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2742. }
  2743. else
  2744. {
  2745. client->GetPlayer()->AddCoins(outVal);
  2746. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  2747. }
  2748. }
  2749. }
  2750. break;
  2751. }
  2752. case COMMAND_HOUSE:
  2753. {
  2754. if (sep && sep->IsNumber(0))
  2755. {
  2756. int32 unique_id = atoi(sep->arg[0]);
  2757. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2758. HouseZone* hz = 0;
  2759. if (ph)
  2760. hz = world.GetHouseZone(ph->house_id);
  2761. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2762. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2763. }
  2764. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  2765. {
  2766. // inside a house or something? Send the access window
  2767. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2768. HouseZone* hz = 0;
  2769. if ( ph )
  2770. hz = world.GetHouseZone(ph->house_id);
  2771. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2772. client->GetCurrentZone()->SendHouseItems(client);
  2773. }
  2774. break;
  2775. }
  2776. case COMMAND_HOUSE_UI:
  2777. {
  2778. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  2779. {
  2780. int32 unique_id = atoi(sep->arg[0]);
  2781. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2782. HouseZone* hz = 0;
  2783. if ( ph )
  2784. hz = world.GetHouseZone(ph->house_id);
  2785. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2786. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  2787. }
  2788. break;
  2789. }
  2790. case COMMAND_PLACE_HOUSE_ITEM: {
  2791. if (sep && sep->IsNumber(0))
  2792. {
  2793. int32 uniqueid = atoi(sep->arg[0]);
  2794. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  2795. //Item* item = player->GetEquipmentList()->GetItem(slot);
  2796. if (item && item->IsHouseItem())
  2797. {
  2798. if (!client->HasOwnerOrEditAccess())
  2799. {
  2800. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  2801. break;
  2802. }
  2803. else if (!item->generic_info.appearance_id)
  2804. {
  2805. 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);
  2806. break;
  2807. }
  2808. if (client->GetTempPlacementSpawn())
  2809. {
  2810. Spawn* tmp = client->GetTempPlacementSpawn();
  2811. client->GetCurrentZone()->RemoveSpawn(false, tmp);
  2812. delete tmp;
  2813. client->SetTempPlacementSpawn(nullptr);
  2814. }
  2815. Spawn* spawn = new Object();
  2816. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2817. spawn->SetID(Spawn::NextID());
  2818. spawn->SetX(client->GetPlayer()->GetX());
  2819. spawn->SetY(client->GetPlayer()->GetY());
  2820. spawn->SetZ(client->GetPlayer()->GetZ());
  2821. spawn->SetHeading(client->GetPlayer()->GetHeading());
  2822. spawn->SetSpawnOrigX(spawn->GetX());
  2823. spawn->SetSpawnOrigY(spawn->GetY());
  2824. spawn->SetSpawnOrigZ(spawn->GetZ());
  2825. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  2826. spawn->appearance.targetable = 1;
  2827. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  2828. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  2829. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  2830. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  2831. spawn->SetZone(client->GetCurrentZone());
  2832. client->GetCurrentZone()->SendSpawn(spawn, client);
  2833. client->SetTempPlacementSpawn(spawn);
  2834. client->SetPlacementUniqueItemID(uniqueid);
  2835. client->SendMoveObjectMode(spawn, 0);
  2836. }
  2837. }
  2838. break;
  2839. }
  2840. case COMMAND_GM:
  2841. {
  2842. if (sep->arg[0] && sep->arg[1])
  2843. {
  2844. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  2845. if (strcmp(sep->arg[0], "vision") == 0)
  2846. {
  2847. client->GetPlayer()->SetGMVision(onOff);
  2848. #if defined(__GNUC__)
  2849. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  2850. #else
  2851. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  2852. #endif
  2853. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  2854. if (onOff)
  2855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  2856. else
  2857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  2858. }
  2859. else if (strcmp(sep->arg[0], "luadebug") == 0)
  2860. {
  2861. client->SetLuaDebugClient(onOff);
  2862. #if defined(__GNUC__)
  2863. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  2864. #else
  2865. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  2866. #endif
  2867. if (onOff)
  2868. {
  2869. if (lua_interface)
  2870. lua_interface->UpdateDebugClients(client);
  2871. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  2872. }
  2873. else
  2874. {
  2875. if (lua_interface)
  2876. lua_interface->RemoveDebugClients(client);
  2877. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  2878. }
  2879. }
  2880. }
  2881. break;
  2882. }
  2883. case COMMAND_ATTACK:
  2884. case COMMAND_AUTO_ATTACK:{
  2885. int8 type = 1;
  2886. Player* player = client->GetPlayer();
  2887. if(!player)
  2888. break;
  2889. bool incombat = player->EngagedInCombat();
  2890. if(sep && sep->arg[0] && sep->IsNumber(0))
  2891. type = atoi(sep->arg[0]);
  2892. if(client->GetPlayer()->GetHP() == 0){
  2893. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  2894. break;
  2895. }
  2896. if(type == 0){
  2897. if(incombat)
  2898. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  2899. player->InCombat(false);
  2900. player->InCombat(false, true);
  2901. player->SetRangeAttack(false);
  2902. }
  2903. else {
  2904. if(type == 2){
  2905. player->InCombat(false);
  2906. if(incombat && player->GetRangeAttack()){
  2907. player->SetRangeAttack(false);
  2908. player->InCombat(false, true);
  2909. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  2910. }
  2911. else{
  2912. player->SetRangeAttack(true);
  2913. player->InCombat(true, true);
  2914. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  2915. }
  2916. }
  2917. else {
  2918. player->InCombat(false, true);
  2919. player->SetRangeAttack(false);
  2920. player->InCombat(true);
  2921. if(!incombat)
  2922. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  2923. }
  2924. /*else
  2925. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  2926. }
  2927. player->SetCharSheetChanged(true);
  2928. break;
  2929. }
  2930. case COMMAND_DEPOP:{
  2931. bool allow_respawns = false;
  2932. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2933. if(atoi(sep->arg[0]) == 1)
  2934. allow_respawns = true;
  2935. }
  2936. client->GetCurrentZone()->Depop(allow_respawns);
  2937. break;
  2938. }
  2939. case COMMAND_REPOP:{
  2940. client->GetCurrentZone()->Depop(false, true);
  2941. break;
  2942. }
  2943. case COMMAND_BUYBACK:{
  2944. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2945. // 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
  2946. int64 id = atoi64(sep->arg[0]);
  2947. // get the first int32, the item id
  2948. //int32 item_id = (int32)id;
  2949. // get the second int32, the unique id
  2950. int32 unique_id = (int32)(id>>32);
  2951. int8 quantity = atoi(sep->arg[1]);
  2952. if(quantity == 255)
  2953. quantity = 1;
  2954. client->BuyBack(unique_id, quantity);
  2955. }
  2956. break;
  2957. }
  2958. case COMMAND_MERCHANT_BUY:{
  2959. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2960. int32 item_id = atoul(sep->arg[0]);
  2961. int8 quantity = atoi(sep->arg[1]);
  2962. client->BuyItem(item_id, quantity);
  2963. }
  2964. else
  2965. Command_SendMerchantWindow(client, sep);
  2966. break;
  2967. }
  2968. case COMMAND_MERCHANT_SELL:{
  2969. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2970. // 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
  2971. int64 id = atoi64(sep->arg[0]);
  2972. // get the first int32, the item id
  2973. int32 item_id = (int32)id;
  2974. // get the second int32, the unique id
  2975. int32 unique_id = (int32)(id>>32);
  2976. int8 quantity = atoi(sep->arg[1]);
  2977. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  2978. client->SellItem(item_id, quantity, unique_id);
  2979. }
  2980. break;
  2981. }
  2982. case COMMAND_MENDER_REPAIR: {
  2983. if (sep && sep->arg[0] && sep->IsNumber(0))
  2984. client->RepairItem(atoul(sep->arg[0]));
  2985. break;
  2986. }
  2987. case COMMAND_MENDER_REPAIR_ALL: {
  2988. client->RepairAllItems();
  2989. break;
  2990. }
  2991. case COMMAND_CANCEL_MERCHANT:{
  2992. client->SetMerchantTransaction(0);
  2993. break;
  2994. }
  2995. case COMMAND_START_MERCHANT:{
  2996. break;
  2997. }
  2998. case COMMAND_INVULNERABLE:{
  2999. sint8 val = -1;
  3000. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3001. val = atoi(sep->arg[0]);
  3002. //devn00b: Fix for linux builds
  3003. #if defined(__GNUC__)
  3004. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  3005. #else
  3006. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3007. #endif
  3008. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3009. client->GetPlayer()->SetInvulnerable(val==1);
  3010. if(client->GetPlayer()->GetInvulnerable())
  3011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  3012. else
  3013. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  3014. }
  3015. if(val == -1)
  3016. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  3017. break;
  3018. }
  3019. case COMMAND_REPAIR: {
  3020. Spawn* spawn = cmdTarget;
  3021. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  3022. client->SendHailCommand(spawn);
  3023. client->SetMerchantTransaction(spawn);
  3024. client->SendRepairList();
  3025. }
  3026. break;
  3027. }
  3028. case COMMAND_LOTTO: {
  3029. Spawn* spawn = cmdTarget;
  3030. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  3031. client->SetMerchantTransaction(spawn);
  3032. client->ShowLottoWindow();
  3033. }
  3034. break;
  3035. }
  3036. case COMMAND_ACCEPT_REWARD:{
  3037. int32 unknown = 0;
  3038. int32 selectable_item_id = 0;
  3039. //Quest *quest = 0;
  3040. Collection *collection = 0;
  3041. /* no idea what the first argument is for (faction maybe?)
  3042. if the reward has a selectable item reward, it's sent as the second argument
  3043. if neither of these are included in the reward, there is no sep
  3044. 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
  3045. only 1 quest or collection reward may be displayed at a time */
  3046. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3047. unknown = atoul(sep->arg[0]);
  3048. selectable_item_id = atoul(sep->arg[1]);
  3049. }
  3050. //if ((quest = player->GetPendingQuestReward()))
  3051. // client->AcceptQuestRewards(quest, selectable_item_id);
  3052. /* the below needs to go away eventually and be redone */
  3053. int32 item_id = 0;
  3054. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3055. item_id = atoul(sep->arg[0]);
  3056. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3057. if(quest){
  3058. client->AcceptQuestReward(quest, item_id);
  3059. break;
  3060. }
  3061. bool collectedItems = false;
  3062. if (collection = player->GetPendingCollectionReward())
  3063. client->AcceptCollectionRewards(collection, selectable_item_id);
  3064. else if (client->GetPlayer()->HasPendingItemRewards()) {
  3065. vector<Item*> items = client->GetPlayer()->GetPendingItemRewards();
  3066. if (items.size() > 0) {
  3067. collectedItems = true;
  3068. for (int i = 0; i < items.size(); i++) {
  3069. client->GetPlayer()->AddItem(new Item(items[i]));
  3070. }
  3071. client->GetPlayer()->ClearPendingItemRewards();
  3072. }
  3073. map<int32, Item*> selectable_item = client->GetPlayer()->GetPendingSelectableItemReward(item_id);
  3074. if (selectable_item.size() > 0) {
  3075. collectedItems = true;
  3076. map<int32, Item*>::iterator itr;
  3077. for (itr = selectable_item.begin(); itr != selectable_item.end(); itr++) {
  3078. client->GetPlayer()->AddItem(new Item(itr->second));
  3079. client->GetPlayer()->ClearPendingSelectableItemRewards(itr->first);
  3080. }
  3081. }
  3082. }
  3083. if (collectedItems) {
  3084. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  3085. if (outapp)
  3086. client->QueuePacket(outapp);
  3087. }
  3088. else
  3089. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  3090. break;
  3091. }
  3092. case COMMAND_BUY_FROM_BROKER:{
  3093. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3094. int32 item_id = atoul(sep->arg[0]);
  3095. int16 quantity = atoul(sep->arg[1]);
  3096. client->AddItem(item_id, quantity);
  3097. }
  3098. break;
  3099. }
  3100. case COMMAND_SEARCH_STORES_PAGE:{
  3101. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3102. int32 page = atoul(sep->arg[0]);
  3103. client->SearchStore(page);
  3104. }
  3105. break;
  3106. }
  3107. case COMMAND_SEARCH_STORES:{
  3108. if(sep && sep->arg[0][0]){
  3109. const char* values = sep->argplus[0];
  3110. if(values){
  3111. map<string, string> str_values = TranslateBrokerRequest(values);
  3112. vector<Item*>* items = master_item_list.GetItems(str_values);
  3113. if(items){
  3114. client->SetItemSearch(items);
  3115. client->SearchStore(0);
  3116. }
  3117. }
  3118. }
  3119. break;
  3120. }
  3121. case COMMAND_LUADEBUG:{
  3122. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  3123. client->SetLuaDebugClient(true);
  3124. if(lua_interface)
  3125. lua_interface->UpdateDebugClients(client);
  3126. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3127. }
  3128. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  3129. client->SetLuaDebugClient(false);
  3130. if(lua_interface)
  3131. lua_interface->RemoveDebugClients(client);
  3132. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3133. }
  3134. else{
  3135. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  3136. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  3137. }
  3138. break;
  3139. }
  3140. case COMMAND_SPAWN_GROUP:
  3141. {
  3142. Spawn* target = cmdTarget;
  3143. if(target && target->IsPlayer() == false)
  3144. {
  3145. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  3146. {
  3147. if(target->GetSpawnLocationPlacementID() > 0)
  3148. {
  3149. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  3150. {
  3151. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  3152. if(id > 0)
  3153. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  3154. else
  3155. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  3156. target->SetSpawnGroupID(id);
  3157. target->AddSpawnToGroup(target);
  3158. }
  3159. else
  3160. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  3161. }
  3162. else
  3163. 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.");
  3164. }
  3165. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  3166. {
  3167. if(sep->arg[1] && sep->IsNumber(1))
  3168. {
  3169. int32 group_id = atoul(sep->arg[1]);
  3170. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  3171. if(leader)
  3172. {
  3173. leader->AddSpawnToGroup(target);
  3174. target->SetSpawnGroupID(group_id);
  3175. if(database.SpawnGroupAddSpawn(target, group_id))
  3176. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  3177. else
  3178. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  3179. }
  3180. else
  3181. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  3182. }
  3183. else
  3184. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  3185. }
  3186. else if(target->GetSpawnGroupID() == 0)
  3187. {
  3188. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  3189. }
  3190. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  3191. {
  3192. int32 group_id = target->GetSpawnGroupID();
  3193. target->RemoveSpawnFromGroup();
  3194. if(database.SpawnGroupRemoveSpawn(target, group_id))
  3195. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  3196. else
  3197. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  3198. }
  3199. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  3200. {
  3201. int32 group_id = target->GetSpawnGroupID();
  3202. if(sep->arg[1] && sep->IsNumber(1))
  3203. {
  3204. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  3205. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  3206. else
  3207. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  3208. }
  3209. else
  3210. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  3211. }
  3212. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  3213. {
  3214. int32 group_id = target->GetSpawnGroupID();
  3215. if(sep->arg[1] && sep->IsNumber(1))
  3216. {
  3217. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  3218. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  3219. else
  3220. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  3221. }
  3222. else
  3223. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  3224. }
  3225. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  3226. {
  3227. if(sep->arg[1] && sep->IsNumber(1))
  3228. {
  3229. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  3230. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  3231. else
  3232. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  3233. }
  3234. else
  3235. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  3236. }
  3237. else
  3238. {
  3239. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  3240. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  3241. }
  3242. }
  3243. else
  3244. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  3245. break;
  3246. }
  3247. case COMMAND_SPAWN_COMBINE:{
  3248. Spawn* spawn = cmdTarget;
  3249. float radius = 0;
  3250. bool failed = true;
  3251. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  3252. failed = false;
  3253. if(spawn->GetSpawnGroupID() > 0){
  3254. 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.");
  3255. }
  3256. else if(sep->IsNumber(0)){
  3257. radius = atof(sep->arg[0]);
  3258. client->CombineSpawns(radius, spawn);
  3259. }
  3260. else{
  3261. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  3262. client->AddCombineSpawn(spawn);
  3263. }
  3264. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  3265. client->RemoveCombineSpawn(spawn);
  3266. }
  3267. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  3268. const char* name = 0;
  3269. if(sep->arg[1] && sep->arg[1][0])
  3270. name = sep->argplus[1];
  3271. client->SaveCombineSpawns(name);
  3272. }
  3273. else
  3274. failed = true;
  3275. }
  3276. }
  3277. if(failed){
  3278. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  3279. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  3280. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  3281. }
  3282. break;
  3283. }
  3284. case COMMAND_SPAWN_CREATE:{
  3285. Spawn* spawn = 0;
  3286. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3287. spawn = new Object();
  3288. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3289. }
  3290. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3291. spawn = new GroundSpawn();
  3292. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3293. }
  3294. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3295. spawn = new Sign();
  3296. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3297. }
  3298. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3299. spawn = new NPC();
  3300. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3301. spawn->appearance.pos.collision_radius = 32;
  3302. spawn->secondary_command_list_id = 0;
  3303. spawn->primary_command_list_id = 0;
  3304. spawn->appearance.display_name = 1;
  3305. spawn->appearance.show_level = 1;
  3306. spawn->appearance.attackable = 1;
  3307. }
  3308. else{
  3309. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  3310. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  3311. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  3312. break;
  3313. }
  3314. spawn->SetID(Spawn::NextID());
  3315. spawn->SetX(client->GetPlayer()->GetX());
  3316. spawn->SetY(client->GetPlayer()->GetY());
  3317. spawn->SetZ(client->GetPlayer()->GetZ());
  3318. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3319. spawn->SetSpawnOrigX(spawn->GetX());
  3320. spawn->SetSpawnOrigY(spawn->GetY());
  3321. spawn->SetSpawnOrigZ(spawn->GetZ());
  3322. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3323. spawn->appearance.targetable = 1;
  3324. spawn->appearance.race = 255;
  3325. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3326. spawn->SetModelType(atoi(sep->arg[1]));
  3327. spawn->SetAdventureClass(atoi(sep->arg[2]));
  3328. spawn->SetLevel(atoi(sep->arg[3]));
  3329. spawn->SetName(sep->arg[4]);
  3330. if(sep->arg[5][0] && sep->IsNumber(5))
  3331. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  3332. if(sep->arg[6][0] && sep->IsNumber(6))
  3333. spawn->size = atoi(sep->arg[6]);
  3334. if(spawn->GetTotalHP() == 0){
  3335. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  3336. spawn->SetHP(25*spawn->GetLevel() + 1);
  3337. }
  3338. if(spawn->GetTotalPower() == 0){
  3339. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3340. spawn->SetPower(25*spawn->GetLevel() + 1);
  3341. }
  3342. client->GetCurrentZone()->AddSpawn(spawn);
  3343. break;
  3344. }
  3345. case COMMAND_SPAWN_EQUIPMENT:{
  3346. Spawn* spawn = cmdTarget;
  3347. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3348. int8 slot = atoi(sep->arg[0]);
  3349. int16 type = atoi(sep->arg[1]);
  3350. int8 red = 0;
  3351. int8 green = 0;
  3352. int8 blue = 0;
  3353. int8 h_red = 0;
  3354. int8 h_green = 0;
  3355. int8 h_blue = 0;
  3356. if(sep->arg[2])
  3357. red = atoi(sep->arg[2]);
  3358. if(sep->arg[3])
  3359. green = atoi(sep->arg[3]);
  3360. if(sep->arg[4])
  3361. blue = atoi(sep->arg[4]);
  3362. if(sep->arg[5])
  3363. h_red = atoi(sep->arg[5]);
  3364. if(sep->arg[6])
  3365. h_green = atoi(sep->arg[6]);
  3366. if(sep->arg[7])
  3367. h_blue = atoi(sep->arg[7]);
  3368. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3369. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3370. }
  3371. else{
  3372. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3373. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3374. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3375. }
  3376. break;
  3377. }
  3378. case COMMAND_SPAWN_DETAILS: {
  3379. Spawn* spawn = cmdTarget;
  3380. if (sep && sep->arg[0][0]) {
  3381. if (cmdTarget)
  3382. {
  3383. if (ToLower(string(sep->arg[0])) == "los")
  3384. {
  3385. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3386. if (hasLOS)
  3387. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3388. else
  3389. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3390. break;
  3391. }
  3392. else if (ToLower(string(sep->arg[0])) == "bestz")
  3393. {
  3394. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3395. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3396. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3397. break;
  3398. }
  3399. else if (ToLower(string(sep->arg[0])) == "pathto")
  3400. {
  3401. break;
  3402. }
  3403. else if (ToLower(string(sep->arg[0])) == "pathfrom")
  3404. {
  3405. break;
  3406. }
  3407. }
  3408. if (sep->IsNumber(0))
  3409. {
  3410. float radius = atof(sep->arg[0]);
  3411. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3412. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3413. break;
  3414. }
  3415. }
  3416. if (spawn) {
  3417. const char* type = "NPC";
  3418. if (spawn->IsObject())
  3419. type = "Object";
  3420. else if (spawn->IsSign())
  3421. type = "Sign";
  3422. else if (spawn->IsWidget())
  3423. type = "Widget";
  3424. else if (spawn->IsGroundSpawn())
  3425. type = "GroundSpawn";
  3426. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3427. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3428. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3429. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3430. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3431. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3432. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3433. 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());
  3434. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3435. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3436. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3437. if (spawn->IsEntity()) {
  3438. 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());
  3439. 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());
  3440. }
  3441. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3442. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3443. 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());
  3444. 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);
  3445. if (spawn->IsNPC())
  3446. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3447. string details;
  3448. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3449. details += "Type: " + string(type) + "\n";
  3450. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3451. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3452. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3453. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3454. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3455. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3456. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3457. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3458. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3459. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3460. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3461. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3462. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3463. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3464. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3465. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3466. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3467. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3468. char x[16];
  3469. sprintf(x, "%.2f", spawn->GetX());
  3470. char y[16];
  3471. sprintf(y, "%.2f", spawn->GetY());
  3472. char z[16];
  3473. sprintf(z, "%.2f", spawn->GetZ());
  3474. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3475. string details2;
  3476. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3477. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3478. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3479. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3480. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3481. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3482. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3483. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3484. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3485. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3486. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3487. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3488. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3489. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3490. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3491. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3492. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3493. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3494. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3495. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3496. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3497. string details3;
  3498. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3499. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3500. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3501. string details4;
  3502. if (spawn->IsEntity()) {
  3503. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3504. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3505. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3506. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3507. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3508. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3509. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3510. if (spawn->IsNPC()) {
  3511. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3512. }
  3513. }
  3514. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3515. client->SendShowBook(client->GetPlayer(), title, 4, details, details2, details3, details4);
  3516. }
  3517. else {
  3518. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3519. 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.");
  3520. }
  3521. break;
  3522. }
  3523. case COMMAND_SPAWN_TARGET:{
  3524. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3525. int32 spawn_id = atoul(sep->arg[0]);
  3526. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3527. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3528. }
  3529. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3530. float distance = atof(sep->arg[1]);
  3531. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3532. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3533. }
  3534. else{
  3535. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3536. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3537. }
  3538. break;
  3539. }
  3540. case COMMAND_SPAWN_SET:
  3541. {
  3542. Spawn* spawn = cmdTarget;
  3543. sint16 set_type = -1;
  3544. string type_str;
  3545. if (spawn)
  3546. {
  3547. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3548. 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)
  3549. {
  3550. // set the type, which will be 0 if location or list or invalid
  3551. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3552. }
  3553. if(set_type > 0)
  3554. {
  3555. // check if spawn set is NOT a char update, or not location, or isn't a number
  3556. 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)
  3557. {
  3558. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3559. }
  3560. else
  3561. {
  3562. string name = string(spawn->GetName());
  3563. if(SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  3564. {
  3565. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  3566. {
  3567. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  3568. }
  3569. else if (set_type == SPAWN_SET_VALUE_NAME)
  3570. {
  3571. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3572. }
  3573. else if (set_type == SPAWN_SET_SKIN_COLOR)
  3574. {
  3575. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set skin_color to R G B: %s.", sep->argplus[1]);
  3576. }
  3577. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3578. {
  3579. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3580. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3581. }
  3582. else
  3583. {
  3584. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3585. }
  3586. switch (set_type)
  3587. {
  3588. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  3589. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  3590. case SPAWN_SET_VALUE_FACTION:
  3591. {
  3592. // not applicable
  3593. break;
  3594. }
  3595. default:
  3596. {
  3597. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  3598. break;
  3599. }
  3600. }
  3601. 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))
  3602. {
  3603. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3604. {
  3605. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3606. }
  3607. else if(spawn->GetSpawnLocationID() > 0)
  3608. {
  3609. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3610. }
  3611. }
  3612. else
  3613. {
  3614. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3615. {
  3616. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3617. }
  3618. else if(spawn->GetDatabaseID() > 0)
  3619. {
  3620. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3621. }
  3622. }
  3623. }
  3624. }
  3625. }
  3626. else if(set_type == 0)
  3627. {
  3628. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3629. map<string, int8>::iterator itr;
  3630. int i=0;
  3631. string list;
  3632. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3633. {
  3634. if(i==10)
  3635. {
  3636. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3637. i = 0;
  3638. }
  3639. if(i>0)
  3640. {
  3641. list.append(", ").append(itr->first);
  3642. }
  3643. else
  3644. {
  3645. list = itr->first;
  3646. }
  3647. }
  3648. if(list.length() > 0)
  3649. {
  3650. // if 1 or more, display in client.
  3651. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3652. }
  3653. }
  3654. else
  3655. {
  3656. // syntax fail
  3657. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3658. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3659. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3660. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3661. }
  3662. }
  3663. break;
  3664. }
  3665. case COMMAND_SPAWN_REMOVE:{
  3666. Spawn* spawn = cmdTarget;
  3667. if(spawn && !spawn->IsPlayer()){
  3668. if(spawn->GetSpawnLocationID() > 0){
  3669. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3670. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, false);
  3671. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3672. }
  3673. else
  3674. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3675. }
  3676. else
  3677. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3678. }
  3679. else{
  3680. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3681. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3682. }
  3683. break;
  3684. }
  3685. case COMMAND_SPAWN_LIST:{
  3686. if(sep && sep->arg[0][0]){
  3687. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3688. vector<string>::iterator itr;
  3689. if(results){
  3690. for(itr=results->begin();itr!=results->end();itr++){
  3691. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3692. }
  3693. safe_delete(results);
  3694. }
  3695. else
  3696. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3697. }
  3698. else{
  3699. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3700. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3701. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3702. }
  3703. break;
  3704. }
  3705. case COMMAND_SPAWN_ADD:{
  3706. Spawn* spawn = cmdTarget;
  3707. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3708. if(spawn->GetSpawnLocationID() > 0){
  3709. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3710. break;
  3711. }
  3712. if(spawn->GetDatabaseID() == 0){
  3713. if(database.SaveSpawnInfo(spawn)) {
  3714. char spawn_type[32];
  3715. memset(spawn_type, 0, sizeof(spawn_type));
  3716. if (spawn->IsNPC())
  3717. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3718. else if (spawn->IsObject())
  3719. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3720. else if (spawn->IsSign())
  3721. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3722. else if (spawn->IsGroundSpawn())
  3723. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3724. else
  3725. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3726. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3727. }
  3728. else
  3729. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3730. }
  3731. int32 spawn_group_id = 0;
  3732. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3733. spawn_group_id = database.GetNextSpawnLocation();
  3734. else
  3735. spawn_group_id = atol(sep->arg[0]);
  3736. int8 percent = 100;
  3737. if(sep->arg[2] && sep->IsNumber(2))
  3738. percent = atoi(sep->arg[2]);
  3739. spawn->SetSpawnLocationID(spawn_group_id);
  3740. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3741. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3742. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3743. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3744. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3745. else
  3746. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3747. }
  3748. else{
  3749. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3750. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3751. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3752. }
  3753. break;
  3754. }
  3755. case COMMAND_SPAWN:{
  3756. int32 id = 0;
  3757. Spawn* spawn = 0;
  3758. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3759. id = atol(sep->arg[0]);
  3760. spawn = client->GetCurrentZone()->GetSpawn(id);
  3761. }
  3762. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3763. id = 0;
  3764. if(!id || !spawn){
  3765. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3766. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3767. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3768. safe_delete(sep);
  3769. return;
  3770. }
  3771. if(sep && sep->arg[1][0]){
  3772. float x = atof(sep->arg[1]);
  3773. spawn->appearance.pos.X = x;
  3774. }
  3775. else
  3776. spawn->SetX(client->GetPlayer()->GetX(), false);
  3777. if(sep && sep->arg[2][0]){
  3778. float y = atof(sep->arg[2]);
  3779. spawn->appearance.pos.Y = y;
  3780. }
  3781. else
  3782. spawn->SetY(client->GetPlayer()->GetY(), false);
  3783. if(sep && sep->arg[3][0]){
  3784. float z = atof(sep->arg[3]);
  3785. spawn->appearance.pos.Z = z;
  3786. }
  3787. else
  3788. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3789. if(sep && sep->arg[4][0]){
  3790. float heading = atof(sep->arg[4]);
  3791. spawn->SetHeading(heading);
  3792. }
  3793. else
  3794. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3795. spawn->SetSpawnOrigX(spawn->GetX());
  3796. spawn->SetSpawnOrigY(spawn->GetY());
  3797. spawn->SetSpawnOrigZ(spawn->GetZ());
  3798. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3799. if(sep && sep->arg[5][0])
  3800. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3801. else
  3802. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3803. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3804. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3805. spawn->SetHP(spawn->GetTotalHP());
  3806. }
  3807. if(spawn->GetTotalPower() == 0){
  3808. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3809. spawn->SetPower(spawn->GetTotalPower());
  3810. }
  3811. const char* script = world.GetSpawnScript(id);
  3812. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3813. spawn->SetSpawnScript(string(script));
  3814. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  3815. client->GetCurrentZone()->AddSpawn(spawn);
  3816. if(spawn->IsNPC())
  3817. spawn->GetZone()->AddLoot((NPC*)spawn);
  3818. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3819. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3820. break;
  3821. }
  3822. case COMMAND_ADMINFLAG:
  3823. {
  3824. if(sep && sep->arg[0]){
  3825. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3826. sint16 new_status = atoi(sep->arg[1]);
  3827. if(tmp_status == -10)
  3828. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3829. else if(tmp_status >= client->GetAdminStatus())
  3830. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3831. else if (new_status > client->GetAdminStatus())
  3832. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3833. else{
  3834. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3835. if (!client2)
  3836. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3837. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3838. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3839. if (client2) {
  3840. client2->SetAdminStatus(new_status);
  3841. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3842. }
  3843. }
  3844. else
  3845. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3846. }
  3847. }else{
  3848. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3849. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3850. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3851. }
  3852. break;
  3853. }
  3854. case COMMAND_CANNEDEMOTE:{
  3855. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3856. break;
  3857. }
  3858. case COMMAND_BROADCAST: {
  3859. if (sep && sep->arg[0])
  3860. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3861. else
  3862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3863. break;
  3864. }
  3865. case COMMAND_ANNOUNCE: {
  3866. if (sep && sep->arg[0])
  3867. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3868. else
  3869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3870. break;
  3871. }
  3872. case COMMAND_RELOAD_ITEMS:{
  3873. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3875. database.ReloadItemList();
  3876. database.LoadMerchantInformation();
  3877. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3878. break;
  3879. }
  3880. case COMMAND_ENABLE_ABILITY_QUE:{
  3881. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3882. if(app)
  3883. client->QueuePacket(app);
  3884. break;
  3885. }
  3886. case COMMAND_ITEMSEARCH:{
  3887. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3888. if (packet) {
  3889. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3890. //packet->setDataByName("unknown", 1);
  3891. packet->setDataByName("unknown2", 5, 0);
  3892. packet->setDataByName("unknown2", 20, 1);
  3893. packet->setDataByName("unknown2", 58, 3);
  3894. packet->setDataByName("unknown2", 40, 4);
  3895. client->QueuePacket(packet->serialize());
  3896. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3897. if (packet2) {
  3898. packet2->setDataByName("char_id", client->GetCharacterID());
  3899. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3900. safe_delete(packet2);
  3901. }
  3902. safe_delete(packet);
  3903. }
  3904. break;
  3905. }
  3906. case COMMAND_ANIMTEST:{
  3907. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3908. if(command_packet){
  3909. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  3910. if (cmdTarget)
  3911. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  3912. command_packet->setDataByName ( "spawn_id" , id);
  3913. int animID = 1;
  3914. if(sep && sep->arg[0] && sep->IsNumber(0))
  3915. animID = atoi(sep->arg[0]);
  3916. VisualState* vs = NULL;
  3917. if(animID == 0)
  3918. {
  3919. vs = visual_states.FindVisualState(sep->arg[0]);
  3920. }
  3921. char msg[128];
  3922. sprintf(msg,"Animation Test ID: %i",animID);
  3923. command_packet->setMediumStringByName ( "emote_msg" , msg );
  3924. if(vs != NULL)
  3925. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  3926. else
  3927. command_packet->setDataByName ( "anim_type", animID );
  3928. command_packet->setDataByName ( "unknown0", 0 );
  3929. EQ2Packet* outapp = command_packet->serialize();
  3930. client->QueuePacket(outapp);
  3931. safe_delete(command_packet);
  3932. }
  3933. break;
  3934. }
  3935. case COMMAND_KICK:
  3936. {
  3937. if( sep == 0 || sep->arg[0] == 0)
  3938. {
  3939. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  3940. }
  3941. else
  3942. {
  3943. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  3944. if ( kickClient == client )
  3945. {
  3946. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  3947. break;
  3948. }
  3949. else if(kickClient != NULL)
  3950. {
  3951. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3952. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  3953. {
  3954. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3955. break;
  3956. }
  3957. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  3958. kickClient->Disconnect();
  3959. }
  3960. else
  3961. {
  3962. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3963. }
  3964. }
  3965. break;
  3966. }
  3967. case COMMAND_LOCK:
  3968. {
  3969. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  3970. int worldLocked = atoi(sep->arg[0]);
  3971. net.world_locked = worldLocked;
  3972. if ( worldLocked )
  3973. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  3974. else
  3975. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  3976. }
  3977. else
  3978. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  3979. break;
  3980. }
  3981. case COMMAND_BAN:{
  3982. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  3983. {
  3984. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  3985. }
  3986. else
  3987. {
  3988. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  3989. if ( kickClient == client )
  3990. {
  3991. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  3992. break;
  3993. }
  3994. else if(kickClient != NULL)
  3995. {
  3996. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3997. if ( maxStatus > client->GetAdminStatus( ) ||
  3998. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  3999. {
  4000. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  4001. break;
  4002. }
  4003. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  4004. int perm = atol(sep->arg[1]);
  4005. if ( perm == 1 )
  4006. database.UpdateAdminStatus(sep->arg[0],-2);
  4007. else
  4008. database.UpdateAdminStatus(sep->arg[0],-1);
  4009. kickClient->Disconnect();
  4010. }
  4011. else
  4012. {
  4013. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  4014. }
  4015. }
  4016. break;
  4017. }
  4018. case COMMAND_SET_COMBAT_VOICE:{
  4019. int32 value = 0;
  4020. if(sep && sep->arg[0] && sep->IsNumber(0))
  4021. value = atoi(sep->arg[0]);
  4022. client->GetPlayer()->SetCombatVoice(value);
  4023. break;
  4024. }
  4025. case COMMAND_SET_EMOTE_VOICE:{
  4026. int32 value = 0;
  4027. if(sep && sep->arg[0] && sep->IsNumber(0))
  4028. value = atoi(sep->arg[0]);
  4029. client->GetPlayer()->SetEmoteVoice(value);
  4030. break;
  4031. }
  4032. case COMMAND_GIVEITEM:{
  4033. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  4034. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  4035. if ( itemToClient == NULL )
  4036. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  4037. else
  4038. {
  4039. int32 item_id = atol(sep->arg[1]);
  4040. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  4041. itemToClient->AddItem(item_id);
  4042. }
  4043. }
  4044. else
  4045. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  4046. break;
  4047. }
  4048. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  4049. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  4050. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  4051. case COMMAND_SKILL :
  4052. case COMMAND_SKILL_ADD :
  4053. case COMMAND_SKILL_REMOVE :
  4054. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  4055. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  4056. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  4057. case COMMAND_ENTITYCOMMAND :
  4058. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  4059. case COMMAND_MERCHANT :
  4060. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  4061. case COMMAND_APPEARANCE :
  4062. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  4063. case COMMAND_TRACK : { Command_Track(client); break; }
  4064. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  4065. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  4066. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  4067. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  4068. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  4069. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  4070. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  4071. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  4072. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  4073. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  4074. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  4075. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  4076. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  4077. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  4078. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  4079. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  4080. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  4081. case COMMAND_LOCATION : { Command_Location(client); break; }
  4082. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  4083. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  4084. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  4085. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  4086. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  4087. case COMMAND_GRID : { Command_Grid(client); break; }
  4088. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  4089. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  4090. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  4091. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  4092. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  4093. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  4094. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  4095. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  4096. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  4097. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  4098. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  4099. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  4100. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  4101. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  4102. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  4103. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  4104. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  4105. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  4106. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  4107. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  4108. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  4109. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  4110. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  4111. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  4112. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  4113. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  4114. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  4115. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  4116. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  4117. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  4118. case COMMAND_MOTD : { Command_MOTD(client); break; }
  4119. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  4120. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  4121. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  4122. case COMMAND_TITLE : { Command_Title(client); break; }
  4123. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  4124. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  4125. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  4126. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  4127. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  4128. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  4129. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  4130. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  4131. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  4132. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  4133. case COMMAND_PET : { Command_Pet(client, sep); break; }
  4134. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  4135. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  4136. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  4137. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  4138. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  4139. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  4140. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  4141. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  4142. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  4143. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  4144. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  4145. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  4146. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  4147. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  4148. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  4149. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  4150. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  4151. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  4152. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  4153. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  4154. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  4155. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  4156. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  4157. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  4158. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  4159. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  4160. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  4161. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  4162. case COMMAND_MODIFY : { Command_Modify(client); break; }
  4163. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  4164. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  4165. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  4166. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  4167. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  4168. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  4169. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  4170. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  4171. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  4172. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  4173. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  4174. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  4175. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  4176. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  4177. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  4178. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  4179. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  4180. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  4181. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  4182. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  4183. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  4184. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  4185. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  4186. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  4187. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  4188. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  4189. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  4190. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  4191. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  4192. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  4193. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  4194. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  4195. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  4196. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  4197. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  4198. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  4199. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  4200. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  4201. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  4202. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  4203. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  4204. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  4205. case ADD_AA : { Add_AA(client, sep); break; }
  4206. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  4207. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  4208. case BACK_AA : { Back_AA(client, sep); break; }
  4209. case REMOVE_AA : { Remove_AA(client, sep); break; }
  4210. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  4211. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  4212. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  4213. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  4214. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  4215. default:
  4216. {
  4217. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  4218. break;
  4219. }
  4220. }
  4221. safe_delete(sep);
  4222. }
  4223. /******************** New COMMAND Handler Functions ********************/
  4224. /*
  4225. Started breaking apart the huge switch() for commands into sepErate
  4226. functions so it is easier to locate the blocks of code by command
  4227. -- JA 2012.03.03
  4228. */
  4229. // sample function header
  4230. /*
  4231. Function:
  4232. Purpose :
  4233. Params :
  4234. Dev :
  4235. Example :
  4236. */
  4237. //void Commands::Command()
  4238. //{
  4239. //}
  4240. /*
  4241. Function: Command_AcceptAdvancement()
  4242. Purpose : Player accepts a new advancement option
  4243. Params : Spell ID
  4244. Dev : Jabantiz
  4245. */
  4246. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4247. {
  4248. Player *player = client->GetPlayer();
  4249. if (sep && sep->IsSet(0)) {
  4250. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4251. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4252. if (!player->HasSpell(trait->spellID, 0, true))
  4253. {
  4254. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4255. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4256. }
  4257. else
  4258. {
  4259. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4260. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4261. player->RemoveSpellBookEntry(spell->GetSpellID());
  4262. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4263. player->UnlockSpell(spell);
  4264. client->SendSpellUpdate(spell);
  4265. }
  4266. // Spell book update
  4267. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4268. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4269. }
  4270. }
  4271. /*
  4272. Function:
  4273. Purpose :
  4274. Params :
  4275. Dev :
  4276. Example :
  4277. */
  4278. void Commands::Command_AFK(Client* client, Seperator* sep)
  4279. {
  4280. Player* player = client->GetPlayer();
  4281. player->toggle_character_flag(CF_AFK);
  4282. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4283. if (player->get_character_flag(CF_AFK))
  4284. {
  4285. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4286. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  4287. if (sep && sep->argplus[0])
  4288. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4289. else
  4290. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4291. string message = string(player->GetName()) + " is going afk.";
  4292. Spawn* target = player->GetTarget();
  4293. if (target && target != player)
  4294. {
  4295. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4296. player->GetGender() == 1 ? message += "he" : message += "she";
  4297. message += " is going afk.";
  4298. }
  4299. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4300. }
  4301. /*else
  4302. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  4303. }
  4304. /*
  4305. Function: Command_Appearance()
  4306. Purpose : Handles /appearance commands
  4307. Params : list
  4308. Dev : Scatman
  4309. Example : /appearance list
  4310. */
  4311. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4312. {
  4313. if( handler == COMMAND_APPEARANCE )
  4314. {
  4315. // /appearance command by itself shows help (to be extended)
  4316. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4317. return;
  4318. }
  4319. else if( handler == COMMAND_APPEARANCE_LIST )
  4320. {
  4321. // /appearance list command expects "name" param
  4322. if (sep && sep->arg[0])
  4323. {
  4324. const char* appearance_name = sep->argplus[0];
  4325. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4326. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4327. if (appearances)
  4328. {
  4329. vector<int16>::iterator itr;
  4330. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4331. {
  4332. int16 id = *itr;
  4333. string name = database.GetAppearanceName(id);
  4334. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4335. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4336. }
  4337. safe_delete(appearances);
  4338. }
  4339. }
  4340. else // no param
  4341. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4342. }
  4343. }
  4344. /*
  4345. Function: Command_Claim()
  4346. Purpose :
  4347. Params :
  4348. Dev :
  4349. Example :
  4350. */
  4351. void Commands::Command_Claim(Client* client, Seperator* sep)
  4352. {
  4353. if (sep && sep->arg[0] && sep->IsNumber(0))
  4354. {
  4355. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4356. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4357. }
  4358. else
  4359. client->ShowClaimWindow();
  4360. }
  4361. /*
  4362. Function: Command_ClearAllQueued()
  4363. Purpose :
  4364. Params :
  4365. Dev :
  4366. Example :
  4367. */
  4368. void Commands::Command_ClearAllQueued(Client* client)
  4369. {
  4370. ZoneServer* zone = client->GetPlayer()->GetZone();
  4371. if (zone && zone->GetSpellProcess())
  4372. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4373. }
  4374. /*
  4375. Function: Command_CancelMaintained()
  4376. Purpose : Cancels maintained spells
  4377. Params : Maintained Spell Index
  4378. Dev : Zcoretri
  4379. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4380. */
  4381. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4382. {
  4383. if (sep && sep->arg[0] && sep->IsNumber(0))
  4384. {
  4385. int32 spell_index = atoul(sep->arg[0]);
  4386. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4387. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4388. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4389. // just not spelleffects/dets - Foof
  4390. //{
  4391. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled"))
  4392. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4393. // }
  4394. //else
  4395. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4396. }
  4397. }
  4398. /*
  4399. Function: Command_Create()
  4400. Purpose : Handler for starting Tradeskilling table
  4401. Params :
  4402. Dev : Zcoretri
  4403. Example :
  4404. */
  4405. void Commands::Command_Create(Client* client, Seperator* sep)
  4406. {
  4407. PrintSep(sep, "COMMAND_CREATE");
  4408. client->SendRecipeList();
  4409. client->ShowRecipeBook();
  4410. }
  4411. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4412. {
  4413. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4414. if (sep && sep->arg[0] && sep->IsNumber(0))
  4415. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4416. }
  4417. /*
  4418. Function: Command_Distance()
  4419. Purpose : Displays distance from targeted spawn
  4420. Params :
  4421. Dev : Scatman
  4422. Example : /distance
  4423. */
  4424. void Commands::Command_Distance(Client* client)
  4425. {
  4426. Spawn* target = client->GetPlayer()->GetTarget();
  4427. if (target)
  4428. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4429. else
  4430. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4431. }
  4432. /*
  4433. Function: Command_Duel()
  4434. Purpose : Handle the /duel commands - not yet implemented
  4435. Params : unknown
  4436. Dev :
  4437. Example :
  4438. */
  4439. void Commands::Command_Duel(Client* client, Seperator* sep)
  4440. {
  4441. PrintSep(sep, "COMMAND_DUEL");
  4442. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4443. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4444. }
  4445. /*
  4446. Function: Command_DuelBet()
  4447. Purpose : Handle the /duel commands - not yet implemented
  4448. Params : unknown
  4449. Dev :
  4450. Example :
  4451. */
  4452. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4453. {
  4454. PrintSep(sep, "COMMAND_DUELBET");
  4455. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4456. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4457. }
  4458. /*
  4459. Function: Command_DuelAccept()
  4460. Purpose : Handle the /duel commands - not yet implemented
  4461. Params : unknown
  4462. Dev :
  4463. Example :
  4464. */
  4465. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4466. {
  4467. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4468. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4469. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4470. }
  4471. /*
  4472. Function: Command_DuelDecline()
  4473. Purpose : Handle the /duel commands - not yet implemented
  4474. Params : unknown
  4475. Dev :
  4476. Example :
  4477. */
  4478. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4479. {
  4480. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4481. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4482. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4483. }
  4484. /*
  4485. Function: Command_DuelSurrender()
  4486. Purpose : Handle the /duel commands - not yet implemented
  4487. Params : unknown
  4488. Dev :
  4489. Example :
  4490. */
  4491. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4492. {
  4493. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4494. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4495. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4496. // JA, just messin around ;)
  4497. char surrender[64];
  4498. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4499. zone_list.HandleGlobalAnnouncement(surrender);
  4500. }
  4501. /*
  4502. Function: Command_DuelToggle()
  4503. Purpose : Handle the /duel commands - not yet implemented
  4504. Params : unknown
  4505. Dev :
  4506. Example :
  4507. */
  4508. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4509. {
  4510. PrintSep(sep, "COMMAND_DUEL");
  4511. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4512. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4513. }
  4514. /*
  4515. Function:
  4516. Purpose :
  4517. Params :
  4518. Dev :
  4519. Example :
  4520. */
  4521. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4522. {
  4523. if( handler == COMMAND_ENTITYCOMMAND )
  4524. {
  4525. // /entitycommand command by itself shows help (to be extended)
  4526. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4527. return;
  4528. }
  4529. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4530. {
  4531. // /entitycommand list command expects "name" param
  4532. if (sep && sep->arg[0])
  4533. {
  4534. const char* entity_command_name = sep->argplus[0];
  4535. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4536. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4537. map<int32, vector<EntityCommand*>*>::iterator itr;
  4538. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4539. {
  4540. vector<EntityCommand*>* entity_command_list = itr->second;
  4541. vector<EntityCommand*>::iterator itr2;
  4542. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4543. {
  4544. EntityCommand* entity_command = *itr2;
  4545. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4546. 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);
  4547. }
  4548. }
  4549. }
  4550. else // no command name
  4551. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4552. }
  4553. }
  4554. /*
  4555. Function: Command_Follow()
  4556. Purpose : Handle the /follow command - not yet implemented
  4557. Params :
  4558. Dev :
  4559. Example :
  4560. */
  4561. void Commands::Command_Follow(Client* client, Seperator* sep)
  4562. {
  4563. PrintSep(sep, "COMMAND_FOLLOW");
  4564. // flag to toggle if the players target is in the players group
  4565. bool targetInGroup = false;
  4566. // get a pointer to the players group
  4567. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4568. // If the player has a group and has a target
  4569. if (gmi && client->GetPlayer()->GetTarget()) {
  4570. deque<GroupMemberInfo*>::iterator itr;
  4571. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4572. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  4573. if (group)
  4574. {
  4575. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  4576. deque<GroupMemberInfo*>* members = group->GetMembers();
  4577. // Loop through the group members
  4578. for (itr = members->begin(); itr != members->end(); itr++) {
  4579. // If a group member matches a target
  4580. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4581. // toggle the flag and break the loop
  4582. targetInGroup = true;
  4583. break;
  4584. }
  4585. }
  4586. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  4587. }
  4588. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4589. }
  4590. if (targetInGroup) {
  4591. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4592. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4593. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4594. client->GetPlayer()->info_changed = true;
  4595. client->GetPlayer()->changed = true;
  4596. }
  4597. else
  4598. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  4599. }
  4600. /*
  4601. Function: Command_StopFollow()
  4602. Purpose : Handle the /stop_follow command - not yet implemented
  4603. Params :
  4604. Dev :
  4605. Example :
  4606. */
  4607. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4608. {
  4609. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4610. if (client->GetPlayer()->GetFollowTarget()) {
  4611. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4612. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4613. client->GetPlayer()->SetFollowTarget(0);
  4614. client->GetPlayer()->info_changed = true;
  4615. client->GetPlayer()->changed = true;
  4616. }
  4617. }
  4618. #include "../Zone/SPGrid.h"
  4619. /*
  4620. Function: Command_Grid()
  4621. Purpose : Show player's current Grid ID
  4622. Params :
  4623. Dev : Scatman
  4624. Example : /grid
  4625. */
  4626. void Commands::Command_Grid(Client* client)
  4627. {
  4628. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4629. if (client->GetCurrentZone()->Grid != nullptr) {
  4630. int32 grid = client->GetCurrentZone()->Grid->GetGridID(client->GetPlayer());
  4631. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4632. }
  4633. }
  4634. /*
  4635. Function: Command_Guild()
  4636. Purpose : Handler for all UI-related guild commands
  4637. Dev : Scatman
  4638. */
  4639. void Commands::Command_Guild(Client* client, Seperator* sep)
  4640. {
  4641. Guild* guild = client->GetPlayer()->GetGuild();
  4642. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  4643. {
  4644. const char* command = sep->arg[0];
  4645. int32 length = strlen(command);
  4646. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4647. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4648. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4649. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4650. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4651. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4652. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4653. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4654. guild->KickGuildMember(client, sep->arg[1]);
  4655. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4656. guild->DemoteGuildMember(client, sep->arg[1]);
  4657. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4658. guild->PromoteGuildMember(client, sep->arg[1]);
  4659. else if (strncmp(command, "points", length) == 0 && guild)
  4660. {
  4661. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4662. {
  4663. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4664. {
  4665. float points = atof(sep->arg[2]);
  4666. const char* option = sep->arg[3];
  4667. const char* comment = sep->argplus[4];
  4668. if (strncmp(option, "all", strlen(option)) == 0)
  4669. guild->AddPointsToAll(client, points, comment);
  4670. else if (strncmp(option, "online", strlen(option)) == 0)
  4671. guild->AddPointsToAllOnline(client, points, comment);
  4672. else if (strncmp(option, "group", strlen(option)) == 0)
  4673. guild->AddPointsToGroup(client, points, comment);
  4674. else if (strncmp(option, "raid", strlen(option)) == 0)
  4675. guild->AddPointsToRaid(client, points, comment);
  4676. else
  4677. guild->AddPointsToGuildMember(client, points, option, comment);
  4678. }
  4679. }
  4680. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4681. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4682. else
  4683. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4684. }
  4685. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4686. guild->SetMOTD(sep->argplus[1]);
  4687. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4688. {
  4689. if (sep->arg[1])
  4690. {
  4691. const char* option = sep->arg[1];
  4692. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4693. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4694. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4695. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4696. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4697. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4698. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4699. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4700. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4701. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4702. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4703. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4704. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4705. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4706. else
  4707. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4708. }
  4709. else
  4710. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4711. }
  4712. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4713. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4714. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4715. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4716. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4717. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4718. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4719. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4720. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4721. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4722. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4723. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4724. else if (strncmp(command, "invite", length) == 0 && guild)
  4725. {
  4726. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4727. guild->InvitePlayer(client, sep->arg[1]);
  4728. else
  4729. {
  4730. Spawn* target = client->GetPlayer()->GetTarget();
  4731. if (target)
  4732. {
  4733. if (target->IsPlayer())
  4734. guild->InvitePlayer(client, target->GetName());
  4735. else
  4736. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  4737. }
  4738. }
  4739. }
  4740. else if (strncmp(command, "accept", length) == 0)
  4741. {
  4742. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4743. if (pgi && pgi->guild && pgi->invited_by)
  4744. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4745. client->SetPendingGuildInvite(0);
  4746. }
  4747. else if (strncmp(command, "decline", length) == 0)
  4748. {
  4749. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4750. if (pgi && pgi->guild && pgi->invited_by)
  4751. {
  4752. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4753. if (client_inviter)
  4754. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4755. }
  4756. client->SetPendingGuildInvite(0);
  4757. }
  4758. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4759. {
  4760. const char* guild_name = sep->argplus[1];
  4761. if (!guild_list.GetGuild(guild_name))
  4762. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  4763. else
  4764. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  4765. }
  4766. else if (strncmp(command, "search", length) == 0)
  4767. client->ShowGuildSearchWindow();
  4768. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4769. {
  4770. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4771. if (to_guild)
  4772. to_guild->SendGuildRecruitingDetails(client);
  4773. }
  4774. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4775. {
  4776. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4777. if (to_guild)
  4778. to_guild->SendGuildRecruitingImages(client);
  4779. }
  4780. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4781. {
  4782. if (sep->arg[1])
  4783. {
  4784. const char* option = sep->arg[1];
  4785. if (strncmp(option, "toggle", strlen(option)) == 0)
  4786. guild->ToggleGuildRecruiterAdventureClass(client);
  4787. }
  4788. else
  4789. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4790. }
  4791. else if (strncmp(command, "display_heraldry", length) == 0)
  4792. {
  4793. // JA: not sure this is right...
  4794. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4795. client->GetPlayer()->SetCharSheetChanged(true);
  4796. }
  4797. else
  4798. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4799. }
  4800. }
  4801. /*
  4802. Function: Command_GuildCreate()
  4803. Purpose : Display's in-game Guild Creation window
  4804. Dev : Scatman
  4805. */
  4806. void Commands::Command_CreateGuild(Client* client)
  4807. {
  4808. client->SendGuildCreateWindow();
  4809. }
  4810. /*
  4811. Function: Command_SetGuildOfficerNote()
  4812. Purpose :
  4813. Dev : Scatman
  4814. */
  4815. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4816. {
  4817. if (sep && sep->arg[0] && sep->arg[1])
  4818. {
  4819. Guild* guild = client->GetPlayer()->GetGuild();
  4820. if (guild)
  4821. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4822. }
  4823. }
  4824. /*
  4825. Function: Command_SetGuildMemberNote()
  4826. Purpose :
  4827. Dev : Scatman
  4828. */
  4829. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4830. {
  4831. if (sep && sep->arg[0] && sep->arg[1])
  4832. {
  4833. Guild* guild = client->GetPlayer()->GetGuild();
  4834. if (guild)
  4835. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4836. }
  4837. }
  4838. /*
  4839. Function: Command_GuildSay()
  4840. Purpose :
  4841. Dev : Scatman
  4842. */
  4843. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4844. {
  4845. Guild* guild = client->GetPlayer()->GetGuild();
  4846. if (guild)
  4847. {
  4848. if (sep && sep->arg[0])
  4849. guild->HandleGuildSay(client, sep->argplus[0]);
  4850. }
  4851. else
  4852. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  4853. }
  4854. /*
  4855. Function: Command_OfficerSay()
  4856. Purpose :
  4857. Dev : Scatman
  4858. */
  4859. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4860. {
  4861. Guild* guild = client->GetPlayer()->GetGuild();
  4862. if (guild)
  4863. {
  4864. if (sep && sep->arg[0])
  4865. guild->HandleOfficerSay(client, sep->argplus[0]);
  4866. }
  4867. else
  4868. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  4869. }
  4870. /*
  4871. Function: Command_Guilds()
  4872. Purpose : Shows help for /guild command
  4873. Params :
  4874. Dev : Scatman
  4875. Example :
  4876. */
  4877. void Commands::Command_Guilds(Client* client)
  4878. {
  4879. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4880. }
  4881. /*
  4882. Function: Command_GuildsAdd()
  4883. Purpose : Add's players to a guild
  4884. Params : guild_name|guild_id, player name
  4885. Dev : Scatman
  4886. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4887. */
  4888. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4889. {
  4890. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4891. {
  4892. Guild* guild = 0;
  4893. bool found = true;
  4894. if (sep->IsNumber(0))
  4895. {
  4896. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4897. if (!guild)
  4898. {
  4899. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4900. found = false;
  4901. }
  4902. }
  4903. else
  4904. {
  4905. guild = guild_list.GetGuild(sep->arg[0]);
  4906. if (!guild)
  4907. {
  4908. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4909. found = false;
  4910. }
  4911. }
  4912. if (found)
  4913. {
  4914. Client* to_client = 0;
  4915. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4916. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4917. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4918. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4919. if (to_client)
  4920. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  4921. else
  4922. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4923. }
  4924. }
  4925. else
  4926. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  4927. }
  4928. /*
  4929. Function: Command_GuildsCreate()
  4930. Purpose : Creates a guild
  4931. Params : guild_name, player_name (optional)
  4932. Dev : Scatman
  4933. Example : /guilds create [guild name] (player name)
  4934. */
  4935. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  4936. {
  4937. if (sep && sep->arg[0])
  4938. {
  4939. const char* guild_name = sep->arg[0];
  4940. if (!guild_list.GetGuild(guild_name))
  4941. {
  4942. bool ret = false;
  4943. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4944. {
  4945. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4946. if (to_client)
  4947. {
  4948. world.CreateGuild(guild_name, to_client);
  4949. ret = true;
  4950. }
  4951. else
  4952. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  4953. }
  4954. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4955. {
  4956. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4957. if (to_client)
  4958. {
  4959. world.CreateGuild(guild_name, to_client);
  4960. ret = true;
  4961. }
  4962. }
  4963. else
  4964. {
  4965. world.CreateGuild(guild_name);
  4966. ret = true;
  4967. }
  4968. if (ret)
  4969. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  4970. else
  4971. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  4972. }
  4973. else
  4974. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  4975. }
  4976. else
  4977. 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.");
  4978. }
  4979. /*
  4980. Function: Command_GuildsDelete()
  4981. Purpose : Delete's a guild
  4982. Params : guild name
  4983. Dev : Scatman
  4984. Example : /guilds delete Test
  4985. */
  4986. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  4987. {
  4988. if (sep && sep->arg[0])
  4989. {
  4990. Guild* guild = 0;
  4991. bool found = true;
  4992. if (sep->IsNumber(0))
  4993. {
  4994. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4995. if (!guild)
  4996. {
  4997. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4998. found = false;
  4999. }
  5000. }
  5001. else
  5002. {
  5003. guild = guild_list.GetGuild(sep->arg[0]);
  5004. if (!guild)
  5005. {
  5006. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5007. found = false;
  5008. }
  5009. }
  5010. if (found)
  5011. {
  5012. guild->RemoveAllGuildMembers();
  5013. database.DeleteGuild(guild);
  5014. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  5015. guild_list.RemoveGuild(guild, true);
  5016. }
  5017. }
  5018. else
  5019. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  5020. }
  5021. /*
  5022. Function: Command_GuildsList()
  5023. Purpose : Lists current guilds on server
  5024. Params :
  5025. Dev : Scatman
  5026. Example : /guilds list
  5027. */
  5028. void Commands::Command_GuildsList(Client* client)
  5029. {
  5030. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  5031. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  5032. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  5033. if (guilds->size() == 0)
  5034. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  5035. else {
  5036. while (itr.Next()) {
  5037. Guild* guild = itr.second;
  5038. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  5039. }
  5040. }
  5041. }
  5042. /*
  5043. Function: Command_GuildsRemove()
  5044. Purpose : Removes a player from a guild
  5045. Params : guild name|guild id, player name
  5046. Dev : Scatman
  5047. Example : /guilds remove 1 Admin = removes Admin from guild 1
  5048. */
  5049. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  5050. {
  5051. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5052. {
  5053. Guild* guild = 0;
  5054. bool found = true;
  5055. if (sep->IsNumber(0))
  5056. {
  5057. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5058. if (!guild)
  5059. {
  5060. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5061. found = false;
  5062. }
  5063. }
  5064. else
  5065. {
  5066. guild = guild_list.GetGuild(sep->arg[0]);
  5067. if (!guild)
  5068. {
  5069. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5070. found = false;
  5071. }
  5072. }
  5073. if (found)
  5074. {
  5075. Client* to_client = 0;
  5076. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5077. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5078. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5079. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5080. if (to_client)
  5081. {
  5082. Player* to_player = to_client->GetPlayer();
  5083. if (to_player->GetGuild())
  5084. {
  5085. if (to_player->GetGuild() == guild)
  5086. {
  5087. guild->KickGuildMember(client, to_player->GetName());
  5088. }
  5089. else
  5090. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  5091. }
  5092. else
  5093. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  5094. }
  5095. else
  5096. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5097. }
  5098. }
  5099. else
  5100. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  5101. }
  5102. /*
  5103. Function: Command_InspectPlayer()
  5104. Purpose : Handle the Inspect functions
  5105. Params : Client to inspect
  5106. Dev : Scatman
  5107. Example : /inspect Scatman
  5108. */
  5109. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  5110. {
  5111. if (sep && sep->arg[0])
  5112. {
  5113. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  5114. if (inspect_client)
  5115. client->InspectPlayer(inspect_client->GetPlayer());
  5116. }
  5117. else
  5118. {
  5119. Spawn* target = client->GetPlayer()->GetTarget();
  5120. if (target && target->IsPlayer())
  5121. client->InspectPlayer((Player*)target);
  5122. }
  5123. }
  5124. /*
  5125. Function: Command_Inventory()
  5126. Purpose : Handle changes in player inventory
  5127. Params : <TBD>
  5128. Dev : All
  5129. Example : /inventory delete item_id
  5130. */
  5131. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  5132. {
  5133. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  5134. Player* player = client->GetPlayer();
  5135. if(sep && sep->arg[0][0])
  5136. {
  5137. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  5138. if(client->GetPlayer()->GetHP() == 0)
  5139. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  5140. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5141. {
  5142. int16 index = atoi(sep->arg[1]);
  5143. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5144. if(item)
  5145. {
  5146. if(item->GetItemScript() && lua_interface)
  5147. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  5148. int32 bag_id = item->details.inv_slot_id;
  5149. database.DeleteItem(client->GetCharacterID(), item, 0);
  5150. client->GetPlayer()->item_list.DestroyItem(index);
  5151. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  5152. client->QueuePacket(outapp);
  5153. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  5154. if (outapp)
  5155. client->QueuePacket(outapp);
  5156. }
  5157. }
  5158. 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))
  5159. {
  5160. int16 from_index = atoi(sep->arg[1]);
  5161. sint16 to_slot = atoi(sep->arg[2]);
  5162. sint32 bag_id = atol(sep->arg[3]);
  5163. int8 charges = atoi(sep->arg[4]);
  5164. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  5165. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  5166. {
  5167. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  5168. return;
  5169. }
  5170. sint32 old_inventory_id = 0;
  5171. if(item)
  5172. old_inventory_id = item->details.inv_slot_id;
  5173. //autobank
  5174. if (bag_id == -3 && to_slot == -1)
  5175. {
  5176. if (player->HasFreeBankSlot())
  5177. to_slot = player->FindFreeBankSlot();
  5178. else
  5179. {
  5180. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  5181. return;
  5182. }
  5183. }
  5184. //auto inventory
  5185. if (bag_id == 0 && to_slot == -1)
  5186. {
  5187. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5188. {
  5189. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  5190. return;
  5191. }
  5192. }
  5193. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  5194. client->QueuePacket(outapp);
  5195. //removed from bag send update
  5196. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  5197. {
  5198. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  5199. if(outapp)
  5200. client->QueuePacket(outapp);
  5201. }
  5202. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  5203. {
  5204. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  5205. if(outapp)
  5206. client->QueuePacket(outapp);
  5207. }
  5208. }
  5209. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  5210. {
  5211. if(client->GetPlayer()->EngagedInCombat())
  5212. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  5213. else
  5214. {
  5215. int16 index = atoi(sep->arg[1]);
  5216. int8 slot_id = 255;
  5217. if(sep->arg[2][0] && sep->IsNumber(2))
  5218. slot_id = atoi(sep->arg[2]);
  5219. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  5220. EQ2Packet* outapp = 0;
  5221. for(int32 i=0;i<packets.size();i++)
  5222. {
  5223. outapp = packets[i];
  5224. if(outapp)
  5225. client->QueuePacket(outapp);
  5226. }
  5227. client->GetPlayer()->ChangePrimaryWeapon();
  5228. client->GetPlayer()->ChangeSecondaryWeapon();
  5229. client->GetPlayer()->ChangeRangedWeapon();
  5230. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5231. client->QueuePacket(characterSheetPackets);
  5232. }
  5233. }
  5234. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5235. {
  5236. if (client->GetPlayer()->EngagedInCombat())
  5237. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5238. else {
  5239. int16 index = atoi(sep->arg[1]);
  5240. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5241. if (item) {
  5242. // client->GetPlayer()->item_list.DestroyItem(index);
  5243. if (item->item_sets.size() > 0) {
  5244. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5245. ItemSet* set = item->item_sets[i];
  5246. if (set->item_stack_size == 0)
  5247. set->item_stack_size += 1;
  5248. client->AddItem(set->item_id, set->item_stack_size);
  5249. }
  5250. }
  5251. }
  5252. client->RemoveItem(item, 1);
  5253. }
  5254. }
  5255. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5256. {
  5257. if(client->GetPlayer()->EngagedInCombat())
  5258. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5259. else
  5260. {
  5261. int16 index = atoi(sep->arg[1]);
  5262. sint32 bag_id = -999;
  5263. int8 to_slot = 255;
  5264. if(sep->arg[3][0])
  5265. {
  5266. if(sep->IsNumber(2))
  5267. bag_id = atol(sep->arg[2]);
  5268. if(sep->IsNumber(3))
  5269. to_slot = atoi(sep->arg[3]);
  5270. }
  5271. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  5272. EQ2Packet* outapp = 0;
  5273. for(int32 i=0;i<packets.size();i++)
  5274. {
  5275. outapp = packets[i];
  5276. if(outapp)
  5277. client->QueuePacket(outapp);
  5278. }
  5279. client->GetPlayer()->ChangePrimaryWeapon();
  5280. client->GetPlayer()->ChangeSecondaryWeapon();
  5281. client->GetPlayer()->ChangeRangedWeapon();
  5282. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5283. client->QueuePacket(characterSheetPackets);
  5284. }
  5285. }
  5286. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5287. {
  5288. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5289. int16 index1 = atoi(sep->arg[1]);
  5290. int16 index2 = atoi(sep->arg[2]);
  5291. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  5292. if(outapp)
  5293. client->QueuePacket(outapp);
  5294. else
  5295. {
  5296. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5297. return;
  5298. }
  5299. }
  5300. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5301. {
  5302. sint16 to_slot = atoi(sep->arg[1]);
  5303. sint32 bag_id = atoi(sep->arg[2]);
  5304. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5305. if (item) {
  5306. //auto inventory
  5307. if (bag_id == 0 && to_slot == -1)
  5308. {
  5309. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5310. {
  5311. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5312. return;
  5313. }
  5314. // Set the slot for the item
  5315. item->details.inv_slot_id = bag_id;
  5316. item->details.slot_id = to_slot;
  5317. // Flag the item so it gets saved in its new location
  5318. item->save_needed = true;
  5319. // Add the item to its new location
  5320. player->item_list.AddItem(item);
  5321. // Remove the item from the overflow list
  5322. player->item_list.RemoveOverflowItem(item);
  5323. // Send the inventory update packet
  5324. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5325. return;
  5326. }
  5327. else if (bag_id == -3 && to_slot == -1) {
  5328. // Auto Bank
  5329. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5330. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5331. return;
  5332. }
  5333. item->details.inv_slot_id = bag_id;
  5334. item->details.slot_id = to_slot;
  5335. item->save_needed = true;
  5336. player->item_list.AddItem(item);
  5337. player->item_list.RemoveOverflowItem(item);
  5338. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5339. }
  5340. else if (bag_id == -4) {
  5341. // Shared Bank
  5342. if (!player->item_list.SharedBankAddAllowed(item)) {
  5343. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5344. return;
  5345. }
  5346. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5347. if (tmp_item) {
  5348. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5349. return;
  5350. }
  5351. else {
  5352. item->details.inv_slot_id = bag_id;
  5353. item->details.slot_id = to_slot;
  5354. item->save_needed = true;
  5355. player->item_list.AddItem(item);
  5356. player->item_list.RemoveOverflowItem(item);
  5357. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5358. return;
  5359. }
  5360. }
  5361. else {
  5362. // Try to get an item from the given bag id and slot id
  5363. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5364. // Check to see if we got an item, if we do send an error,
  5365. // if we don't put the overflow item into this slot
  5366. if (tmp_item) {
  5367. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5368. }
  5369. else {
  5370. item->details.inv_slot_id = bag_id;
  5371. item->details.slot_id = to_slot;
  5372. item->save_needed = true;
  5373. player->item_list.AddItem(item);
  5374. player->item_list.RemoveOverflowItem(item);
  5375. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5376. return;
  5377. }
  5378. }
  5379. }
  5380. }
  5381. }
  5382. else
  5383. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5384. }
  5385. /*
  5386. Function: Command_IRC()
  5387. Purpose : Handle the IRC functions
  5388. Params : IRC Commands
  5389. Dev : Scatman
  5390. Example : /irc say #Channel Hello World!
  5391. */
  5392. void Commands::Command_IRC(Client* client, Seperator* sep)
  5393. {
  5394. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5395. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5396. return;
  5397. }
  5398. if (sep && sep->arg[0][0]) {
  5399. if (strcasecmp(sep->arg[0], "say") == 0) {
  5400. if (sep->arg[1][0] && sep->arg[2][0]) {
  5401. if (sep->IsNumber(sep->arg[1]))
  5402. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5403. else
  5404. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5405. }
  5406. else
  5407. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5408. }
  5409. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5410. if (sep->arg[1][0])
  5411. irc.JoinChannel(client, sep->arg[1]);
  5412. else
  5413. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5414. }
  5415. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5416. if (sep->arg[1][0])
  5417. irc.LeaveChannel(client, sep->arg[1]);
  5418. else
  5419. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5420. }
  5421. else if (strcasecmp(sep->arg[0], "list") == 0)
  5422. irc.ListChannels(client);
  5423. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5424. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5425. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5426. else
  5427. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5428. }
  5429. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5430. irc.DisconnectFromServer(client);
  5431. else
  5432. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5433. }
  5434. else
  5435. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5436. }
  5437. /*
  5438. Function: Command_Languages()
  5439. Purpose : Show's languages the player knows
  5440. Params :
  5441. Dev : Zcoretri
  5442. Example :
  5443. */
  5444. void Commands::Command_Languages(Client* client, Seperator* sep)
  5445. {
  5446. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5447. list<Language*>::iterator itr;
  5448. Language* language;
  5449. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  5450. for(itr = languages->begin(); itr != languages->end(); itr++)
  5451. {
  5452. language = *itr;
  5453. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  5454. }
  5455. }
  5456. /*
  5457. Function: Command_SetLanguage()
  5458. Purpose : Handles language commands
  5459. Params : Language ID
  5460. Dev : Zcoretri
  5461. Example :
  5462. */
  5463. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5464. {
  5465. Player* player = client->GetPlayer();
  5466. if (sep && sep->arg[0])
  5467. {
  5468. if(!sep->IsNumber(0))
  5469. {
  5470. //String passed in
  5471. const char* value = sep->arg[0];
  5472. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5473. {
  5474. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5475. client->SendLanguagesUpdate(0);
  5476. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  5477. }
  5478. else
  5479. {
  5480. if(player->HasLanguage(value))
  5481. {
  5482. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5483. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5484. client->SendLanguagesUpdate(language->GetID());
  5485. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  5486. }
  5487. else
  5488. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  5489. }
  5490. }
  5491. else
  5492. {
  5493. //Number passed in
  5494. int32 id = atoul(sep->arg[0]);
  5495. if(player->HasLanguage(id))
  5496. {
  5497. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5498. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5499. client->SendLanguagesUpdate(id);
  5500. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  5501. }
  5502. else
  5503. {
  5504. Language* language = master_languages_list.GetLanguage(id);
  5505. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  5506. }
  5507. }
  5508. }
  5509. else
  5510. {
  5511. //No value was passed in
  5512. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5513. if(id > 0)
  5514. {
  5515. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5516. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  5517. }
  5518. else
  5519. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  5520. }
  5521. }
  5522. /*
  5523. Function: Command_LastName()
  5524. Purpose : Sets player surname
  5525. Params : Name text
  5526. Dev : theFoof
  5527. Example :
  5528. */
  5529. void Commands::Command_LastName(Client* client, Seperator* sep)
  5530. {
  5531. if (!client)
  5532. return;
  5533. if (sep && sep->arg[0])
  5534. {
  5535. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5536. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5537. return;
  5538. }
  5539. client->RemovePendingLastName();
  5540. uchar* checkname = (uchar*)sep->arg[0];
  5541. bool valid_name = true;
  5542. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5543. if (!alpha_check(checkname[i])) {
  5544. valid_name = false;
  5545. break;
  5546. }
  5547. }
  5548. if (!valid_name) {
  5549. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5550. return;
  5551. }
  5552. string last_name = (string)sep->arg[0];
  5553. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5554. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5555. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5556. client->SetPendingLastName(last_name);
  5557. client->SendLastNameConfirmation();
  5558. }
  5559. else
  5560. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5561. }
  5562. }
  5563. /*
  5564. Function: Command_ConfirmLastName()
  5565. Purpose : Confirms setting of player surname
  5566. Params : Name text
  5567. Dev : theFoof
  5568. Example :
  5569. */
  5570. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5571. {
  5572. if (!client)
  5573. return;
  5574. string* name = client->GetPendingLastName();
  5575. if (name){
  5576. Player* player = client->GetPlayer();
  5577. player->SetLastName(name->c_str(), false);
  5578. client->SendTitleUpdate();
  5579. player->SetCharSheetChanged(true);
  5580. client->RemovePendingLastName();
  5581. }
  5582. }
  5583. /*
  5584. Function: Command_Location()
  5585. Purpose : Display's Help for /location commands
  5586. Params :
  5587. Dev : Scatman
  5588. Example : /location = show's help for command
  5589. */
  5590. void Commands::Command_Location(Client* client)
  5591. {
  5592. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5593. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5594. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5595. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5596. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5597. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5598. }
  5599. /*
  5600. Function: Command_LocationAdd()
  5601. Purpose : Add's a location to an existing location config
  5602. Params : location_id
  5603. Dev : Scatman
  5604. Example : /location add {location_id}
  5605. */
  5606. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5607. {
  5608. if (sep && sep->arg[0] && sep->IsNumber(0))
  5609. {
  5610. int32 location_id = atoul(sep->arg[0]);
  5611. float x = client->GetPlayer()->GetX();
  5612. float y = client->GetPlayer()->GetY();
  5613. float z = client->GetPlayer()->GetZ();
  5614. if (database.AddLocationPoint(location_id, x, y, z))
  5615. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5616. else
  5617. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5618. }
  5619. else
  5620. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5621. }
  5622. /*
  5623. Function: Command_LocationCreate()
  5624. Purpose : Creates a new location config
  5625. Params : location name, 0/1 for include_y (optional)
  5626. Dev : Scatman
  5627. Example : /location create Test 1 = creates a new location named Test with include_y True
  5628. */
  5629. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5630. {
  5631. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5632. {
  5633. const char* name = sep->arg[0];
  5634. bool include_y = false;
  5635. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5636. include_y = true;
  5637. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5638. if (location_id > 0)
  5639. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5640. else
  5641. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5642. }
  5643. else
  5644. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5645. }
  5646. /*
  5647. Function: Command_LocationDelete()
  5648. Purpose : Delete's a location config and all it's location points
  5649. Params : location_id
  5650. Dev : Scatman
  5651. Example : /location delete {location_id}
  5652. */
  5653. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5654. {
  5655. if (sep && sep->arg[0] && sep->IsNumber(0))
  5656. {
  5657. int32 location_id = atoul(sep->arg[0]);
  5658. if (database.DeleteLocation(location_id))
  5659. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5660. else
  5661. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5662. }
  5663. else
  5664. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5665. }
  5666. /*
  5667. Function: Command_LocationList()
  5668. Purpose : Display's a list of location points
  5669. Params : location_id
  5670. Dev : Scatman
  5671. Example : /location list {location_id}
  5672. */
  5673. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5674. {
  5675. if (sep && sep->arg[0])
  5676. {
  5677. const char* option = sep->arg[0];
  5678. if (strncmp(option, "locations", strlen(option)) == 0)
  5679. database.ListLocations(client);
  5680. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5681. {
  5682. int32 location_id = atoul(sep->arg[1]);
  5683. database.ListLocationPoints(client, location_id);
  5684. }
  5685. else
  5686. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5687. }
  5688. else
  5689. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5690. }
  5691. /*
  5692. Function: Command_LocationRemove()
  5693. Purpose : Removes a single location point from a location config
  5694. Params : location_point_id (gotten from /location list {id})
  5695. Dev : Scatman
  5696. Example : /location remove 1 = will remove location_point_id 1
  5697. */
  5698. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5699. {
  5700. if (sep && sep->arg[0] && sep->IsNumber(0))
  5701. {
  5702. int32 location_point_id = atoul(sep->arg[0]);
  5703. if (database.DeleteLocationPoint(location_point_id))
  5704. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5705. else
  5706. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5707. }
  5708. else
  5709. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5710. }
  5711. /*
  5712. Function: Command_Merchant()
  5713. Purpose : Handles Merchant commands
  5714. Params : list
  5715. Dev : Scatman
  5716. Example : /merchant list
  5717. */
  5718. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5719. {
  5720. if( handler == COMMAND_MERCHANT )
  5721. {
  5722. // /merchant command by itself shows help (to be extended)
  5723. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5724. return;
  5725. }
  5726. else if( handler == COMMAND_MERCHANT_LIST )
  5727. {
  5728. // /merchant list command expects "description" param
  5729. if (sep && sep->arg[0])
  5730. {
  5731. const char* merchant_description = sep->argplus[0];
  5732. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5733. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5734. map<int32, MerchantInfo*>::iterator itr;
  5735. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5736. {
  5737. string description = database.GetMerchantDescription(itr->first);
  5738. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5739. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5740. }
  5741. }
  5742. else // no description
  5743. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5744. }
  5745. }
  5746. /*
  5747. Function: Command_Modify()
  5748. Purpose : to replace our other "set" commands
  5749. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5750. Dev : John Adams
  5751. Example : /modify spell set name "Aegolism III"
  5752. */
  5753. void Commands::Command_Modify(Client* client)
  5754. {
  5755. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5756. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5757. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5758. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5759. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5760. }
  5761. /*
  5762. Function: Command_ModifySpawn()
  5763. Purpose : replace "spawn set" commands
  5764. Params : Action : the action to perform (or special handler)
  5765. : Field : the DB field to change
  5766. : Value : what to set the value to
  5767. : Target : what object to change (my target, or spawn_id)
  5768. Dev : John Adams
  5769. Example : /modify spawn set name "Lady Vox"
  5770. :
  5771. Note : Special Handlers, like "zoneto" for Signs
  5772. : /modify spawn zoneto
  5773. : Will set a sign's zone x/y/z to my current coords
  5774. */
  5775. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5776. {
  5777. PrintSep(sep, "COMMAND_MODIFY");
  5778. // need at least 2 args for a valid command
  5779. if( sep && sep->arg[1] )
  5780. {
  5781. // JA: just a quick implementation because I need it :)
  5782. if (strcmp(sep->arg[0], "zoneto") == 0)
  5783. {
  5784. if( sep->IsNumber(1) )
  5785. {
  5786. int32 spawn_id = atoul(sep->arg[1]);
  5787. float x_coord = client->GetPlayer()->GetX();
  5788. float y_coord = client->GetPlayer()->GetY();
  5789. float z_coord = client->GetPlayer()->GetZ();
  5790. float h_coord = client->GetPlayer()->GetHeading();
  5791. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5792. }
  5793. else
  5794. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5795. }
  5796. }
  5797. else
  5798. Command_Modify(client);
  5799. }
  5800. /*
  5801. Function: Command_ModifyCharacter()
  5802. Purpose : to replace our other "set" commands
  5803. Params : Action : Add, Remove
  5804. : Field : copper, silver, gold, plat
  5805. : Value : min 1, max unlimited
  5806. : Target : Self, Player
  5807. Dev : Cynnar
  5808. Example : /modify character add gold 50
  5809. : /modify character remove silver 25
  5810. */
  5811. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5812. {
  5813. PrintSep(sep, "COMMAND_MODIFY");
  5814. int64 value = 0;
  5815. Player* player = client->GetPlayer();
  5816. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5817. player = (Player*)player->GetTarget();
  5818. // need at least 2 args for a valid command
  5819. if( sep && sep->arg[1] )
  5820. {
  5821. if (strcmp(sep->arg[0], "add") == 0)
  5822. {
  5823. if (strcmp(sep->arg[1], "copper") == 0)
  5824. {
  5825. value = atoi64(sep->arg[2]);
  5826. player->AddCoins(value);
  5827. if (client->GetPlayer() == player)
  5828. {
  5829. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5830. }
  5831. else {
  5832. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5833. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5834. }
  5835. }
  5836. else if (strcmp(sep->arg[1], "silver") == 0)
  5837. {
  5838. value = atoi64(sep->arg[2]) * 100;
  5839. player->AddCoins(value);
  5840. if (client->GetPlayer() == player)
  5841. {
  5842. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5843. }
  5844. else {
  5845. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5846. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5847. }
  5848. }
  5849. else if (strcmp(sep->arg[1], "gold") == 0)
  5850. {
  5851. value = atoi64(sep->arg[2]) * 10000;
  5852. player->AddCoins(value);
  5853. if (client->GetPlayer() == player)
  5854. {
  5855. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5856. }
  5857. else {
  5858. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5859. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5860. }
  5861. }
  5862. else if (strcmp(sep->arg[1], "plat") == 0)
  5863. {
  5864. value = atoi64(sep->arg[2]) * 1000000;
  5865. player->AddCoins(value);
  5866. if (client->GetPlayer() == player)
  5867. {
  5868. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5869. }
  5870. else {
  5871. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5872. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5873. }
  5874. }
  5875. else
  5876. {
  5877. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5878. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5879. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5880. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5881. }
  5882. }
  5883. else if (strcmp(sep->arg[0], "remove") == 0)
  5884. {
  5885. if (strcmp(sep->arg[1], "copper") == 0)
  5886. {
  5887. value = atoi64(sep->arg[2]);
  5888. player->RemoveCoins(value);
  5889. if (client->GetPlayer() == player)
  5890. {
  5891. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5892. }
  5893. else {
  5894. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5895. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5896. }
  5897. }
  5898. else if (strcmp(sep->arg[1], "silver") == 0)
  5899. {
  5900. value = atoi64(sep->arg[2]) * 100;
  5901. player->RemoveCoins(value);
  5902. if (client->GetPlayer() == player)
  5903. {
  5904. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5905. }
  5906. else {
  5907. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5908. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5909. }
  5910. }
  5911. else if (strcmp(sep->arg[1], "gold") == 0)
  5912. {
  5913. value = atoi64(sep->arg[2]) * 10000;
  5914. player->RemoveCoins(value);
  5915. if (client->GetPlayer() == player)
  5916. {
  5917. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  5918. }
  5919. else {
  5920. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  5921. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5922. }
  5923. }
  5924. else if (strcmp(sep->arg[1], "plat") == 0)
  5925. {
  5926. value = atoi64(sep->arg[2]) * 1000000;
  5927. player->RemoveCoins(value);
  5928. if (client->GetPlayer() == player)
  5929. {
  5930. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  5931. }
  5932. else {
  5933. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  5934. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5935. }
  5936. }
  5937. else
  5938. {
  5939. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5940. }
  5941. }
  5942. else if (strcmp(sep->arg[0], "set") == 0) {
  5943. if (strcmp(sep->arg[1], "tslevel") == 0) {
  5944. int8 level = atoi(sep->arg[2]);
  5945. if (level > 0 && level < 256) {
  5946. if (player) {
  5947. if (client->GetPlayer() == player)
  5948. client->ChangeTSLevel(player->GetTSLevel(), level);
  5949. else
  5950. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  5951. }
  5952. }
  5953. else
  5954. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  5955. }
  5956. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  5957. int8 tsclass = atoi(sep->arg[2]);
  5958. player->SetTradeskillClass(tsclass);
  5959. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  5960. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  5961. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  5962. player->SetCharSheetChanged(true);
  5963. }
  5964. }
  5965. }
  5966. else
  5967. {
  5968. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5969. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5970. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5971. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5972. }
  5973. }
  5974. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  5975. {
  5976. PrintSep(sep, "COMMAND_MODIFY");
  5977. // need at least 2 args for a valid command
  5978. if( sep && sep->arg[1] )
  5979. {
  5980. }
  5981. else
  5982. Command_Modify(client);
  5983. }
  5984. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  5985. {
  5986. PrintSep(sep, "COMMAND_MODIFY");
  5987. // need at least 2 args for a valid command
  5988. if( sep && sep->arg[1] )
  5989. {
  5990. }
  5991. else
  5992. Command_Modify(client);
  5993. }
  5994. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  5995. {
  5996. PrintSep(sep, "COMMAND_MODIFY");
  5997. // need at least 2 args for a valid command
  5998. if( sep && sep->arg[1] )
  5999. {
  6000. }
  6001. else
  6002. Command_Modify(client);
  6003. }
  6004. /*
  6005. Function: Command_ModifyQuest()
  6006. Purpose : to list players quest and completed quests
  6007. Params : Action : list, completed
  6008. : Target : Self, Player
  6009. Dev : Cynnar
  6010. Example : /modify quest list
  6011. : /modify quest completed
  6012. */
  6013. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  6014. {
  6015. PrintSep(sep, "COMMAND_MODIFY");
  6016. int64 value = 0;
  6017. Player* player = client->GetPlayer();
  6018. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  6019. player = (Player*)player->GetTarget();
  6020. // need at least 2 args for a valid command
  6021. if (sep && sep->arg[1])
  6022. {
  6023. if (strcmp(sep->arg[0], "list") == 0)
  6024. {
  6025. map<int32, Quest*>* quests = player->GetPlayerQuests();
  6026. map<int32, Quest*>::iterator itr;
  6027. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  6028. if (quests->size() == 0)
  6029. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  6030. else
  6031. {
  6032. for (itr = quests->begin(); itr != quests->end(); itr++)
  6033. {
  6034. Quest* quest = itr->second;
  6035. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6036. }
  6037. }
  6038. }
  6039. else if (strcmp(sep->arg[0], "completed") == 0)
  6040. {
  6041. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  6042. map<int32, Quest*>::iterator itr;
  6043. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  6044. if (quests->size() == 0)
  6045. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  6046. else
  6047. {
  6048. for (itr = quests->begin(); itr != quests->end(); itr++)
  6049. {
  6050. Quest* quest = itr->second;
  6051. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6052. }
  6053. }
  6054. }
  6055. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  6056. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  6057. else if (strcmp(sep->arg[0], "remove") == 0)
  6058. {
  6059. int32 quest_id = 0;
  6060. if (sep && sep->arg[1] && sep->IsNumber(1))
  6061. quest_id = atoul(sep->arg[1]);
  6062. if (quest_id > 0)
  6063. {
  6064. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  6065. {
  6066. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6067. if (quest)
  6068. if (client->GetPlayer() == player)
  6069. {
  6070. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  6071. }
  6072. else
  6073. {
  6074. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  6075. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  6076. }
  6077. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  6078. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  6079. }
  6080. client->RemovePlayerQuest(quest_id);
  6081. client->GetCurrentZone()->SendQuestUpdates(client);
  6082. }
  6083. }
  6084. else if (strcmp(sep->arg[0], "advance") == 0)
  6085. {
  6086. int32 quest_id = 0;
  6087. int32 step = 0;
  6088. if (sep && sep->arg[1] && sep->IsNumber(1))
  6089. {
  6090. quest_id = atoul(sep->arg[1]);
  6091. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6092. if (sep && sep->arg[2] && sep->IsNumber(1))
  6093. {
  6094. step = atoul(sep->arg[2]);
  6095. if (quest_id > 0 && step > 0)
  6096. {
  6097. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  6098. {
  6099. if (client)
  6100. {
  6101. client->AddPendingQuestUpdate(quest_id, step);
  6102. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  6103. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  6104. }
  6105. }
  6106. }
  6107. else
  6108. {
  6109. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  6110. }
  6111. }
  6112. else
  6113. {
  6114. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  6115. }
  6116. }
  6117. else
  6118. {
  6119. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  6120. }
  6121. }
  6122. else
  6123. {
  6124. Command_Modify(client);
  6125. }
  6126. }
  6127. else
  6128. {
  6129. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  6130. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  6131. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  6132. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  6133. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  6134. }
  6135. }
  6136. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  6137. {
  6138. PrintSep(sep, "COMMAND_MODIFY");
  6139. // need at least 2 args for a valid command
  6140. if( sep && sep->arg[1] )
  6141. {
  6142. if (strcmp(sep->arg[0], "add") == 0) {
  6143. const char* skill_name = sep->argplus[1];
  6144. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6145. if (skill) {
  6146. Player* player = 0;
  6147. Client* to_client = 0;
  6148. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6149. player = (Player*)client->GetPlayer()->GetTarget();
  6150. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6151. }
  6152. else {
  6153. player = client->GetPlayer();
  6154. to_client = client;
  6155. }
  6156. if (player)
  6157. {
  6158. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6159. {
  6160. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6161. if (to_client == client) {
  6162. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  6163. }
  6164. else {
  6165. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6166. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6167. }
  6168. }
  6169. else
  6170. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  6171. }
  6172. }
  6173. else
  6174. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6175. }
  6176. else if (strcmp(sep->arg[0], "remove") == 0) {
  6177. const char* skill_name = sep->argplus[1];
  6178. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6179. if (skill) {
  6180. Player* player = 0;
  6181. Client* to_client = 0;
  6182. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6183. player = (Player*)client->GetPlayer()->GetTarget();
  6184. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6185. }
  6186. else {
  6187. player = client->GetPlayer();
  6188. to_client = client;
  6189. }
  6190. if (player)
  6191. {
  6192. if (player->GetSkills()->HasSkill(skill->skill_id))
  6193. {
  6194. player->RemoveSkillFromDB(skill, true);
  6195. if (client == to_client) {
  6196. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  6197. }
  6198. else {
  6199. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6200. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6201. }
  6202. }
  6203. else {
  6204. if (client == to_client)
  6205. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  6206. else
  6207. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6208. }
  6209. }
  6210. }
  6211. else
  6212. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6213. }
  6214. else if (strcmp(sep->arg[0], "set") == 0) {
  6215. if (!sep->IsNumber(2)) {
  6216. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  6217. return;
  6218. }
  6219. const char* skill_name = sep->arg[1];
  6220. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6221. if (skill) {
  6222. int16 val = atoi(sep->arg[2]);
  6223. Player* player = 0;
  6224. Client* to_client = 0;
  6225. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6226. player = (Player*)client->GetPlayer()->GetTarget();
  6227. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6228. }
  6229. else {
  6230. player = client->GetPlayer();
  6231. to_client = client;
  6232. }
  6233. if (player)
  6234. {
  6235. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6236. player->GetSkills()->SetSkill(skill->skill_id, val);
  6237. if (client != to_client)
  6238. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6239. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6240. }
  6241. else {
  6242. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6243. }
  6244. }
  6245. }
  6246. else {
  6247. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6248. }
  6249. }
  6250. else {
  6251. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6252. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6253. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6254. }
  6255. }
  6256. else {
  6257. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6258. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6259. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6260. }
  6261. }
  6262. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6263. {
  6264. PrintSep(sep, "COMMAND_MODIFY");
  6265. // need at least 2 args for a valid command
  6266. if( sep && sep->arg[1] )
  6267. {
  6268. }
  6269. else
  6270. Command_Modify(client);
  6271. }
  6272. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6273. {
  6274. PrintSep(sep, "COMMAND_MODIFY");
  6275. // need at least 2 args for a valid command
  6276. if( sep && sep->arg[1] )
  6277. {
  6278. }
  6279. else
  6280. Command_Modify(client);
  6281. }
  6282. /*
  6283. Function: Command_MOTD()
  6284. Purpose : Displays server MOTD
  6285. Params :
  6286. Dev : LethalEncounter
  6287. Example : /motd
  6288. */
  6289. void Commands::Command_MOTD(Client* client)
  6290. {
  6291. if (client)
  6292. ClientPacketFunctions::SendMOTD(client);
  6293. }
  6294. /*
  6295. Function: Command_Pet()
  6296. Purpose : Handle Pet {Command} commands
  6297. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6298. Dev :
  6299. Example : /pet preserve_master
  6300. */
  6301. void Commands::Command_Pet(Client* client, Seperator* sep)
  6302. {
  6303. PrintSep(sep, "COMMAND_PET");
  6304. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6305. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6306. if (!sep || !sep->arg[0])
  6307. return; // should have sep->arg[0] filled
  6308. if (strcmp(sep->arg[0], "hide") == 0) {
  6309. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6310. Entity* pet = client->GetPlayer()->GetDeityPet();
  6311. if (pet) {
  6312. if (pet->IsPrivateSpawn())
  6313. client->GetPlayer()->HideDeityPet(false);
  6314. else
  6315. client->GetPlayer()->HideDeityPet(true);
  6316. }
  6317. pet = client->GetPlayer()->GetCosmeticPet();
  6318. if (pet) {
  6319. if (pet->IsPrivateSpawn())
  6320. client->GetPlayer()->HideCosmeticPet(false);
  6321. else
  6322. client->GetPlayer()->HideCosmeticPet(true);
  6323. }
  6324. return;
  6325. }
  6326. // below is for all combat pets
  6327. if (!client->GetPlayer()->HasPet()) {
  6328. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6329. return;
  6330. }
  6331. if (strcmp(sep->arg[0], "stay") == 0) {
  6332. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6333. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  6334. client->GetPlayer()->SetCharSheetChanged(true);
  6335. if (client->GetPlayer()->GetPet())
  6336. client->GetPlayer()->GetPet()->following = false;
  6337. if (client->GetPlayer()->GetCharmedPet())
  6338. client->GetPlayer()->GetCharmedPet()->following = false;
  6339. }
  6340. else if (strcmp(sep->arg[0], "follow") == 0) {
  6341. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6342. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  6343. client->GetPlayer()->SetCharSheetChanged(true);
  6344. }
  6345. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6346. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  6347. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6348. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  6349. }
  6350. else {
  6351. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6352. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  6353. }
  6354. client->GetPlayer()->SetCharSheetChanged(true);
  6355. }
  6356. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6357. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  6358. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6359. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  6360. }
  6361. else {
  6362. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6363. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  6364. }
  6365. client->GetPlayer()->SetCharSheetChanged(true);
  6366. }
  6367. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6368. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6369. if (client->GetPlayer()->GetPet())
  6370. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6371. if (client->GetPlayer()->GetCharmedPet())
  6372. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6373. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  6374. client->GetPlayer()->SetCharSheetChanged(true);
  6375. }
  6376. else if (strcmp(sep->arg[0], "attack") == 0) {
  6377. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6378. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6379. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6380. if (client->GetPlayer()->GetPet())
  6381. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6382. if (client->GetPlayer()->GetCharmedPet())
  6383. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6384. }
  6385. else
  6386. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6387. }
  6388. else
  6389. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6390. }
  6391. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6392. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6393. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6394. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6395. }
  6396. else
  6397. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6398. }
  6399. /*
  6400. Function: Command_PetName()
  6401. Purpose : Pet your name (???)
  6402. Params :
  6403. Dev :
  6404. Example :
  6405. */
  6406. void Commands::Command_PetName(Client* client, Seperator* sep)
  6407. {
  6408. PrintSep(sep, "COMMAND_PETNAME");
  6409. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6410. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6411. }
  6412. /*
  6413. Function: Command_NamePet()
  6414. Purpose : Name your pet
  6415. Params :
  6416. Dev :
  6417. Example :
  6418. */
  6419. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6420. {
  6421. PrintSep(sep, "COMMAND_NAME_PET");
  6422. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6423. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6424. }
  6425. /*
  6426. Function: Command_Rename()
  6427. Purpose : Renames existing pet
  6428. Params :
  6429. Dev :
  6430. Example :
  6431. */
  6432. void Commands::Command_Rename(Client* client, Seperator* sep)
  6433. {
  6434. PrintSep(sep, "COMMAND_RENAME");
  6435. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6436. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6437. }
  6438. /*
  6439. Function: Command_ConfirmRename()
  6440. Purpose : Confirms renaming your pet
  6441. Params :
  6442. Dev :
  6443. Example :
  6444. */
  6445. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6446. {
  6447. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6448. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6449. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6450. }
  6451. /*
  6452. Function: Command_PetOptions()
  6453. Purpose : Sets various pet options
  6454. Params :
  6455. Dev :
  6456. Example :
  6457. */
  6458. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6459. {
  6460. PrintSep(sep, "COMMAND_PETOPTIONS");
  6461. Player* player = client->GetPlayer();
  6462. Spawn* target = player->GetTarget();
  6463. if (!target)
  6464. return;
  6465. if (target == player->GetPet())
  6466. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6467. else if (target == player->GetCharmedPet())
  6468. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6469. else if (target == player->GetCosmeticPet())
  6470. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6471. else if (target == player->GetDeityPet())
  6472. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6473. }
  6474. /*
  6475. Function: Command_Random()
  6476. Purpose : Handles /random dice roll in-game
  6477. Params : 1-100
  6478. Dev : Scatman
  6479. Example : /randon 1 100
  6480. */
  6481. void Commands::Command_Random(Client* client, Seperator* sep)
  6482. {
  6483. char message[256] = {0};
  6484. if (sep)
  6485. {
  6486. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6487. 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])));
  6488. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6489. 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])));
  6490. else
  6491. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6492. }
  6493. else
  6494. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6495. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6496. }
  6497. /*
  6498. Function: Command_Randomize()
  6499. Purpose : Sets randomize (appearance) values for NPCs
  6500. Params : Attrib Name
  6501. Dev : Scatman
  6502. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6503. */
  6504. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6505. {
  6506. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6507. if (target)
  6508. {
  6509. if (target->IsNPC())
  6510. {
  6511. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6512. {
  6513. const char* value = sep->arg[0];
  6514. if (strncasecmp(value, "show", strlen(value)) == 0)
  6515. {
  6516. client->DisplayRandomizeFeatures(target->GetRandomize());
  6517. }
  6518. else
  6519. {
  6520. if (sep->arg[1] && sep->IsNumber(1))
  6521. {
  6522. int8 option = atoi(sep->arg[1]);
  6523. if (option == 0 || option == 1)
  6524. {
  6525. int32 feature = 0;
  6526. char feature_text[32] = {0};
  6527. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6528. feature = RANDOMIZE_GENDER;
  6529. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6530. }
  6531. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6532. feature = RANDOMIZE_RACE;
  6533. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6534. }
  6535. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6536. feature = RANDOMIZE_MODEL_TYPE;
  6537. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6538. }
  6539. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6540. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6541. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6542. }
  6543. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6544. feature = RANDOMIZE_HAIR_TYPE;
  6545. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6546. }
  6547. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6548. feature = RANDOMIZE_WING_TYPE;
  6549. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6550. }
  6551. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6552. feature = RANDOMIZE_CHEEK_TYPE;
  6553. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6554. }
  6555. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6556. feature = RANDOMIZE_CHIN_TYPE;
  6557. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6558. }
  6559. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6560. feature = RANDOMIZE_EAR_TYPE;
  6561. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6562. }
  6563. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6564. feature = RANDOMIZE_EYE_BROW_TYPE;
  6565. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6566. }
  6567. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6568. feature = RANDOMIZE_EYE_TYPE;
  6569. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6570. }
  6571. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6572. feature = RANDOMIZE_LIP_TYPE;
  6573. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6574. }
  6575. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6576. feature = RANDOMIZE_NOSE_TYPE;
  6577. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6578. }
  6579. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6580. feature = RANDOMIZE_EYE_COLOR;
  6581. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6582. }
  6583. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6584. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6585. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6586. }
  6587. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6588. feature = RANDOMIZE_HAIR_COLOR1;
  6589. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6590. }
  6591. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6592. feature = RANDOMIZE_HAIR_COLOR2;
  6593. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6594. }
  6595. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6596. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6597. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6598. }
  6599. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6600. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6601. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6602. }
  6603. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6604. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6605. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6606. }
  6607. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6608. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6609. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6610. }
  6611. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6612. feature = RANDOMIZE_SKIN_COLOR;
  6613. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6614. }
  6615. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6616. feature = RANDOMIZE_WING_COLOR1;
  6617. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6618. }
  6619. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6620. feature = RANDOMIZE_WING_COLOR2;
  6621. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6622. }
  6623. else {
  6624. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6625. 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'.");
  6626. }
  6627. if (feature > 0) {
  6628. if (option == 1) {
  6629. if (target->GetRandomize() & feature)
  6630. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6631. else {
  6632. target->AddRandomize(feature);
  6633. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6634. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6635. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6636. }
  6637. }
  6638. else {
  6639. if (target->GetRandomize() & feature) {
  6640. target->AddRandomize(-feature);
  6641. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6642. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6643. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6644. }
  6645. else
  6646. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6647. }
  6648. }
  6649. }
  6650. else
  6651. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6652. }
  6653. else
  6654. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6655. }
  6656. }
  6657. else {
  6658. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6659. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6660. 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'.");
  6661. }
  6662. }
  6663. else
  6664. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6665. }
  6666. else
  6667. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6668. }
  6669. /*
  6670. Function: Command_ShowCloak()
  6671. Purpose : Character Settings combo box for Show Cloak
  6672. Params : true/false
  6673. Dev : John Adams
  6674. Example :
  6675. */
  6676. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6677. {
  6678. Player* player = client->GetPlayer();
  6679. if (sep && sep->arg[0])
  6680. {
  6681. const char* value = sep->arg[0];
  6682. if (strncasecmp(value, "true", strlen(value)) == 0)
  6683. {
  6684. player->set_character_flag(CF_SHOW_CLOAK);
  6685. player->reset_character_flag(CF2_SHOW_RANGED);
  6686. }
  6687. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6688. player->reset_character_flag(CF_SHOW_CLOAK);
  6689. else
  6690. {
  6691. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6692. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6693. }
  6694. }
  6695. }
  6696. /*
  6697. Function: Command_ShowHelm()
  6698. Purpose : Character Settings combo box for Show Helm
  6699. Params : true/false
  6700. Dev : John Adams
  6701. Example :
  6702. */
  6703. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6704. {
  6705. Player* player = client->GetPlayer();
  6706. if (sep && sep->arg[0])
  6707. {
  6708. const char* value = sep->arg[0];
  6709. if (strncasecmp(value, "true", strlen(value)) == 0)
  6710. {
  6711. player->reset_character_flag(CF_HIDE_HELM);
  6712. player->set_character_flag(CF_HIDE_HOOD);
  6713. }
  6714. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6715. player->set_character_flag(CF_HIDE_HELM);
  6716. else
  6717. {
  6718. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6719. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6720. }
  6721. }
  6722. }
  6723. /*
  6724. Function: Command_ShowHood()
  6725. Purpose : Character Settings combo box for Show Hood
  6726. Params : true/false
  6727. Dev : John Adams
  6728. Example :
  6729. */
  6730. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6731. {
  6732. Player* player = client->GetPlayer();
  6733. if (sep && sep->arg[0])
  6734. {
  6735. const char* value = sep->arg[0];
  6736. if (strncasecmp(value, "true", strlen(value)) == 0)
  6737. {
  6738. player->reset_character_flag(CF_HIDE_HOOD);
  6739. player->set_character_flag(CF_HIDE_HELM);
  6740. }
  6741. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6742. player->set_character_flag(CF_HIDE_HOOD);
  6743. else
  6744. {
  6745. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6746. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6747. }
  6748. }
  6749. }
  6750. /*
  6751. Function: Command_ShowHoodHelm()
  6752. Purpose : Character Settings combo box for Show Helm or Hood
  6753. Params : true/false
  6754. Dev : John Adams
  6755. Example :
  6756. */
  6757. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6758. {
  6759. Player* player = client->GetPlayer();
  6760. if (sep && sep->arg[0])
  6761. {
  6762. const char* value = sep->arg[0];
  6763. if (strncasecmp(value, "true", strlen(value)) == 0)
  6764. {
  6765. player->reset_character_flag(CF_HIDE_HOOD);
  6766. player->reset_character_flag(CF_HIDE_HELM);
  6767. }
  6768. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6769. {
  6770. // don't think we ever wind up in here...
  6771. player->set_character_flag(CF_HIDE_HOOD);
  6772. player->set_character_flag(CF_HIDE_HELM);
  6773. }
  6774. else
  6775. {
  6776. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6777. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6778. }
  6779. }
  6780. }
  6781. /*
  6782. Function: Command_ShowRanged()
  6783. Purpose : Character Settings combo box for Show Ranged weapon
  6784. Params : true/false
  6785. Dev : John Adams
  6786. Example :
  6787. */
  6788. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6789. {
  6790. Player* player = client->GetPlayer();
  6791. if (sep && sep->arg[0])
  6792. {
  6793. const char* value = sep->arg[0];
  6794. if (strncasecmp(value, "true", strlen(value)) == 0)
  6795. {
  6796. player->set_character_flag(CF2_SHOW_RANGED);
  6797. player->reset_character_flag(CF_SHOW_CLOAK);
  6798. }
  6799. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6800. player->reset_character_flag(CF2_SHOW_RANGED);
  6801. else
  6802. {
  6803. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6804. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6805. }
  6806. }
  6807. }
  6808. /*
  6809. Function:
  6810. Purpose :
  6811. Params :
  6812. Dev :
  6813. Example :
  6814. */
  6815. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6816. {
  6817. Player* player = 0;
  6818. Client* to_client = 0;
  6819. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6820. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6821. switch(handler)
  6822. {
  6823. case COMMAND_SKILL:
  6824. {
  6825. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6826. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6827. break;
  6828. }
  6829. case COMMAND_SKILL_ADD:
  6830. {
  6831. if (sep && sep->arg[0])
  6832. {
  6833. const char* skill_name = sep->argplus[0];
  6834. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6835. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6836. {
  6837. player = to_client->GetPlayer();
  6838. if (player)
  6839. {
  6840. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6841. {
  6842. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6843. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6844. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6845. }
  6846. else
  6847. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6848. }
  6849. }
  6850. else if (skill) // add skill to yourself
  6851. {
  6852. player = client->GetPlayer();
  6853. if (player)
  6854. {
  6855. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6856. {
  6857. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6858. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6859. }
  6860. else
  6861. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6862. }
  6863. }
  6864. else
  6865. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6866. }
  6867. else
  6868. {
  6869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6871. }
  6872. break;
  6873. }
  6874. case COMMAND_SKILL_REMOVE:
  6875. {
  6876. if (sep && sep->arg[0])
  6877. {
  6878. const char* skill_name = sep->argplus[0];
  6879. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6880. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6881. {
  6882. player = to_client->GetPlayer();
  6883. if (player)
  6884. {
  6885. if (player->GetSkills()->HasSkill(skill->skill_id))
  6886. {
  6887. player->RemoveSkillFromDB(skill, true);
  6888. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6889. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6890. }
  6891. else
  6892. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6893. }
  6894. }
  6895. else if(skill) // remove skill from yourself
  6896. {
  6897. Player* player = client->GetPlayer();
  6898. if (player)
  6899. {
  6900. if (player->GetSkills()->HasSkill(skill->skill_id))
  6901. {
  6902. player->RemoveSkillFromDB(skill, true);
  6903. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6904. }
  6905. else
  6906. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6907. }
  6908. }
  6909. else
  6910. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6911. }
  6912. else
  6913. {
  6914. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  6915. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6916. }
  6917. break;
  6918. }
  6919. case COMMAND_SKILL_LIST:
  6920. {
  6921. if (sep && sep->arg[0])
  6922. {
  6923. const char* skill_name = sep->argplus[0];
  6924. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  6925. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  6926. map<int32, Skill*>::iterator itr;
  6927. if (skills && skills->size() > 0)
  6928. {
  6929. for (itr = skills->begin(); itr != skills->end(); itr++)
  6930. {
  6931. Skill* skill = itr->second;
  6932. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  6933. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  6934. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  6935. }
  6936. }
  6937. }
  6938. else
  6939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  6940. break;
  6941. }
  6942. }
  6943. }
  6944. /*
  6945. Function: Command_SpawnTemplate()
  6946. Purpose : Create or Use defined Spawn Templates
  6947. Params : create, save, rempve, list
  6948. Dev : John Adams
  6949. Example : /spawn template create "Test"
  6950. */
  6951. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  6952. {
  6953. if (sep == NULL || sep->arg[0] == NULL)
  6954. {
  6955. 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.");
  6956. return;
  6957. }
  6958. // got params, continue
  6959. const char * template_cmd = sep->arg[0];
  6960. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  6961. {
  6962. if (!sep->IsSet(1))
  6963. {
  6964. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  6965. 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.");
  6966. return;
  6967. }
  6968. map<int32, string>* template_names = 0;
  6969. if (sep->IsNumber(1))
  6970. {
  6971. int32 location_id = 0;
  6972. location_id = atoi(sep->arg[1]);
  6973. template_names = database.GetSpawnTemplateListByID(location_id);
  6974. }
  6975. else
  6976. {
  6977. const char* name = 0;
  6978. name = sep->argplus[1];
  6979. template_names = database.GetSpawnTemplateListByName(name);
  6980. }
  6981. if(!template_names)
  6982. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  6983. else
  6984. {
  6985. map<int32, string>::iterator itr;
  6986. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  6987. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  6988. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  6989. safe_delete(template_names);
  6990. }
  6991. }
  6992. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  6993. {
  6994. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6995. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  6996. {
  6997. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  6998. {
  6999. // first, lookup to see if template name already exists
  7000. const char* name = 0;
  7001. name = sep->argplus[1];
  7002. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  7003. if(!template_names)
  7004. {
  7005. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  7006. if( new_template_id > 0 )
  7007. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  7008. else
  7009. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  7010. }
  7011. else
  7012. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  7013. }
  7014. else
  7015. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  7016. }
  7017. else
  7018. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  7019. }
  7020. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  7021. {
  7022. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  7023. {
  7024. int32 template_id = 0;
  7025. template_id = atoi(sep->arg[1]);
  7026. if (database.RemoveSpawnTemplate(template_id))
  7027. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  7028. else
  7029. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  7030. }
  7031. else
  7032. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  7033. }
  7034. // Renamed create to spawn
  7035. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  7036. {
  7037. if (sep && sep->arg[1][0])
  7038. {
  7039. int32 new_location = 0;
  7040. if (sep->IsNumber(1))
  7041. {
  7042. int32 template_id = 0;
  7043. template_id = atoi(sep->arg[1]);
  7044. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  7045. if( new_location > 0 )
  7046. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  7047. else
  7048. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  7049. }
  7050. else
  7051. {
  7052. const char* name = 0;
  7053. name = sep->argplus[1];
  7054. new_location = database.CreateSpawnFromTemplateByName(client, name);
  7055. if( new_location > 0 )
  7056. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  7057. else
  7058. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  7059. }
  7060. }
  7061. else
  7062. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  7063. }
  7064. else
  7065. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  7066. }
  7067. void Commands::Command_Speed(Client* client, Seperator* sep) {
  7068. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  7069. float new_speed = atof(sep->arg[0]);
  7070. if (new_speed > 0.0f)
  7071. {
  7072. client->GetPlayer()->SetSpeed(new_speed, true);
  7073. client->GetPlayer()->SetCharSheetChanged(true);
  7074. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  7075. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  7076. }
  7077. else
  7078. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  7079. }
  7080. else{
  7081. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  7082. }
  7083. }
  7084. /*
  7085. Function: Command_StationMarketPlace()
  7086. Purpose : just trying to eat the console spam for now
  7087. Params :
  7088. Dev : John
  7089. */
  7090. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  7091. {
  7092. PrintSep(sep, "COMMAND_SMP");
  7093. // This will reduce the spam from once every 10 sec to once every 30 sec,
  7094. // can't seem to reduce it any more get rid of it completely...
  7095. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  7096. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  7097. if (packet) {
  7098. packet->setDataByName("account_id", client->GetAccountID());
  7099. packet->setDataByName("character_id", client->GetCharacterID());
  7100. packet->setDataByName("unknown1", 1, 5);
  7101. packet->setDataByName("unknown1", 26, 6);
  7102. packet->setDataByName("unknown2", 0xFFFFFFFF);
  7103. packet->setDataByName("unknown3", 248, 1);
  7104. client->QueuePacket(packet->serialize());
  7105. }
  7106. safe_delete(packet);
  7107. }
  7108. }
  7109. /*
  7110. Function: Command_StopDrinking()
  7111. Purpose : Stops player from auto-consuming drink
  7112. Params :
  7113. Dev : Zcoretri
  7114. Example : /stopdrinking
  7115. */
  7116. void Commands::Command_StopDrinking(Client* client)
  7117. {
  7118. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  7119. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  7120. }
  7121. /*
  7122. Function: Command_StopEating()
  7123. Purpose : Stops player from auto-consuming food
  7124. Params :
  7125. Dev : Zcoretri
  7126. Example : /stopeating
  7127. */
  7128. void Commands::Command_StopEating(Client* client)
  7129. {
  7130. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  7131. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  7132. }
  7133. /*
  7134. Function: Command_Title()
  7135. Purpose : Help for /title command
  7136. Params : n/a
  7137. Dev : Zcoretri
  7138. Example : /title
  7139. */
  7140. void Commands::Command_Title(Client* client)
  7141. {
  7142. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  7143. }
  7144. /*
  7145. Function: Command_TitleList()
  7146. Purpose : List available titles for player
  7147. Params : n/a
  7148. Dev : Zcoretri
  7149. Example : /title list
  7150. */
  7151. void Commands::Command_TitleList(Client* client)
  7152. {
  7153. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  7154. list<Title*>::iterator itr;
  7155. Title* title;
  7156. int16 i = 0;
  7157. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  7158. for(itr = titles->begin(); itr != titles->end(); itr++)
  7159. {
  7160. title = *itr;
  7161. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  7162. i++;
  7163. }
  7164. }
  7165. /*
  7166. Function: Command_TitleSetPrefix()
  7167. Purpose : Set Prefix title for player
  7168. Params : Title ID
  7169. Dev : Zcoretri
  7170. Example : /title setprefix 1
  7171. */
  7172. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  7173. {
  7174. if (sep && sep->arg[0] && sep->IsNumber(0))
  7175. {
  7176. int32 index = atoul(sep->arg[0]);
  7177. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  7178. client->SendTitleUpdate();
  7179. }
  7180. }
  7181. /*
  7182. Function: Command_TitleSetSuffix()
  7183. Purpose : Set Suffix title for player
  7184. Params : Title ID
  7185. Dev : Zcoretri
  7186. Example : /title setsuffix 1
  7187. */
  7188. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  7189. {
  7190. if (sep && sep->arg[0] && sep->IsNumber(0))
  7191. {
  7192. int32 index = atoul(sep->arg[0]);
  7193. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  7194. client->SendTitleUpdate();
  7195. }
  7196. }
  7197. /*
  7198. Function: Command_TitleFix()
  7199. Purpose : Fix title for player (???)
  7200. Params :
  7201. Dev : Zcoretri
  7202. Example :
  7203. */
  7204. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  7205. {
  7206. PrintSep(sep, "COMMAND_TITLE_FIX");
  7207. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  7208. }
  7209. /*
  7210. Function: Command_Toggle_Anonymous()
  7211. Purpose : Toggles player Anonymous
  7212. Params :
  7213. Dev : paulgh
  7214. Example : /anon
  7215. */
  7216. void Commands::Command_Toggle_Anonymous(Client* client)
  7217. {
  7218. Player* player = client->GetPlayer();
  7219. player->toggle_character_flag(CF_ANONYMOUS);
  7220. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  7221. if (player->get_character_flag(CF_ANONYMOUS))
  7222. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  7223. else
  7224. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  7225. }
  7226. /*
  7227. Function: Command_Toggle_AutoConsume()
  7228. Purpose : Toggles player food/drink auto consume
  7229. Params : unknown
  7230. Dev : paulgh
  7231. Example : /set_auto_consume
  7232. */
  7233. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7234. {
  7235. Player* player = client->GetPlayer();
  7236. if (sep && sep->arg[0])
  7237. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7238. if (sep && sep->arg[0] && sep->IsNumber(0))
  7239. {
  7240. int8 slot = atoi(sep->arg[0]);
  7241. int8 flag = atoi(sep->arg[1]);
  7242. if (slot == EQ2_FOOD_SLOT)
  7243. {
  7244. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7245. player->SetCharSheetChanged(true);
  7246. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7247. if (flag == 1)
  7248. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  7249. else
  7250. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  7251. }
  7252. else
  7253. {
  7254. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7255. player->SetCharSheetChanged(true);
  7256. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7257. if (flag == 1)
  7258. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  7259. else
  7260. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  7261. }
  7262. }
  7263. }
  7264. /*
  7265. Function: Command_Toggle_BonusXP()
  7266. Purpose : Toggles player Bonus XP
  7267. Params :
  7268. Dev : John Adams
  7269. Example : /disable_char_bonus_exp
  7270. */
  7271. void Commands::Command_Toggle_BonusXP(Client* client)
  7272. {
  7273. Player* player = client->GetPlayer();
  7274. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7275. player->SetCharSheetChanged(true);
  7276. }
  7277. /*
  7278. Function: Command_Toggle_CombatXP()
  7279. Purpose : Toggles player Adventure XP
  7280. Params :
  7281. Dev : John Adams
  7282. Example : /disable_combat_exp
  7283. */
  7284. void Commands::Command_Toggle_CombatXP(Client* client)
  7285. {
  7286. Player* player = client->GetPlayer();
  7287. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7288. player->SetCharSheetChanged(true);
  7289. }
  7290. /*
  7291. Function: Command_Toggle_GMHide()
  7292. Purpose : Toggles hiding player GM status
  7293. Params :
  7294. Dev : Scatman
  7295. Example : /gm_hide
  7296. */
  7297. void Commands::Command_Toggle_GMHide(Client* client)
  7298. {
  7299. Player* player = client->GetPlayer();
  7300. player->toggle_character_flag(CF_HIDE_STATUS);
  7301. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7302. }
  7303. /*
  7304. Function: Command_Toggle_GMVanish()
  7305. Purpose : Toggles hiding GM players from /who searches
  7306. Params :
  7307. Dev : Scatman
  7308. Example : /gm_vanish
  7309. */
  7310. void Commands::Command_Toggle_GMVanish(Client* client)
  7311. {
  7312. Player* player = client->GetPlayer();
  7313. player->toggle_character_flag(CF_GM_HIDDEN);
  7314. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7315. }
  7316. /*
  7317. Function: Command_Toggle_Illusions()
  7318. Purpose : Toggles player illusion form
  7319. Params : not sure sep is needed, testing
  7320. Dev : paulgh
  7321. Example : /hide_illusions
  7322. */
  7323. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7324. {
  7325. if (sep && sep->arg[0])
  7326. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7327. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7328. }
  7329. /*
  7330. Function: Command_Toggle_LFG()
  7331. Purpose : Toggles player LFG Flag
  7332. Params :
  7333. Dev : paulgh
  7334. Example : /lfg
  7335. */
  7336. void Commands::Command_Toggle_LFG(Client* client)
  7337. {
  7338. Player* player = client->GetPlayer();
  7339. player->toggle_character_flag(CF_LFG);
  7340. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7341. if (player->get_character_flag(CF_LFG))
  7342. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7343. else
  7344. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7345. }
  7346. /*
  7347. Function: Command_Toggle_LFW()
  7348. Purpose : Toggles player LFW Flag
  7349. Params :
  7350. Dev : paulgh
  7351. Example : /lfw
  7352. */
  7353. void Commands::Command_Toggle_LFW(Client* client)
  7354. {
  7355. Player* player = client->GetPlayer();
  7356. player->toggle_character_flag(CF_LFW);
  7357. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7358. if (player->get_character_flag(CF_LFW))
  7359. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7360. else
  7361. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7362. }
  7363. /*
  7364. Function: Command_Toggle_QuestXP()
  7365. Purpose : Toggles player Quest XP
  7366. Params :
  7367. Dev : John Adams
  7368. Example : /disable_quest_exp
  7369. */
  7370. void Commands::Command_Toggle_QuestXP(Client* client)
  7371. {
  7372. Player* player = client->GetPlayer();
  7373. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7374. player->SetCharSheetChanged(true);
  7375. }
  7376. /*
  7377. Function: Command_Toggle_Roleplaying()
  7378. Purpose : Toggles player Roleplaying flag
  7379. Params :
  7380. Dev : paulgh
  7381. Example : /role
  7382. */
  7383. void Commands::Command_Toggle_Roleplaying(Client* client)
  7384. {
  7385. Player* player = client->GetPlayer();
  7386. player->toggle_character_flag(CF_ROLEPLAYING);
  7387. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  7388. if (player->get_character_flag(CF_ROLEPLAYING))
  7389. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  7390. else
  7391. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  7392. }
  7393. void Commands::Command_Toggle_Duels(Client* client)
  7394. {
  7395. Player* player = client->GetPlayer();
  7396. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7397. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7398. }
  7399. void Commands::Command_Toggle_Trades(Client* client)
  7400. {
  7401. Player* player = client->GetPlayer();
  7402. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7403. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7404. }
  7405. void Commands::Command_Toggle_Guilds(Client* client)
  7406. {
  7407. Player* player = client->GetPlayer();
  7408. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7409. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7410. }
  7411. void Commands::Command_Toggle_Groups(Client* client)
  7412. {
  7413. Player* player = client->GetPlayer();
  7414. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7415. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7416. }
  7417. void Commands::Command_Toggle_Raids(Client* client)
  7418. {
  7419. Player* player = client->GetPlayer();
  7420. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7421. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7422. }
  7423. void Commands::Command_Toggle_LON(Client* client)
  7424. {
  7425. Player* player = client->GetPlayer();
  7426. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7427. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7428. }
  7429. void Commands::Command_Toggle_VoiceChat(Client* client)
  7430. {
  7431. Player* player = client->GetPlayer();
  7432. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7433. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7434. }
  7435. /*
  7436. Function: Command_TradeStart()
  7437. Purpose : Starts item/coin trade between players
  7438. Params :
  7439. Dev :
  7440. Example :
  7441. */
  7442. #include "../Trade.h"
  7443. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7444. {
  7445. PrintSep(sep, "COMMAND_START_TRADE");
  7446. Entity* trader = client->GetPlayer();
  7447. Entity* trader2 = 0;
  7448. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7449. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7450. if (spawn) {
  7451. if (spawn->IsEntity())
  7452. trader2 = (Entity*)spawn;
  7453. }
  7454. }
  7455. else if (client->GetPlayer()->GetTarget()) {
  7456. if (client->GetPlayer()->GetTarget()->IsEntity())
  7457. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7458. }
  7459. // can only trade with player or bots
  7460. if (trader && trader2) {
  7461. if (trader == trader2) {
  7462. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7463. }
  7464. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7465. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7466. if (trader->trade)
  7467. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7468. else if (trader2->trade)
  7469. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7470. else {
  7471. Trade* trade = new Trade(trader, trader2);
  7472. trader->trade = trade;
  7473. trader2->trade = trade;
  7474. }
  7475. }
  7476. else {
  7477. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  7478. }
  7479. }
  7480. else
  7481. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  7482. }
  7483. /*
  7484. Function: Command_Track()
  7485. Purpose : Starts/Stops Tracking for a player
  7486. Params :
  7487. Dev : Scatman
  7488. Example : /track
  7489. */
  7490. void Commands::Command_Track(Client* client)
  7491. {
  7492. if (!client->GetPlayer()->GetIsTracking())
  7493. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7494. else
  7495. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7496. }
  7497. /*
  7498. Function: Command_TradeAccept()
  7499. Purpose : Accepts item/coin trade between players
  7500. Params :
  7501. Dev :
  7502. Example :
  7503. */
  7504. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7505. {
  7506. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7507. Trade* trade = client->GetPlayer()->trade;
  7508. if (trade) {
  7509. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7510. if (trade_complete)
  7511. safe_delete(trade);
  7512. }
  7513. else
  7514. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7515. }
  7516. /*
  7517. Function: Command_TradeReject()
  7518. Purpose : Rejects item/coin trade between players
  7519. Params :
  7520. Dev :
  7521. Example :
  7522. */
  7523. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7524. {
  7525. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7526. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7527. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7528. }
  7529. /*
  7530. Function: Command_TradeCancel()
  7531. Purpose : Cancels item/coin trade between players
  7532. Params :
  7533. Dev :
  7534. Example :
  7535. */
  7536. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7537. {
  7538. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7539. Trade* trade = client->GetPlayer()->trade;
  7540. if (trade) {
  7541. trade->CancelTrade(client->GetPlayer());
  7542. safe_delete(trade);
  7543. }
  7544. else
  7545. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7546. }
  7547. /*
  7548. Function: Command_TradeSetCoin()
  7549. Purpose : Sets coin trade between players
  7550. Params :
  7551. Dev :
  7552. Example :
  7553. */
  7554. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7555. {
  7556. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7557. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7558. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7559. }
  7560. /*
  7561. Function: Command_TradeAddCoin()
  7562. Purpose : Adds coin to trade between players
  7563. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7564. Dev :
  7565. Example :
  7566. */
  7567. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7568. {
  7569. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7570. Trade* trade = client->GetPlayer()->trade;
  7571. if (trade) {
  7572. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7573. int32 amount = atoi(sep->arg[0]);
  7574. int64 val = 0;
  7575. switch (handler) {
  7576. case COMMAND_ADD_TRADE_COPPER:
  7577. {
  7578. val = amount;
  7579. trade->AddCoinToTrade(client->GetPlayer(), val);
  7580. break;
  7581. }
  7582. case COMMAND_ADD_TRADE_SILVER:
  7583. {
  7584. val = amount * 100;
  7585. trade->AddCoinToTrade(client->GetPlayer(), val);
  7586. break;
  7587. }
  7588. case COMMAND_ADD_TRADE_GOLD:
  7589. {
  7590. val = amount * 10000;
  7591. trade->AddCoinToTrade(client->GetPlayer(), val);
  7592. break;
  7593. }
  7594. case COMMAND_ADD_TRADE_PLAT:
  7595. {
  7596. val = amount * 1000000;
  7597. trade->AddCoinToTrade(client->GetPlayer(), val);
  7598. break;
  7599. }
  7600. default:
  7601. {
  7602. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7603. break;
  7604. }
  7605. }
  7606. }
  7607. else
  7608. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7609. }
  7610. else
  7611. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7612. }
  7613. /*
  7614. Function: Command_TradeRemoveCoin()
  7615. Purpose : Removes coin from trade between players
  7616. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7617. Dev :
  7618. Example :
  7619. */
  7620. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7621. {
  7622. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7623. Trade* trade = client->GetPlayer()->trade;
  7624. if (trade) {
  7625. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7626. int32 amount = atoi(sep->arg[0]);
  7627. int64 val = 0;
  7628. switch (handler) {
  7629. case COMMAND_REMOVE_TRADE_COPPER:
  7630. {
  7631. val = amount;
  7632. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7633. break;
  7634. }
  7635. case COMMAND_REMOVE_TRADE_SILVER:
  7636. {
  7637. val = amount * 100;
  7638. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7639. break;
  7640. }
  7641. case COMMAND_REMOVE_TRADE_GOLD:
  7642. {
  7643. val = amount * 10000;
  7644. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7645. break;
  7646. }
  7647. case COMMAND_REMOVE_TRADE_PLAT:
  7648. {
  7649. val = amount * 1000000;
  7650. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7651. break;
  7652. }
  7653. default:
  7654. {
  7655. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7656. break;
  7657. }
  7658. }
  7659. }
  7660. else
  7661. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7662. }
  7663. else
  7664. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7665. }
  7666. /*
  7667. Function: Command_TradeAddItem()
  7668. Purpose : Adds item to trade between players
  7669. Params :
  7670. Dev :
  7671. Example :
  7672. */
  7673. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7674. {
  7675. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7676. /*
  7677. arg[0] = item index
  7678. arg[1] = slot
  7679. arg[2] = quantity
  7680. */
  7681. if (!client->GetPlayer()->trade) {
  7682. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7683. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7684. return;
  7685. }
  7686. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7687. Item* item = 0;
  7688. int32 index = atoi(sep->arg[0]);
  7689. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7690. if (item) {
  7691. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7692. if (result == 1)
  7693. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7694. else if (result == 2)
  7695. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7696. else if (result == 3)
  7697. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7698. else if (result == 255)
  7699. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7700. }
  7701. else {
  7702. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7703. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7704. }
  7705. }
  7706. else
  7707. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7708. }
  7709. /*
  7710. Function: Command_TradeRemoveItem()
  7711. Purpose : Removes item from trade between players
  7712. Params :
  7713. Dev :
  7714. Example :
  7715. */
  7716. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7717. {
  7718. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7719. /*
  7720. arg[0] = trade window slot
  7721. */
  7722. Trade* trade = client->GetPlayer()->trade;
  7723. if (trade) {
  7724. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7725. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7726. }
  7727. else
  7728. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7729. }
  7730. else
  7731. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7732. }
  7733. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7734. {
  7735. Item *item = 0;
  7736. sint32 crc;
  7737. if (sep) {
  7738. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7739. if (client->GetVersion() < 1096) {
  7740. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7741. {
  7742. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7743. crc = atol(sep->arg[2]);
  7744. }
  7745. }
  7746. else {
  7747. // From the broker and links in chat
  7748. if (strcmp(sep->arg[0], "crc") == 0) {
  7749. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7750. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7751. crc = atol(sep->arg[3]);
  7752. }
  7753. }
  7754. // From inventory
  7755. if (strcmp(sep->arg[0], "dbid") == 0) {
  7756. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7757. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7758. crc = atol(sep->arg[4]);
  7759. }
  7760. }
  7761. }
  7762. if (item)
  7763. client->ShowDressingRoom(item, crc);
  7764. }
  7765. }
  7766. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7767. const char *channel_name, *password = NULL;
  7768. if (sep == NULL || !sep->IsSet(0)) {
  7769. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7770. return;
  7771. }
  7772. channel_name = sep->arg[0];
  7773. if (sep->IsSet(1))
  7774. password = sep->arg[1];
  7775. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7776. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7777. return;
  7778. }
  7779. if (chat.IsInChannel(client, channel_name)) {
  7780. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  7781. return;
  7782. }
  7783. if (chat.HasPassword(channel_name)) {
  7784. if (password == NULL) {
  7785. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  7786. return;
  7787. }
  7788. if (!chat.PasswordMatches(channel_name, password)) {
  7789. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  7790. return;
  7791. }
  7792. }
  7793. if (!chat.JoinChannel(client, channel_name))
  7794. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7795. }
  7796. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7797. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7798. Command_JoinChannel(client, sep);
  7799. }
  7800. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7801. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7802. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7803. PrintSep(sep, "tellchannel");
  7804. return;
  7805. }
  7806. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7807. }
  7808. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7809. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7810. if (sep->IsSet(0)) {
  7811. if (atoi(sep->arg[0]) == 1) {
  7812. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  7813. if (packet2) {
  7814. packet2->setDataByName("spell_type", 2);
  7815. packet2->setDataByName("spell_id", 8308);
  7816. packet2->setDataByName("spell_name", "Sprint");
  7817. packet2->setDataByName("add_silently", 0);
  7818. packet2->setDataByName("tier", 1);
  7819. packet2->setDataByName("blah1", 1);
  7820. packet2->setDataByName("blah2", 1);
  7821. EQ2Packet* outapp = packet2->serialize();
  7822. DumpPacket(outapp);
  7823. client->QueuePacket(outapp);
  7824. safe_delete(packet2);
  7825. }
  7826. }
  7827. else if (atoi(sep->arg[0]) == 2) {
  7828. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  7829. if (packet2) {
  7830. packet2->setDataByName("guild_name", "Test");
  7831. packet2->setDataByName("guild_motd", "Test MOTD");
  7832. packet2->setDataByName("guild_id", 1234);
  7833. packet2->setDataByName("guild_level", 1);
  7834. packet2->setDataByName("unknown", 2);
  7835. packet2->setDataByName("unknown2", 3);
  7836. packet2->setDataByName("exp_current", 1);
  7837. packet2->setDataByName("exp_to_next_level", 4);
  7838. EQ2Packet* outapp = packet2->serialize();
  7839. DumpPacket(outapp);
  7840. client->QueuePacket(outapp);
  7841. safe_delete(packet2);
  7842. }
  7843. }
  7844. else if (atoi(sep->arg[0]) == 3) {
  7845. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  7846. if (packet2) {
  7847. packet2->setDataByName("guild_id", 1234);
  7848. packet2->setDataByName("character_id", 1);
  7849. packet2->setDataByName("account_id", 2);
  7850. packet2->setDataByName("guild_level", 1);
  7851. packet2->setDataByName("name", "Test");
  7852. packet2->setDataByName("unknown2", 0);
  7853. packet2->setDataByName("unknown3", 1);
  7854. packet2->setDataByName("adventure_class", 6);
  7855. packet2->setDataByName("adventure_level", 7);
  7856. packet2->setDataByName("tradeskill_class", 4);
  7857. packet2->setDataByName("tradeskill_level", 5);
  7858. packet2->setDataByName("rank", 0);
  7859. packet2->setDataByName("member_flags", 2);
  7860. packet2->setDataByName("join_date", 1591112273);
  7861. packet2->setDataByName("guild_status", 2);
  7862. packet2->setDataByName("last_login", 1591132273);
  7863. packet2->setDataByName("recruiter_id", 1);
  7864. packet2->setDataByName("points", 2345);
  7865. packet2->setDataByName("note", "note");
  7866. packet2->setMediumStringByName("officer_note", "O note");
  7867. packet2->setMediumStringByName("zone", "Blah");
  7868. EQ2Packet* outapp = packet2->serialize();
  7869. DumpPacket(outapp);
  7870. client->QueuePacket(outapp);
  7871. safe_delete(packet2);
  7872. }
  7873. }
  7874. else if (atoi(sep->arg[0]) == 5) {
  7875. int16 offset = atoi(sep->arg[0]);
  7876. int32 value1 = atol(sep->arg[1]);
  7877. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  7878. client->QueuePacket(outapp);
  7879. }
  7880. else if (atoi(sep->arg[0]) == 6) {
  7881. Spawn* spawn = client->GetPlayer()->GetTarget();
  7882. if (!spawn)
  7883. spawn = client->GetPlayer();
  7884. else if (spawn->IsEntity())
  7885. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  7886. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  7887. }
  7888. else if (atoi(sep->arg[0]) == 7) {
  7889. int32 id = 0;
  7890. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  7891. if (spawn) {
  7892. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7893. spawn->SetY(client->GetPlayer()->GetY(), false);
  7894. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7895. float heading = client->GetPlayer()->GetHeading() + 180;
  7896. if (heading > 360)
  7897. heading -= 360;
  7898. spawn->SetLevel(5);
  7899. spawn->SetAdventureClass(4);
  7900. spawn->SetHeading(heading, false);
  7901. spawn->SetSpawnOrigX(spawn->GetX());
  7902. spawn->SetSpawnOrigY(spawn->GetY());
  7903. spawn->SetSpawnOrigZ(spawn->GetZ());
  7904. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  7905. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  7906. spawn->appearance.targetable = 1;
  7907. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  7908. spawn->SetTotalHP(spawn->GetLevel() * 15);
  7909. spawn->SetHP(spawn->GetTotalHP());
  7910. }
  7911. if (spawn->GetTotalPower() == 0) {
  7912. spawn->SetTotalPower(spawn->GetLevel() * 15);
  7913. spawn->SetPower(spawn->GetTotalPower());
  7914. }
  7915. int16 offset = atoi(sep->arg[1]);
  7916. int32 value1 = atol(sep->arg[2]);
  7917. sprintf(spawn->appearance.name, "Offset %i", offset);
  7918. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  7919. DumpPacket(ret);
  7920. client->QueuePacket(ret);
  7921. }
  7922. }
  7923. else if (atoi(sep->arg[0]) == 8) {
  7924. int32 id = atoi(sep->arg[1]);
  7925. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  7926. if (spawn) {
  7927. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7928. spawn->SetY(client->GetPlayer()->GetY(), false);
  7929. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7930. float heading = client->GetPlayer()->GetHeading() + 180;
  7931. if (heading > 360)
  7932. heading -= 360;
  7933. spawn->SetLevel(5);
  7934. spawn->SetAdventureClass(4);
  7935. spawn->SetHeading(heading, false);
  7936. spawn->SetSpawnOrigX(spawn->GetX());
  7937. spawn->SetSpawnOrigY(spawn->GetY());
  7938. spawn->SetSpawnOrigZ(spawn->GetZ());
  7939. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  7940. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  7941. spawn->appearance.targetable = 1;
  7942. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  7943. spawn->SetTotalHP(spawn->GetLevel() * 15);
  7944. spawn->SetHP(spawn->GetTotalHP());
  7945. }
  7946. if (spawn->GetTotalPower() == 0) {
  7947. spawn->SetTotalPower(spawn->GetLevel() * 15);
  7948. spawn->SetPower(spawn->GetTotalPower());
  7949. }
  7950. int16 offset = atoi(sep->arg[2]);
  7951. int16 offset2 = atoi(sep->arg[3]);
  7952. int32 value1 = atol(sep->arg[4]);
  7953. int16 offset3 = 0;
  7954. int16 offset4 = 0;
  7955. int32 value2 = 0;
  7956. if (sep->IsSet(7)) {
  7957. offset3 = atoi(sep->arg[5]);
  7958. offset4 = atoi(sep->arg[6]);
  7959. value2 = atol(sep->arg[7]);
  7960. }
  7961. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  7962. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  7963. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  7964. DumpPacket(ret);
  7965. client->QueuePacket(ret);
  7966. }
  7967. }
  7968. else if (atoi(sep->arg[0]) == 9) {
  7969. Spawn* spawn = client->GetPlayer()->GetTarget();
  7970. if (spawn) {
  7971. if (sep->IsSet(3)) {
  7972. int32 amount = (int32)atoi(sep->arg[3]);
  7973. spawn->SetActivityStatus(amount);
  7974. }
  7975. if (sep->IsSet(2)) {
  7976. int8 amount = (int8)atoi(sep->arg[2]);
  7977. spawn->SetLockedNoLoot(amount);
  7978. }
  7979. if (sep->IsSet(1)) {
  7980. sint8 amount = (sint8)atoi(sep->arg[1]);
  7981. spawn->AddIconValue(amount);
  7982. }
  7983. }
  7984. }
  7985. else if (atoi(sep->arg[0]) == 10) {
  7986. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  7987. if (packet2) {
  7988. packet2->setArrayLengthByName("num_quests", 1);
  7989. packet2->setArrayDataByName("active", 1);
  7990. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  7991. packet2->setArrayDataByName("quest_type", "Hallmark");
  7992. packet2->setArrayDataByName("quest_zone", "Hallmark");
  7993. packet2->setArrayDataByName("journal_updated", 1);
  7994. packet2->setArrayDataByName("quest_id", 524);
  7995. packet2->setArrayDataByName("day", 19);
  7996. packet2->setArrayDataByName("month", 6);
  7997. packet2->setArrayDataByName("year", 20);
  7998. packet2->setArrayDataByName("level", 2);
  7999. packet2->setArrayDataByName("encounter_level", 4);
  8000. packet2->setArrayDataByName("difficulty", 3);
  8001. packet2->setArrayDataByName("visible", 1);
  8002. packet2->setDataByName("visible_quest_id", 524);
  8003. packet2->setDataByName("player_crc", 2900677088);
  8004. packet2->setDataByName("player_name", "LethalEncounter");
  8005. EQ2Packet* app = packet2->serialize();
  8006. if (sep->IsSet(2)) {
  8007. int8 offset = atoi(sep->arg[1]);
  8008. uchar* ptr2 = app->pBuffer;
  8009. ptr2 += offset;
  8010. if (sep->IsNumber(2)) {
  8011. int32 value1 = atol(sep->arg[2]);
  8012. if (value1 > 0xFFFF)
  8013. memcpy(ptr2, (uchar*)&value1, 4);
  8014. else if (value1 > 0xFF)
  8015. memcpy(ptr2, (uchar*)&value1, 2);
  8016. else
  8017. memcpy(ptr2, (uchar*)&value1, 1);
  8018. }
  8019. else {
  8020. int8 len = strlen(sep->arg[2]);
  8021. memcpy(ptr2, (uchar*)&len, 1);
  8022. ptr2 += 1;
  8023. memcpy(ptr2, sep->arg[2], len);
  8024. }
  8025. }
  8026. DumpPacket(app);
  8027. client->QueuePacket(app);
  8028. safe_delete(packet2);
  8029. }
  8030. }
  8031. else if (atoi(sep->arg[0]) == 11) {
  8032. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8033. if (packet2) {
  8034. packet2->setDataByName("quest_id", 5);
  8035. packet2->setDataByName("player_crc", 2900677088);
  8036. packet2->setDataByName("name", "Archetype Selection");
  8037. packet2->setDataByName("description", "I have reported my profession to Garven Tralk");
  8038. packet2->setDataByName("type", "Hallmark");
  8039. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8040. packet2->setDataByName("day", 19);
  8041. packet2->setDataByName("month", 6);
  8042. packet2->setDataByName("year", 20);
  8043. packet2->setDataByName("level", 2);
  8044. packet2->setDataByName("encounter_level", 4);
  8045. packet2->setDataByName("difficulty", 3);
  8046. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8047. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8048. packet2->setDataByName("timer_duration", 300);
  8049. packet2->setDataByName("timer_running", 1);
  8050. packet2->setArrayLengthByName("task_groups_completed", 0);
  8051. packet2->setArrayLengthByName("num_task_groups", 1);
  8052. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8053. packet2->setSubArrayLengthByName("num_tasks", 1);
  8054. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8055. packet2->setSubArrayLengthByName("num_updates", 1);
  8056. packet2->setSubArrayDataByName("update_currentval", 0);
  8057. packet2->setSubArrayDataByName("update_maxval", 1);
  8058. packet2->setSubArrayDataByName("icon", 11);
  8059. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8060. packet2->setDataByName("journal_updated", 1);
  8061. EQ2Packet* app = packet2->serialize();
  8062. if (sep->IsSet(2)) {
  8063. int16 offset = atoi(sep->arg[1]);
  8064. uchar* ptr2 = app->pBuffer;
  8065. ptr2 += offset;
  8066. if (sep->IsNumber(2)) {
  8067. int32 value1 = atol(sep->arg[2]);
  8068. if (value1 > 0xFFFF)
  8069. memcpy(ptr2, (uchar*)&value1, 4);
  8070. else if (value1 > 0xFF)
  8071. memcpy(ptr2, (uchar*)&value1, 2);
  8072. else
  8073. memcpy(ptr2, (uchar*)&value1, 1);
  8074. }
  8075. else {
  8076. int16 len = strlen(sep->arg[2]);
  8077. memcpy(ptr2, (uchar*)&len, 2);
  8078. ptr2 += 2;
  8079. memcpy(ptr2, sep->arg[2], len);
  8080. }
  8081. }
  8082. DumpPacket(app);
  8083. client->QueuePacket(app);
  8084. safe_delete(packet2);
  8085. }
  8086. }
  8087. else if (atoi(sep->arg[0]) == 12) {
  8088. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8089. if (packet2) {
  8090. packet2->setDataByName("quest_id", 5);
  8091. packet2->setDataByName("player_crc", 2900677088);
  8092. packet2->setDataByName("name", "Archetype Selection");
  8093. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  8094. packet2->setDataByName("type", "Hallmark");
  8095. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8096. packet2->setDataByName("day", 19);
  8097. packet2->setDataByName("month", 6);
  8098. packet2->setDataByName("year", 20);
  8099. packet2->setDataByName("level", 2);
  8100. packet2->setDataByName("encounter_level", 4);
  8101. packet2->setDataByName("difficulty", 3);
  8102. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8103. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8104. packet2->setDataByName("timer_duration", 300);
  8105. packet2->setDataByName("timer_running", 1);
  8106. packet2->setArrayLengthByName("task_groups_completed", 0);
  8107. packet2->setArrayLengthByName("num_task_groups", 1);
  8108. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8109. packet2->setSubArrayLengthByName("num_tasks", 1);
  8110. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8111. packet2->setSubArrayLengthByName("num_updates", 1);
  8112. packet2->setSubArrayDataByName("update_currentval", 0);
  8113. packet2->setSubArrayDataByName("update_maxval", 1);
  8114. packet2->setSubArrayDataByName("icon", 11);
  8115. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8116. packet2->setDataByName("journal_updated", 1);
  8117. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8118. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8119. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  8120. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8121. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8122. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8123. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  8124. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  8125. Item* item = master_item_list.GetItem(152755);
  8126. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8127. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8128. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  8129. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  8130. packet2->setSubstructDataByName("item", "icon", 0xe7);
  8131. packet2->setSubstructDataByName("item", "tier", 4);
  8132. packet2->setSubstructDataByName("item", "flags", 0x60);
  8133. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  8134. packet2->setSubstructDataByName("item", "stat_type", 1);
  8135. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  8136. packet2->setSubstructDataByName("item", "value", 3);
  8137. packet2->setSubstructDataByName("item", "condition", 100);
  8138. packet2->setSubstructDataByName("item", "weight", 1);
  8139. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  8140. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  8141. packet2->setSubstructDataByName("item", "skill_min", 1);
  8142. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  8143. packet2->setSubstructDataByName("item", "adventure_class", 1);
  8144. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  8145. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  8146. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  8147. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  8148. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  8149. packet2->setSubstructDataByName("item", "level", 0x1e);
  8150. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  8151. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  8152. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  8153. //packet2->PrintPacket();
  8154. EQ2Packet* app = packet2->serialize();
  8155. if (sep->IsSet(2)) {
  8156. int16 offset = atoi(sep->arg[1]);
  8157. uchar* ptr2 = app->pBuffer;
  8158. ptr2 += offset;
  8159. if (sep->IsNumber(2)) {
  8160. int32 value1 = atol(sep->arg[2]);
  8161. if (value1 > 0xFFFF)
  8162. memcpy(ptr2, (uchar*)&value1, 4);
  8163. else if (value1 > 0xFF)
  8164. memcpy(ptr2, (uchar*)&value1, 2);
  8165. else
  8166. memcpy(ptr2, (uchar*)&value1, 1);
  8167. }
  8168. else {
  8169. int16 len = strlen(sep->arg[2]);
  8170. memcpy(ptr2, (uchar*)&len, 2);
  8171. ptr2 += 2;
  8172. memcpy(ptr2, sep->arg[2], len);
  8173. }
  8174. }
  8175. DumpPacket(app);
  8176. client->QueuePacket(app);
  8177. safe_delete(packet2);
  8178. }
  8179. }
  8180. else if (atoi(sep->arg[0]) == 13) {
  8181. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  8182. if (packet2 && sep->IsSet(7)) {
  8183. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  8184. char blah[128];
  8185. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  8186. packet2->setDataByName("text", blah);
  8187. packet2->setDataByName("message_type", sep->arg[3]);
  8188. packet2->setDataByName("size", atof(sep->arg[4]));
  8189. packet2->setDataByName("red", atoi(sep->arg[5]));
  8190. packet2->setDataByName("green", atoi(sep->arg[6]));
  8191. packet2->setDataByName("blue", atoi(sep->arg[7]));
  8192. EQ2Packet* app = packet2->serialize();
  8193. DumpPacket(app);
  8194. client->QueuePacket(app);
  8195. safe_delete(packet2);
  8196. }
  8197. }
  8198. else if (atoi(sep->arg[0]) == 14) {
  8199. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  8200. if (packet2 && sep->IsSet(3)) {
  8201. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  8202. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  8203. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  8204. 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.");
  8205. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  8206. packet2->setArrayLengthByName("num_goals", 1);
  8207. //packet2->setArrayDataByName("goal_text", )
  8208. packet2->setSubArrayLengthByName("num_tasks", 1);
  8209. packet2->setSubArrayDataByName("task_text", "continue");
  8210. packet2->setDataByName("complete_sound", "click");
  8211. packet2->setDataByName("signal", "introduction");
  8212. packet2->setDataByName("voice_key1", 0xcda65173);
  8213. packet2->setDataByName("voice_key2", 0x984bfc6d);
  8214. EQ2Packet* app = packet2->serialize();
  8215. DumpPacket(app);
  8216. client->QueuePacket(app);
  8217. safe_delete(packet2);
  8218. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  8219. packet2->setDataByName("window", "MainHUD.StartMenu");
  8220. packet2->setDataByName("show", 1);
  8221. app = packet2->serialize();
  8222. DumpPacket(app);
  8223. client->QueuePacket(app);
  8224. safe_delete(packet2);
  8225. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  8226. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  8227. packet2->setDataByName("flash_seconds", 10);
  8228. app = packet2->serialize();
  8229. DumpPacket(app);
  8230. client->QueuePacket(app);
  8231. safe_delete(packet2);
  8232. }
  8233. }
  8234. else if (atoi(sep->arg[0]) == 15) {
  8235. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8236. if (packet2) {
  8237. packet2->setArrayLengthByName("loot_count", 1);
  8238. packet2->setArrayDataByName("name", "Test");
  8239. packet2->setArrayDataByName("item_id", 1234);
  8240. packet2->setArrayDataByName("count", 1);
  8241. packet2->setArrayDataByName("icon", 258);
  8242. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  8243. Spawn* spawn = client->GetPlayer()->GetTarget();
  8244. if (spawn)
  8245. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8246. packet2->setDataByName("unknown3", 1);
  8247. packet2->setDataByName("unknown4", 1);
  8248. packet2->setDataByName("unknown5", 60);
  8249. EQ2Packet* app = packet2->serialize();
  8250. DumpPacket(app);
  8251. client->QueuePacket(app);
  8252. safe_delete(packet2);
  8253. }
  8254. }
  8255. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  8256. char blah[32];
  8257. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  8258. client->SimpleMessage(atoi(sep->arg[1]), blah);
  8259. }
  8260. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  8261. if (sep->IsSet(2)) {
  8262. int16 offset = atoi(sep->arg[1]);
  8263. if (sep->IsNumber(2)) {
  8264. int32 value1 = atol(sep->arg[2]);
  8265. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  8266. cout << "Sent" << endl;
  8267. }
  8268. }
  8269. }
  8270. else if (atoi(sep->arg[0]) == 18) {
  8271. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  8272. if (packet2) {
  8273. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8274. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8275. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8276. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8277. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8278. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  8279. Item* item = new Item(master_item_list.GetItem(36212));
  8280. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8281. item->stack_count = 20;
  8282. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8283. safe_delete(item);
  8284. item = new Item(master_item_list.GetItem(36685));
  8285. item->stack_count = 20;
  8286. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8287. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  8288. safe_delete(item);
  8289. item = master_item_list.GetItem(1414);
  8290. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8291. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  8292. item = master_item_list.GetItem(75057);
  8293. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8294. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  8295. EQ2Packet* app = packet2->serialize();
  8296. if (sep->IsSet(2)) {
  8297. int16 offset = atoi(sep->arg[1]);
  8298. uchar* ptr2 = app->pBuffer;
  8299. ptr2 += offset;
  8300. if (sep->IsNumber(2)) {
  8301. int32 value1 = atol(sep->arg[2]);
  8302. if (value1 > 0xFFFF)
  8303. memcpy(ptr2, (uchar*)&value1, 4);
  8304. else if (value1 > 0xFF)
  8305. memcpy(ptr2, (uchar*)&value1, 2);
  8306. else
  8307. memcpy(ptr2, (uchar*)&value1, 1);
  8308. }
  8309. else {
  8310. int16 len = strlen(sep->arg[2]);
  8311. memcpy(ptr2, (uchar*)&len, 2);
  8312. ptr2 += 2;
  8313. memcpy(ptr2, sep->arg[2], len);
  8314. }
  8315. }
  8316. DumpPacket(app);
  8317. client->QueuePacket(app);
  8318. safe_delete(packet2);
  8319. }
  8320. }
  8321. else if (atoi(sep->arg[0]) == 19) {
  8322. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8323. Spawn* spawn = client->GetPlayer()->GetTarget();
  8324. if (packet2 && spawn) {
  8325. Item* item = master_item_list.GetItem(130053);
  8326. packet2->setArrayLengthByName("loot_count", 1);
  8327. packet2->setArrayDataByName("loot_id", item->details.item_id);
  8328. packet2->setArrayDataByName("unknown2", 1);
  8329. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  8330. packet2->setDataByName("display", 1);
  8331. packet2->setDataByName("unknown2b", 1);
  8332. packet2->setDataByName("unknown3", 0x3c);
  8333. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8334. packet2->PrintPacket();
  8335. EQ2Packet* app = packet2->serialize();
  8336. if (sep->IsSet(2)) {
  8337. int16 offset = atoi(sep->arg[1]);
  8338. int16 offset2 = 0;
  8339. int32 value1 = 0;
  8340. if (sep->IsSet(3)) {
  8341. offset2 = atoi(sep->arg[2]);
  8342. value1 = atol(sep->arg[3]);
  8343. }
  8344. else
  8345. value1 = atol(sep->arg[2]);
  8346. int16 offset3 = 0;
  8347. int16 offset4 = 0;
  8348. int32 value2 = 0;
  8349. if (sep->IsSet(6)) {
  8350. offset3 = atoi(sep->arg[4]);
  8351. offset4 = atoi(sep->arg[5]);
  8352. value2 = atol(sep->arg[6]);
  8353. }
  8354. offset--;
  8355. if (offset2 > 0 && offset2 >= offset) {
  8356. offset2--;
  8357. uchar* ptr2 = app->pBuffer;
  8358. ptr2 += offset;
  8359. for (int i = offset; i <= offset2; i++) {
  8360. if (value1 > 0xFFFF) {
  8361. memcpy(ptr2, (uchar*)&value1, 4);
  8362. i += 3;
  8363. ptr2 += 3;
  8364. }
  8365. else if (value1 > 0xFF) {
  8366. memcpy(ptr2, (uchar*)&value1, 2);
  8367. i++;
  8368. ptr2++;
  8369. }
  8370. else
  8371. memcpy(ptr2, (uchar*)&value1, 1);
  8372. ptr2++;
  8373. }
  8374. }
  8375. if (offset4 > 0 && offset4 >= offset3) {
  8376. offset3--;
  8377. offset4--;
  8378. uchar* ptr2 = app->pBuffer;
  8379. ptr2 += offset3;
  8380. for (int i = offset3; i <= offset4; i++) {
  8381. if (value2 > 0xFFFF) {
  8382. memcpy(ptr2, (uchar*)&value2, 4);
  8383. i += 3;
  8384. ptr2 += 3;
  8385. }
  8386. else if (value2 > 0xFF) {
  8387. memcpy(ptr2, (uchar*)&value2, 2);
  8388. i++;
  8389. ptr2++;
  8390. }
  8391. else
  8392. memcpy(ptr2, (uchar*)&value2, 1);
  8393. ptr2++;
  8394. }
  8395. }
  8396. }
  8397. DumpPacket(app);
  8398. client->QueuePacket(app);
  8399. safe_delete(packet2);
  8400. }
  8401. }
  8402. else if (atoi(sep->arg[0]) == 21) {
  8403. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8404. if (packet2) {
  8405. packet2->setDataByName("unknown0", 255);
  8406. packet2->setDataByName("reward", "New Quest");
  8407. packet2->setDataByName("title", "Title");
  8408. packet2->setDataByName("description", "description");
  8409. packet2->setDataByName("quest_difficulty", 3);
  8410. packet2->setDataByName("unknown1", 5);
  8411. packet2->setDataByName("level", 3);
  8412. packet2->setDataByName("coin", 150);
  8413. packet2->setDataByName("status_points", 5);
  8414. packet2->setDataByName("exp_bonus", 10);
  8415. packet2->setArrayLengthByName("num_rewards", 1);
  8416. Item* item = new Item(master_item_list.GetItem(36212));
  8417. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8418. item->stack_count = 20;
  8419. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8420. safe_delete(item);
  8421. char accept[35] = { 0 };
  8422. char decline[35] = { 0 };
  8423. sprintf(accept, "q_accept_pending_quest %u", 0);
  8424. sprintf(decline, "q_deny_pending_quest %u", 0);
  8425. packet2->setDataByName("accept_command", accept);
  8426. packet2->setDataByName("decline_command", decline);
  8427. EQ2Packet* app = packet2->serialize();
  8428. if (sep->IsSet(2)) {
  8429. int16 offset = atoi(sep->arg[1]);
  8430. uchar* ptr2 = app->pBuffer;
  8431. ptr2 += offset;
  8432. if (sep->IsNumber(2)) {
  8433. int32 value1 = atol(sep->arg[2]);
  8434. if (value1 > 0xFFFF)
  8435. memcpy(ptr2, (uchar*)&value1, 4);
  8436. else if (value1 > 0xFF)
  8437. memcpy(ptr2, (uchar*)&value1, 2);
  8438. else
  8439. memcpy(ptr2, (uchar*)&value1, 1);
  8440. }
  8441. DumpPacket(app);
  8442. client->QueuePacket(app);
  8443. safe_delete(packet2);
  8444. }
  8445. }
  8446. }
  8447. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  8448. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8449. if (packet2) {
  8450. packet2->setDataByName("unknown0", 255);
  8451. packet2->setDataByName("reward", "New Quest");
  8452. packet2->setDataByName("title", "Title");
  8453. packet2->setDataByName("description", "description");
  8454. packet2->setDataByName("quest_difficulty", 3);
  8455. packet2->setDataByName("unknown1", 5);
  8456. packet2->setDataByName("level", 3);
  8457. packet2->setDataByName("coin", 150);
  8458. packet2->setDataByName("status_points", 5);
  8459. packet2->setDataByName("exp_bonus", 10);
  8460. packet2->setArrayLengthByName("num_rewards", 1);
  8461. Item* item = new Item(master_item_list.GetItem(36212));
  8462. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8463. item->stack_count = 20;
  8464. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8465. safe_delete(item);
  8466. char accept[35] = { 0 };
  8467. char decline[35] = { 0 };
  8468. sprintf(accept, "q_accept_pending_quest %u", 0);
  8469. sprintf(decline, "q_deny_pending_quest %u", 0);
  8470. packet2->setDataByName("accept_command", accept);
  8471. packet2->setDataByName("decline_command", decline);
  8472. EQ2Packet* app = packet2->serialize();
  8473. if (sep->IsSet(2)) {
  8474. int16 offset = atoi(sep->arg[1]);
  8475. uchar* ptr2 = app->pBuffer;
  8476. ptr2 += offset;
  8477. if (sep->IsNumber(2)) {
  8478. int32 value1 = atol(sep->arg[2]);
  8479. if (value1 > 0xFFFF)
  8480. memcpy(ptr2, (uchar*)&value1, 4);
  8481. else if (value1 > 0xFF)
  8482. memcpy(ptr2, (uchar*)&value1, 2);
  8483. else
  8484. memcpy(ptr2, (uchar*)&value1, 1);
  8485. }
  8486. else {
  8487. int8 len = strlen(sep->arg[2]);
  8488. memcpy(ptr2, (uchar*)&len, 1);
  8489. ptr2 += 1;
  8490. memcpy(ptr2, sep->arg[2], len);
  8491. }
  8492. }
  8493. DumpPacket(app);
  8494. client->QueuePacket(app);
  8495. safe_delete(packet2);
  8496. }
  8497. }
  8498. else if (atoi(sep->arg[0]) == 23) {
  8499. if (client->GetPlayer()->GetTarget()) {
  8500. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  8501. if (packet2) {
  8502. Spawn* target = client->GetPlayer()->GetTarget();
  8503. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8504. Item* item = new Item(master_item_list.GetItem(12565));
  8505. int8 i = 0;
  8506. packet2->setArrayLengthByName("num_items", 1);
  8507. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  8508. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  8509. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  8510. packet2->setArrayDataByName("icon", item->details.icon, i);
  8511. int8 tmp_level = 0;
  8512. if (item->generic_info.adventure_default_level > 0)
  8513. tmp_level = item->generic_info.adventure_default_level;
  8514. else
  8515. tmp_level = item->generic_info.tradeskill_default_level;
  8516. packet2->setArrayDataByName("level", tmp_level, i);
  8517. packet2->setArrayDataByName("tier", item->details.tier, i);
  8518. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  8519. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  8520. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  8521. item_difficulty = ARROW_COLOR_WHITE;
  8522. item_difficulty -= 6;
  8523. if (item_difficulty < 0)
  8524. item_difficulty *= -1;
  8525. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  8526. packet2->setArrayDataByName("quantity", 2, i);
  8527. packet2->setArrayDataByName("unknown5", 255, i);
  8528. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  8529. packet2->setArrayDataByName("description", item->description.c_str(), i);
  8530. packet2->setDataByName("type", 2);
  8531. EQ2Packet* app = packet2->serialize();
  8532. if (sep->IsSet(2)) {
  8533. int16 offset = atoi(sep->arg[1]);
  8534. uchar* ptr2 = app->pBuffer;
  8535. ptr2 += offset;
  8536. if (sep->IsNumber(2)) {
  8537. int32 value1 = atol(sep->arg[2]);
  8538. if (value1 > 0xFFFF)
  8539. memcpy(ptr2, (uchar*)&value1, 4);
  8540. else if (value1 > 0xFF)
  8541. memcpy(ptr2, (uchar*)&value1, 2);
  8542. else
  8543. memcpy(ptr2, (uchar*)&value1, 1);
  8544. }
  8545. else {
  8546. int8 len = strlen(sep->arg[2]);
  8547. memcpy(ptr2, (uchar*)&len, 1);
  8548. ptr2 += 1;
  8549. memcpy(ptr2, sep->arg[2], len);
  8550. }
  8551. }
  8552. DumpPacket(app);
  8553. client->QueuePacket(app);
  8554. safe_delete(packet2);
  8555. }
  8556. }
  8557. }
  8558. else if (atoi(sep->arg[0]) == 24) {
  8559. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  8560. if (packet2) {
  8561. if (sep->IsSet(2)) {
  8562. packet2->setDataByName("event_name", sep->arg[1]);
  8563. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  8564. EQ2Packet* app = packet2->serialize();
  8565. DumpPacket(app);
  8566. client->QueuePacket(app);
  8567. safe_delete(packet2);
  8568. }
  8569. }
  8570. }
  8571. else if (atoi(sep->arg[0]) == 25) {
  8572. if (sep->IsSet(1)) {
  8573. Widget* new_spawn = new Widget();
  8574. int32 id = atoul(sep->arg[1]);
  8575. new_spawn->SetWidgetID(id);
  8576. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  8577. client->QueuePacket(ret);
  8578. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  8579. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  8580. if (packet2) {
  8581. packet2->setDataByName("spawn_index", index);
  8582. packet2->setDataByName("delete", 1);
  8583. EQ2Packet* app = packet2->serialize();
  8584. client->QueuePacket(app);
  8585. safe_delete(packet2);
  8586. }
  8587. }
  8588. }
  8589. else if (atoi(sep->arg[0]) == 26) {
  8590. if (sep->IsSet(4)) {
  8591. Widget* new_spawn = new Widget();
  8592. int32 id = atoul(sep->arg[1]);
  8593. new_spawn->SetWidgetID(id);
  8594. float x = atof(sep->arg[2]);
  8595. float y = atof(sep->arg[3]);
  8596. float z = atof(sep->arg[4]);
  8597. new_spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8598. new_spawn->SetWidgetX(x);
  8599. new_spawn->SetWidgetY(y);
  8600. new_spawn->SetWidgetZ(z);
  8601. new_spawn->SetX(x);
  8602. new_spawn->SetY(y);
  8603. new_spawn->SetZ(z);
  8604. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  8605. client->QueuePacket(ret);
  8606. }
  8607. }
  8608. else if (atoi(sep->arg[0]) == 27) {
  8609. Spawn* target = client->GetPlayer()->GetTarget();
  8610. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  8611. if (packet2 && target && sep->IsSet(2)) {
  8612. packet2->setSubstructDataByName("header", "defender", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8613. packet2->setSubstructDataByName("header", "defender_proxy", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8614. packet2->setSubstructDataByName("header", "attacker", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  8615. packet2->setArrayLengthByName("num_dmg", 1);
  8616. packet2->setArrayDataByName("damage_type", atoi(sep->arg[1]));
  8617. packet2->setArrayDataByName("damage", atoi(sep->arg[2]));
  8618. packet2->setDataByName("spell", 1);
  8619. packet2->setDataByName("spell_name", "Testing");
  8620. EQ2Packet* app = packet2->serialize();
  8621. if (sep->IsSet(4)) {
  8622. int16 offset = atoi(sep->arg[3]);
  8623. uchar* ptr2 = app->pBuffer;
  8624. ptr2 += offset;
  8625. if (sep->IsNumber(4)) {
  8626. int32 value1 = atol(sep->arg[4]);
  8627. if (value1 > 0xFFFF)
  8628. memcpy(ptr2, (uchar*)&value1, 4);
  8629. else if (value1 > 0xFF)
  8630. memcpy(ptr2, (uchar*)&value1, 2);
  8631. else
  8632. memcpy(ptr2, (uchar*)&value1, 1);
  8633. }
  8634. else {
  8635. int8 len = strlen(sep->arg[4]);
  8636. memcpy(ptr2, (uchar*)&len, 1);
  8637. ptr2 += 1;
  8638. memcpy(ptr2, sep->arg[4], len);
  8639. }
  8640. }
  8641. if (sep->IsSet(6)) {
  8642. int16 offset = atoi(sep->arg[5]);
  8643. uchar* ptr2 = app->pBuffer;
  8644. ptr2 += offset;
  8645. if (sep->IsNumber(6)) {
  8646. int32 value1 = atol(sep->arg[6]);
  8647. if (value1 > 0xFFFF)
  8648. memcpy(ptr2, (uchar*)&value1, 4);
  8649. else if (value1 > 0xFF)
  8650. memcpy(ptr2, (uchar*)&value1, 2);
  8651. else
  8652. memcpy(ptr2, (uchar*)&value1, 1);
  8653. }
  8654. else {
  8655. int8 len = strlen(sep->arg[6]);
  8656. memcpy(ptr2, (uchar*)&len, 1);
  8657. ptr2 += 1;
  8658. memcpy(ptr2, sep->arg[6], len);
  8659. }
  8660. }
  8661. DumpPacket(app);
  8662. client->QueuePacket(app);
  8663. safe_delete(packet2);
  8664. }
  8665. }
  8666. }
  8667. else {
  8668. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  8669. if (packet2) {
  8670. packet2->setSubstructDataByName("info_header", "show_name", 1);
  8671. packet2->setSubstructDataByName("info_header", "unknown", 7);
  8672. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  8673. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  8674. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  8675. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  8676. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  8677. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  8678. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  8679. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  8680. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  8681. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  8682. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  8683. packet2->setSubstructDataByName("info_header", "packettype", 3);
  8684. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  8685. packet2->setSubstructDataByName("spell_info", "level", 19);
  8686. packet2->setSubstructDataByName("spell_info", "tier", 1);
  8687. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  8688. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  8689. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  8690. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  8691. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  8692. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  8693. packet2->setSubstructDataByName("spell_info", "recast", 280);
  8694. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  8695. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  8696. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  8697. packet2->setSubstructDataByName("spell_info", "quality", 3);
  8698. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  8699. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  8700. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  8701. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  8702. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  8703. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  8704. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  8705. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  8706. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  8707. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  8708. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  8709. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  8710. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  8711. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  8712. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  8713. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  8714. packet2->setArrayDataByName("reagent", "Alcohol");
  8715. packet2->setArrayDataByName("consumed", "123");
  8716. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  8717. packet2->setSubstructDataByName("spell_info", "id", 8308);
  8718. packet2->setSubstructDataByName("spell_info", "icon", 303);
  8719. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  8720. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  8721. packet2->setSubstructDataByName("spell_info", "type", 2);
  8722. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  8723. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  8724. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  8725. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  8726. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  8727. EQ2Packet* outapp = packet2->serialize();
  8728. DumpPacket(outapp);
  8729. client->QueuePacket(outapp);
  8730. safe_delete(packet2);
  8731. }
  8732. }
  8733. return;
  8734. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  8735. if (!p) return;
  8736. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8737. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  8738. //}
  8739. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8740. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  8741. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  8742. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  8743. if (packet) {
  8744. client->QueuePacket(packet->serialize());
  8745. safe_delete(packet);
  8746. }
  8747. }*/
  8748. /*if (client->GetCurrentZone()->Grid != nullptr) {
  8749. int32 numFaces = 0;
  8750. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  8751. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  8752. map<int32, vector<Face*> >::iterator itr;
  8753. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  8754. numFaces += (*itr).second.size();
  8755. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  8756. }*/
  8757. //uchar blah[] = {
  8758. // 1208 - OP_EQUpdateStoreCmd
  8759. // /*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
  8760. // /*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
  8761. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  8762. // /*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
  8763. /*};
  8764. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8765. int8 val = 0;
  8766. int16 pos = 0;
  8767. int idx = 0;
  8768. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  8769. pos = atoi(sep2->arg[idx]);
  8770. val = atoi(sep2->arg[idx+1]);
  8771. memset(blah+pos, val, 1);
  8772. idx+=2;
  8773. }
  8774. DumpPacket(blah, sizeof(blah));
  8775. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  8776. if (client->GetPlayer()->GetTarget()) {
  8777. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  8778. if (packet) {
  8779. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8780. packet->setDataByName("size", 0);
  8781. packet->setDataByName("unknown2", 0);
  8782. EQ2Packet* app = packet->serialize();
  8783. client->QueuePacket(app);
  8784. safe_delete(packet);
  8785. }
  8786. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  8787. if (set_pov) {
  8788. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8789. EQ2Packet* app_pov = set_pov->serialize();
  8790. client->QueuePacket(app_pov);
  8791. safe_delete(set_pov);
  8792. }
  8793. }
  8794. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8795. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  8796. if (packet) {
  8797. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  8798. packet->setDataByName("Type", atoi(sep2->arg[0]));
  8799. else
  8800. packet->setDataByName("Type", 2);
  8801. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  8802. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  8803. else
  8804. packet->setDataByName("race_id", 0);
  8805. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  8806. packet->setDataByName("gender", atoi(sep2->arg[2]));
  8807. else
  8808. packet->setDataByName("gender", 2);
  8809. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  8810. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  8811. else
  8812. packet->setDataByName("unknown", 0, 0);
  8813. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  8814. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  8815. else
  8816. packet->setDataByName("unknown", 0, 1);
  8817. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  8818. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  8819. else
  8820. packet->setDataByName("unknown", 0, 2);
  8821. client->QueuePacket(packet->serialize());
  8822. }
  8823. safe_delete(packet);
  8824. safe_delete(sep2);
  8825. }
  8826. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  8827. const char *channel_name;
  8828. if (sep == NULL || !sep->IsSet(0)) {
  8829. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  8830. PrintSep(sep);
  8831. return;
  8832. }
  8833. channel_name = sep->arg[0];
  8834. if (!chat.IsInChannel(client, channel_name))
  8835. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  8836. else if (!chat.LeaveChannel(client, channel_name))
  8837. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  8838. }
  8839. /*
  8840. Function:
  8841. Purpose :
  8842. Params :
  8843. Dev :
  8844. Example :
  8845. */
  8846. void Commands::Command_WeaponStats(Client* client)
  8847. {
  8848. Player* player = client->GetPlayer();
  8849. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  8850. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  8851. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  8852. client->SimpleMessage(0, "Primary:");
  8853. if (primary) {
  8854. client->Message(0, "Name: %s", primary->name.c_str());
  8855. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  8856. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8857. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  8858. client->Message(0, "Proc Percent: %d%%", 0);
  8859. client->Message(0, "Procs Per Minute: %d", 0);
  8860. }
  8861. else {
  8862. client->SimpleMessage(0, "Name: fist");
  8863. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8864. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8865. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  8866. client->Message(0, "Proc Percent: %d%%", 0);
  8867. client->Message(0, "Procs Per Minute: %d", 0);
  8868. }
  8869. client->SimpleMessage(0, " ");
  8870. client->SimpleMessage(0, " ");
  8871. if (secondary) {
  8872. client->SimpleMessage(0, "Secondary:");
  8873. client->Message(0, "Name: %s", secondary->name.c_str());
  8874. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  8875. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  8876. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  8877. client->Message(0, "Proc Percent: %d%%", 0);
  8878. client->Message(0, "Procs Per Minute: %d", 0);
  8879. client->SimpleMessage(0, " ");
  8880. client->SimpleMessage(0, " ");
  8881. }
  8882. client->SimpleMessage(0, "Ranged:");
  8883. if (ranged) {
  8884. client->Message(0, "Name: %s", ranged->name.c_str());
  8885. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  8886. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  8887. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  8888. client->Message(0, "Proc Percent: %d%%", 0);
  8889. client->Message(0, "Procs Per Minute: %d", 0);
  8890. }
  8891. else
  8892. client->SimpleMessage(0, "None");
  8893. }
  8894. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  8895. const char *channel_name;
  8896. if (sep == NULL || !sep->IsSet(0)) {
  8897. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  8898. return;
  8899. }
  8900. channel_name = sep->arg[0];
  8901. if (!chat.ChannelExists(channel_name))
  8902. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  8903. else
  8904. chat.SendChannelUserList(client, channel_name);
  8905. }
  8906. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  8907. {
  8908. ZoneServer* zone = 0;
  8909. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  8910. if (zone_id > 0)
  8911. {
  8912. zone = zone_list.Get(zone_id, false);
  8913. if (zone)
  8914. {
  8915. zone->SetSafeX(client->GetPlayer()->GetX());
  8916. zone->SetSafeY(client->GetPlayer()->GetY());
  8917. zone->SetSafeZ(client->GetPlayer()->GetZ());
  8918. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  8919. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  8920. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  8921. else
  8922. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  8923. }
  8924. }
  8925. }
  8926. /*
  8927. Function:
  8928. Purpose :
  8929. Params :
  8930. Dev :
  8931. Example :
  8932. */
  8933. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  8934. {
  8935. ZoneInfo* zone_info = new ZoneInfo;
  8936. if (sep && sep->arg[0])
  8937. {
  8938. if (sep->IsNumber(0))
  8939. zone_info->id = atoi(sep->arg[0]);
  8940. else
  8941. zone_info->id = database.GetZoneID(sep->arg[0]);
  8942. if (zone_info->id > 0)
  8943. {
  8944. database.LoadZoneInfo(zone_info);
  8945. 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);
  8946. 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);
  8947. 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);
  8948. 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);
  8949. 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);
  8950. 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);
  8951. 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);
  8952. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  8953. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  8954. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  8955. }
  8956. else
  8957. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  8958. }
  8959. else
  8960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  8961. safe_delete(zone_info);
  8962. }
  8963. /*
  8964. Function:
  8965. Purpose :
  8966. Params :
  8967. Dev :
  8968. Example :
  8969. */
  8970. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  8971. {
  8972. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  8973. {
  8974. ZoneServer* zone = 0;
  8975. int32 zone_id = 0;
  8976. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  8977. {
  8978. zone_id = atoi(sep->arg[0]);
  8979. zone = zone_list.Get(atoi(sep->arg[0]), false);
  8980. }
  8981. else
  8982. {
  8983. zone_id = database.GetZoneID(sep->arg[0]);
  8984. if (zone_id > 0)
  8985. zone = zone_list.Get(sep->arg[0], false);
  8986. }
  8987. if (zone_id > 0)
  8988. {
  8989. if (zone_set_values.count(string(sep->arg[1])) > 0)
  8990. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  8991. else
  8992. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  8993. }
  8994. else
  8995. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  8996. }
  8997. else
  8998. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  8999. }
  9000. void Commands::Command_Rain(Client* client, Seperator* sep) {
  9001. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  9002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  9003. return;
  9004. }
  9005. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  9006. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  9007. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  9008. }
  9009. void Commands::Command_Wind(Client* client, Seperator* sep) {
  9010. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  9011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  9012. return;
  9013. }
  9014. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  9015. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  9016. }
  9017. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  9018. Spawn* spawn = client->GetPlayer()->GetTarget();
  9019. if(spawn) {
  9020. client->SetMerchantTransaction(spawn);
  9021. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  9022. client->SendHailCommand(spawn);
  9023. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  9024. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  9025. client->SendBuyMerchantList(sell);
  9026. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  9027. client->SendSellMerchantList(sell);
  9028. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  9029. client->SendBuyBackList(sell);
  9030. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9031. if (packet) {
  9032. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  9033. packet->setDataByName("type", 16);
  9034. EQ2Packet* outapp = packet->serialize();
  9035. if (outapp)
  9036. client->QueuePacket(outapp);
  9037. safe_delete(packet);
  9038. }
  9039. }
  9040. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  9041. client->SendRepairList();
  9042. }
  9043. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  9044. }
  9045. void Commands::Command_Weather(Client* client, Seperator* sep)
  9046. {
  9047. //PrintSep(sep, "Weather");
  9048. if( sep && sep->arg[0] )
  9049. {
  9050. ZoneServer* zsZone = client->GetCurrentZone();
  9051. const char* value = sep->arg[0];
  9052. // process single-param commands first
  9053. if( strncasecmp(value, "details", strlen(value)) == 0 )
  9054. {
  9055. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  9056. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  9057. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  9058. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  9059. }
  9060. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  9061. {
  9062. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9063. zsZone->ProcessWeather();
  9064. }
  9065. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  9066. {
  9067. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  9068. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  9069. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  9070. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  9071. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  9072. zsZone->SetWeatherPattern(1);
  9073. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  9074. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  9075. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  9076. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9077. zsZone->ProcessWeather();
  9078. }
  9079. // process commands with params
  9080. if( sep->arg[1] )
  9081. {
  9082. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  9083. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  9084. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  9085. zsZone->SetWeatherType(atoi(sep->arg[1]));
  9086. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  9087. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  9088. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  9089. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  9090. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  9091. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  9092. }
  9093. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  9094. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  9095. zsZone->SetRain(zsZone->GetCurrentWeather());
  9096. }
  9097. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  9098. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  9099. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  9100. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  9101. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9102. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  9103. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9104. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  9105. }
  9106. }
  9107. else
  9108. {
  9109. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  9110. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  9111. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  9112. return;
  9113. }
  9114. }
  9115. void Commands::Command_Select(Client* client, Seperator* sep) {
  9116. if (sep && sep->arg[1]) {
  9117. Spawn* spawn = client->GetPlayer()->GetTarget();
  9118. if (spawn && strlen(sep->arg[1]) > 0)
  9119. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  9120. }
  9121. }
  9122. /*
  9123. Function: Command_ConsumeFood()
  9124. Purpose : Consume Food/Drink and apply mods
  9125. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  9126. Dev : Zcoretri
  9127. Example : /consume_food 22
  9128. */
  9129. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  9130. if (sep && sep->arg[0] && sep->IsNumber(0))
  9131. {
  9132. Player* player = client->GetPlayer();
  9133. int8 slot = atoi(sep->arg[0]);
  9134. Item* item = player->GetEquipmentList()->GetItem(slot);
  9135. if(item) {
  9136. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  9137. if(item->GetItemScript() && lua_interface){
  9138. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  9139. if (slot == 22)
  9140. client->Message(CHANNEL_NARRATIVE, "You eat a %s.", item->name.c_str());
  9141. else
  9142. client->Message(CHANNEL_NARRATIVE, "You drink a %s.", item->name.c_str());
  9143. }
  9144. }
  9145. if (item->details.count > 1) {
  9146. item->details.count -= 1;
  9147. item->save_needed = true;
  9148. }
  9149. else {
  9150. player->GetEquipmentList()->RemoveItem(slot, true);
  9151. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  9152. }
  9153. client->GetPlayer()->SetCharSheetChanged(true);
  9154. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  9155. }
  9156. }
  9157. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  9158. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9159. if (atoi(sep->arg[0]) == 1) {
  9160. client->GetPlayer()->GetInfoStruct()->vision = 4;
  9161. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  9162. client->GetPlayer()->SetCharSheetChanged(true);
  9163. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  9164. }
  9165. else {
  9166. client->GetPlayer()->GetInfoStruct()->vision = 0;
  9167. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  9168. client->GetPlayer()->SetCharSheetChanged(true);
  9169. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  9170. }
  9171. }
  9172. else
  9173. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  9174. }
  9175. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  9176. {
  9177. if(sep)
  9178. {
  9179. string data;
  9180. if(sep->arg[0]){
  9181. data = string(sep->arg[0]);
  9182. }
  9183. for(int i=1;i<sep->GetMaxArgNum();i++){
  9184. if(sep->arg[i])
  9185. data.append(" ").append(sep->arg[i]);
  9186. }
  9187. const char* target_name = 0;
  9188. int32 spawn_id = 0;
  9189. if(client->GetPlayer()->GetTarget())
  9190. {
  9191. target_name = client->GetPlayer()->GetTarget()->GetName();
  9192. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9193. }
  9194. else
  9195. target_name = "N/A";
  9196. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  9197. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  9198. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  9199. else
  9200. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  9201. }
  9202. }
  9203. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  9204. PrintSep(sep, "Command_Attune_Inv");
  9205. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9206. // Get the item index from the first parameter
  9207. int16 index = atoi(sep->arg[0]);
  9208. // Check to see if this is a valid item index for the player, if not exit out of the function
  9209. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  9210. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  9211. return;
  9212. }
  9213. // Get the item
  9214. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  9215. if(item) {
  9216. // Valid item lets check to make sure this item is attunable, if not return out
  9217. if (!item->CheckFlag(ATTUNEABLE)) {
  9218. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  9219. return;
  9220. }
  9221. // Remove the attunable flag
  9222. item->generic_info.item_flags -= ATTUNEABLE;
  9223. // Set the attuned flag
  9224. item->generic_info.item_flags += ATTUNED;
  9225. // Flag this item for saving
  9226. item->save_needed = true;
  9227. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  9228. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  9229. EQ2Packet* outapp = 0;
  9230. for (int32 i=0;i<packets.size();i++) {
  9231. outapp = packets[i];
  9232. if(outapp)
  9233. client->QueuePacket(outapp);
  9234. }
  9235. }
  9236. }
  9237. }
  9238. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  9239. PrintSep(sep, "Command_Reset_Zone_Timer");
  9240. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9241. int32 db_id = atoul(sep->arg[0]);
  9242. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  9243. if (data) {
  9244. // TODO: add a check to timers to ensure it can be reset
  9245. // Delete the character from the instance
  9246. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  9247. data->instance_id = 0;
  9248. // Update the success time and set to 0 so the player can enter it again
  9249. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  9250. data->last_success_timestamp = 0;
  9251. }
  9252. }*/
  9253. }
  9254. void Commands::Command_Player(Client* client, Seperator* sep) {
  9255. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  9256. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  9257. }
  9258. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  9259. // /player coins add 10
  9260. // /player coins add plat 10
  9261. Player* player = client->GetPlayer();
  9262. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  9263. player = (Player*)player->GetTarget();
  9264. if (sep && sep->arg[0] && sep->arg[1]) {
  9265. const char* action = sep->arg[0];
  9266. int64 value = 0;
  9267. if (strncasecmp(action, "add", strlen(action)) == 0) {
  9268. if (sep->IsNumber(1)) {
  9269. value = atoi64(sep->arg[1]);
  9270. player->AddCoins(value);
  9271. if (client->GetPlayer() == player)
  9272. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9273. else {
  9274. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9275. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9276. }
  9277. return;
  9278. }
  9279. else if (sep->arg[2] && sep->IsNumber(2)) {
  9280. const char* type = sep->arg[1];
  9281. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  9282. value = atoi64(sep->arg[2]);
  9283. }
  9284. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  9285. value = atoi64(sep->arg[2]) * 100;
  9286. }
  9287. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  9288. value = atoi64(sep->arg[2]) * 10000;
  9289. }
  9290. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  9291. value = atoi64(sep->arg[2]) * 1000000;
  9292. }
  9293. player->AddCoins(value);
  9294. if (client->GetPlayer() == player)
  9295. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9296. else {
  9297. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9298. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9299. }
  9300. return;
  9301. }
  9302. }
  9303. }
  9304. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  9305. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  9306. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  9307. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  9308. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  9309. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  9310. }
  9311. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  9312. PrintSep(sep, "ACHIEVEMENT_ADD");
  9313. if (sep && sep->IsSet(0)) {
  9314. int32 spell_id = atoul(sep->arg[1]);
  9315. int8 spell_tier = 0;
  9316. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9317. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9318. // addspellbookentry here
  9319. if (spell_tier >= data->maxRank) {
  9320. return;
  9321. }
  9322. if (!spell_tier) {
  9323. spell_tier = 1;
  9324. }
  9325. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9326. {
  9327. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9328. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9329. client->GetPlayer()->UnlockSpell(spell);
  9330. client->SendSpellUpdate(spell);
  9331. }
  9332. else
  9333. {
  9334. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  9335. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9336. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9337. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9338. client->GetPlayer()->UnlockSpell(spell);
  9339. client->SendSpellUpdate(spell);
  9340. }
  9341. // cast spell here
  9342. if (!spell_tier)
  9343. spell_tier = 1;
  9344. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9345. if (spell) {
  9346. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9347. }
  9348. }
  9349. else {
  9350. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9351. }
  9352. master_aa_list.DisplayAA(client, 0, 0);
  9353. }
  9354. void Commands::Command_Editor(Client* client, Seperator* sep) {
  9355. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  9356. if (packet) {
  9357. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  9358. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  9359. char command[255];
  9360. url = "browser " + url;
  9361. int32 spawn_id = 0;
  9362. int32 zone_id = 0;
  9363. string type;
  9364. if (client->GetCurrentZone())
  9365. zone_id = client->GetCurrentZone()->GetZoneID();
  9366. if (client->GetPlayer()->GetTarget()) {
  9367. Spawn* target = client->GetPlayer()->GetTarget();
  9368. if (target->IsWidget())
  9369. type = "widgets";
  9370. else if (target->IsSign())
  9371. type = "signs";
  9372. else if (target->IsObject())
  9373. type = "objects";
  9374. else if (target->IsNPC())
  9375. type = "npcs";
  9376. else if (target->IsGroundSpawn())
  9377. type = "ground";
  9378. else
  9379. type = "spawn";
  9380. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9381. }
  9382. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  9383. packet->setDataByName("accept_command", command);
  9384. }
  9385. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  9386. char command[255];
  9387. url = "browser " + url;
  9388. if (client->GetPlayer()->GetTarget())
  9389. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  9390. packet->setDataByName("accept_command", command);
  9391. }
  9392. else {
  9393. string command = "browser " + url;
  9394. packet->setDataByName("accept_command", command.c_str());
  9395. }
  9396. packet->setDataByName("text", "Open the web editor?");
  9397. packet->setDataByName("accept_text", "Open");
  9398. packet->setDataByName("cancel_text", "Cancel");
  9399. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  9400. packet->setDataByName("unknown2", 50);
  9401. packet->setDataByName("unknown4", 1);
  9402. client->QueuePacket(packet->serialize());
  9403. safe_delete(packet);
  9404. }
  9405. }
  9406. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  9407. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9408. return;
  9409. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9410. if(client->GetCurrentRez()->active)
  9411. client->AcceptResurrection();
  9412. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9413. }
  9414. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  9415. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9416. return;
  9417. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9418. if(client->GetCurrentRez()->active)
  9419. client->GetCurrentRez()->should_delete = true;
  9420. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9421. }
  9422. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  9423. PrintSep(sep, "Switch_AA_Profile");
  9424. if (sep && sep->IsSet(0)) {
  9425. string type = sep->arg[0];
  9426. int8 newtemplate = atoul(sep->arg[1]);
  9427. master_aa_list.DisplayAA(client, newtemplate, 1);
  9428. }
  9429. }
  9430. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  9431. PrintSep(sep, "Get_AA_Xml");
  9432. if (sep && sep->IsSet(0)) {
  9433. string tabnum = sep->arg[0];
  9434. string spellid = sep->arg[1];
  9435. }
  9436. }
  9437. void Commands::Add_AA(Client* client, Seperator* sep) {
  9438. PrintSep(sep, "Add_AA");
  9439. if (sep && sep->IsSet(0)) {
  9440. int32 spell_id = atoul(sep->arg[1]);
  9441. int8 spell_tier = 0;
  9442. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9443. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9444. // addspellbookentry here
  9445. if (spell_tier >= data->maxRank) {
  9446. return;
  9447. }
  9448. if (!spell_tier) {
  9449. spell_tier = 1;
  9450. }
  9451. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9452. {
  9453. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9454. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9455. client->GetPlayer()->UnlockSpell(spell);
  9456. client->SendSpellUpdate(spell);
  9457. }
  9458. else
  9459. {
  9460. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  9461. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9462. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9463. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9464. client->GetPlayer()->UnlockSpell(spell);
  9465. client->SendSpellUpdate(spell);
  9466. }
  9467. // cast spell here
  9468. if (!spell_tier)
  9469. spell_tier = 1;
  9470. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9471. if (spell) {
  9472. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9473. }
  9474. }
  9475. else {
  9476. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9477. }
  9478. master_aa_list.DisplayAA(client, 0, 0);
  9479. }
  9480. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  9481. PrintSep(sep, "Commit_AA_Profile");
  9482. if (sep && sep->IsSet(0)) {
  9483. }
  9484. }
  9485. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  9486. PrintSep(sep, "Begin_AA_Profile");
  9487. if (sep && sep->IsSet(0)) {
  9488. master_aa_list.DisplayAA(client, 100, 2);
  9489. }
  9490. }
  9491. void Commands::Back_AA(Client* client, Seperator* sep) {
  9492. if (sep && sep->IsSet(0)) {
  9493. PrintSep(sep, "Back_AA");
  9494. }
  9495. }
  9496. void Commands::Remove_AA(Client* client, Seperator* sep) {
  9497. if (sep && sep->IsSet(0)) {
  9498. PrintSep(sep, "Remove_AA");
  9499. }
  9500. }
  9501. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  9502. MasterAAList master_aa_list;
  9503. PrintSep(sep, "Cancel_AA_Profile");
  9504. master_aa_list.DisplayAA(client, 0, 0);
  9505. }
  9506. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  9507. if (sep && sep->IsSet(0)) {
  9508. PrintSep(sep, "Save_AA_Profile");
  9509. }
  9510. }
  9511. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  9512. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  9513. if (!sep->IsNumber(0)) return;
  9514. int32 request_id = atoul(sep->arg[0]);
  9515. if (!sep->IsNumber(1)) return;
  9516. sint32 item_id = atoi(sep->arg[1]);
  9517. if (client->IsCurrentTransmuteID(request_id)) {
  9518. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  9519. }
  9520. else if (client->IsCurrentTransmuteID(item_id)) {
  9521. if (!sep->IsSet(2)) return;
  9522. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  9523. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  9524. }
  9525. }
  9526. }
  9527. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  9528. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  9529. }