Commands.cpp 317 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952
  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. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  145. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  146. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  147. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  148. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  149. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  150. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  151. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  152. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  153. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  154. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  155. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  156. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  157. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  158. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  159. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  160. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  161. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  162. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  163. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  164. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  165. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  166. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  167. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  168. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  169. }
  170. Commands::~Commands() {
  171. safe_delete(remote_commands);
  172. }
  173. int32 Commands::GetSpawnSetType(string val){
  174. if(spawn_set_values.count(val) > 0)
  175. return spawn_set_values[val];
  176. return 0xFFFFFFFF;
  177. }
  178. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  179. if(!target)
  180. return false;
  181. int32 val = 0;
  182. try{
  183. if(type != SPAWN_SET_VALUE_NAME && !(type >= SPAWN_SET_VALUE_SPAWN_SCRIPT && type <= SPAWN_SET_VALUE_SUB_TITLE) && !(type >= SPAWN_SET_VALUE_PREFIX && type <= SPAWN_SET_VALUE_LASTNAME))
  184. val = atoul(value);
  185. }
  186. catch(...){
  187. if(client)
  188. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  189. return false;
  190. }
  191. if(temporary && temp_value){
  192. char tmp[128] = {0};
  193. switch(type){
  194. case SPAWN_SET_VALUE_NAME:{
  195. sprintf(tmp, "%s", target->GetName());
  196. target->SetName(value);
  197. client->GetCurrentZone()->SendUpdateTitles(target);
  198. break;
  199. }
  200. case SPAWN_SET_VALUE_X_OFFSET:
  201. {
  202. sprintf(tmp, "%f", target->GetXOffset());
  203. target->SetXOffset(float(val));
  204. break;
  205. }
  206. case SPAWN_SET_VALUE_Y_OFFSET:
  207. {
  208. sprintf(tmp, "%f", target->GetYOffset());
  209. target->SetYOffset(float(val));
  210. break;
  211. }
  212. case SPAWN_SET_VALUE_Z_OFFSET:
  213. {
  214. sprintf(tmp, "%f", target->GetZOffset());
  215. target->SetZOffset(float(val));
  216. break;
  217. }
  218. case SPAWN_SET_VALUE_EXPIRE: {
  219. sprintf(tmp, "%u", target->GetExpireTime());
  220. target->SetExpireTime(val);
  221. break;
  222. }
  223. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  224. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  225. target->SetExpireOffsetTime(val);
  226. break;
  227. }
  228. case SPAWN_SET_VALUE_SUB_TITLE: {
  229. sprintf(tmp, "%s", target->GetSubTitle());
  230. target->SetSubTitle(value);
  231. client->GetCurrentZone()->SendUpdateTitles(target);
  232. break;
  233. }
  234. case SPAWN_SET_VALUE_LEVEL:{
  235. sprintf(tmp, "%i", target->GetLevel());
  236. target->SetLevel(val, send_update);
  237. break;
  238. }
  239. case SPAWN_SET_VALUE_DIFFICULTY:{
  240. sprintf(tmp, "%i", target->GetEncounterLevel());
  241. target->SetEncounterLevel(val, send_update);
  242. break;
  243. }
  244. case SPAWN_SET_VALUE_MODEL_TYPE:{
  245. sprintf(tmp, "%i", target->GetModelType());
  246. target->SetModelType(val, send_update);
  247. break;
  248. }
  249. case SPAWN_SET_VALUE_CLASS:{
  250. sprintf(tmp, "%i", target->GetAdventureClass());
  251. target->SetAdventureClass(val, send_update);
  252. break;
  253. }
  254. case SPAWN_SET_VALUE_GENDER:{
  255. sprintf(tmp, "%i", target->GetGender());
  256. target->SetGender(val, send_update);
  257. break;
  258. }
  259. case SPAWN_SET_VALUE_SHOW_NAME:{
  260. sprintf(tmp, "%i", target->GetShowName());
  261. target->SetShowName(val, send_update);
  262. break;
  263. }
  264. case SPAWN_SET_VALUE_ATTACKABLE:{
  265. sprintf(tmp, "%i", target->GetAttackable());
  266. target->SetAttackable(val, send_update);
  267. break;
  268. }
  269. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  270. sprintf(tmp, "%i", target->GetShowLevel());
  271. target->SetShowLevel(val, send_update);
  272. break;
  273. }
  274. case SPAWN_SET_VALUE_TARGETABLE:{
  275. sprintf(tmp, "%i", target->GetTargetable());
  276. target->SetTargetable(val, send_update);
  277. break;
  278. }
  279. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  280. sprintf(tmp, "%i", target->GetShowCommandIcon());
  281. target->SetShowCommandIcon(val, send_update);
  282. break;
  283. }
  284. case SPAWN_SET_VALUE_HAND_ICON:{
  285. sprintf(tmp, "%i", target->GetShowHandIcon());
  286. target->SetShowHandIcon(val, send_update);
  287. break;
  288. }
  289. case SPAWN_SET_VALUE_HAIR_TYPE:{
  290. if(target->IsEntity()){
  291. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  292. ((Entity*)target)->SetHairType(val, send_update);
  293. }
  294. break;
  295. }
  296. case SPAWN_SET_VALUE_FACIAL_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_WING_TYPE:{
  304. if(target->IsEntity()){
  305. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  306. ((Entity*)target)->SetWingType(val, send_update);
  307. }
  308. break;
  309. }
  310. case SPAWN_SET_VALUE_CHEST_TYPE:{
  311. if(target->IsEntity()){
  312. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  313. ((Entity*)target)->SetChestType(val, send_update);
  314. }
  315. break;
  316. }
  317. case SPAWN_SET_VALUE_LEGS_TYPE:{
  318. if(target->IsEntity()){
  319. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  320. ((Entity*)target)->SetLegsType(val, send_update);
  321. }
  322. break;
  323. }
  324. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  325. if(target->IsEntity()){
  326. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  327. ((Entity*)target)->SetSogaHairType(val, send_update);
  328. }
  329. break;
  330. }
  331. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  332. if(target->IsEntity()){
  333. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  334. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  335. }
  336. break;
  337. }
  338. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  339. sprintf(tmp, "%i", target->GetSogaModelType());
  340. target->SetSogaModelType(val, send_update);
  341. break;
  342. }
  343. case SPAWN_SET_VALUE_SIZE:{
  344. sprintf(tmp, "%i", target->GetSize());
  345. target->SetSize(val, send_update);
  346. break;
  347. }
  348. case SPAWN_SET_VALUE_HP:{
  349. sprintf(tmp, "%i", target->GetHP());
  350. target->SetHP(val, send_update);
  351. break;
  352. }
  353. case SPAWN_SET_VALUE_POWER:{
  354. sprintf(tmp, "%i", target->GetPower());
  355. target->SetPower(val, send_update);
  356. break;
  357. }
  358. case SPAWN_SET_VALUE_HEROIC:{
  359. sprintf(tmp, "%i", target->GetHeroic());
  360. target->SetHeroic(val, send_update);
  361. break;
  362. }
  363. case SPAWN_SET_VALUE_RESPAWN:{
  364. sprintf(tmp, "%u", target->GetRespawnTime());
  365. target->SetRespawnTime(val);
  366. break;
  367. }
  368. case SPAWN_SET_VALUE_X:{
  369. sprintf(tmp, "%f", target->GetX());
  370. target->SetX(atof(value), send_update);
  371. break;
  372. }
  373. case SPAWN_SET_VALUE_Y:{
  374. sprintf(tmp, "%f", target->GetY());
  375. target->SetY(atof(value), send_update);
  376. break;
  377. }
  378. case SPAWN_SET_VALUE_Z:{
  379. sprintf(tmp, "%f", target->GetZ());
  380. target->SetZ(atof(value), send_update);
  381. break;
  382. }
  383. case SPAWN_SET_VALUE_HEADING:{
  384. sprintf(tmp, "%f", target->GetHeading());
  385. target->SetHeading(atof(value) + 360, send_update);
  386. break;
  387. }
  388. case SPAWN_SET_VALUE_VISUAL_STATE:{
  389. sprintf(tmp, "%i", target->GetVisualState());
  390. target->SetVisualState(val, send_update);
  391. break;
  392. }
  393. case SPAWN_SET_VALUE_ACTION_STATE:{
  394. sprintf(tmp, "%i", target->GetActionState());
  395. target->SetActionState(val, send_update);
  396. break;
  397. }
  398. case SPAWN_SET_VALUE_MOOD_STATE:{
  399. sprintf(tmp, "%i", target->GetMoodState());
  400. target->SetMoodState(val, send_update);
  401. break;
  402. }
  403. case SPAWN_SET_VALUE_INITIAL_STATE:{
  404. sprintf(tmp, "%i", target->GetInitialState());
  405. target->SetInitialState(val, send_update);
  406. break;
  407. }
  408. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  409. sprintf(tmp, "%i", target->GetActivityStatus());
  410. target->SetActivityStatus(val, send_update);
  411. break;
  412. }
  413. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  414. sprintf(tmp, "%i", target->GetCollisionRadius());
  415. target->SetCollisionRadius(val, send_update);
  416. break;
  417. }
  418. case SPAWN_SET_VALUE_DEVICE_ID: {
  419. if (target->IsObject()) {
  420. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  421. ((Object*)target)->SetDeviceID(val);
  422. }
  423. break;
  424. }
  425. case SPAWN_SET_VALUE_PITCH: {
  426. sprintf(tmp, "%f", target->GetPitch());
  427. target->SetPitch(atof(value), send_update);
  428. break;
  429. }
  430. case SPAWN_SET_VALUE_ROLL: {
  431. sprintf(tmp, "%f", target->GetRoll());
  432. target->SetRoll(atof(value), send_update);
  433. break;
  434. }
  435. case SPAWN_SET_VALUE_HIDE_HOOD: {
  436. sprintf(tmp, "%i", target->appearance.hide_hood);
  437. target->SetHideHood(val);
  438. break;
  439. }
  440. case SPAWN_SET_VALUE_EMOTE_STATE: {
  441. sprintf(tmp, "%i", target->appearance.emote_state);
  442. target->SetEmoteState(val);
  443. break;
  444. }
  445. case SPAWN_SET_VALUE_ICON: {
  446. sprintf(tmp, "%i", target->GetIconValue());
  447. target->SetIcon(val);
  448. break;
  449. }
  450. case SPAWN_SET_VALUE_PREFIX: {
  451. sprintf(tmp, "%s", target->GetPrefixTitle());
  452. target->SetPrefixTitle(value);
  453. client->GetCurrentZone()->SendUpdateTitles(target);
  454. break;
  455. }
  456. case SPAWN_SET_VALUE_SUFFIX: {
  457. sprintf(tmp, "%s", target->GetSuffixTitle());
  458. target->SetSuffixTitle(value);
  459. client->GetCurrentZone()->SendUpdateTitles(target);
  460. break;
  461. }
  462. case SPAWN_SET_VALUE_LASTNAME: {
  463. sprintf(tmp, "%s", target->GetLastName());
  464. target->SetLastName(value);
  465. client->GetCurrentZone()->SendUpdateTitles(target);
  466. break;
  467. }
  468. *temp_value = string(tmp);
  469. }
  470. }
  471. else{
  472. switch(type){
  473. case SPAWN_SET_VALUE_NAME:{
  474. target->SetName(value);
  475. client->GetCurrentZone()->SendUpdateTitles(target);
  476. break;
  477. }
  478. case SPAWN_SET_VALUE_SUB_TITLE: {
  479. target->SetSubTitle(value);
  480. client->GetCurrentZone()->SendUpdateTitles(target);
  481. break;
  482. }
  483. case SPAWN_SET_VALUE_X_OFFSET:
  484. {
  485. target->SetXOffset(atof(value));
  486. break;
  487. }
  488. case SPAWN_SET_VALUE_Y_OFFSET:
  489. {
  490. target->SetYOffset(atof(value));
  491. break;
  492. }
  493. case SPAWN_SET_VALUE_Z_OFFSET:
  494. {
  495. target->SetZOffset(atof(value));
  496. break;
  497. }
  498. case SPAWN_SET_VALUE_EXPIRE: {
  499. target->SetExpireTime(val);
  500. break;
  501. }
  502. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  503. target->SetExpireOffsetTime(val);
  504. break;
  505. }
  506. case SPAWN_SET_VALUE_LEVEL:{
  507. target->SetLevel(val, send_update);
  508. break;
  509. }
  510. case SPAWN_SET_VALUE_DIFFICULTY:{
  511. target->SetEncounterLevel(val, send_update);
  512. break;
  513. }
  514. case SPAWN_SET_VALUE_MODEL_TYPE:{
  515. target->SetModelType(val, send_update);
  516. break;
  517. }
  518. case SPAWN_SET_VALUE_CLASS:{
  519. target->SetAdventureClass(val, send_update);
  520. break;
  521. }
  522. case SPAWN_SET_VALUE_GENDER:{
  523. target->SetGender(val, send_update);
  524. break;
  525. }
  526. case SPAWN_SET_VALUE_SHOW_NAME:{
  527. target->SetShowName(val, send_update);
  528. break;
  529. }
  530. case SPAWN_SET_VALUE_ATTACKABLE:{
  531. target->SetAttackable(val, send_update);
  532. break;
  533. }
  534. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  535. target->SetShowLevel(val, send_update);
  536. break;
  537. }
  538. case SPAWN_SET_VALUE_TARGETABLE:{
  539. target->SetTargetable(val, send_update);
  540. break;
  541. }
  542. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  543. target->SetShowCommandIcon(val, send_update);
  544. break;
  545. }
  546. case SPAWN_SET_VALUE_HAND_ICON:{
  547. target->SetShowHandIcon(val, send_update);
  548. break;
  549. }
  550. case SPAWN_SET_VALUE_HAIR_TYPE:{
  551. if(target->IsEntity())
  552. ((Entity*)target)->SetHairType(val, send_update);
  553. break;
  554. }
  555. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  556. if(target->IsEntity())
  557. ((Entity*)target)->SetHairType(val, send_update);
  558. break;
  559. }
  560. case SPAWN_SET_VALUE_WING_TYPE:{
  561. if(target->IsEntity())
  562. ((Entity*)target)->SetWingType(val, send_update);
  563. break;
  564. }
  565. case SPAWN_SET_VALUE_CHEST_TYPE:{
  566. if(target->IsEntity())
  567. ((Entity*)target)->SetChestType(val, send_update);
  568. break;
  569. }
  570. case SPAWN_SET_VALUE_LEGS_TYPE:{
  571. if(target->IsEntity())
  572. ((Entity*)target)->SetLegsType(val, send_update);
  573. break;
  574. }
  575. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  576. if(target->IsEntity())
  577. ((Entity*)target)->SetSogaHairType(val, send_update);
  578. break;
  579. }
  580. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  581. if(target->IsEntity())
  582. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  583. break;
  584. }
  585. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  586. target->SetSogaModelType(val, send_update);
  587. break;
  588. }
  589. case SPAWN_SET_VALUE_SIZE:{
  590. target->SetSize(val, send_update);
  591. break;
  592. }
  593. case SPAWN_SET_VALUE_HP:{
  594. target->SetHP(val, send_update);
  595. break;
  596. }
  597. case SPAWN_SET_VALUE_POWER:{
  598. target->SetPower(val, send_update);
  599. break;
  600. }
  601. case SPAWN_SET_VALUE_HEROIC:{
  602. target->SetHeroic(val, send_update);
  603. break;
  604. }
  605. case SPAWN_SET_VALUE_RESPAWN:{
  606. target->SetRespawnTime(val);
  607. break;
  608. }
  609. case SPAWN_SET_VALUE_X:{
  610. target->SetX(atof(value), send_update);
  611. target->SetSpawnOrigX(target->GetX());
  612. break;
  613. }
  614. case SPAWN_SET_VALUE_Y:{
  615. target->SetY(atof(value), send_update);
  616. target->SetSpawnOrigY(target->GetY());
  617. break;
  618. }
  619. case SPAWN_SET_VALUE_Z:{
  620. target->SetZ(atof(value), send_update);
  621. target->SetSpawnOrigZ(target->GetZ());
  622. break;
  623. }
  624. case SPAWN_SET_VALUE_HEADING:{
  625. target->SetHeading(atof(value), send_update);
  626. target->SetSpawnOrigHeading(target->GetHeading());
  627. break;
  628. }
  629. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  630. ZoneServer* zone = target->GetZone();
  631. if (!zone)
  632. zone = client->GetCurrentZone();
  633. if(zone->GetEntityCommandList(val))
  634. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  635. target->primary_command_list_id = val;
  636. break;
  637. }
  638. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  639. ZoneServer* zone = target->GetZone();
  640. if (!zone)
  641. zone = client->GetCurrentZone();
  642. if (zone->GetEntityCommandList(val))
  643. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  644. target->secondary_command_list_id = val;
  645. break;
  646. }
  647. case SPAWN_SET_VALUE_VISUAL_STATE:{
  648. target->SetVisualState(val, send_update);
  649. break;
  650. }
  651. case SPAWN_SET_VALUE_ACTION_STATE:{
  652. target->SetActionState(val, send_update);
  653. break;
  654. }
  655. case SPAWN_SET_VALUE_MOOD_STATE:{
  656. target->SetMoodState(val, send_update);
  657. break;
  658. }
  659. case SPAWN_SET_VALUE_INITIAL_STATE:{
  660. target->SetInitialState(val, send_update);
  661. break;
  662. }
  663. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  664. target->SetActivityStatus(val, send_update);
  665. break;
  666. }
  667. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  668. target->SetCollisionRadius(val, send_update);
  669. break;
  670. }
  671. case SPAWN_SET_VALUE_FACTION:{
  672. ZoneServer* zone = target->GetZone();
  673. if (!zone)
  674. zone = client->GetCurrentZone();
  675. target->faction_id = val;
  676. zone->RemoveDeadEnemyList(target);
  677. if(target->IsNPC())
  678. zone->AddEnemyList((NPC*)target);
  679. break;
  680. }
  681. case SPAWN_SET_VALUE_DEVICE_ID:{
  682. if (target->IsObject())
  683. ((Object*)target)->SetDeviceID(val);
  684. break;
  685. }
  686. case SPAWN_SET_VALUE_PITCH: {
  687. target->SetPitch(atof(value), send_update);
  688. target->SetSpawnOrigPitch(atof(value));
  689. break;
  690. }
  691. case SPAWN_SET_VALUE_ROLL: {
  692. target->SetRoll(atof(value), send_update);
  693. target->SetSpawnOrigRoll(atof(value));
  694. break;
  695. }
  696. case SPAWN_SET_VALUE_HIDE_HOOD: {
  697. target->SetHideHood(val);
  698. break;
  699. }
  700. case SPAWN_SET_VALUE_EMOTE_STATE: {
  701. target->SetEmoteState(val);
  702. break;
  703. }
  704. case SPAWN_SET_VALUE_ICON: {
  705. target->SetIcon(val);
  706. break;
  707. }
  708. case SPAWN_SET_VALUE_PREFIX: {
  709. target->SetPrefixTitle(value);
  710. client->GetCurrentZone()->SendUpdateTitles(target);
  711. break;
  712. }
  713. case SPAWN_SET_VALUE_SUFFIX: {
  714. target->SetSuffixTitle(value);
  715. client->GetCurrentZone()->SendUpdateTitles(target);
  716. break;
  717. }
  718. case SPAWN_SET_VALUE_LASTNAME: {
  719. target->SetLastName(value);
  720. client->GetCurrentZone()->SendUpdateTitles(target);
  721. break;
  722. }
  723. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  724. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  725. if(client){
  726. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  727. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  728. }
  729. return false;
  730. }
  731. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  732. return false;
  733. else{
  734. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  735. target->SetSpawnScript(value);
  736. }
  737. break;
  738. }
  739. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  740. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  741. if(client){
  742. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  743. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  744. }
  745. return false;
  746. }
  747. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  748. return false;
  749. else{
  750. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  751. target->SetSpawnScript(value);
  752. }
  753. break;
  754. }
  755. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  756. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  757. if(client){
  758. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  759. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  760. }
  761. return false;
  762. }
  763. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  764. return false;
  765. else
  766. target->SetSpawnScript(value);
  767. break;
  768. }
  769. }
  770. }
  771. return true;
  772. }
  773. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  774. the database fields always and also update the zone in memory if it's running. */
  775. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  776. if (client && zone_id > 0 && type > 0 && value) {
  777. sint32 int_value = 0;
  778. float float_value = 0;
  779. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  780. try {
  781. float_value = atof(value);
  782. }
  783. catch (...) {
  784. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  785. return false;
  786. }
  787. }
  788. 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) {
  789. try {
  790. int_value = atoi(value);
  791. }
  792. catch (...) {
  793. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  794. return false;
  795. }
  796. }
  797. switch (type) {
  798. case ZONE_SET_VALUE_EXPANSION_ID: {
  799. break;
  800. }
  801. case ZONE_SET_VALUE_NAME: {
  802. if (zone)
  803. zone->SetZoneName(const_cast<char*>(value));
  804. database.SaveZoneInfo(zone_id, "name", value);
  805. break;
  806. }
  807. case ZONE_SET_VALUE_FILE: {
  808. if (zone)
  809. zone->SetZoneFile(const_cast<char*>(value));
  810. database.SaveZoneInfo(zone_id, "file", value);
  811. break;
  812. }
  813. case ZONE_SET_VALUE_DESCRIPTION: {
  814. if (zone)
  815. zone->SetZoneDescription(const_cast<char*>(value));
  816. database.SaveZoneInfo(zone_id, "description", value);
  817. break;
  818. }
  819. case ZONE_SET_VALUE_SAFE_X: {
  820. if (zone)
  821. zone->SetSafeX(float_value);
  822. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  823. break;
  824. }
  825. case ZONE_SET_VALUE_SAFE_Y: {
  826. if (zone)
  827. zone->SetSafeY(float_value);
  828. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  829. break;
  830. }
  831. case ZONE_SET_VALUE_SAFE_Z: {
  832. if (zone)
  833. zone->SetSafeZ(float_value);
  834. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  835. break;
  836. }
  837. case ZONE_SET_VALUE_UNDERWORLD: {
  838. if (zone)
  839. zone->SetUnderWorld(float_value);
  840. database.SaveZoneInfo(zone_id, "underworld", float_value);
  841. break;
  842. }
  843. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  844. break;
  845. }
  846. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  847. break;
  848. }
  849. case ZONE_SET_VALUE_ZONE_TYPE: {
  850. break;
  851. }
  852. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  853. if (zone)
  854. zone->SetAlwaysLoaded(int_value == 1);
  855. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  856. break;
  857. }
  858. case ZONE_SET_VALUE_CITY_ZONE: {
  859. if (zone)
  860. zone->SetCityZone(int_value == 1);
  861. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  862. break;
  863. }
  864. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  865. if (zone)
  866. zone->SetWeatherAllowed(int_value == 1);
  867. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  868. break;
  869. }
  870. case ZONE_SET_VALUE_MIN_STATUS: {
  871. if (zone)
  872. zone->SetMinimumStatus(int_value);
  873. database.SaveZoneInfo(zone_id, "min_status", int_value);
  874. break;
  875. }
  876. case ZONE_SET_VALUE_MIN_LEVEL: {
  877. if (zone)
  878. zone->SetMinimumLevel(int_value);
  879. database.SaveZoneInfo(zone_id, "min_level", int_value);
  880. break;
  881. }
  882. case ZONE_SET_VALUE_MAX_LEVEL: {
  883. if (zone)
  884. zone->SetMaximumLevel(int_value);
  885. database.SaveZoneInfo(zone_id, "max_level", int_value);
  886. break;
  887. }
  888. case ZONE_SET_VALUE_START_ZONE: {
  889. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  890. break;
  891. }
  892. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  893. if (zone)
  894. zone->SetInstanceType(int_value);
  895. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  896. break;
  897. }
  898. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  899. if (zone)
  900. zone->SetDefaultReenterTime(int_value);
  901. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  902. break;
  903. }
  904. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  905. if (zone)
  906. zone->SetDefaultResetTime(int_value);
  907. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  908. break;
  909. }
  910. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  911. if (zone)
  912. zone->SetDefaultLockoutTime(int_value);
  913. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  914. break;
  915. }
  916. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  917. if (zone)
  918. zone->SetForceGroupZoneOption(int_value);
  919. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  920. break;
  921. }
  922. case ZONE_SET_VALUE_LUA_SCRIPT: {
  923. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  924. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  925. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  926. return false;
  927. }
  928. else {
  929. world.AddZoneScript(zone_id, const_cast<char*>(value));
  930. database.SaveZoneInfo(zone_id, "lua_script", value);
  931. }
  932. break;
  933. }
  934. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  935. if (zone)
  936. zone->SetShutdownTimer(int_value);
  937. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  938. break;
  939. }
  940. case ZONE_SET_VALUE_ZONE_MOTD: {
  941. if (zone)
  942. zone->SetZoneMOTD(string(value));
  943. database.SaveZoneInfo(zone_id, "zone_motd", value);
  944. break;
  945. }
  946. default: {
  947. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  948. return false;
  949. }
  950. }
  951. }
  952. else {
  953. if (client)
  954. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  955. return false;
  956. }
  957. return true;
  958. }
  959. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  960. if (index >= remote_commands->commands.size()) {
  961. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  962. return;
  963. }
  964. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  965. EQ2_RemoteCommandString* parent_command = 0;
  966. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  967. Seperator* sep = 0;
  968. if (command_parms->size > 0) {
  969. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  970. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  971. parent_command = command;
  972. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  973. safe_delete(sep);
  974. if (command_parms->data.length() > (command->command.data.length() + 1))
  975. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  976. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  977. }
  978. else
  979. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  980. }
  981. int ndx = 0;
  982. if (command->required_status > client->GetAdminStatus())
  983. {
  984. 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());
  985. safe_delete(sep);
  986. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  987. return;
  988. }
  989. Player* player = client->GetPlayer();
  990. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  991. switch (command->handler) {
  992. case COMMAND_RELOAD: {
  993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  994. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  996. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  997. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  998. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  999. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1000. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1001. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1003. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1004. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1005. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1006. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1007. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1008. break;
  1009. }
  1010. case COMMAND_RELOADSTRUCTS: {
  1011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1012. configReader.ReloadStructs();
  1013. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1014. break;
  1015. }
  1016. case COMMAND_RELOAD_QUESTS: {
  1017. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1018. master_quest_list.Reload();
  1019. client_list.ReloadQuests();
  1020. zone_list.ReloadClientQuests();
  1021. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1022. break;
  1023. }
  1024. case COMMAND_RELOAD_SPAWNS: {
  1025. client->GetCurrentZone()->ReloadSpawns();
  1026. break;
  1027. }
  1028. case COMMAND_RELOAD_SPELLS: {
  1029. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1030. zone_list.DeleteSpellProcess();
  1031. master_spell_list.Reload();
  1032. if (lua_interface)
  1033. lua_interface->ReloadSpells();
  1034. zone_list.LoadSpellProcess();
  1035. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1036. break;
  1037. }
  1038. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1039. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1040. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1041. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1042. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1043. break;
  1044. }
  1045. case COMMAND_RELOAD_ZONESCRIPTS: {
  1046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1047. world.ResetZoneScripts();
  1048. database.LoadZoneScriptData();
  1049. if (lua_interface)
  1050. lua_interface->DestroyZoneScripts();
  1051. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1052. break;
  1053. }
  1054. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1056. client->GetCurrentZone()->ClearEntityCommands();
  1057. database.LoadEntityCommands(client->GetCurrentZone());
  1058. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1059. break;
  1060. }
  1061. case COMMAND_RELOAD_FACTIONS: {
  1062. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1063. master_faction_list.Clear();
  1064. database.LoadFactionList();
  1065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1066. break;
  1067. }
  1068. case COMMAND_RELOAD_MAIL: {
  1069. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1070. zone_list.ReloadMail();
  1071. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1072. break;
  1073. }
  1074. case COMMAND_RELOAD_GUILDS: {
  1075. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1076. world.ReloadGuilds();
  1077. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1078. break;
  1079. }
  1080. case COMMAND_RELOAD_LOCATIONS: {
  1081. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1082. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1083. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1084. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1085. break;
  1086. }
  1087. case COMMAND_READ: {
  1088. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1089. if (strcmp(sep->arg[0], "read") == 0) {
  1090. int32 item_index = atol(sep->arg[1]);
  1091. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1092. if (item) {
  1093. Spawn* spawn = cmdTarget;
  1094. int8 numpages = item->book_pages.size();
  1095. string page1 = string(item->book_pages[0]->page_text.data);
  1096. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  1097. string title = item->name;
  1098. if (packet) {
  1099. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  1100. packet->setDataByName("book_title", title.c_str());
  1101. packet->setDataByName("book_type", "simple");
  1102. packet->setDataByName("unknown2", 1);
  1103. packet->setDataByName("unknown5", 1, 4);
  1104. packet->setArrayLengthByName("num_pages", numpages);
  1105. for (int8 pages = 1; pages <= numpages; pages++) {
  1106. int8 pagenum = int8(item->book_pages[pages - 1]->page);
  1107. string page = string(item->book_pages[pages-1]->page_text.data);
  1108. int8 valign = int8(item->book_pages[pages - 1]->valign);
  1109. int8 halign = int8(item->book_pages[pages - 1]->halign);
  1110. packet->setArrayDataByName("page_text", page.c_str(), pagenum -1);
  1111. packet->setArrayDataByName("page_text_valign", valign , pagenum - 1);
  1112. packet->setArrayDataByName("page_text_halign", halign, pagenum - 1);
  1113. // Need to add support for images
  1114. }
  1115. client->QueuePacket(packet->serialize());
  1116. safe_delete(packet);
  1117. }
  1118. break;
  1119. }
  1120. }
  1121. }
  1122. }
  1123. case COMMAND_USEABILITY:{
  1124. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1125. if (client->GetPlayer()->GetHP() == 0) {
  1126. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1127. }
  1128. else {
  1129. int32 spell_id = atoul(sep->arg[0]);
  1130. int8 spell_tier = 0;
  1131. if (sep->arg[1][0] && sep->IsNumber(1))
  1132. spell_tier = atoi(sep->arg[1]);
  1133. else
  1134. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1135. if (!spell_tier)
  1136. spell_tier = 1;
  1137. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1138. if (spell) {
  1139. 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)
  1140. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1141. else
  1142. {
  1143. if (cmdTarget)
  1144. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1145. else
  1146. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1147. }
  1148. }
  1149. }
  1150. }
  1151. else if (cmdTarget && cmdTarget->IsWidget())
  1152. {
  1153. Widget* widget = (Widget*)cmdTarget;
  1154. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1155. }
  1156. else
  1157. {
  1158. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1159. }
  1160. break;
  1161. }
  1162. case COMMAND_INFO:{
  1163. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1164. if(strcmp(sep->arg[0], "inventory") == 0){
  1165. int32 item_index = atol(sep->arg[1]);
  1166. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1167. if(item){
  1168. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1169. break;
  1170. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1171. //DumpPacket(app);
  1172. client->QueuePacket(app);
  1173. if(item->GetItemScript() && lua_interface)
  1174. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1175. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1176. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id);
  1177. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1178. client->AddPendingQuest(quest);
  1179. }
  1180. }
  1181. else
  1182. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1183. }
  1184. else if(strcmp(sep->arg[0], "equipment") == 0){
  1185. int32 item_index = atol(sep->arg[1]);
  1186. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1187. if(item){
  1188. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1189. client->QueuePacket(app);
  1190. if(item->GetItemScript() && lua_interface)
  1191. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1192. }
  1193. else
  1194. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1195. }
  1196. 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){
  1197. int32 item_id = atoul(sep->arg[1]);
  1198. Item* item = master_item_list.GetItem(item_id);
  1199. if(item){
  1200. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1201. client->QueuePacket(app);
  1202. }
  1203. else
  1204. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1205. }
  1206. else if (strcmp(sep->arg[0], "spell") == 0) {
  1207. sint32 spell_id = atol(sep->arg[1]);
  1208. int8 tier = atoi(sep->arg[3]);
  1209. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1210. if (outapp)
  1211. client->QueuePacket(outapp);
  1212. else
  1213. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1214. }
  1215. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1216. sint32 spell_id = atol(sep->arg[2]);
  1217. int8 group = atoi(sep->arg[1]);
  1218. AltAdvanceData* data = 0;
  1219. SpellBookEntry* spellentry = 0;
  1220. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1221. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1222. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1223. if (outapp)
  1224. client->QueuePacket(outapp);
  1225. else
  1226. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1227. }
  1228. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1229. sint32 spell_id = atol(sep->arg[1]);
  1230. int8 tier = atoi(sep->arg[2]);
  1231. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1232. if (outapp)
  1233. client->QueuePacket(outapp);
  1234. else
  1235. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1236. }
  1237. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1238. sint32 recipe_id = atol(sep->arg[1]);
  1239. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1240. if(outapp)
  1241. client->QueuePacket(outapp);
  1242. else
  1243. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1244. }
  1245. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1246. int32 slot = atol(sep->arg[1]);
  1247. int32 spell_id = atol(sep->arg[2]);
  1248. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1249. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1250. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1251. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1252. if(outapp)
  1253. client->QueuePacket(outapp);
  1254. else
  1255. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1256. }
  1257. else if (strcmp(sep->arg[0], "effect") == 0) {
  1258. int32 spell_id = atol(sep->arg[1]);
  1259. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1260. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1261. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, 0x00);
  1262. if (outapp){
  1263. client->QueuePacket(outapp);
  1264. }
  1265. else
  1266. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1267. }
  1268. }
  1269. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1270. Item* item = player->item_list.GetOverflowItem();
  1271. if(item) {
  1272. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1273. client->QueuePacket(app);
  1274. }
  1275. else
  1276. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1277. }
  1278. else
  1279. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1280. break;
  1281. }
  1282. case COMMAND_USE_EQUIPPED_ITEM:{
  1283. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1284. int32 slot_id = atoul(sep->arg[0]);
  1285. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1286. if (item && item->generic_info.usable && item->GetItemScript())
  1287. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1288. }
  1289. break;
  1290. }
  1291. case COMMAND_USE_ITEM: {
  1292. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1293. int32 item_index = atoul(sep->arg[0]);
  1294. Item* item = player->item_list.GetItemFromIndex(item_index);
  1295. if (item && item->GetItemScript()) {
  1296. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1297. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1298. else {
  1299. if (item->generic_info.display_charges > 0) {
  1300. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1301. item->generic_info.display_charges -= 1;
  1302. item->save_needed = true;
  1303. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1304. }
  1305. }
  1306. }
  1307. }
  1308. break;
  1309. }
  1310. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1311. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1312. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1313. if (item) {
  1314. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1315. if(item->generic_info.item_type == 6) {
  1316. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1317. int8 old_slot = 0;
  1318. if (spell) {
  1319. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1320. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1321. player->RemoveSpellBookEntry(spell->GetSpellID());
  1322. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1323. player->UnlockSpell(spell);
  1324. client->SendSpellUpdate(spell);
  1325. database.DeleteItem(client->GetCharacterID(), item, 0);
  1326. player->item_list.RemoveItem(item, true);
  1327. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1328. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1329. }
  1330. }
  1331. else
  1332. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1333. }
  1334. else if(item->generic_info.item_type == 7){
  1335. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1336. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1337. // if valid recipe book and the player doesn't have it
  1338. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1339. client->Message(CHANNEL_COLOR_WHITE, "Your tradeskill level is not high enough to scribe this book.");
  1340. safe_delete(recipe_book);
  1341. }
  1342. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1343. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1344. // Add recipe book to the players list
  1345. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1346. // Get a list of all recipes this book contains
  1347. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1348. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1349. // Create the packet to send to update the players recipe list
  1350. PacketStruct* packet = 0;
  1351. if (client->GetRecipeListSent()) {
  1352. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1353. if (packet)
  1354. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1355. }
  1356. // loop through the list
  1357. vector<Recipe*>::iterator itr;
  1358. int16 i = 0;
  1359. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1360. // check to see if the player already has this recipe some how
  1361. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1362. // Player doesn't already have this recipe so lets add it
  1363. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1364. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1365. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1366. client->Message(CHANNEL_COLOR_WHITE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1367. if (packet && client->GetRecipeListSent()) {
  1368. packet->setArrayDataByName("id", recipe->GetID(), i);
  1369. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1370. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1371. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1372. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1373. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1374. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1375. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1376. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1377. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1378. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1379. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1380. i++;
  1381. }
  1382. }
  1383. }
  1384. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1385. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1386. database.DeleteItem(client->GetCharacterID(), item, 0);
  1387. client->GetPlayer()->item_list.RemoveItem(item, true);
  1388. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1389. if (packet && client->GetRecipeListSent())
  1390. client->QueuePacket(packet->serialize());
  1391. safe_delete(packet);
  1392. }
  1393. else {
  1394. if (recipe_book)
  1395. client->Message(CHANNEL_COLOR_WHITE, "You have already learned all you can from this item.");
  1396. safe_delete(recipe_book);
  1397. }
  1398. }
  1399. }
  1400. else
  1401. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1402. }
  1403. break;
  1404. }
  1405. case COMMAND_SUMMONITEM: {
  1406. if (sep && sep->IsNumber(0)) {
  1407. int32 item_id = atol(sep->arg[0]);
  1408. int32 quantity = 1;
  1409. if (sep->arg[1] && sep->IsNumber(1))
  1410. quantity = atoi(sep->arg[1]);
  1411. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1412. client->AddItemToBank(item_id,quantity);
  1413. }
  1414. else {
  1415. client->AddItem(item_id, quantity);
  1416. }
  1417. }
  1418. else {
  1419. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1420. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1421. }
  1422. break;
  1423. }
  1424. case COMMAND_COLLECTION_ADDITEM: {
  1425. // takes 2 params: collection_id, slot
  1426. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1427. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1428. if (item)
  1429. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1430. else
  1431. 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]));
  1432. }
  1433. else
  1434. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1435. break;
  1436. }
  1437. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1438. // takes 1 param: slot
  1439. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1440. int i = 0;
  1441. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1442. printf("\t%u: %s\n", i, sep->arg[i]);
  1443. i++;
  1444. }
  1445. break;
  1446. }
  1447. case COMMAND_WHO:{
  1448. const char* who = 0;
  1449. if(sep && sep->arg[0]){
  1450. //cout << "Who query: \n";
  1451. who = sep->argplus[0];
  1452. //cout << who << endl;
  1453. }
  1454. zone_list.ProcessWhoQuery(who, client);
  1455. break;
  1456. }
  1457. case COMMAND_SELECT_JUNCTION:{
  1458. 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__);
  1459. int32 choice = 0;
  1460. if(sep && sep->arg[0] && sep->IsNumber(0))
  1461. choice = atoul(sep->arg[0]);
  1462. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1463. client->HandlePlayerRevive(choice);
  1464. }
  1465. break;
  1466. }
  1467. case COMMAND_SPAWN_MOVE:{
  1468. if(cmdTarget && cmdTarget->IsPlayer() == false){
  1469. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1470. if(packet){
  1471. float unknown2_3 = 0;
  1472. int8 placement_mode = 0;
  1473. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1474. if(sep && sep->arg[0][0]){
  1475. if(strcmp(sep->arg[0], "wall") == 0){
  1476. placement_mode = 2;
  1477. unknown2_3 = 150;
  1478. }
  1479. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1480. placement_mode = 1;
  1481. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1482. {
  1483. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1484. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1485. }
  1486. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1487. {
  1488. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1489. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1490. }
  1491. else if (strcmp(sep->arg[0], "myloc") == 0)
  1492. {
  1493. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1494. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1495. safe_delete(packet);
  1496. break;
  1497. }
  1498. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1499. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1500. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1501. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1502. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1503. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1504. safe_delete(packet);
  1505. break;
  1506. }
  1507. }
  1508. packet->setDataByName("placement_mode", placement_mode);
  1509. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1510. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1511. packet->setDataByName("unknown", 1); //size
  1512. packet->setDataByName("unknown2", 1); //size 2
  1513. packet->setDataByName("unknown2", .5, 1); //size 3
  1514. packet->setDataByName("unknown2", 3, 2);
  1515. packet->setDataByName("unknown2", unknown2_3, 3);
  1516. packet->setDataByName("max_distance", 500);
  1517. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1518. client->QueuePacket(packet->serialize());
  1519. safe_delete(packet);
  1520. }
  1521. }
  1522. else{
  1523. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1524. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1525. }
  1526. break;
  1527. }
  1528. case COMMAND_HAIL:{
  1529. Spawn* spawn = cmdTarget;
  1530. if(spawn && spawn->GetTargetable())
  1531. {
  1532. char tmp[75] = {0};
  1533. sprintf(tmp, "Hail, %s", spawn->GetName());
  1534. bool show_bubble = true;
  1535. if (spawn->IsNPC())
  1536. show_bubble = false;
  1537. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1538. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < 30){
  1539. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1540. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1541. else
  1542. spawn->ProcessMovement();
  1543. LogWrite(MISC__TODO, 0, "Check", "ProcessMovement has been called");
  1544. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer());
  1545. }
  1546. }
  1547. else {
  1548. string tmp = "Hail";
  1549. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1550. }
  1551. break;
  1552. }
  1553. case COMMAND_SAY:{
  1554. if (sep && sep->arg[0][0]) {
  1555. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1556. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1557. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1558. }
  1559. else
  1560. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1561. break;
  1562. }
  1563. case COMMAND_TELL:{
  1564. if(sep && sep->arg[0] && sep->argplus[1]){
  1565. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_TELL, sep->argplus[1]))
  1566. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1567. }else
  1568. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1569. break;
  1570. }
  1571. case COMMAND_SHOUT:{
  1572. if(sep && sep->arg[0][0])
  1573. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1574. else
  1575. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1576. break;
  1577. }
  1578. case COMMAND_AUCTION:{
  1579. if(sep && sep->arg[0][0])
  1580. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1581. else
  1582. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1583. break;
  1584. }
  1585. case COMMAND_OOC:{
  1586. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  1587. if(sep && sep->arg[0][0])
  1588. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OOC, sep->argplus[0]);
  1589. else
  1590. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  1591. break;
  1592. }
  1593. case COMMAND_EMOTE:{
  1594. if(sep && sep->arg[0][0])
  1595. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  1596. else
  1597. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  1598. break;
  1599. }
  1600. case COMMAND_RACE:{
  1601. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  1602. if(sep->arg[1][0] && sep->IsNumber(1)){
  1603. client->GetPlayer()->GetInfoStruct()->race = atoi(sep->arg[1]);
  1604. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  1605. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  1606. client->GetPlayer()->SetCharSheetChanged(true);
  1607. }
  1608. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  1609. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  1610. //client->QueuePacket(outapp);
  1611. }
  1612. else{
  1613. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  1614. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  1615. }
  1616. break;
  1617. }
  1618. case COMMAND_BANK_DEPOSIT:{
  1619. if(client->GetBanker() && sep && sep->arg[0]){
  1620. int64 amount = 0;
  1621. string deposit = string(sep->arg[0]);
  1622. amount = atoi64(deposit.c_str());
  1623. client->BankDeposit(amount);
  1624. }
  1625. break;
  1626. }
  1627. case COMMAND_BANK_WITHDRAWAL:{
  1628. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  1629. int64 amount = 0;
  1630. string deposit = string(sep->arg[0]);
  1631. amount = atoi64(deposit.c_str());
  1632. client->BankWithdrawal(amount);
  1633. }
  1634. break;
  1635. }
  1636. case COMMAND_BANK_CANCEL:{
  1637. Spawn* banker = cmdTarget;
  1638. client->Bank(banker, true);
  1639. break;
  1640. }
  1641. case COMMAND_BANK:{
  1642. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  1643. Spawn* banker = cmdTarget;
  1644. client->Bank(banker);
  1645. break;
  1646. }
  1647. case COMMAND_GUILD_BANK:{
  1648. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  1649. //Spawn* banker = client->GetPlayer()->GetTarget();
  1650. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  1651. break;
  1652. }
  1653. case COMMAND_START_MAIL: {
  1654. client->SetMailTransaction(cmdTarget);
  1655. client->SendMailList();
  1656. break;
  1657. }
  1658. case COMMAND_CANCEL_MAIL: {
  1659. client->SetMailTransaction(0);
  1660. break;
  1661. }
  1662. case COMMAND_GET_MAIL_MESSAGE: {
  1663. if (sep && sep->arg[0] && sep->IsNumber(0))
  1664. client->DisplayMailMessage(atoul(sep->arg[0]));
  1665. break;
  1666. }
  1667. case COMMAND_ADD_MAIL_PLAT: {
  1668. if (sep && sep->arg[0] && sep->IsNumber(0))
  1669. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1670. break;
  1671. }
  1672. case COMMAND_ADD_MAIL_GOLD: {
  1673. if (sep && sep->arg[0] && sep->IsNumber(0))
  1674. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  1675. break;
  1676. }
  1677. case COMMAND_ADD_MAIL_SILVER: {
  1678. if (sep && sep->arg[0] && sep->IsNumber(0))
  1679. client->AddMailCoin(0, atoul(sep->arg[0]));
  1680. break;
  1681. }
  1682. case COMMAND_ADD_MAIL_COPPER: {
  1683. if (sep && sep->arg[0] && sep->IsNumber(0))
  1684. client->AddMailCoin(atoul(sep->arg[0]));
  1685. break;
  1686. }
  1687. case COMMAND_SET_MAIL_ITEM: {
  1688. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1689. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1690. break;
  1691. }
  1692. case COMMAND_REMOVE_MAIL_PLAT: {
  1693. if (sep && sep->arg[0] && sep->IsNumber(0))
  1694. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1695. break;
  1696. }
  1697. case COMMAND_REMOVE_MAIL_GOLD: {
  1698. if (sep && sep->arg[0] && sep->IsNumber(0))
  1699. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  1700. break;
  1701. }
  1702. case COMMAND_REMOVE_MAIL_SILVER: {
  1703. if (sep && sep->arg[0] && sep->IsNumber(0))
  1704. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  1705. break;
  1706. }
  1707. case COMMAND_REMOVE_MAIL_COPPER: {
  1708. if (sep && sep->arg[0] && sep->IsNumber(0))
  1709. client->RemoveMailCoin(atoul(sep->arg[0]));
  1710. break;
  1711. }
  1712. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  1713. if (sep && sep->arg[0] && sep->IsNumber(0))
  1714. client->TakeMailAttachments(atoul(sep->arg[0]));
  1715. break;
  1716. }
  1717. case COMMAND_CANCEL_SEND_MAIL: {
  1718. client->CancelSendMail();
  1719. break;
  1720. }
  1721. case COMMAND_DELETE_MAIL_MESSAGE: {
  1722. if (sep && sep->arg[0] && sep->IsNumber(0))
  1723. client->DeleteMail(atoul(sep->arg[0]), true);
  1724. break;
  1725. }
  1726. case COMMAND_REPORT_SPAM: {
  1727. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1728. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1729. break;
  1730. }
  1731. case COMMAND_KILL:{
  1732. Spawn* dead = 0;
  1733. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  1734. dead=client->GetPlayer();
  1735. client->GetPlayer()->SetHP(0);
  1736. client->GetPlayer()->KillSpawn(dead);
  1737. }else{
  1738. dead= cmdTarget;
  1739. if(dead && dead->IsPlayer() == false){
  1740. dead->SetHP(0);
  1741. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  1742. client->GetCurrentZone()->RemoveSpawn(false, dead, true);
  1743. else
  1744. client->GetPlayer()->KillSpawn(dead);
  1745. }else{
  1746. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  1747. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  1748. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  1749. }
  1750. }
  1751. break;
  1752. }
  1753. case COMMAND_LEVEL:{
  1754. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  1755. int16 new_level = atoi(sep->arg[ndx]);
  1756. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  1757. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  1758. else {
  1759. if (new_level < 1)
  1760. new_level = 1;
  1761. if (new_level > 255)
  1762. new_level = 255;
  1763. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  1764. client->GetPlayer()->SetXP(1);
  1765. client->GetPlayer()->SetNeededXP();
  1766. }
  1767. }else
  1768. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  1769. break;
  1770. }
  1771. case COMMAND_SIT: {
  1772. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1773. if(client->GetPlayer()->GetHP() > 0){
  1774. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  1775. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  1776. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  1777. }
  1778. break;
  1779. }
  1780. case COMMAND_STAND: {
  1781. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1782. if(client->GetPlayer()->GetHP() > 0){
  1783. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  1784. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  1785. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  1786. }
  1787. break;
  1788. }
  1789. case COMMAND_CLASS:{
  1790. if(sep && sep->arg[ndx][0]){
  1791. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  1792. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  1793. }else
  1794. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  1795. break;
  1796. }
  1797. case COMMAND_GENDER:{
  1798. if(sep && sep->arg[ndx][0]){
  1799. client->GetPlayer()->GetInfoStruct()->gender = atoi(sep->arg[ndx]);
  1800. client->GetPlayer()->SetCharSheetChanged(true);
  1801. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  1802. }else{
  1803. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  1804. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  1805. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  1806. }
  1807. break;
  1808. }
  1809. case COMMAND_FLYMODE:{
  1810. if(sep && sep->arg[0] && sep->IsNumber(0)){
  1811. PrintSep(sep, "COMMAND_FLYMODE");
  1812. int8 val = atoi(sep->arg[0]);
  1813. ClientPacketFunctions::SendFlyMode(client, val);
  1814. }
  1815. else{
  1816. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  1817. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  1818. }
  1819. break;
  1820. }
  1821. case COMMAND_LOOT_LIST:{
  1822. Spawn* spawn = cmdTarget;
  1823. if(spawn && spawn->IsEntity()){
  1824. if (sep && sep->arg[0]) {
  1825. if (!spawn->GetDatabaseID())
  1826. {
  1827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  1828. break;
  1829. }
  1830. else if (!spawn->IsNPC())
  1831. {
  1832. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  1833. break;
  1834. }
  1835. bool reloadLoot = false;
  1836. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  1837. {
  1838. int32 loottable_id = atoul(sep->arg[1]);
  1839. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  1840. {
  1841. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  1842. reloadLoot = true;
  1843. }
  1844. else
  1845. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  1846. }
  1847. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  1848. {
  1849. int32 loottable_id = atoul(sep->arg[1]);
  1850. if (loottable_id > 0)
  1851. {
  1852. database.AddLootTableToSpawn(spawn, loottable_id);
  1853. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  1854. reloadLoot = true;
  1855. }
  1856. else
  1857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  1858. }
  1859. else if (!stricmp(sep->arg[0], "clearall"))
  1860. {
  1861. if (database.RemoveSpawnLootTable(spawn, 0))
  1862. {
  1863. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  1864. reloadLoot = true;
  1865. }
  1866. else
  1867. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  1868. }
  1869. else
  1870. {
  1871. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  1872. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  1873. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  1874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  1875. break;
  1876. }
  1877. if (reloadLoot)
  1878. {
  1879. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  1880. if (spawn->IsNPC())
  1881. {
  1882. Entity* ent = (Entity*)spawn;
  1883. ent->SetLootCoins(0);
  1884. ent->ClearLootList();
  1885. spawn->GetZone()->AddLoot((NPC*)spawn);
  1886. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  1887. }
  1888. }
  1889. break; // nothing further this is the end of these sub commands
  1890. }
  1891. else
  1892. {
  1893. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  1894. if (loot_list.size() > 0) {
  1895. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  1896. vector<int32>::iterator list_itr;
  1897. LootTable* table = 0;
  1898. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  1899. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  1900. if (table)
  1901. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  1902. }
  1903. }
  1904. Entity* target = (Entity*)spawn;
  1905. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", target->GetLootCoins());
  1906. vector<Item*>* items = target->GetLootItems();
  1907. if (items) {
  1908. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  1909. vector<Item*>::iterator itr;
  1910. Item* item = 0;
  1911. for (itr = items->begin(); itr != items->end(); itr++) {
  1912. item = *itr;
  1913. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  1914. }
  1915. }
  1916. else
  1917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  1918. }
  1919. }
  1920. break;
  1921. }
  1922. case COMMAND_LOOT_SETCOIN:{
  1923. Spawn* spawn = cmdTarget;
  1924. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1925. Entity* target = (Entity*)spawn;
  1926. target->SetLootCoins(atoul(sep->arg[0]));
  1927. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  1928. }
  1929. else
  1930. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  1931. break;
  1932. }
  1933. case COMMAND_LOOT_ADDITEM:{
  1934. Spawn* spawn = cmdTarget;
  1935. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1936. Entity* target = (Entity*)spawn;
  1937. int16 charges = 1;
  1938. if(sep->arg[1] && sep->IsNumber(1))
  1939. charges = atoi(sep->arg[1]);
  1940. target->AddLootItem(atoul(sep->arg[0]), charges);
  1941. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  1942. }
  1943. else
  1944. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  1945. break;
  1946. }
  1947. case COMMAND_LOOT_REMOVEITEM:{
  1948. Spawn* spawn = cmdTarget;
  1949. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1950. Entity* target = (Entity*)spawn;
  1951. target->LootItem(atoul(sep->arg[0]));
  1952. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  1953. }
  1954. else
  1955. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  1956. break;
  1957. }
  1958. case COMMAND_LOOT_CORPSE:
  1959. case COMMAND_DISARM:
  1960. case COMMAND_LOOT:{
  1961. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  1962. {
  1963. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  1964. break;
  1965. }
  1966. if(cmdTarget && cmdTarget->IsEntity()){
  1967. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  1968. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  1969. client->OpenChest((Entity*)cmdTarget, true);
  1970. else
  1971. client->Loot((Entity*)cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  1972. if (!((Entity*)cmdTarget)->HasLoot()){
  1973. if (((Entity*)cmdTarget)->IsNPC())
  1974. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  1975. }
  1976. }
  1977. else
  1978. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  1979. }
  1980. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  1981. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  1982. break;
  1983. }
  1984. case COMMAND_RELOADSPAWNSCRIPTS:{
  1985. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  1986. if (lua_interface)
  1987. lua_interface->SetSpawnScriptsReloading(true);
  1988. world.ResetSpawnScripts();
  1989. database.LoadSpawnScriptData();
  1990. if(lua_interface) {
  1991. lua_interface->DestroySpawnScripts();
  1992. lua_interface->SetSpawnScriptsReloading(false);
  1993. }
  1994. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  1995. break;
  1996. }
  1997. case COMMAND_RELOADLUASYSTEM:{
  1998. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  1999. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2000. safe_delete(lua_interface);
  2001. lua_interface = new LuaInterface();
  2002. if(lua_interface)
  2003. lua_interface->SetSpawnScriptsReloading(true);
  2004. if(lua_interface && debug_clients.size() > 0){
  2005. map<Client*, int32>::iterator itr;
  2006. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2007. if(lua_interface)
  2008. lua_interface->UpdateDebugClients(itr->first);
  2009. }
  2010. }
  2011. world.ResetSpawnScripts();
  2012. database.LoadSpawnScriptData();
  2013. world.ResetZoneScripts();
  2014. database.LoadZoneScriptData();
  2015. int32 quest_count = database.LoadQuests();
  2016. zone_list.DeleteSpellProcess();
  2017. master_spell_list.Reload();
  2018. int32 spell_count = 0;
  2019. if(lua_interface) {
  2020. lua_interface->DestroySpawnScripts();
  2021. lua_interface->DestroySpells();
  2022. spell_count = database.LoadSpellScriptData();
  2023. lua_interface->SetSpawnScriptsReloading(false);
  2024. }
  2025. zone_list.LoadSpellProcess();
  2026. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2027. break;
  2028. }
  2029. case COMMAND_DECLINE_QUEST:{
  2030. int32 quest_id = 0;
  2031. if(sep && sep->arg[0] && sep->IsNumber(0))
  2032. quest_id = atoul(sep->arg[0]);
  2033. if(quest_id > 0){
  2034. Quest* quest = client->GetPendingQuest(quest_id);
  2035. if(quest){
  2036. client->RemovePendingQuest(quest);
  2037. if(lua_interface)
  2038. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2039. safe_delete(quest);
  2040. client->GetCurrentZone()->SendQuestUpdates(client);
  2041. }
  2042. }
  2043. break;
  2044. }
  2045. case COMMAND_DELETE_QUEST:{
  2046. int32 quest_id = 0;
  2047. if(sep && sep->arg[0] && sep->IsNumber(0))
  2048. quest_id = atoul(sep->arg[0]);
  2049. if(quest_id > 0){
  2050. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2051. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2052. if (quest)
  2053. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2054. }
  2055. client->RemovePlayerQuest(quest_id);
  2056. client->GetCurrentZone()->SendQuestUpdates(client);
  2057. }
  2058. break;
  2059. }
  2060. case COMMAND_ACCEPT_QUEST:{
  2061. int32 quest_id = 0;
  2062. if(sep && sep->arg[0] && sep->IsNumber(0))
  2063. quest_id = atoul(sep->arg[0]);
  2064. if(quest_id > 0){
  2065. Quest* quest = client->GetPendingQuest(quest_id);
  2066. if(quest){
  2067. client->RemovePendingQuest(quest);
  2068. client->AddPlayerQuest(quest);
  2069. client->GetCurrentZone()->SendQuestUpdates(client);
  2070. // If character has already completed this quest once update the given date in the database
  2071. if (client->GetPlayer()->GetCompletedPlayerQuests()->count(quest_id) > 0) {
  2072. Quest* quest2 = client->GetPlayer()->GetCompletedQuest(quest_id);
  2073. if (quest2)
  2074. quest->SetCompleteCount(quest2->GetCompleteCount());
  2075. database.SaveCharRepeatableQuest(client, quest_id, quest->GetCompleteCount());
  2076. }
  2077. }
  2078. }
  2079. break;
  2080. }
  2081. case COMMAND_NAME:{
  2082. if(sep && sep->arg[ndx][0]){
  2083. memset(client->GetPlayer()->GetInfoStruct()->name, 0, 40);
  2084. strncpy(client->GetPlayer()->GetInfoStruct()->name, sep->arg[ndx], 39);
  2085. client->GetPlayer()->SetCharSheetChanged(true);
  2086. }else
  2087. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2088. break;
  2089. }
  2090. case COMMAND_GROUPSAY:{
  2091. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2092. if(sep && sep->arg[0] && gmi)
  2093. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2094. break;
  2095. }
  2096. case COMMAND_GROUPINVITE: {
  2097. Entity* target = 0;
  2098. Client* target_client = 0;
  2099. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2100. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2101. return;
  2102. }
  2103. // name provided with command so it has to be a player, npc not supported here
  2104. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2105. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2106. if (target_client) {
  2107. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2108. target = 0;
  2109. else
  2110. target = target_client->GetPlayer();
  2111. }
  2112. }
  2113. // if name was not provided use the players target, npc or player supported here
  2114. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2115. target = (Entity*)client->GetPlayer()->GetTarget();
  2116. if (target->IsPlayer()) {
  2117. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2118. }
  2119. }
  2120. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2121. if (result == 0) {
  2122. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2123. if (target_client) {
  2124. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2125. if (packet) {
  2126. packet->setDataByName("type", 1);
  2127. packet->setDataByName("name", client->GetPlayer()->GetName());
  2128. packet->setDataByName("unknown2", 1);
  2129. target_client->QueuePacket(packet->serialize());
  2130. safe_delete(packet);
  2131. }
  2132. }
  2133. }
  2134. else if (result == 1)
  2135. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2136. else if (result == 2)
  2137. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2138. else if (result == 3)
  2139. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2140. else if (result == 4)
  2141. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2142. else if (result == 5)
  2143. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2144. else if (result == 6)
  2145. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2146. else
  2147. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2148. break;
  2149. }
  2150. case COMMAND_GROUPDISBAND: {
  2151. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2152. if (gmi) { // TODO: Leader check
  2153. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2154. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2155. }
  2156. break;
  2157. }
  2158. case COMMAND_GROUP_LEAVE: {
  2159. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2160. if (gmi) {
  2161. int32 group_id = gmi->group_id;
  2162. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2163. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2164. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2165. }
  2166. else {
  2167. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2168. }
  2169. client->SimpleMessage(CHANNEL_COLOR_GROUP, "You have left the group");
  2170. }
  2171. break;
  2172. }
  2173. case COMMAND_FRIEND_ADD:{
  2174. string name = "";
  2175. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2176. name = database.GetPlayerName(sep->arg[0]);
  2177. else if(cmdTarget && cmdTarget->IsPlayer())
  2178. name = string(cmdTarget->GetName());
  2179. if(name.length() > 0){
  2180. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2181. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2182. client->GetPlayer()->RemoveIgnore(name.c_str());
  2183. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2184. client->SendChatRelationship(3, name.c_str());
  2185. }
  2186. client->GetPlayer()->AddFriend(name.c_str(), true);
  2187. client->SendChatRelationship(0, name.c_str());
  2188. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2189. if(zone_list.GetClientByCharName(name))
  2190. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2191. }
  2192. else
  2193. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2194. }
  2195. else
  2196. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2197. break;
  2198. }
  2199. case COMMAND_FRIEND_REMOVE:{
  2200. string name = "";
  2201. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2202. name = database.GetPlayerName(sep->arg[0]);
  2203. else if(cmdTarget && cmdTarget->IsPlayer())
  2204. name = string(cmdTarget->GetName());
  2205. if(name.length() > 0){
  2206. client->GetPlayer()->RemoveFriend(name.c_str());
  2207. client->SendChatRelationship(1, name.c_str());
  2208. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2209. }
  2210. else
  2211. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2212. break;
  2213. }
  2214. case COMMAND_FRIENDS:{
  2215. break;
  2216. }
  2217. case COMMAND_IGNORE_ADD:{
  2218. string name = "";
  2219. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2220. name = database.GetPlayerName(sep->arg[0]);
  2221. else if(cmdTarget && cmdTarget->IsPlayer())
  2222. name = string(cmdTarget->GetName());
  2223. if(name.length() > 0){
  2224. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2225. if(client->GetPlayer()->IsFriend(name.c_str())){
  2226. client->GetPlayer()->RemoveFriend(name.c_str());
  2227. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2228. client->SendChatRelationship(1, name.c_str());
  2229. }
  2230. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2231. client->SendChatRelationship(2, name.c_str());
  2232. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2233. }
  2234. else
  2235. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2236. }
  2237. else
  2238. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2239. break;
  2240. }
  2241. case COMMAND_IGNORE_REMOVE:{
  2242. string name = "";
  2243. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2244. name = database.GetPlayerName(sep->arg[0]);
  2245. else if(cmdTarget && cmdTarget->IsPlayer())
  2246. name = string(cmdTarget->GetName());
  2247. if(name.length() > 0){
  2248. client->GetPlayer()->RemoveIgnore(name.c_str());
  2249. client->SendChatRelationship(3, name.c_str());
  2250. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2251. }
  2252. break;
  2253. }
  2254. case COMMAND_IGNORES:{
  2255. break;
  2256. }
  2257. case COMMAND_GROUP_KICK:{
  2258. Entity* kicked = 0;
  2259. Client* kicked_client = 0;
  2260. int32 group_id = 0;
  2261. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2262. return;
  2263. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2264. if (sep && sep->arg[0]) {
  2265. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2266. if (kicked_client)
  2267. kicked = kicked_client->GetPlayer();
  2268. }
  2269. else if (cmdTarget && cmdTarget->IsEntity()) {
  2270. kicked = (Entity*)cmdTarget;
  2271. }
  2272. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2273. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2274. if (kicked)
  2275. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2276. if(send_kicked_message)
  2277. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2278. else
  2279. client->Message(CHANNEL_COLOR_GROUP, "You kicked %s from the group", kicked->GetName());
  2280. if (kicked_client)
  2281. kicked_client->SimpleMessage(CHANNEL_COLOR_GROUP, "You were kicked from the group");
  2282. break;
  2283. }
  2284. case COMMAND_GROUP_MAKE_LEADER:{
  2285. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2286. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2287. return;
  2288. }
  2289. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2290. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2291. if (new_leader) {
  2292. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2293. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2294. }
  2295. }
  2296. else
  2297. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2298. }
  2299. else if (cmdTarget && cmdTarget->IsPlayer())
  2300. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2301. else
  2302. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2303. break;
  2304. }
  2305. case COMMAND_GROUP_ACCEPT_INVITE: {
  2306. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2307. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2308. if (result == 0)
  2309. client->SimpleMessage(CHANNEL_GROUP, "You have joined the group.");
  2310. else if (result == 1)
  2311. client->SimpleMessage(CHANNEL_GROUP, "You do not have a pending invite.");
  2312. else if (result == 2)
  2313. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - could not find leader.");
  2314. else
  2315. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - unknown error.");
  2316. }
  2317. break;
  2318. }
  2319. case COMMAND_GROUP_DECLINE_INVITE: {
  2320. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2321. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2322. }
  2323. break;
  2324. }
  2325. case COMMAND_SUMMON:{
  2326. char* search_name = 0;
  2327. if(sep && sep->arg[0][0])
  2328. search_name = sep->arg[0];
  2329. if(!search_name && !cmdTarget){
  2330. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2331. 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.");
  2332. }
  2333. else{
  2334. if(!client->Summon(search_name))
  2335. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2336. }
  2337. break;
  2338. }
  2339. case COMMAND_GOTO:{
  2340. const char* search_name = 0;
  2341. if(sep && sep->arg[0][0])
  2342. search_name = sep->argplus[0];
  2343. if(!search_name && !cmdTarget){
  2344. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2345. 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.");
  2346. }
  2347. else{
  2348. if(!client->GotoSpawn(search_name))
  2349. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2350. }
  2351. break;
  2352. }
  2353. case COMMAND_MOVE:{
  2354. bool success = false;
  2355. try{
  2356. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2357. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2358. if(app){
  2359. client->QueuePacket(app);
  2360. success = true;
  2361. }
  2362. }
  2363. }
  2364. catch(...){}
  2365. if(!success){
  2366. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2367. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2368. }
  2369. break;
  2370. }
  2371. case COMMAND_SETTIME:{
  2372. if(sep && sep->arg[0]){
  2373. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2374. if(sep->arg[1] && sep->IsNumber(1))
  2375. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2376. if(sep->arg[2] && sep->IsNumber(2))
  2377. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2378. if(sep->arg[3] && sep->IsNumber(3))
  2379. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2380. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2381. }
  2382. else{
  2383. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2384. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2385. }
  2386. break;
  2387. }
  2388. case COMMAND_VERSION:{
  2389. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2390. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2391. break;
  2392. }
  2393. case COMMAND_ZONE:{
  2394. string* zonename = 0;
  2395. int32 instanceID = 0;
  2396. const char* zone = 0;
  2397. int32 zone_id = 0;
  2398. bool listSearch = false;
  2399. bool isInstance = false;
  2400. ZoneServer* zsZone = 0;
  2401. if(sep && sep->arg[0][0])
  2402. {
  2403. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2404. listSearch = true;
  2405. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2406. {
  2407. zone_list.SendZoneList(client);
  2408. break;
  2409. }
  2410. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2411. {
  2412. if(sep->IsNumber(1))
  2413. instanceID = atol(sep->arg[1]);
  2414. }
  2415. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2416. {
  2417. PrintSep(sep, "ZONE LOCK");
  2418. if(sep->IsNumber(1))
  2419. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2420. else
  2421. zsZone = zone_list.Get(sep->arg[1], false);
  2422. if( zsZone )
  2423. {
  2424. zsZone->SetZoneLockState(true);
  2425. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2426. }
  2427. else
  2428. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2429. break;
  2430. }
  2431. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2432. {
  2433. PrintSep(sep, "ZONE UNLOCK");
  2434. if(sep->IsNumber(1))
  2435. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2436. else
  2437. zsZone = zone_list.Get(sep->arg[1], false);
  2438. if( zsZone )
  2439. {
  2440. zsZone->SetZoneLockState(false);
  2441. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2442. }
  2443. else
  2444. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2445. break;
  2446. }
  2447. else
  2448. {
  2449. if(sep->IsNumber(0))
  2450. {
  2451. zone_id = atoul(sep->arg[0]);
  2452. zonename = database.GetZoneName(zone_id);
  2453. if(zonename)
  2454. zone = zonename->c_str();
  2455. }
  2456. else
  2457. zone = sep->arg[0];
  2458. }
  2459. if(instanceID > 0)
  2460. {
  2461. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2462. if(zsInstance != NULL)
  2463. {
  2464. instanceID = zsInstance->GetInstanceID();
  2465. zone = zsInstance->GetZoneName();
  2466. zone_id = zsInstance->GetZoneID();
  2467. isInstance = true;
  2468. }
  2469. }
  2470. }
  2471. if(!listSearch)
  2472. {
  2473. if(!zone)
  2474. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2475. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2476. zone_id != client->GetCurrentZone()->GetZoneID())
  2477. {
  2478. if(database.VerifyZone(zone))
  2479. {
  2480. if(client->CheckZoneAccess(zone))
  2481. {
  2482. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zone);
  2483. if(isInstance)
  2484. client->Zone(instanceID,true,true);
  2485. else
  2486. client->Zone(zone);
  2487. }
  2488. }
  2489. else
  2490. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zone);
  2491. }
  2492. else
  2493. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2494. }
  2495. else
  2496. {
  2497. const char* name = 0;
  2498. if(sep && sep->arg[1][0])
  2499. {
  2500. map<int32, string>* zone_names;
  2501. name = sep->argplus[1];
  2502. sint16 status = client->GetAdminStatus();
  2503. if( status > 0 )
  2504. {
  2505. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2506. zone_names = database.GetZoneList(name, true);
  2507. }
  2508. else
  2509. zone_names = database.GetZoneList(name);
  2510. if(!zone_names)
  2511. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2512. else
  2513. {
  2514. map<int32, string>::iterator itr;
  2515. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2516. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2517. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2518. safe_delete(zone_names);
  2519. }
  2520. }
  2521. else
  2522. {
  2523. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2524. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2525. }
  2526. }
  2527. safe_delete(zonename);
  2528. break;
  2529. }
  2530. case COMMAND_USE: {
  2531. Spawn* target = cmdTarget;
  2532. if (target->IsWidget())
  2533. ((Widget*)target)->HandleUse(client, "use");
  2534. break;
  2535. }
  2536. case COMMAND_OPEN: {
  2537. Spawn* target = cmdTarget;
  2538. if (target->IsWidget())
  2539. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2540. break;
  2541. }
  2542. case COMMAND_CASTSPELL: {
  2543. if (sep && sep->arg[0] && sep->IsNumber(0))
  2544. {
  2545. int8 tier = 1;
  2546. if (sep->arg[1] && sep->IsNumber(1))
  2547. tier = atoul(sep->arg[1]);
  2548. int32 spellid = atoul(sep->arg[0]);
  2549. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2550. if (spell)
  2551. {
  2552. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2553. SpellProcess* spellProcess = 0;
  2554. // Get the current zones spell process
  2555. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2556. spellProcess->CastInstant(spell, (Entity*)client->GetPlayer(), (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2557. }
  2558. else
  2559. {
  2560. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2561. }
  2562. }
  2563. else if (sep && sep->arg[0])
  2564. {
  2565. database.FindSpell(client, (char*)sep->argplus[0]);
  2566. }
  2567. else
  2568. {
  2569. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2570. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2571. }
  2572. break;
  2573. }
  2574. case COMMAND_ATTACK:
  2575. case COMMAND_AUTO_ATTACK:{
  2576. int8 type = 1;
  2577. Player* player = client->GetPlayer();
  2578. if(!player)
  2579. break;
  2580. bool incombat = player->EngagedInCombat();
  2581. if(sep && sep->arg[0] && sep->IsNumber(0))
  2582. type = atoi(sep->arg[0]);
  2583. if(client->GetPlayer()->GetHP() == 0){
  2584. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  2585. break;
  2586. }
  2587. if(type == 0){
  2588. if(incombat)
  2589. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2590. player->InCombat(false);
  2591. player->InCombat(false, true);
  2592. player->SetRangeAttack(false);
  2593. }
  2594. else {
  2595. if(type == 2){
  2596. player->InCombat(false);
  2597. if(incombat && player->GetRangeAttack()){
  2598. player->SetRangeAttack(false);
  2599. player->InCombat(false, true);
  2600. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2601. }
  2602. else{
  2603. player->SetRangeAttack(true);
  2604. player->InCombat(true, true);
  2605. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2606. }
  2607. }
  2608. else {
  2609. player->InCombat(false, true);
  2610. player->SetRangeAttack(false);
  2611. player->InCombat(true);
  2612. if(!incombat)
  2613. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2614. }
  2615. /*else
  2616. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  2617. }
  2618. player->SetCharSheetChanged(true);
  2619. break;
  2620. }
  2621. case COMMAND_DEPOP:{
  2622. bool allow_respawns = false;
  2623. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2624. if(atoi(sep->arg[0]) == 1)
  2625. allow_respawns = true;
  2626. }
  2627. client->GetCurrentZone()->Depop(allow_respawns);
  2628. break;
  2629. }
  2630. case COMMAND_REPOP:{
  2631. client->GetCurrentZone()->Depop(false, true);
  2632. break;
  2633. }
  2634. case COMMAND_BUYBACK:{
  2635. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2636. // 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
  2637. int64 id = atoi64(sep->arg[0]);
  2638. // get the first int32, the item id
  2639. //int32 item_id = (int32)id;
  2640. // get the second int32, the unique id
  2641. int32 unique_id = (int32)(id>>32);
  2642. int8 quantity = atoi(sep->arg[1]);
  2643. if(quantity == 255)
  2644. quantity = 1;
  2645. client->BuyBack(unique_id, quantity);
  2646. }
  2647. break;
  2648. }
  2649. case COMMAND_MERCHANT_BUY:{
  2650. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2651. int32 item_id = atoul(sep->arg[0]);
  2652. int8 quantity = atoi(sep->arg[1]);
  2653. client->BuyItem(item_id, quantity);
  2654. }
  2655. break;
  2656. }
  2657. case COMMAND_MERCHANT_SELL:{
  2658. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2659. // 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
  2660. int64 id = atoi64(sep->arg[0]);
  2661. // get the first int32, the item id
  2662. int32 item_id = (int32)id;
  2663. // get the second int32, the unique id
  2664. int32 unique_id = (int32)(id>>32);
  2665. int8 quantity = atoi(sep->arg[1]);
  2666. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  2667. client->SellItem(item_id, quantity, unique_id);
  2668. }
  2669. break;
  2670. }
  2671. case COMMAND_MENDER_REPAIR: {
  2672. if (sep && sep->arg[0] && sep->IsNumber(0))
  2673. client->RepairItem(atoul(sep->arg[0]));
  2674. break;
  2675. }
  2676. case COMMAND_MENDER_REPAIR_ALL: {
  2677. client->RepairAllItems();
  2678. break;
  2679. }
  2680. case COMMAND_CANCEL_MERCHANT:{
  2681. client->SetMerchantTransaction(0);
  2682. break;
  2683. }
  2684. case COMMAND_START_MERCHANT:{
  2685. break;
  2686. }
  2687. case COMMAND_INVULNERABLE:{
  2688. sint8 val = -1;
  2689. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2690. val = atoi(sep->arg[0]);
  2691. //devn00b: Fix for linux builds
  2692. #if defined(__GNUC__)
  2693. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) 1 : 0);
  2694. #else
  2695. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2696. #endif
  2697. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2698. client->GetPlayer()->SetInvulnerable(val==1);
  2699. if(client->GetPlayer()->GetInvulnerable())
  2700. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  2701. else
  2702. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  2703. }
  2704. if(val == -1)
  2705. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  2706. break;
  2707. }
  2708. case COMMAND_REPAIR: {
  2709. Spawn* spawn = cmdTarget;
  2710. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  2711. client->SetMerchantTransaction(spawn);
  2712. client->SendRepairList();
  2713. }
  2714. break;
  2715. }
  2716. case COMMAND_LOTTO: {
  2717. Spawn* spawn = cmdTarget;
  2718. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  2719. client->SetMerchantTransaction(spawn);
  2720. client->ShowLottoWindow();
  2721. }
  2722. break;
  2723. }
  2724. case COMMAND_ACCEPT_REWARD:{
  2725. int32 unknown = 0;
  2726. int32 selectable_item_id = 0;
  2727. //Quest *quest = 0;
  2728. Collection *collection = 0;
  2729. /* no idea what the first argument is for (faction maybe?)
  2730. if the reward has a selectable item reward, it's sent as the second argument
  2731. if neither of these are included in the reward, there is no sep
  2732. 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
  2733. only 1 quest or collection reward may be displayed at a time */
  2734. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2735. unknown = atoul(sep->arg[0]);
  2736. selectable_item_id = atoul(sep->arg[1]);
  2737. }
  2738. //if ((quest = player->GetPendingQuestReward()))
  2739. // client->AcceptQuestRewards(quest, selectable_item_id);
  2740. /* the below needs to go away eventually and be redone */
  2741. int32 item_id = 0;
  2742. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  2743. item_id = atoul(sep->arg[0]);
  2744. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  2745. if(quest){
  2746. client->AcceptQuestReward(quest, item_id);
  2747. break;
  2748. }
  2749. if (collection = player->GetPendingCollectionReward())
  2750. client->AcceptCollectionRewards(collection, selectable_item_id);
  2751. else
  2752. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  2753. break;
  2754. }
  2755. case COMMAND_BUY_FROM_BROKER:{
  2756. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2757. int32 item_id = atoul(sep->arg[0]);
  2758. int16 quantity = atoul(sep->arg[1]);
  2759. client->AddItem(item_id, quantity);
  2760. }
  2761. break;
  2762. }
  2763. case COMMAND_SEARCH_STORES_PAGE:{
  2764. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2765. int32 page = atoul(sep->arg[0]);
  2766. client->SearchStore(page);
  2767. }
  2768. break;
  2769. }
  2770. case COMMAND_SEARCH_STORES:{
  2771. if(sep && sep->arg[0][0]){
  2772. const char* values = sep->argplus[0];
  2773. if(values){
  2774. map<string, string> str_values = TranslateBrokerRequest(values);
  2775. vector<Item*>* items = master_item_list.GetItems(str_values);
  2776. if(items){
  2777. client->SetItemSearch(items);
  2778. client->SearchStore(0);
  2779. }
  2780. }
  2781. }
  2782. break;
  2783. }
  2784. case COMMAND_LUADEBUG:{
  2785. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  2786. client->SetLuaDebugClient(true);
  2787. if(lua_interface)
  2788. lua_interface->UpdateDebugClients(client);
  2789. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  2790. }
  2791. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  2792. client->SetLuaDebugClient(false);
  2793. if(lua_interface)
  2794. lua_interface->RemoveDebugClients(client);
  2795. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  2796. }
  2797. else{
  2798. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  2799. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  2800. }
  2801. break;
  2802. }
  2803. case COMMAND_SPAWN_GROUP:
  2804. {
  2805. Spawn* target = cmdTarget;
  2806. if(target && target->IsPlayer() == false)
  2807. {
  2808. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  2809. {
  2810. if(target->GetSpawnLocationPlacementID() > 0)
  2811. {
  2812. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  2813. {
  2814. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  2815. if(id > 0)
  2816. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  2817. else
  2818. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  2819. target->SetSpawnGroupID(id);
  2820. target->AddSpawnToGroup(target);
  2821. }
  2822. else
  2823. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  2824. }
  2825. else
  2826. 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.");
  2827. }
  2828. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  2829. {
  2830. if(sep->arg[1] && sep->IsNumber(1))
  2831. {
  2832. int32 group_id = atoul(sep->arg[1]);
  2833. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  2834. if(leader)
  2835. {
  2836. leader->AddSpawnToGroup(target);
  2837. target->SetSpawnGroupID(group_id);
  2838. if(database.SpawnGroupAddSpawn(target, group_id))
  2839. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  2840. else
  2841. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  2842. }
  2843. else
  2844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  2845. }
  2846. else
  2847. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  2848. }
  2849. else if(target->GetSpawnGroupID() == 0)
  2850. {
  2851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  2852. }
  2853. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  2854. {
  2855. int32 group_id = target->GetSpawnGroupID();
  2856. target->RemoveSpawnFromGroup();
  2857. if(database.SpawnGroupRemoveSpawn(target, group_id))
  2858. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  2859. else
  2860. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  2861. }
  2862. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  2863. {
  2864. int32 group_id = target->GetSpawnGroupID();
  2865. if(sep->arg[1] && sep->IsNumber(1))
  2866. {
  2867. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  2868. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  2869. else
  2870. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  2871. }
  2872. else
  2873. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  2874. }
  2875. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  2876. {
  2877. int32 group_id = target->GetSpawnGroupID();
  2878. if(sep->arg[1] && sep->IsNumber(1))
  2879. {
  2880. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  2881. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  2882. else
  2883. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  2884. }
  2885. else
  2886. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  2887. }
  2888. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  2889. {
  2890. if(sep->arg[1] && sep->IsNumber(1))
  2891. {
  2892. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  2893. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  2894. else
  2895. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  2896. }
  2897. else
  2898. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  2899. }
  2900. else
  2901. {
  2902. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  2903. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  2904. }
  2905. }
  2906. else
  2907. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  2908. break;
  2909. }
  2910. case COMMAND_SPAWN_COMBINE:{
  2911. Spawn* spawn = cmdTarget;
  2912. float radius = 0;
  2913. bool failed = true;
  2914. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  2915. failed = false;
  2916. if(spawn->GetSpawnGroupID() > 0){
  2917. 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.");
  2918. }
  2919. else if(sep->IsNumber(0)){
  2920. radius = atof(sep->arg[0]);
  2921. client->CombineSpawns(radius, spawn);
  2922. }
  2923. else{
  2924. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  2925. client->AddCombineSpawn(spawn);
  2926. }
  2927. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  2928. client->RemoveCombineSpawn(spawn);
  2929. }
  2930. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  2931. const char* name = 0;
  2932. if(sep->arg[1] && sep->arg[1][0])
  2933. name = sep->argplus[1];
  2934. client->SaveCombineSpawns(name);
  2935. }
  2936. else
  2937. failed = true;
  2938. }
  2939. }
  2940. if(failed){
  2941. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  2942. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  2943. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  2944. }
  2945. break;
  2946. }
  2947. case COMMAND_SPAWN_CREATE:{
  2948. Spawn* spawn = 0;
  2949. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  2950. spawn = new Object();
  2951. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2952. }
  2953. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  2954. spawn = new GroundSpawn();
  2955. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2956. }
  2957. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  2958. spawn = new Sign();
  2959. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2960. }
  2961. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  2962. spawn = new NPC();
  2963. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2964. spawn->appearance.pos.collision_radius = 32;
  2965. spawn->secondary_command_list_id = 0;
  2966. spawn->primary_command_list_id = 0;
  2967. spawn->appearance.display_name = 1;
  2968. spawn->appearance.show_level = 1;
  2969. spawn->appearance.attackable = 1;
  2970. }
  2971. else{
  2972. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  2973. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  2974. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  2975. break;
  2976. }
  2977. spawn->SetID(Spawn::NextID());
  2978. spawn->SetX(client->GetPlayer()->GetX());
  2979. spawn->SetY(client->GetPlayer()->GetY());
  2980. spawn->SetZ(client->GetPlayer()->GetZ());
  2981. spawn->SetHeading(client->GetPlayer()->GetHeading());
  2982. spawn->SetSpawnOrigX(spawn->GetX());
  2983. spawn->SetSpawnOrigY(spawn->GetY());
  2984. spawn->SetSpawnOrigZ(spawn->GetZ());
  2985. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  2986. spawn->appearance.targetable = 1;
  2987. spawn->appearance.race = 255;
  2988. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  2989. spawn->SetModelType(atoi(sep->arg[1]));
  2990. spawn->SetAdventureClass(atoi(sep->arg[2]));
  2991. spawn->SetLevel(atoi(sep->arg[3]));
  2992. spawn->SetName(sep->arg[4]);
  2993. if(sep->arg[5][0] && sep->IsNumber(5))
  2994. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  2995. if(sep->arg[6][0] && sep->IsNumber(6))
  2996. spawn->size = atoi(sep->arg[6]);
  2997. if(spawn->GetTotalHP() == 0){
  2998. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  2999. spawn->SetHP(25*spawn->GetLevel() + 1);
  3000. }
  3001. if(spawn->GetTotalPower() == 0){
  3002. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3003. spawn->SetPower(25*spawn->GetLevel() + 1);
  3004. }
  3005. client->GetCurrentZone()->AddSpawn(spawn);
  3006. break;
  3007. }
  3008. case COMMAND_SPAWN_EQUIPMENT:{
  3009. Spawn* spawn = cmdTarget;
  3010. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3011. int8 slot = atoi(sep->arg[0]);
  3012. int16 type = atoi(sep->arg[1]);
  3013. int8 red = 0;
  3014. int8 green = 0;
  3015. int8 blue = 0;
  3016. int8 h_red = 0;
  3017. int8 h_green = 0;
  3018. int8 h_blue = 0;
  3019. if(sep->arg[2])
  3020. red = atoi(sep->arg[2]);
  3021. if(sep->arg[3])
  3022. green = atoi(sep->arg[3]);
  3023. if(sep->arg[4])
  3024. blue = atoi(sep->arg[4]);
  3025. if(sep->arg[5])
  3026. h_red = atoi(sep->arg[5]);
  3027. if(sep->arg[6])
  3028. h_green = atoi(sep->arg[6]);
  3029. if(sep->arg[7])
  3030. h_blue = atoi(sep->arg[7]);
  3031. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3032. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3033. }
  3034. else{
  3035. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3036. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3037. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3038. }
  3039. break;
  3040. }
  3041. case COMMAND_SPAWN_DETAILS:{
  3042. Spawn* spawn = cmdTarget;
  3043. if (sep && sep->arg[0][0]) {
  3044. if (cmdTarget)
  3045. {
  3046. if (ToLower(string(sep->arg[0])) == "los")
  3047. {
  3048. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3049. if (hasLOS)
  3050. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3051. else
  3052. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3053. break;
  3054. }
  3055. else if (ToLower(string(sep->arg[0])) == "bestz")
  3056. {
  3057. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3058. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3059. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3060. break;
  3061. }
  3062. else if (ToLower(string(sep->arg[0])) == "pathto")
  3063. {
  3064. break;
  3065. }
  3066. else if (ToLower(string(sep->arg[0])) == "pathfrom")
  3067. {
  3068. break;
  3069. }
  3070. }
  3071. if (sep->IsNumber(0))
  3072. {
  3073. float radius = atof(sep->arg[0]);
  3074. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3075. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3076. break;
  3077. }
  3078. }
  3079. if(spawn){
  3080. const char* type = "NPC";
  3081. if(spawn->IsObject())
  3082. type = "Object";
  3083. else if(spawn->IsSign())
  3084. type = "Sign";
  3085. else if(spawn->IsWidget())
  3086. type = "Widget";
  3087. else if(spawn->IsGroundSpawn())
  3088. type = "GroundSpawn";
  3089. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3090. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3091. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3092. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3093. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3094. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3095. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3096. 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());
  3097. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3098. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3099. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3100. if(spawn->IsEntity()){
  3101. 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());
  3102. 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());
  3103. }
  3104. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3105. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3106. 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());
  3107. 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);
  3108. if (spawn->IsNPC())
  3109. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3110. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  3111. if (packet) {
  3112. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3113. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3114. packet->setDataByName("book_title", title.c_str());
  3115. packet->setDataByName("book_type", "simple");
  3116. packet->setDataByName("unknown2", 1);
  3117. packet->setDataByName("unknown5", 1, 4);
  3118. packet->setArrayLengthByName("num_pages", 4);
  3119. string details;
  3120. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3121. details += "Type: " + string(type) + "\n";
  3122. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3123. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3124. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3125. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3126. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3127. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3128. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3129. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3130. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3131. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3132. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3133. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3134. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3135. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3136. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3137. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3138. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3139. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3140. char x[16];
  3141. sprintf(x, "%.2f", spawn->GetX());
  3142. char y[16];
  3143. sprintf(y, "%.2f", spawn->GetY());
  3144. char z[16];
  3145. sprintf(z, "%.2f", spawn->GetZ());
  3146. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3147. string details2;
  3148. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3149. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3150. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3151. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3152. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3153. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3154. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3155. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3156. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3157. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3158. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3159. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3160. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3161. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3162. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3163. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3164. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3165. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3166. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3167. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3168. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3169. string details3;
  3170. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3171. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3172. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3173. string details4;
  3174. if (spawn->IsEntity()) {
  3175. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3176. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3177. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3178. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3179. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3180. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3181. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3182. if (spawn->IsNPC()) {
  3183. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3184. }
  3185. }
  3186. //details2 += "" + to_string() + "\n";
  3187. packet->setArrayDataByName("page_text", details.c_str());
  3188. packet->setArrayDataByName("page_text", details2.c_str(), 1);
  3189. packet->setArrayDataByName("page_text", details3.c_str(), 2);
  3190. packet->setArrayDataByName("page_text", details4.c_str(), 3);
  3191. client->QueuePacket(packet->serialize());
  3192. safe_delete(packet);
  3193. }
  3194. }
  3195. else {
  3196. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3197. 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.");
  3198. }
  3199. break;
  3200. }
  3201. case COMMAND_SPAWN_TARGET:{
  3202. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3203. int32 spawn_id = atoul(sep->arg[0]);
  3204. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3205. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3206. }
  3207. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3208. float distance = atof(sep->arg[1]);
  3209. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3210. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3211. }
  3212. else{
  3213. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3214. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3215. }
  3216. break;
  3217. }
  3218. case COMMAND_SPAWN_SET:
  3219. {
  3220. Spawn* spawn = cmdTarget;
  3221. sint16 set_type = -1;
  3222. string type_str;
  3223. if (spawn)
  3224. {
  3225. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3226. 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)
  3227. {
  3228. // set the type, which will be 0 if location or list or invalid
  3229. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3230. }
  3231. if(set_type > 0)
  3232. {
  3233. // check if spawn set is NOT a char update, or not location, or isn't a number
  3234. if(!(set_type >= SPAWN_SET_VALUE_PREFIX) && !(set_type <= SPAWN_SET_VALUE_LASTNAME) && 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)
  3235. {
  3236. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3237. }
  3238. else
  3239. {
  3240. string name = string(spawn->GetName());
  3241. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1]))
  3242. {
  3243. if(set_type == SPAWN_SET_VALUE_NAME)
  3244. {
  3245. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3246. }
  3247. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3248. {
  3249. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3250. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3251. }
  3252. else
  3253. {
  3254. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3255. }
  3256. if(set_type != SPAWN_SET_VALUE_FACTION)
  3257. {
  3258. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->arg[1]);
  3259. }
  3260. 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))
  3261. {
  3262. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3263. {
  3264. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3265. }
  3266. else if(spawn->GetSpawnLocationID() > 0)
  3267. {
  3268. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3269. }
  3270. }
  3271. else
  3272. {
  3273. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3274. {
  3275. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3276. }
  3277. else if(spawn->GetDatabaseID() > 0)
  3278. {
  3279. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3280. }
  3281. }
  3282. }
  3283. }
  3284. }
  3285. else if(set_type == 0)
  3286. {
  3287. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3288. map<string, int8>::iterator itr;
  3289. int i=0;
  3290. string list;
  3291. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3292. {
  3293. if(i==10)
  3294. {
  3295. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3296. i = 0;
  3297. }
  3298. if(i>0)
  3299. {
  3300. list.append(", ").append(itr->first);
  3301. }
  3302. else
  3303. {
  3304. list = itr->first;
  3305. }
  3306. }
  3307. if(list.length() > 0)
  3308. {
  3309. // if 1 or more, display in client.
  3310. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3311. }
  3312. }
  3313. else
  3314. {
  3315. // syntax fail
  3316. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3317. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3318. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3319. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3320. }
  3321. }
  3322. break;
  3323. }
  3324. case COMMAND_SPAWN_REMOVE:{
  3325. Spawn* spawn = cmdTarget;
  3326. if(spawn && !spawn->IsPlayer()){
  3327. if(spawn->GetSpawnLocationID() > 0){
  3328. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3329. bool delete_spawn = false;
  3330. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3331. if(atoi(sep->arg[0]) == 1)
  3332. delete_spawn = true;
  3333. }
  3334. if(delete_spawn)
  3335. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, false);
  3336. else
  3337. spawn->SetSpawnLocationID(0);
  3338. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3339. }
  3340. else
  3341. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3342. }
  3343. else
  3344. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3345. }
  3346. else{
  3347. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3348. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3349. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Optionally, you can supply a 1 after the command to despawn it as well. IE /spawn remove 1");
  3350. }
  3351. break;
  3352. }
  3353. case COMMAND_SPAWN_LIST:{
  3354. if(sep && sep->arg[0][0]){
  3355. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3356. vector<string>::iterator itr;
  3357. if(results){
  3358. for(itr=results->begin();itr!=results->end();itr++){
  3359. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3360. }
  3361. safe_delete(results);
  3362. }
  3363. else
  3364. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3365. }
  3366. else{
  3367. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3368. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3369. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3370. }
  3371. break;
  3372. }
  3373. case COMMAND_SPAWN_ADD:{
  3374. Spawn* spawn = cmdTarget;
  3375. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3376. if(spawn->GetSpawnLocationID() > 0){
  3377. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3378. break;
  3379. }
  3380. if(spawn->GetDatabaseID() == 0){
  3381. if(database.SaveSpawnInfo(spawn)) {
  3382. char spawn_type[32];
  3383. memset(spawn_type, 0, sizeof(spawn_type));
  3384. if (spawn->IsNPC())
  3385. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3386. else if (spawn->IsObject())
  3387. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3388. else if (spawn->IsSign())
  3389. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3390. else if (spawn->IsGroundSpawn())
  3391. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3392. else
  3393. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3394. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3395. }
  3396. else
  3397. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3398. }
  3399. int32 spawn_group_id = 0;
  3400. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3401. spawn_group_id = database.GetNextSpawnLocation();
  3402. else
  3403. spawn_group_id = atol(sep->arg[0]);
  3404. int8 percent = 100;
  3405. if(sep->arg[2] && sep->IsNumber(2))
  3406. percent = atoi(sep->arg[2]);
  3407. spawn->SetSpawnLocationID(spawn_group_id);
  3408. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3409. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3410. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3411. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3412. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3413. else
  3414. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3415. }
  3416. else{
  3417. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3418. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3419. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3420. }
  3421. break;
  3422. }
  3423. case COMMAND_SPAWN:{
  3424. int32 id = 0;
  3425. Spawn* spawn = 0;
  3426. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3427. id = atol(sep->arg[0]);
  3428. spawn = client->GetCurrentZone()->GetSpawn(id);
  3429. }
  3430. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3431. id = 0;
  3432. if(!id || !spawn){
  3433. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3434. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3435. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3436. safe_delete(sep);
  3437. return;
  3438. }
  3439. if(sep && sep->arg[1][0]){
  3440. float x = atof(sep->arg[1]);
  3441. spawn->appearance.pos.X = x;
  3442. }
  3443. else
  3444. spawn->SetX(client->GetPlayer()->GetX(), false);
  3445. if(sep && sep->arg[2][0]){
  3446. float y = atof(sep->arg[2]);
  3447. spawn->appearance.pos.Y = y;
  3448. }
  3449. else
  3450. spawn->SetY(client->GetPlayer()->GetY(), false);
  3451. if(sep && sep->arg[3][0]){
  3452. float z = atof(sep->arg[3]);
  3453. spawn->appearance.pos.Z = z;
  3454. }
  3455. else
  3456. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3457. if(sep && sep->arg[4][0]){
  3458. float heading = atof(sep->arg[4]);
  3459. spawn->SetHeading(heading);
  3460. }
  3461. else
  3462. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3463. spawn->SetSpawnOrigX(spawn->GetX());
  3464. spawn->SetSpawnOrigY(spawn->GetY());
  3465. spawn->SetSpawnOrigZ(spawn->GetZ());
  3466. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3467. if(sep && sep->arg[5][0])
  3468. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3469. else
  3470. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3471. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3472. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3473. spawn->SetHP(spawn->GetTotalHP());
  3474. }
  3475. if(spawn->GetTotalPower() == 0){
  3476. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3477. spawn->SetPower(spawn->GetTotalPower());
  3478. }
  3479. const char* script = world.GetSpawnScript(id);
  3480. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3481. spawn->SetSpawnScript(string(script));
  3482. client->GetCurrentZone()->AddSpawn(spawn);
  3483. if(spawn->IsNPC())
  3484. spawn->GetZone()->AddLoot((NPC*)spawn);
  3485. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3486. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3487. break;
  3488. }
  3489. case COMMAND_ADMINFLAG:
  3490. {
  3491. if(sep && sep->arg[0]){
  3492. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3493. sint16 new_status = atoi(sep->arg[1]);
  3494. if(tmp_status == -10)
  3495. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3496. else if(tmp_status >= client->GetAdminStatus())
  3497. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3498. else if (new_status > client->GetAdminStatus())
  3499. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3500. else{
  3501. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3502. if (!client2)
  3503. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3504. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3505. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3506. if (client2) {
  3507. client2->SetAdminStatus(new_status);
  3508. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3509. }
  3510. }
  3511. else
  3512. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3513. }
  3514. }else{
  3515. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3516. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3517. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3518. }
  3519. break;
  3520. }
  3521. case COMMAND_CANNEDEMOTE:{
  3522. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3523. break;
  3524. }
  3525. case COMMAND_BROADCAST: {
  3526. if (sep && sep->arg[0])
  3527. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3528. else
  3529. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3530. break;
  3531. }
  3532. case COMMAND_ANNOUNCE: {
  3533. if (sep && sep->arg[0])
  3534. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3535. else
  3536. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3537. break;
  3538. }
  3539. case COMMAND_RELOAD_ITEMS:{
  3540. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3541. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3542. database.ReloadItemList();
  3543. database.LoadMerchantInformation();
  3544. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3545. break;
  3546. }
  3547. case COMMAND_ENABLE_ABILITY_QUE:{
  3548. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3549. if(app)
  3550. client->QueuePacket(app);
  3551. break;
  3552. }
  3553. case COMMAND_ITEMSEARCH:{
  3554. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3555. if (packet) {
  3556. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3557. //packet->setDataByName("unknown", 1);
  3558. packet->setDataByName("unknown2", 5, 0);
  3559. packet->setDataByName("unknown2", 20, 1);
  3560. packet->setDataByName("unknown2", 58, 3);
  3561. packet->setDataByName("unknown2", 40, 4);
  3562. client->QueuePacket(packet->serialize());
  3563. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3564. if (packet2) {
  3565. packet2->setDataByName("char_id", client->GetCharacterID());
  3566. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3567. safe_delete(packet2);
  3568. }
  3569. safe_delete(packet);
  3570. }
  3571. break;
  3572. }
  3573. case COMMAND_ANIMTEST:{
  3574. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3575. if(command_packet){
  3576. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  3577. if (cmdTarget)
  3578. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  3579. command_packet->setDataByName ( "spawn_id" , id);
  3580. int animID = 1;
  3581. if(sep && sep->arg[0] && sep->IsNumber(0))
  3582. animID = atoi(sep->arg[0]);
  3583. VisualState* vs = NULL;
  3584. if(animID == 0)
  3585. {
  3586. vs = visual_states.FindVisualState(sep->arg[0]);
  3587. }
  3588. char msg[128];
  3589. sprintf(msg,"Animation Test ID: %i",animID);
  3590. command_packet->setMediumStringByName ( "emote_msg" , msg );
  3591. if(vs != NULL)
  3592. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  3593. else
  3594. command_packet->setDataByName ( "anim_type", animID );
  3595. command_packet->setDataByName ( "unknown0", 0 );
  3596. EQ2Packet* outapp = command_packet->serialize();
  3597. client->QueuePacket(outapp);
  3598. safe_delete(command_packet);
  3599. }
  3600. break;
  3601. }
  3602. case COMMAND_KICK:
  3603. {
  3604. if( sep == 0 || sep->arg[0] == 0)
  3605. {
  3606. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  3607. }
  3608. else
  3609. {
  3610. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  3611. if ( kickClient == client )
  3612. {
  3613. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  3614. break;
  3615. }
  3616. else if(kickClient != NULL)
  3617. {
  3618. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3619. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  3620. {
  3621. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3622. break;
  3623. }
  3624. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  3625. kickClient->Disconnect();
  3626. }
  3627. else
  3628. {
  3629. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3630. }
  3631. }
  3632. break;
  3633. }
  3634. case COMMAND_LOCK:
  3635. {
  3636. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  3637. int worldLocked = atoi(sep->arg[0]);
  3638. net.world_locked = worldLocked;
  3639. if ( worldLocked )
  3640. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  3641. else
  3642. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  3643. }
  3644. else
  3645. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  3646. break;
  3647. }
  3648. case COMMAND_BAN:{
  3649. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  3650. {
  3651. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  3652. }
  3653. else
  3654. {
  3655. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  3656. if ( kickClient == client )
  3657. {
  3658. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  3659. break;
  3660. }
  3661. else if(kickClient != NULL)
  3662. {
  3663. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3664. if ( maxStatus > client->GetAdminStatus( ) ||
  3665. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  3666. {
  3667. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3668. break;
  3669. }
  3670. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  3671. int perm = atol(sep->arg[1]);
  3672. if ( perm == 1 )
  3673. database.UpdateAdminStatus(sep->arg[0],-2);
  3674. else
  3675. database.UpdateAdminStatus(sep->arg[0],-1);
  3676. kickClient->Disconnect();
  3677. }
  3678. else
  3679. {
  3680. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3681. }
  3682. }
  3683. break;
  3684. }
  3685. case COMMAND_SET_COMBAT_VOICE:{
  3686. int32 value = 0;
  3687. if(sep && sep->arg[0] && sep->IsNumber(0))
  3688. value = atoi(sep->arg[0]);
  3689. client->GetPlayer()->SetCombatVoice(value);
  3690. break;
  3691. }
  3692. case COMMAND_SET_EMOTE_VOICE:{
  3693. int32 value = 0;
  3694. if(sep && sep->arg[0] && sep->IsNumber(0))
  3695. value = atoi(sep->arg[0]);
  3696. client->GetPlayer()->SetEmoteVoice(value);
  3697. break;
  3698. }
  3699. case COMMAND_GIVEITEM:{
  3700. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  3701. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  3702. if ( itemToClient == NULL )
  3703. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  3704. else
  3705. {
  3706. int32 item_id = atol(sep->arg[1]);
  3707. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  3708. itemToClient->AddItem(item_id);
  3709. }
  3710. }
  3711. else
  3712. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  3713. break;
  3714. }
  3715. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  3716. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  3717. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  3718. case COMMAND_SKILL :
  3719. case COMMAND_SKILL_ADD :
  3720. case COMMAND_SKILL_REMOVE :
  3721. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  3722. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  3723. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  3724. case COMMAND_ENTITYCOMMAND :
  3725. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  3726. case COMMAND_MERCHANT :
  3727. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  3728. case COMMAND_APPEARANCE :
  3729. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  3730. case COMMAND_TRACK : { Command_Track(client); break; }
  3731. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  3732. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  3733. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  3734. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  3735. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  3736. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  3737. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  3738. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  3739. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  3740. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  3741. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  3742. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  3743. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  3744. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  3745. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  3746. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  3747. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  3748. case COMMAND_LOCATION : { Command_Location(client); break; }
  3749. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  3750. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  3751. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  3752. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  3753. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  3754. case COMMAND_GRID : { Command_Grid(client); break; }
  3755. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  3756. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  3757. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  3758. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  3759. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  3760. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  3761. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  3762. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  3763. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  3764. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  3765. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  3766. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  3767. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  3768. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  3769. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  3770. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  3771. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  3772. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  3773. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  3774. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  3775. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  3776. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  3777. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  3778. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  3779. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  3780. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  3781. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  3782. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  3783. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  3784. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  3785. case COMMAND_MOTD : { Command_MOTD(client); break; }
  3786. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  3787. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  3788. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  3789. case COMMAND_TITLE : { Command_Title(client); break; }
  3790. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  3791. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  3792. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  3793. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  3794. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  3795. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  3796. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  3797. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  3798. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  3799. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  3800. case COMMAND_PET : { Command_Pet(client, sep); break; }
  3801. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  3802. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  3803. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  3804. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  3805. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  3806. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  3807. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  3808. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  3809. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  3810. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  3811. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  3812. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  3813. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  3814. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  3815. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  3816. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  3817. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  3818. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  3819. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  3820. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  3821. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  3822. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  3823. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  3824. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  3825. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  3826. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  3827. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  3828. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  3829. case COMMAND_MODIFY : { Command_Modify(client); break; }
  3830. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  3831. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  3832. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  3833. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  3834. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  3835. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  3836. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  3837. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  3838. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  3839. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  3840. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  3841. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  3842. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  3843. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  3844. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  3845. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  3846. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  3847. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  3848. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  3849. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  3850. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  3851. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  3852. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  3853. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  3854. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  3855. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  3856. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  3857. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  3858. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  3859. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  3860. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  3861. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  3862. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  3863. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  3864. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  3865. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  3866. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  3867. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  3868. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  3869. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  3870. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  3871. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  3872. case ADD_AA : { Add_AA(client, sep); break; }
  3873. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  3874. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  3875. case BACK_AA : { Back_AA(client, sep); break; }
  3876. case REMOVE_AA : { Remove_AA(client, sep); break; }
  3877. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  3878. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  3879. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  3880. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  3881. default:
  3882. {
  3883. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  3884. break;
  3885. }
  3886. }
  3887. safe_delete(sep);
  3888. }
  3889. /******************** New COMMAND Handler Functions ********************/
  3890. /*
  3891. Started breaking apart the huge switch() for commands into sepErate
  3892. functions so it is easier to locate the blocks of code by command
  3893. -- JA 2012.03.03
  3894. */
  3895. // sample function header
  3896. /*
  3897. Function:
  3898. Purpose :
  3899. Params :
  3900. Dev :
  3901. Example :
  3902. */
  3903. //void Commands::Command()
  3904. //{
  3905. //}
  3906. /*
  3907. Function: Command_AcceptAdvancement()
  3908. Purpose : Player accepts a new advancement option
  3909. Params : Spell ID
  3910. Dev : Jabantiz
  3911. */
  3912. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  3913. {
  3914. Player *player = client->GetPlayer();
  3915. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  3916. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  3917. if (!player->HasSpell(trait->spellID, 0, true))
  3918. {
  3919. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  3920. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  3921. }
  3922. else
  3923. {
  3924. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  3925. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  3926. player->RemoveSpellBookEntry(spell->GetSpellID());
  3927. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  3928. player->UnlockSpell(spell);
  3929. client->SendSpellUpdate(spell);
  3930. }
  3931. // Spell book update
  3932. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  3933. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  3934. }
  3935. /*
  3936. Function:
  3937. Purpose :
  3938. Params :
  3939. Dev :
  3940. Example :
  3941. */
  3942. void Commands::Command_AFK(Client* client, Seperator* sep)
  3943. {
  3944. Player* player = client->GetPlayer();
  3945. player->toggle_character_flag(CF_AFK);
  3946. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  3947. if (player->get_character_flag(CF_AFK))
  3948. {
  3949. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  3950. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  3951. if (sep && sep->argplus[0])
  3952. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  3953. else
  3954. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  3955. string message = string(player->GetName()) + " is going afk.";
  3956. Spawn* target = player->GetTarget();
  3957. if (target && target != player)
  3958. {
  3959. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  3960. player->GetGender() == 1 ? message += "he" : message += "she";
  3961. message += " is going afk.";
  3962. }
  3963. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  3964. }
  3965. /*else
  3966. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  3967. }
  3968. /*
  3969. Function: Command_Appearance()
  3970. Purpose : Handles /appearance commands
  3971. Params : list
  3972. Dev : Scatman
  3973. Example : /appearance list
  3974. */
  3975. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  3976. {
  3977. if( handler == COMMAND_APPEARANCE )
  3978. {
  3979. // /appearance command by itself shows help (to be extended)
  3980. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  3981. return;
  3982. }
  3983. else if( handler == COMMAND_APPEARANCE_LIST )
  3984. {
  3985. // /appearance list command expects "name" param
  3986. if (sep && sep->arg[0])
  3987. {
  3988. const char* appearance_name = sep->argplus[0];
  3989. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  3990. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  3991. if (appearances)
  3992. {
  3993. vector<int16>::iterator itr;
  3994. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  3995. {
  3996. int16 id = *itr;
  3997. string name = database.GetAppearanceName(id);
  3998. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  3999. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4000. }
  4001. safe_delete(appearances);
  4002. }
  4003. }
  4004. else // no param
  4005. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4006. }
  4007. }
  4008. /*
  4009. Function: Command_Claim()
  4010. Purpose :
  4011. Params :
  4012. Dev :
  4013. Example :
  4014. */
  4015. void Commands::Command_Claim(Client* client, Seperator* sep)
  4016. {
  4017. if (sep && sep->arg[0] && sep->IsNumber(0))
  4018. {
  4019. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4020. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4021. }
  4022. else
  4023. client->ShowClaimWindow();
  4024. }
  4025. /*
  4026. Function: Command_ClearAllQueued()
  4027. Purpose :
  4028. Params :
  4029. Dev :
  4030. Example :
  4031. */
  4032. void Commands::Command_ClearAllQueued(Client* client)
  4033. {
  4034. ZoneServer* zone = client->GetPlayer()->GetZone();
  4035. if (zone && zone->GetSpellProcess())
  4036. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4037. }
  4038. /*
  4039. Function: Command_CancelMaintained()
  4040. Purpose : Cancels maintained spells
  4041. Params : Maintained Spell Index
  4042. Dev : Zcoretri
  4043. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4044. */
  4045. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4046. {
  4047. if (sep && sep->arg[0] && sep->IsNumber(0))
  4048. {
  4049. int32 spell_index = atoul(sep->arg[0]);
  4050. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4051. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4052. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4053. // just not spelleffects/dets - Foof
  4054. //{
  4055. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell))
  4056. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4057. // }
  4058. //else
  4059. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4060. }
  4061. }
  4062. /*
  4063. Function: Command_Create()
  4064. Purpose : Handler for starting Tradeskilling table
  4065. Params :
  4066. Dev : Zcoretri
  4067. Example :
  4068. */
  4069. void Commands::Command_Create(Client* client, Seperator* sep)
  4070. {
  4071. PrintSep(sep, "COMMAND_CREATE");
  4072. client->SendRecipeList();
  4073. client->ShowRecipeBook();
  4074. }
  4075. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4076. {
  4077. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4078. if (sep && sep->arg[0] && sep->IsNumber(0))
  4079. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4080. }
  4081. /*
  4082. Function: Command_Distance()
  4083. Purpose : Displays distance from targeted spawn
  4084. Params :
  4085. Dev : Scatman
  4086. Example : /distance
  4087. */
  4088. void Commands::Command_Distance(Client* client)
  4089. {
  4090. Spawn* target = client->GetPlayer()->GetTarget();
  4091. if (target)
  4092. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4093. else
  4094. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4095. }
  4096. /*
  4097. Function: Command_Duel()
  4098. Purpose : Handle the /duel commands - not yet implemented
  4099. Params : unknown
  4100. Dev :
  4101. Example :
  4102. */
  4103. void Commands::Command_Duel(Client* client, Seperator* sep)
  4104. {
  4105. PrintSep(sep, "COMMAND_DUEL");
  4106. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4107. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4108. }
  4109. /*
  4110. Function: Command_DuelBet()
  4111. Purpose : Handle the /duel commands - not yet implemented
  4112. Params : unknown
  4113. Dev :
  4114. Example :
  4115. */
  4116. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4117. {
  4118. PrintSep(sep, "COMMAND_DUELBET");
  4119. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4120. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4121. }
  4122. /*
  4123. Function: Command_DuelAccept()
  4124. Purpose : Handle the /duel commands - not yet implemented
  4125. Params : unknown
  4126. Dev :
  4127. Example :
  4128. */
  4129. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4130. {
  4131. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4132. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4133. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4134. }
  4135. /*
  4136. Function: Command_DuelDecline()
  4137. Purpose : Handle the /duel commands - not yet implemented
  4138. Params : unknown
  4139. Dev :
  4140. Example :
  4141. */
  4142. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4143. {
  4144. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4145. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4146. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4147. }
  4148. /*
  4149. Function: Command_DuelSurrender()
  4150. Purpose : Handle the /duel commands - not yet implemented
  4151. Params : unknown
  4152. Dev :
  4153. Example :
  4154. */
  4155. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4156. {
  4157. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4158. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4159. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4160. // JA, just messin around ;)
  4161. char surrender[64];
  4162. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4163. zone_list.HandleGlobalAnnouncement(surrender);
  4164. }
  4165. /*
  4166. Function: Command_DuelToggle()
  4167. Purpose : Handle the /duel commands - not yet implemented
  4168. Params : unknown
  4169. Dev :
  4170. Example :
  4171. */
  4172. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4173. {
  4174. PrintSep(sep, "COMMAND_DUEL");
  4175. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4176. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4177. }
  4178. /*
  4179. Function:
  4180. Purpose :
  4181. Params :
  4182. Dev :
  4183. Example :
  4184. */
  4185. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4186. {
  4187. if( handler == COMMAND_ENTITYCOMMAND )
  4188. {
  4189. // /entitycommand command by itself shows help (to be extended)
  4190. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4191. return;
  4192. }
  4193. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4194. {
  4195. // /entitycommand list command expects "name" param
  4196. if (sep && sep->arg[0])
  4197. {
  4198. const char* entity_command_name = sep->argplus[0];
  4199. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4200. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4201. map<int32, vector<EntityCommand*>*>::iterator itr;
  4202. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4203. {
  4204. vector<EntityCommand*>* entity_command_list = itr->second;
  4205. vector<EntityCommand*>::iterator itr2;
  4206. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4207. {
  4208. EntityCommand* entity_command = *itr2;
  4209. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4210. 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);
  4211. }
  4212. }
  4213. }
  4214. else // no command name
  4215. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4216. }
  4217. }
  4218. /*
  4219. Function: Command_Follow()
  4220. Purpose : Handle the /follow command - not yet implemented
  4221. Params :
  4222. Dev :
  4223. Example :
  4224. */
  4225. void Commands::Command_Follow(Client* client, Seperator* sep)
  4226. {
  4227. PrintSep(sep, "COMMAND_FOLLOW");
  4228. // flag to toggle if the players target is in the players group
  4229. bool targetInGroup = false;
  4230. // get a pointer to the players group
  4231. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4232. // If the player has a group and has a target
  4233. if (gmi && client->GetPlayer()->GetTarget()) {
  4234. deque<GroupMemberInfo*>::iterator itr;
  4235. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4236. deque<GroupMemberInfo*>* members = world.GetGroupManager()->GetGroupMembers(gmi->group_id);
  4237. // Loop through the group members
  4238. for (itr = members->begin(); itr != members->end(); itr++) {
  4239. // If a group member matches a target
  4240. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4241. // toggle the flag and break the loop
  4242. targetInGroup = true;
  4243. break;
  4244. }
  4245. }
  4246. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4247. }
  4248. if (targetInGroup) {
  4249. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4250. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4251. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4252. client->GetPlayer()->info_changed = true;
  4253. client->GetPlayer()->changed = true;
  4254. }
  4255. else
  4256. client->Message(CHANNEL_COLOR_WHITE, "You must first select a group member to follow.");
  4257. }
  4258. /*
  4259. Function: Command_StopFollow()
  4260. Purpose : Handle the /stop_follow command - not yet implemented
  4261. Params :
  4262. Dev :
  4263. Example :
  4264. */
  4265. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4266. {
  4267. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4268. if (client->GetPlayer()->GetFollowTarget()) {
  4269. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4270. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4271. client->GetPlayer()->SetFollowTarget(0);
  4272. client->GetPlayer()->info_changed = true;
  4273. client->GetPlayer()->changed = true;
  4274. }
  4275. }
  4276. #include "../Zone/SPGrid.h"
  4277. /*
  4278. Function: Command_Grid()
  4279. Purpose : Show player's current Grid ID
  4280. Params :
  4281. Dev : Scatman
  4282. Example : /grid
  4283. */
  4284. void Commands::Command_Grid(Client* client)
  4285. {
  4286. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4287. if (client->GetCurrentZone()->Grid != nullptr) {
  4288. int32 grid = client->GetCurrentZone()->Grid->GetGridID(client->GetPlayer());
  4289. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4290. }
  4291. }
  4292. /*
  4293. Function: Command_Guild()
  4294. Purpose : Handler for all UI-related guild commands
  4295. Dev : Scatman
  4296. */
  4297. void Commands::Command_Guild(Client* client, Seperator* sep)
  4298. {
  4299. Guild* guild = client->GetPlayer()->GetGuild();
  4300. if (sep && sep->arg[0])
  4301. {
  4302. const char* command = sep->arg[0];
  4303. int32 length = strlen(command);
  4304. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4305. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4306. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4307. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4308. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4309. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4310. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4311. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4312. guild->KickGuildMember(client, sep->arg[1]);
  4313. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4314. guild->DemoteGuildMember(client, sep->arg[1]);
  4315. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4316. guild->PromoteGuildMember(client, sep->arg[1]);
  4317. else if (strncmp(command, "points", length) == 0 && guild)
  4318. {
  4319. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4320. {
  4321. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4322. {
  4323. float points = atof(sep->arg[2]);
  4324. const char* option = sep->arg[3];
  4325. const char* comment = sep->argplus[4];
  4326. if (strncmp(option, "all", strlen(option)) == 0)
  4327. guild->AddPointsToAll(client, points, comment);
  4328. else if (strncmp(option, "online", strlen(option)) == 0)
  4329. guild->AddPointsToAllOnline(client, points, comment);
  4330. else if (strncmp(option, "group", strlen(option)) == 0)
  4331. guild->AddPointsToGroup(client, points, comment);
  4332. else if (strncmp(option, "raid", strlen(option)) == 0)
  4333. guild->AddPointsToRaid(client, points, comment);
  4334. else
  4335. guild->AddPointsToGuildMember(client, points, option, comment);
  4336. }
  4337. }
  4338. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4339. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4340. else
  4341. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4342. }
  4343. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4344. guild->SetMOTD(sep->argplus[1]);
  4345. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4346. {
  4347. if (sep->arg[1])
  4348. {
  4349. const char* option = sep->arg[1];
  4350. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4351. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4352. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4353. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4354. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4355. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4356. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4357. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4358. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4359. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4360. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4361. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4362. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4363. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4364. else
  4365. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4366. }
  4367. else
  4368. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4369. }
  4370. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4371. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4372. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4373. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4374. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4375. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4376. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4377. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4378. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4379. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4380. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4381. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4382. else if (strncmp(command, "invite", length) == 0 && guild)
  4383. {
  4384. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4385. guild->InvitePlayer(client, sep->arg[1]);
  4386. else
  4387. {
  4388. Spawn* target = client->GetPlayer()->GetTarget();
  4389. if (target)
  4390. {
  4391. if (target->IsPlayer())
  4392. guild->InvitePlayer(client, target->GetName());
  4393. else
  4394. client->Message(CHANNEL_COLOR_WHITE, "%s is not a player.", target->GetName());
  4395. }
  4396. }
  4397. }
  4398. else if (strncmp(command, "accept", length) == 0)
  4399. {
  4400. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4401. if (pgi && pgi->guild && pgi->invited_by)
  4402. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4403. client->SetPendingGuildInvite(0);
  4404. }
  4405. else if (strncmp(command, "decline", length) == 0)
  4406. {
  4407. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4408. if (pgi && pgi->guild && pgi->invited_by)
  4409. {
  4410. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4411. if (client_inviter)
  4412. client_inviter->Message(CHANNEL_COLOR_WHITE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4413. }
  4414. client->SetPendingGuildInvite(0);
  4415. }
  4416. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4417. {
  4418. const char* guild_name = sep->argplus[0];
  4419. if (!guild_list.GetGuild(guild_name))
  4420. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo()->group_id);
  4421. else
  4422. client->SimpleMessage(CHANNEL_COLOR_WHITE, "A guild with that name already exists.");
  4423. }
  4424. else if (strncmp(command, "search", length) == 0)
  4425. client->ShowGuildSearchWindow();
  4426. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4427. {
  4428. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4429. if (to_guild)
  4430. to_guild->SendGuildRecruitingDetails(client);
  4431. }
  4432. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4433. {
  4434. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4435. if (to_guild)
  4436. to_guild->SendGuildRecruitingImages(client);
  4437. }
  4438. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4439. {
  4440. if (sep->arg[1])
  4441. {
  4442. const char* option = sep->arg[1];
  4443. if (strncmp(option, "toggle", strlen(option)) == 0)
  4444. guild->ToggleGuildRecruiterAdventureClass(client);
  4445. }
  4446. else
  4447. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4448. }
  4449. else if (strncmp(command, "display_heraldry", length) == 0)
  4450. {
  4451. // JA: not sure this is right...
  4452. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4453. client->GetPlayer()->SetCharSheetChanged(true);
  4454. }
  4455. else
  4456. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4457. }
  4458. }
  4459. /*
  4460. Function: Command_GuildCreate()
  4461. Purpose : Display's in-game Guild Creation window
  4462. Dev : Scatman
  4463. */
  4464. void Commands::Command_CreateGuild(Client* client)
  4465. {
  4466. client->SendGuildCreateWindow();
  4467. }
  4468. /*
  4469. Function: Command_SetGuildOfficerNote()
  4470. Purpose :
  4471. Dev : Scatman
  4472. */
  4473. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4474. {
  4475. if (sep && sep->arg[0] && sep->arg[1])
  4476. {
  4477. Guild* guild = client->GetPlayer()->GetGuild();
  4478. if (guild)
  4479. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4480. }
  4481. }
  4482. /*
  4483. Function: Command_SetGuildMemberNote()
  4484. Purpose :
  4485. Dev : Scatman
  4486. */
  4487. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4488. {
  4489. if (sep && sep->arg[0] && sep->arg[1])
  4490. {
  4491. Guild* guild = client->GetPlayer()->GetGuild();
  4492. if (guild)
  4493. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4494. }
  4495. }
  4496. /*
  4497. Function: Command_GuildSay()
  4498. Purpose :
  4499. Dev : Scatman
  4500. */
  4501. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4502. {
  4503. Guild* guild = client->GetPlayer()->GetGuild();
  4504. if (guild)
  4505. {
  4506. if (sep && sep->arg[0])
  4507. guild->HandleGuildSay(client, sep->argplus[0]);
  4508. }
  4509. else
  4510. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4511. }
  4512. /*
  4513. Function: Command_OfficerSay()
  4514. Purpose :
  4515. Dev : Scatman
  4516. */
  4517. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4518. {
  4519. Guild* guild = client->GetPlayer()->GetGuild();
  4520. if (guild)
  4521. {
  4522. if (sep && sep->arg[0])
  4523. guild->HandleOfficerSay(client, sep->argplus[0]);
  4524. }
  4525. else
  4526. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4527. }
  4528. /*
  4529. Function: Command_Guilds()
  4530. Purpose : Shows help for /guild command
  4531. Params :
  4532. Dev : Scatman
  4533. Example :
  4534. */
  4535. void Commands::Command_Guilds(Client* client)
  4536. {
  4537. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4538. }
  4539. /*
  4540. Function: Command_GuildsAdd()
  4541. Purpose : Add's players to a guild
  4542. Params : guild_name|guild_id, player name
  4543. Dev : Scatman
  4544. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4545. */
  4546. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4547. {
  4548. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4549. {
  4550. Guild* guild = 0;
  4551. bool found = true;
  4552. if (sep->IsNumber(0))
  4553. {
  4554. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4555. if (!guild)
  4556. {
  4557. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4558. found = false;
  4559. }
  4560. }
  4561. else
  4562. {
  4563. guild = guild_list.GetGuild(sep->arg[0]);
  4564. if (!guild)
  4565. {
  4566. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4567. found = false;
  4568. }
  4569. }
  4570. if (found)
  4571. {
  4572. Client* to_client = 0;
  4573. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4574. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4575. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4576. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4577. if (to_client)
  4578. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  4579. else
  4580. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4581. }
  4582. }
  4583. else
  4584. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  4585. }
  4586. /*
  4587. Function: Command_GuildsCreate()
  4588. Purpose : Creates a guild
  4589. Params : guild_name, player_name (optional)
  4590. Dev : Scatman
  4591. Example : /guilds create [guild name] (player name)
  4592. */
  4593. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  4594. {
  4595. if (sep && sep->arg[0])
  4596. {
  4597. const char* guild_name = sep->arg[0];
  4598. if (!guild_list.GetGuild(guild_name))
  4599. {
  4600. bool ret = false;
  4601. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4602. {
  4603. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4604. if (to_client)
  4605. {
  4606. world.CreateGuild(guild_name, to_client);
  4607. ret = true;
  4608. }
  4609. else
  4610. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  4611. }
  4612. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4613. {
  4614. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4615. if (to_client)
  4616. {
  4617. world.CreateGuild(guild_name, to_client);
  4618. ret = true;
  4619. }
  4620. }
  4621. else
  4622. {
  4623. world.CreateGuild(guild_name);
  4624. ret = true;
  4625. }
  4626. if (ret)
  4627. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  4628. else
  4629. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  4630. }
  4631. else
  4632. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  4633. }
  4634. else
  4635. 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.");
  4636. }
  4637. /*
  4638. Function: Command_GuildsDelete()
  4639. Purpose : Delete's a guild
  4640. Params : guild name
  4641. Dev : Scatman
  4642. Example : /guilds delete Test
  4643. */
  4644. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  4645. {
  4646. if (sep && sep->arg[0])
  4647. {
  4648. Guild* guild = 0;
  4649. bool found = true;
  4650. if (sep->IsNumber(0))
  4651. {
  4652. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4653. if (!guild)
  4654. {
  4655. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4656. found = false;
  4657. }
  4658. }
  4659. else
  4660. {
  4661. guild = guild_list.GetGuild(sep->arg[0]);
  4662. if (!guild)
  4663. {
  4664. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4665. found = false;
  4666. }
  4667. }
  4668. if (found)
  4669. {
  4670. guild->RemoveAllGuildMembers();
  4671. database.DeleteGuild(guild);
  4672. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  4673. guild_list.RemoveGuild(guild, true);
  4674. }
  4675. }
  4676. else
  4677. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  4678. }
  4679. /*
  4680. Function: Command_GuildsList()
  4681. Purpose : Lists current guilds on server
  4682. Params :
  4683. Dev : Scatman
  4684. Example : /guilds list
  4685. */
  4686. void Commands::Command_GuildsList(Client* client)
  4687. {
  4688. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  4689. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  4690. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  4691. if (guilds->size() == 0)
  4692. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  4693. else {
  4694. while (itr.Next()) {
  4695. Guild* guild = itr.second;
  4696. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  4697. }
  4698. }
  4699. }
  4700. /*
  4701. Function: Command_GuildsRemove()
  4702. Purpose : Removes a player from a guild
  4703. Params : guild name|guild id, player name
  4704. Dev : Scatman
  4705. Example : /guilds remove 1 Admin = removes Admin from guild 1
  4706. */
  4707. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  4708. {
  4709. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4710. {
  4711. Guild* guild = 0;
  4712. bool found = true;
  4713. if (sep->IsNumber(0))
  4714. {
  4715. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4716. if (!guild)
  4717. {
  4718. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4719. found = false;
  4720. }
  4721. }
  4722. else
  4723. {
  4724. guild = guild_list.GetGuild(sep->arg[0]);
  4725. if (!guild)
  4726. {
  4727. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4728. found = false;
  4729. }
  4730. }
  4731. if (found)
  4732. {
  4733. Client* to_client = 0;
  4734. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4735. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4736. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4737. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4738. if (to_client)
  4739. {
  4740. Player* to_player = to_client->GetPlayer();
  4741. if (to_player->GetGuild())
  4742. {
  4743. if (to_player->GetGuild() == guild)
  4744. {
  4745. guild->KickGuildMember(client, to_player->GetName());
  4746. }
  4747. else
  4748. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  4749. }
  4750. else
  4751. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  4752. }
  4753. else
  4754. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4755. }
  4756. }
  4757. else
  4758. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  4759. }
  4760. /*
  4761. Function: Command_InspectPlayer()
  4762. Purpose : Handle the Inspect functions
  4763. Params : Client to inspect
  4764. Dev : Scatman
  4765. Example : /inspect Scatman
  4766. */
  4767. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  4768. {
  4769. if (sep && sep->arg[0])
  4770. {
  4771. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  4772. if (inspect_client)
  4773. client->InspectPlayer(inspect_client->GetPlayer());
  4774. }
  4775. else
  4776. {
  4777. Spawn* target = client->GetPlayer()->GetTarget();
  4778. if (target && target->IsPlayer())
  4779. client->InspectPlayer((Player*)target);
  4780. }
  4781. }
  4782. /*
  4783. Function: Command_Inventory()
  4784. Purpose : Handle changes in player inventory
  4785. Params : <TBD>
  4786. Dev : All
  4787. Example : /inventory delete item_id
  4788. */
  4789. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  4790. {
  4791. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  4792. Player* player = client->GetPlayer();
  4793. if(sep && sep->arg[0][0])
  4794. {
  4795. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  4796. if(client->GetPlayer()->GetHP() == 0)
  4797. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  4798. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  4799. {
  4800. int16 index = atoi(sep->arg[1]);
  4801. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  4802. if(item)
  4803. {
  4804. if(item->GetItemScript() && lua_interface)
  4805. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  4806. int32 bag_id = item->details.inv_slot_id;
  4807. database.DeleteItem(client->GetCharacterID(), item, 0);
  4808. client->GetPlayer()->item_list.DestroyItem(index);
  4809. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4810. client->QueuePacket(outapp);
  4811. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  4812. if (outapp)
  4813. client->QueuePacket(outapp);
  4814. }
  4815. }
  4816. 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))
  4817. {
  4818. int16 from_index = atoi(sep->arg[1]);
  4819. sint16 to_slot = atoi(sep->arg[2]);
  4820. sint32 bag_id = atol(sep->arg[3]);
  4821. int8 charges = atoi(sep->arg[4]);
  4822. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  4823. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  4824. {
  4825. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  4826. return;
  4827. }
  4828. sint32 old_inventory_id = 0;
  4829. if(item)
  4830. old_inventory_id = item->details.inv_slot_id;
  4831. //autobank
  4832. if (bag_id == -3 && to_slot == -1)
  4833. {
  4834. if (player->HasFreeBankSlot())
  4835. to_slot = player->FindFreeBankSlot();
  4836. else
  4837. {
  4838. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  4839. return;
  4840. }
  4841. }
  4842. //auto inventory
  4843. if (bag_id == 0 && to_slot == -1)
  4844. {
  4845. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  4846. {
  4847. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  4848. return;
  4849. }
  4850. }
  4851. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  4852. client->QueuePacket(outapp);
  4853. //removed from bag send update
  4854. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  4855. {
  4856. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  4857. if(outapp)
  4858. client->QueuePacket(outapp);
  4859. }
  4860. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  4861. {
  4862. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  4863. if(outapp)
  4864. client->QueuePacket(outapp);
  4865. }
  4866. }
  4867. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  4868. {
  4869. if(client->GetPlayer()->EngagedInCombat())
  4870. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  4871. else
  4872. {
  4873. int16 index = atoi(sep->arg[1]);
  4874. int8 slot_id = 255;
  4875. if(sep->arg[2][0] && sep->IsNumber(2))
  4876. slot_id = atoi(sep->arg[2]);
  4877. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  4878. EQ2Packet* outapp = 0;
  4879. for(int32 i=0;i<packets.size();i++)
  4880. {
  4881. outapp = packets[i];
  4882. if(outapp)
  4883. client->QueuePacket(outapp);
  4884. }
  4885. client->GetPlayer()->ChangePrimaryWeapon();
  4886. client->GetPlayer()->ChangeSecondaryWeapon();
  4887. client->GetPlayer()->ChangeRangedWeapon();
  4888. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  4889. client->QueuePacket(characterSheetPackets);
  4890. }
  4891. }
  4892. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  4893. {
  4894. if (client->GetPlayer()->EngagedInCombat())
  4895. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  4896. else {
  4897. int16 index = atoi(sep->arg[1]);
  4898. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  4899. if (item) {
  4900. // client->GetPlayer()->item_list.DestroyItem(index);
  4901. if (item->item_sets.size() > 0) {
  4902. for (int32 i = 0; i < item->item_sets.size(); i++) {
  4903. ItemSet* set = item->item_sets[i];
  4904. if (set->item_stack_size == 0)
  4905. set->item_stack_size += 1;
  4906. client->AddItem(set->item_id, set->item_stack_size);
  4907. }
  4908. }
  4909. }
  4910. client->RemoveItem(item, 1);
  4911. }
  4912. }
  4913. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  4914. {
  4915. if(client->GetPlayer()->EngagedInCombat())
  4916. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  4917. else
  4918. {
  4919. int16 index = atoi(sep->arg[1]);
  4920. sint32 bag_id = -999;
  4921. int8 to_slot = 255;
  4922. if(sep->arg[3][0])
  4923. {
  4924. if(sep->IsNumber(2))
  4925. bag_id = atol(sep->arg[2]);
  4926. if(sep->IsNumber(3))
  4927. to_slot = atoi(sep->arg[3]);
  4928. }
  4929. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  4930. EQ2Packet* outapp = 0;
  4931. for(int32 i=0;i<packets.size();i++)
  4932. {
  4933. outapp = packets[i];
  4934. if(outapp)
  4935. client->QueuePacket(outapp);
  4936. }
  4937. client->GetPlayer()->ChangePrimaryWeapon();
  4938. client->GetPlayer()->ChangeSecondaryWeapon();
  4939. client->GetPlayer()->ChangeRangedWeapon();
  4940. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  4941. client->QueuePacket(characterSheetPackets);
  4942. }
  4943. }
  4944. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  4945. {
  4946. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4947. int16 index1 = atoi(sep->arg[1]);
  4948. int16 index2 = atoi(sep->arg[2]);
  4949. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  4950. if(outapp)
  4951. client->QueuePacket(outapp);
  4952. else
  4953. {
  4954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  4955. return;
  4956. }
  4957. }
  4958. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  4959. {
  4960. sint16 to_slot = atoi(sep->arg[1]);
  4961. sint32 bag_id = atoi(sep->arg[2]);
  4962. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  4963. if (item) {
  4964. //auto inventory
  4965. if (bag_id == 0 && to_slot == -1)
  4966. {
  4967. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  4968. {
  4969. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  4970. return;
  4971. }
  4972. // Set the slot for the item
  4973. item->details.inv_slot_id = bag_id;
  4974. item->details.slot_id = to_slot;
  4975. // Flag the item so it gets saved in its new location
  4976. item->save_needed = true;
  4977. // Add the item to its new location
  4978. player->item_list.AddItem(item);
  4979. // Remove the item from the overflow list
  4980. player->item_list.RemoveOverflowItem(item);
  4981. // Send the inventory update packet
  4982. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4983. return;
  4984. }
  4985. else if (bag_id == -3 && to_slot == -1) {
  4986. // Auto Bank
  4987. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  4988. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  4989. return;
  4990. }
  4991. item->details.inv_slot_id = bag_id;
  4992. item->details.slot_id = to_slot;
  4993. item->save_needed = true;
  4994. player->item_list.AddItem(item);
  4995. player->item_list.RemoveOverflowItem(item);
  4996. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4997. }
  4998. else if (bag_id == -4) {
  4999. // Shared Bank
  5000. if (!player->item_list.SharedBankAddAllowed(item)) {
  5001. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5002. return;
  5003. }
  5004. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5005. if (tmp_item) {
  5006. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5007. return;
  5008. }
  5009. else {
  5010. item->details.inv_slot_id = bag_id;
  5011. item->details.slot_id = to_slot;
  5012. item->save_needed = true;
  5013. player->item_list.AddItem(item);
  5014. player->item_list.RemoveOverflowItem(item);
  5015. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5016. return;
  5017. }
  5018. }
  5019. else {
  5020. // Try to get an item from the given bag id and slot id
  5021. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5022. // Check to see if we got an item, if we do send an error,
  5023. // if we don't put the overflow item into this slot
  5024. if (tmp_item) {
  5025. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5026. }
  5027. else {
  5028. item->details.inv_slot_id = bag_id;
  5029. item->details.slot_id = to_slot;
  5030. item->save_needed = true;
  5031. player->item_list.AddItem(item);
  5032. player->item_list.RemoveOverflowItem(item);
  5033. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5034. return;
  5035. }
  5036. }
  5037. }
  5038. }
  5039. }
  5040. else
  5041. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5042. }
  5043. /*
  5044. Function: Command_IRC()
  5045. Purpose : Handle the IRC functions
  5046. Params : IRC Commands
  5047. Dev : Scatman
  5048. Example : /irc say #Channel Hello World!
  5049. */
  5050. void Commands::Command_IRC(Client* client, Seperator* sep)
  5051. {
  5052. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5053. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5054. return;
  5055. }
  5056. if (sep && sep->arg[0][0]) {
  5057. if (strcasecmp(sep->arg[0], "say") == 0) {
  5058. if (sep->arg[1][0] && sep->arg[2][0]) {
  5059. if (sep->IsNumber(sep->arg[1]))
  5060. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5061. else
  5062. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5063. }
  5064. else
  5065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5066. }
  5067. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5068. if (sep->arg[1][0])
  5069. irc.JoinChannel(client, sep->arg[1]);
  5070. else
  5071. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5072. }
  5073. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5074. if (sep->arg[1][0])
  5075. irc.LeaveChannel(client, sep->arg[1]);
  5076. else
  5077. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5078. }
  5079. else if (strcasecmp(sep->arg[0], "list") == 0)
  5080. irc.ListChannels(client);
  5081. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5082. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5083. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5084. else
  5085. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5086. }
  5087. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5088. irc.DisconnectFromServer(client);
  5089. else
  5090. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5091. }
  5092. else
  5093. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5094. }
  5095. /*
  5096. Function: Command_Languages()
  5097. Purpose : Show's languages the player knows
  5098. Params :
  5099. Dev : Zcoretri
  5100. Example :
  5101. */
  5102. void Commands::Command_Languages(Client* client, Seperator* sep)
  5103. {
  5104. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5105. list<Language*>::iterator itr;
  5106. Language* language;
  5107. client->Message(CHANNEL_COLOR_WHITE, "You know the following languages:");
  5108. for(itr = languages->begin(); itr != languages->end(); itr++)
  5109. {
  5110. language = *itr;
  5111. client->Message(CHANNEL_COLOR_WHITE, "%s", language->GetName());
  5112. }
  5113. }
  5114. /*
  5115. Function: Command_SetLanguage()
  5116. Purpose : Handles language commands
  5117. Params : Language ID
  5118. Dev : Zcoretri
  5119. Example :
  5120. */
  5121. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5122. {
  5123. Player* player = client->GetPlayer();
  5124. if (sep && sep->arg[0])
  5125. {
  5126. if(!sep->IsNumber(0))
  5127. {
  5128. //String passed in
  5129. const char* value = sep->arg[0];
  5130. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5131. {
  5132. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5133. client->SendLanguagesUpdate(0);
  5134. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", value);
  5135. }
  5136. else
  5137. {
  5138. if(player->HasLanguage(value))
  5139. {
  5140. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5141. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5142. client->SendLanguagesUpdate(language->GetID());
  5143. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5144. }
  5145. else
  5146. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", value);
  5147. }
  5148. }
  5149. else
  5150. {
  5151. //Number passed in
  5152. int32 id = atoul(sep->arg[0]);
  5153. if(player->HasLanguage(id))
  5154. {
  5155. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5156. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5157. client->SendLanguagesUpdate(id);
  5158. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5159. }
  5160. else
  5161. {
  5162. Language* language = master_languages_list.GetLanguage(id);
  5163. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", language->GetName());
  5164. }
  5165. }
  5166. }
  5167. else
  5168. {
  5169. //No value was passed in
  5170. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5171. if(id > 0)
  5172. {
  5173. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5174. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking %s ", language->GetName());
  5175. }
  5176. else
  5177. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking Common");
  5178. }
  5179. }
  5180. /*
  5181. Function: Command_LastName()
  5182. Purpose : Sets player surname
  5183. Params : Name text
  5184. Dev : theFoof
  5185. Example :
  5186. */
  5187. void Commands::Command_LastName(Client* client, Seperator* sep)
  5188. {
  5189. if (!client)
  5190. return;
  5191. if (sep && sep->arg[0])
  5192. {
  5193. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5194. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5195. return;
  5196. }
  5197. client->RemovePendingLastName();
  5198. uchar* checkname = (uchar*)sep->arg[0];
  5199. bool valid_name = true;
  5200. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5201. if (!alpha_check(checkname[i])) {
  5202. valid_name = false;
  5203. break;
  5204. }
  5205. }
  5206. if (!valid_name) {
  5207. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5208. return;
  5209. }
  5210. string last_name = (string)sep->arg[0];
  5211. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5212. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5213. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5214. client->SetPendingLastName(last_name);
  5215. client->SendLastNameConfirmation();
  5216. }
  5217. else
  5218. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5219. }
  5220. }
  5221. /*
  5222. Function: Command_ConfirmLastName()
  5223. Purpose : Confirms setting of player surname
  5224. Params : Name text
  5225. Dev : theFoof
  5226. Example :
  5227. */
  5228. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5229. {
  5230. if (!client)
  5231. return;
  5232. string* name = client->GetPendingLastName();
  5233. if (name){
  5234. Player* player = client->GetPlayer();
  5235. player->SetLastName(name->c_str(), false);
  5236. client->SendTitleUpdate();
  5237. player->SetCharSheetChanged(true);
  5238. client->RemovePendingLastName();
  5239. }
  5240. }
  5241. /*
  5242. Function: Command_Location()
  5243. Purpose : Display's Help for /location commands
  5244. Params :
  5245. Dev : Scatman
  5246. Example : /location = show's help for command
  5247. */
  5248. void Commands::Command_Location(Client* client)
  5249. {
  5250. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5251. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5252. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5253. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5254. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5255. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5256. }
  5257. /*
  5258. Function: Command_LocationAdd()
  5259. Purpose : Add's a location to an existing location config
  5260. Params : location_id
  5261. Dev : Scatman
  5262. Example : /location add {location_id}
  5263. */
  5264. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5265. {
  5266. if (sep && sep->arg[0] && sep->IsNumber(0))
  5267. {
  5268. int32 location_id = atoul(sep->arg[0]);
  5269. float x = client->GetPlayer()->GetX();
  5270. float y = client->GetPlayer()->GetY();
  5271. float z = client->GetPlayer()->GetZ();
  5272. if (database.AddLocationPoint(location_id, x, y, z))
  5273. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5274. else
  5275. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5276. }
  5277. else
  5278. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5279. }
  5280. /*
  5281. Function: Command_LocationCreate()
  5282. Purpose : Creates a new location config
  5283. Params : location name, 0/1 for include_y (optional)
  5284. Dev : Scatman
  5285. Example : /location create Test 1 = creates a new location named Test with include_y True
  5286. */
  5287. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5288. {
  5289. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5290. {
  5291. const char* name = sep->arg[0];
  5292. bool include_y = false;
  5293. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5294. include_y = true;
  5295. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5296. if (location_id > 0)
  5297. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5298. else
  5299. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5300. }
  5301. else
  5302. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5303. }
  5304. /*
  5305. Function: Command_LocationDelete()
  5306. Purpose : Delete's a location config and all it's location points
  5307. Params : location_id
  5308. Dev : Scatman
  5309. Example : /location delete {location_id}
  5310. */
  5311. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5312. {
  5313. if (sep && sep->arg[0] && sep->IsNumber(0))
  5314. {
  5315. int32 location_id = atoul(sep->arg[0]);
  5316. if (database.DeleteLocation(location_id))
  5317. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5318. else
  5319. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5320. }
  5321. else
  5322. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5323. }
  5324. /*
  5325. Function: Command_LocationList()
  5326. Purpose : Display's a list of location points
  5327. Params : location_id
  5328. Dev : Scatman
  5329. Example : /location list {location_id}
  5330. */
  5331. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5332. {
  5333. if (sep && sep->arg[0])
  5334. {
  5335. const char* option = sep->arg[0];
  5336. if (strncmp(option, "locations", strlen(option)) == 0)
  5337. database.ListLocations(client);
  5338. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5339. {
  5340. int32 location_id = atoul(sep->arg[1]);
  5341. database.ListLocationPoints(client, location_id);
  5342. }
  5343. else
  5344. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5345. }
  5346. else
  5347. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5348. }
  5349. /*
  5350. Function: Command_LocationRemove()
  5351. Purpose : Removes a single location point from a location config
  5352. Params : location_point_id (gotten from /location list {id})
  5353. Dev : Scatman
  5354. Example : /location remove 1 = will remove location_point_id 1
  5355. */
  5356. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5357. {
  5358. if (sep && sep->arg[0] && sep->IsNumber(0))
  5359. {
  5360. int32 location_point_id = atoul(sep->arg[0]);
  5361. if (database.DeleteLocationPoint(location_point_id))
  5362. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5363. else
  5364. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5365. }
  5366. else
  5367. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5368. }
  5369. /*
  5370. Function: Command_Merchant()
  5371. Purpose : Handles Merchant commands
  5372. Params : list
  5373. Dev : Scatman
  5374. Example : /merchant list
  5375. */
  5376. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5377. {
  5378. if( handler == COMMAND_MERCHANT )
  5379. {
  5380. // /merchant command by itself shows help (to be extended)
  5381. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5382. return;
  5383. }
  5384. else if( handler == COMMAND_MERCHANT_LIST )
  5385. {
  5386. // /merchant list command expects "description" param
  5387. if (sep && sep->arg[0])
  5388. {
  5389. const char* merchant_description = sep->argplus[0];
  5390. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5391. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5392. map<int32, MerchantInfo*>::iterator itr;
  5393. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5394. {
  5395. string description = database.GetMerchantDescription(itr->first);
  5396. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5397. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5398. }
  5399. }
  5400. else // no description
  5401. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5402. }
  5403. }
  5404. /*
  5405. Function: Command_Modify()
  5406. Purpose : to replace our other "set" commands
  5407. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5408. Dev : John Adams
  5409. Example : /modify spell set name "Aegolism III"
  5410. */
  5411. void Commands::Command_Modify(Client* client)
  5412. {
  5413. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5414. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5415. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5416. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5417. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5418. }
  5419. /*
  5420. Function: Command_ModifySpawn()
  5421. Purpose : replace "spawn set" commands
  5422. Params : Action : the action to perform (or special handler)
  5423. : Field : the DB field to change
  5424. : Value : what to set the value to
  5425. : Target : what object to change (my target, or spawn_id)
  5426. Dev : John Adams
  5427. Example : /modify spawn set name "Lady Vox"
  5428. :
  5429. Note : Special Handlers, like "zoneto" for Signs
  5430. : /modify spawn zoneto
  5431. : Will set a sign's zone x/y/z to my current coords
  5432. */
  5433. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5434. {
  5435. PrintSep(sep, "COMMAND_MODIFY");
  5436. // need at least 2 args for a valid command
  5437. if( sep && sep->arg[1] )
  5438. {
  5439. // JA: just a quick implementation because I need it :)
  5440. if (strcmp(sep->arg[0], "zoneto") == 0)
  5441. {
  5442. if( sep->IsNumber(1) )
  5443. {
  5444. int32 spawn_id = atoul(sep->arg[1]);
  5445. float x_coord = client->GetPlayer()->GetX();
  5446. float y_coord = client->GetPlayer()->GetY();
  5447. float z_coord = client->GetPlayer()->GetZ();
  5448. float h_coord = client->GetPlayer()->GetHeading();
  5449. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5450. }
  5451. else
  5452. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5453. }
  5454. }
  5455. else
  5456. Command_Modify(client);
  5457. }
  5458. /*
  5459. Function: Command_ModifyCharacter()
  5460. Purpose : to replace our other "set" commands
  5461. Params : Action : Add, Remove
  5462. : Field : copper, silver, gold, plat
  5463. : Value : min 1, max unlimited
  5464. : Target : Self, Player
  5465. Dev : Cynnar
  5466. Example : /modify character add gold 50
  5467. : /modify character remove silver 25
  5468. */
  5469. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5470. {
  5471. PrintSep(sep, "COMMAND_MODIFY");
  5472. int64 value = 0;
  5473. Player* player = client->GetPlayer();
  5474. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5475. player = (Player*)player->GetTarget();
  5476. // need at least 2 args for a valid command
  5477. if( sep && sep->arg[1] )
  5478. {
  5479. if (strcmp(sep->arg[0], "add") == 0)
  5480. {
  5481. if (strcmp(sep->arg[1], "copper") == 0)
  5482. {
  5483. value = atoi64(sep->arg[2]);
  5484. player->AddCoins(value);
  5485. if (client->GetPlayer() == player)
  5486. {
  5487. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5488. }
  5489. else {
  5490. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5491. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5492. }
  5493. }
  5494. else if (strcmp(sep->arg[1], "silver") == 0)
  5495. {
  5496. value = atoi64(sep->arg[2]) * 100;
  5497. player->AddCoins(value);
  5498. if (client->GetPlayer() == player)
  5499. {
  5500. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5501. }
  5502. else {
  5503. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5504. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5505. }
  5506. }
  5507. else if (strcmp(sep->arg[1], "gold") == 0)
  5508. {
  5509. value = atoi64(sep->arg[2]) * 10000;
  5510. player->AddCoins(value);
  5511. if (client->GetPlayer() == player)
  5512. {
  5513. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5514. }
  5515. else {
  5516. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5517. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5518. }
  5519. }
  5520. else if (strcmp(sep->arg[1], "plat") == 0)
  5521. {
  5522. value = atoi64(sep->arg[2]) * 1000000;
  5523. player->AddCoins(value);
  5524. if (client->GetPlayer() == player)
  5525. {
  5526. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5527. }
  5528. else {
  5529. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5530. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5531. }
  5532. }
  5533. else
  5534. {
  5535. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5536. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5537. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5538. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5539. }
  5540. }
  5541. else if (strcmp(sep->arg[0], "remove") == 0)
  5542. {
  5543. if (strcmp(sep->arg[1], "copper") == 0)
  5544. {
  5545. value = atoi64(sep->arg[2]);
  5546. player->RemoveCoins(value);
  5547. if (client->GetPlayer() == player)
  5548. {
  5549. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5550. }
  5551. else {
  5552. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5553. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5554. }
  5555. }
  5556. else if (strcmp(sep->arg[1], "silver") == 0)
  5557. {
  5558. value = atoi64(sep->arg[2]) * 100;
  5559. player->RemoveCoins(value);
  5560. if (client->GetPlayer() == player)
  5561. {
  5562. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5563. }
  5564. else {
  5565. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5566. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5567. }
  5568. }
  5569. else if (strcmp(sep->arg[1], "gold") == 0)
  5570. {
  5571. value = atoi64(sep->arg[2]) * 10000;
  5572. player->RemoveCoins(value);
  5573. if (client->GetPlayer() == player)
  5574. {
  5575. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  5576. }
  5577. else {
  5578. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  5579. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5580. }
  5581. }
  5582. else if (strcmp(sep->arg[1], "plat") == 0)
  5583. {
  5584. value = atoi64(sep->arg[2]) * 1000000;
  5585. player->RemoveCoins(value);
  5586. if (client->GetPlayer() == player)
  5587. {
  5588. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  5589. }
  5590. else {
  5591. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  5592. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5593. }
  5594. }
  5595. else
  5596. {
  5597. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5598. }
  5599. }
  5600. else if (strcmp(sep->arg[0], "set") == 0) {
  5601. if (strcmp(sep->arg[1], "tslevel") == 0) {
  5602. int8 level = atoi(sep->arg[2]);
  5603. if (level > 0 && level < 256) {
  5604. if (player) {
  5605. if (client->GetPlayer() == player)
  5606. client->ChangeTSLevel(player->GetTSLevel(), level);
  5607. else
  5608. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  5609. }
  5610. }
  5611. else
  5612. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  5613. }
  5614. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  5615. int8 tsclass = atoi(sep->arg[2]);
  5616. player->SetTradeskillClass(tsclass);
  5617. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  5618. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  5619. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  5620. player->SetCharSheetChanged(true);
  5621. }
  5622. }
  5623. }
  5624. else
  5625. {
  5626. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5627. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5628. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5629. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5630. }
  5631. }
  5632. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  5633. {
  5634. PrintSep(sep, "COMMAND_MODIFY");
  5635. // need at least 2 args for a valid command
  5636. if( sep && sep->arg[1] )
  5637. {
  5638. }
  5639. else
  5640. Command_Modify(client);
  5641. }
  5642. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  5643. {
  5644. PrintSep(sep, "COMMAND_MODIFY");
  5645. // need at least 2 args for a valid command
  5646. if( sep && sep->arg[1] )
  5647. {
  5648. }
  5649. else
  5650. Command_Modify(client);
  5651. }
  5652. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  5653. {
  5654. PrintSep(sep, "COMMAND_MODIFY");
  5655. // need at least 2 args for a valid command
  5656. if( sep && sep->arg[1] )
  5657. {
  5658. }
  5659. else
  5660. Command_Modify(client);
  5661. }
  5662. /*
  5663. Function: Command_ModifyQuest()
  5664. Purpose : to list players quest and completed quests
  5665. Params : Action : list, completed
  5666. : Target : Self, Player
  5667. Dev : Cynnar
  5668. Example : /modify quest list
  5669. : /modify quest completed
  5670. */
  5671. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  5672. {
  5673. PrintSep(sep, "COMMAND_MODIFY");
  5674. int64 value = 0;
  5675. Player* player = client->GetPlayer();
  5676. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5677. player = (Player*)player->GetTarget();
  5678. // need at least 2 args for a valid command
  5679. if (sep && sep->arg[1])
  5680. {
  5681. if (strcmp(sep->arg[0], "list") == 0)
  5682. {
  5683. map<int32, Quest*>* quests = player->GetPlayerQuests();
  5684. map<int32, Quest*>::iterator itr;
  5685. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  5686. if (quests->size() == 0)
  5687. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  5688. else
  5689. {
  5690. for (itr = quests->begin(); itr != quests->end(); itr++)
  5691. {
  5692. Quest* quest = itr->second;
  5693. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5694. }
  5695. }
  5696. }
  5697. else if (strcmp(sep->arg[0], "completed") == 0)
  5698. {
  5699. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  5700. map<int32, Quest*>::iterator itr;
  5701. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  5702. if (quests->size() == 0)
  5703. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  5704. else
  5705. {
  5706. for (itr = quests->begin(); itr != quests->end(); itr++)
  5707. {
  5708. Quest* quest = itr->second;
  5709. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5710. }
  5711. }
  5712. }
  5713. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  5714. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  5715. else if (strcmp(sep->arg[0], "remove") == 0)
  5716. {
  5717. int32 quest_id = 0;
  5718. if (sep && sep->arg[1] && sep->IsNumber(1))
  5719. quest_id = atoul(sep->arg[1]);
  5720. if (quest_id > 0)
  5721. {
  5722. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  5723. {
  5724. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5725. if (quest)
  5726. if (client->GetPlayer() == player)
  5727. {
  5728. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  5729. }
  5730. else
  5731. {
  5732. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  5733. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  5734. }
  5735. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  5736. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  5737. }
  5738. client->RemovePlayerQuest(quest_id);
  5739. client->GetCurrentZone()->SendQuestUpdates(client);
  5740. }
  5741. }
  5742. else if (strcmp(sep->arg[0], "advance") == 0)
  5743. {
  5744. int32 quest_id = 0;
  5745. int32 step = 0;
  5746. if (sep && sep->arg[1] && sep->IsNumber(1))
  5747. {
  5748. quest_id = atoul(sep->arg[1]);
  5749. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5750. if (sep && sep->arg[2] && sep->IsNumber(1))
  5751. {
  5752. step = atoul(sep->arg[2]);
  5753. if (quest_id > 0 && step > 0)
  5754. {
  5755. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  5756. {
  5757. if (client)
  5758. {
  5759. client->AddPendingQuestUpdate(quest_id, step);
  5760. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  5761. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  5762. }
  5763. }
  5764. }
  5765. else
  5766. {
  5767. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  5768. }
  5769. }
  5770. else
  5771. {
  5772. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  5773. }
  5774. }
  5775. else
  5776. {
  5777. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  5778. }
  5779. }
  5780. else
  5781. {
  5782. Command_Modify(client);
  5783. }
  5784. }
  5785. else
  5786. {
  5787. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  5788. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  5789. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  5790. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  5791. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  5792. }
  5793. }
  5794. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  5795. {
  5796. PrintSep(sep, "COMMAND_MODIFY");
  5797. // need at least 2 args for a valid command
  5798. if( sep && sep->arg[1] )
  5799. {
  5800. if (strcmp(sep->arg[0], "add") == 0) {
  5801. const char* skill_name = sep->argplus[1];
  5802. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5803. if (skill) {
  5804. Player* player = 0;
  5805. Client* to_client = 0;
  5806. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5807. player = (Player*)client->GetPlayer()->GetTarget();
  5808. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5809. }
  5810. else {
  5811. player = client->GetPlayer();
  5812. to_client = client;
  5813. }
  5814. if (player)
  5815. {
  5816. if (!player->GetSkills()->HasSkill(skill->skill_id))
  5817. {
  5818. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  5819. if (to_client == client) {
  5820. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  5821. }
  5822. else {
  5823. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  5824. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  5825. }
  5826. }
  5827. else
  5828. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  5829. }
  5830. }
  5831. else
  5832. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5833. }
  5834. else if (strcmp(sep->arg[0], "remove") == 0) {
  5835. const char* skill_name = sep->argplus[1];
  5836. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5837. if (skill) {
  5838. Player* player = 0;
  5839. Client* to_client = 0;
  5840. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5841. player = (Player*)client->GetPlayer()->GetTarget();
  5842. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5843. }
  5844. else {
  5845. player = client->GetPlayer();
  5846. to_client = client;
  5847. }
  5848. if (player)
  5849. {
  5850. if (player->GetSkills()->HasSkill(skill->skill_id))
  5851. {
  5852. player->RemoveSkillFromDB(skill, true);
  5853. if (client == to_client) {
  5854. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  5855. }
  5856. else {
  5857. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  5858. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  5859. }
  5860. }
  5861. else {
  5862. if (client == to_client)
  5863. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  5864. else
  5865. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  5866. }
  5867. }
  5868. }
  5869. else
  5870. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5871. }
  5872. else if (strcmp(sep->arg[0], "set") == 0) {
  5873. if (!sep->IsNumber(2)) {
  5874. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  5875. return;
  5876. }
  5877. const char* skill_name = sep->arg[1];
  5878. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5879. if (skill) {
  5880. int16 val = atoi(sep->arg[2]);
  5881. Player* player = 0;
  5882. Client* to_client = 0;
  5883. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5884. player = (Player*)client->GetPlayer()->GetTarget();
  5885. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5886. }
  5887. else {
  5888. player = client->GetPlayer();
  5889. to_client = client;
  5890. }
  5891. if (player)
  5892. {
  5893. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  5894. player->GetSkills()->SetSkill(skill->skill_id, val);
  5895. if (client != to_client)
  5896. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  5897. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  5898. }
  5899. else {
  5900. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  5901. }
  5902. }
  5903. }
  5904. else {
  5905. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5906. }
  5907. }
  5908. else {
  5909. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  5910. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  5911. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  5912. }
  5913. }
  5914. else {
  5915. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  5916. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  5917. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  5918. }
  5919. }
  5920. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  5921. {
  5922. PrintSep(sep, "COMMAND_MODIFY");
  5923. // need at least 2 args for a valid command
  5924. if( sep && sep->arg[1] )
  5925. {
  5926. }
  5927. else
  5928. Command_Modify(client);
  5929. }
  5930. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  5931. {
  5932. PrintSep(sep, "COMMAND_MODIFY");
  5933. // need at least 2 args for a valid command
  5934. if( sep && sep->arg[1] )
  5935. {
  5936. }
  5937. else
  5938. Command_Modify(client);
  5939. }
  5940. /*
  5941. Function: Command_MOTD()
  5942. Purpose : Displays server MOTD
  5943. Params :
  5944. Dev : LethalEncounter
  5945. Example : /motd
  5946. */
  5947. void Commands::Command_MOTD(Client* client)
  5948. {
  5949. if (client)
  5950. ClientPacketFunctions::SendMOTD(client);
  5951. }
  5952. /*
  5953. Function: Command_Pet()
  5954. Purpose : Handle Pet {Command} commands
  5955. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  5956. Dev :
  5957. Example : /pet preserve_master
  5958. */
  5959. void Commands::Command_Pet(Client* client, Seperator* sep)
  5960. {
  5961. PrintSep(sep, "COMMAND_PET");
  5962. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  5963. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  5964. if (strcmp(sep->arg[0], "hide") == 0) {
  5965. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  5966. Entity* pet = client->GetPlayer()->GetDeityPet();
  5967. if (pet) {
  5968. if (pet->IsPrivateSpawn())
  5969. client->GetPlayer()->HideDeityPet(false);
  5970. else
  5971. client->GetPlayer()->HideDeityPet(true);
  5972. }
  5973. pet = client->GetPlayer()->GetCosmeticPet();
  5974. if (pet) {
  5975. if (pet->IsPrivateSpawn())
  5976. client->GetPlayer()->HideCosmeticPet(false);
  5977. else
  5978. client->GetPlayer()->HideCosmeticPet(true);
  5979. }
  5980. return;
  5981. }
  5982. // below is for all combat pets
  5983. if (!client->GetPlayer()->HasPet()) {
  5984. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  5985. return;
  5986. }
  5987. if (strcmp(sep->arg[0], "stay") == 0) {
  5988. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  5989. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  5990. client->GetPlayer()->SetCharSheetChanged(true);
  5991. if (client->GetPlayer()->GetPet())
  5992. client->GetPlayer()->GetPet()->following = false;
  5993. if (client->GetPlayer()->GetCharmedPet())
  5994. client->GetPlayer()->GetCharmedPet()->following = false;
  5995. }
  5996. else if (strcmp(sep->arg[0], "follow") == 0) {
  5997. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  5998. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  5999. client->GetPlayer()->SetCharSheetChanged(true);
  6000. }
  6001. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6002. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  6003. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6004. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  6005. }
  6006. else {
  6007. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6008. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  6009. }
  6010. client->GetPlayer()->SetCharSheetChanged(true);
  6011. }
  6012. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6013. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  6014. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6015. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  6016. }
  6017. else {
  6018. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6019. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  6020. }
  6021. client->GetPlayer()->SetCharSheetChanged(true);
  6022. }
  6023. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6024. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6025. if (client->GetPlayer()->GetPet())
  6026. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6027. if (client->GetPlayer()->GetCharmedPet())
  6028. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6029. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  6030. client->GetPlayer()->SetCharSheetChanged(true);
  6031. }
  6032. else if (strcmp(sep->arg[0], "attack") == 0) {
  6033. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6034. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6035. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6036. if (client->GetPlayer()->GetPet())
  6037. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6038. if (client->GetPlayer()->GetCharmedPet())
  6039. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6040. }
  6041. else
  6042. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6043. }
  6044. else
  6045. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6046. }
  6047. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6048. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6049. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6050. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6051. }
  6052. else
  6053. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6054. }
  6055. /*
  6056. Function: Command_PetName()
  6057. Purpose : Pet your name (???)
  6058. Params :
  6059. Dev :
  6060. Example :
  6061. */
  6062. void Commands::Command_PetName(Client* client, Seperator* sep)
  6063. {
  6064. PrintSep(sep, "COMMAND_PETNAME");
  6065. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6066. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6067. }
  6068. /*
  6069. Function: Command_NamePet()
  6070. Purpose : Name your pet
  6071. Params :
  6072. Dev :
  6073. Example :
  6074. */
  6075. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6076. {
  6077. PrintSep(sep, "COMMAND_NAME_PET");
  6078. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6079. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6080. }
  6081. /*
  6082. Function: Command_Rename()
  6083. Purpose : Renames existing pet
  6084. Params :
  6085. Dev :
  6086. Example :
  6087. */
  6088. void Commands::Command_Rename(Client* client, Seperator* sep)
  6089. {
  6090. PrintSep(sep, "COMMAND_RENAME");
  6091. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6092. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6093. }
  6094. /*
  6095. Function: Command_ConfirmRename()
  6096. Purpose : Confirms renaming your pet
  6097. Params :
  6098. Dev :
  6099. Example :
  6100. */
  6101. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6102. {
  6103. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6104. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6105. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6106. }
  6107. /*
  6108. Function: Command_PetOptions()
  6109. Purpose : Sets various pet options
  6110. Params :
  6111. Dev :
  6112. Example :
  6113. */
  6114. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6115. {
  6116. PrintSep(sep, "COMMAND_PETOPTIONS");
  6117. Player* player = client->GetPlayer();
  6118. Spawn* target = player->GetTarget();
  6119. if (!target)
  6120. return;
  6121. if (target == player->GetPet())
  6122. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6123. else if (target == player->GetCharmedPet())
  6124. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6125. else if (target == player->GetCosmeticPet())
  6126. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6127. else if (target == player->GetDeityPet())
  6128. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6129. }
  6130. /*
  6131. Function: Command_Random()
  6132. Purpose : Handles /random dice roll in-game
  6133. Params : 1-100
  6134. Dev : Scatman
  6135. Example : /randon 1 100
  6136. */
  6137. void Commands::Command_Random(Client* client, Seperator* sep)
  6138. {
  6139. char message[256] = {0};
  6140. if (sep)
  6141. {
  6142. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6143. 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])));
  6144. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6145. 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])));
  6146. else
  6147. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6148. }
  6149. else
  6150. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6151. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6152. }
  6153. /*
  6154. Function: Command_Randomize()
  6155. Purpose : Sets randomize (appearance) values for NPCs
  6156. Params : Attrib Name
  6157. Dev : Scatman
  6158. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6159. */
  6160. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6161. {
  6162. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6163. if (target)
  6164. {
  6165. if (target->IsNPC())
  6166. {
  6167. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6168. {
  6169. const char* value = sep->arg[0];
  6170. if (strncasecmp(value, "show", strlen(value)) == 0)
  6171. {
  6172. client->DisplayRandomizeFeatures(target->GetRandomize());
  6173. }
  6174. else
  6175. {
  6176. if (sep->arg[1] && sep->IsNumber(1))
  6177. {
  6178. int8 option = atoi(sep->arg[1]);
  6179. if (option == 0 || option == 1)
  6180. {
  6181. int32 feature = 0;
  6182. char feature_text[32] = {0};
  6183. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6184. feature = RANDOMIZE_GENDER;
  6185. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6186. }
  6187. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6188. feature = RANDOMIZE_RACE;
  6189. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6190. }
  6191. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6192. feature = RANDOMIZE_MODEL_TYPE;
  6193. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6194. }
  6195. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6196. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6197. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6198. }
  6199. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6200. feature = RANDOMIZE_HAIR_TYPE;
  6201. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6202. }
  6203. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6204. feature = RANDOMIZE_WING_TYPE;
  6205. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6206. }
  6207. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6208. feature = RANDOMIZE_CHEEK_TYPE;
  6209. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6210. }
  6211. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6212. feature = RANDOMIZE_CHIN_TYPE;
  6213. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6214. }
  6215. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6216. feature = RANDOMIZE_EAR_TYPE;
  6217. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6218. }
  6219. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6220. feature = RANDOMIZE_EYE_BROW_TYPE;
  6221. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6222. }
  6223. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6224. feature = RANDOMIZE_EYE_TYPE;
  6225. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6226. }
  6227. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6228. feature = RANDOMIZE_LIP_TYPE;
  6229. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6230. }
  6231. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6232. feature = RANDOMIZE_NOSE_TYPE;
  6233. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6234. }
  6235. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6236. feature = RANDOMIZE_EYE_COLOR;
  6237. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6238. }
  6239. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6240. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6241. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6242. }
  6243. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6244. feature = RANDOMIZE_HAIR_COLOR1;
  6245. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6246. }
  6247. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6248. feature = RANDOMIZE_HAIR_COLOR2;
  6249. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6250. }
  6251. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6252. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6253. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6254. }
  6255. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6256. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6257. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6258. }
  6259. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6260. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6261. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6262. }
  6263. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6264. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6265. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6266. }
  6267. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6268. feature = RANDOMIZE_SKIN_COLOR;
  6269. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6270. }
  6271. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6272. feature = RANDOMIZE_WING_COLOR1;
  6273. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6274. }
  6275. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6276. feature = RANDOMIZE_WING_COLOR2;
  6277. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6278. }
  6279. else {
  6280. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6281. 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'.");
  6282. }
  6283. if (feature > 0) {
  6284. if (option == 1) {
  6285. if (target->GetRandomize() & feature)
  6286. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6287. else {
  6288. target->AddRandomize(feature);
  6289. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6290. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6291. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6292. }
  6293. }
  6294. else {
  6295. if (target->GetRandomize() & feature) {
  6296. target->AddRandomize(-feature);
  6297. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6298. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6299. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6300. }
  6301. else
  6302. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6303. }
  6304. }
  6305. }
  6306. else
  6307. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6308. }
  6309. else
  6310. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6311. }
  6312. }
  6313. else {
  6314. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6315. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6316. 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'.");
  6317. }
  6318. }
  6319. else
  6320. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6321. }
  6322. else
  6323. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6324. }
  6325. /*
  6326. Function: Command_ShowCloak()
  6327. Purpose : Character Settings combo box for Show Cloak
  6328. Params : true/false
  6329. Dev : John Adams
  6330. Example :
  6331. */
  6332. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6333. {
  6334. Player* player = client->GetPlayer();
  6335. if (sep && sep->arg[0])
  6336. {
  6337. const char* value = sep->arg[0];
  6338. if (strncasecmp(value, "true", strlen(value)) == 0)
  6339. {
  6340. player->set_character_flag(CF_SHOW_CLOAK);
  6341. player->reset_character_flag(CF2_SHOW_RANGED);
  6342. }
  6343. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6344. player->reset_character_flag(CF_SHOW_CLOAK);
  6345. else
  6346. {
  6347. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6348. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6349. }
  6350. }
  6351. }
  6352. /*
  6353. Function: Command_ShowHelm()
  6354. Purpose : Character Settings combo box for Show Helm
  6355. Params : true/false
  6356. Dev : John Adams
  6357. Example :
  6358. */
  6359. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6360. {
  6361. Player* player = client->GetPlayer();
  6362. if (sep && sep->arg[0])
  6363. {
  6364. const char* value = sep->arg[0];
  6365. if (strncasecmp(value, "true", strlen(value)) == 0)
  6366. {
  6367. player->reset_character_flag(CF_HIDE_HELM);
  6368. player->set_character_flag(CF_HIDE_HOOD);
  6369. }
  6370. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6371. player->set_character_flag(CF_HIDE_HELM);
  6372. else
  6373. {
  6374. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6375. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6376. }
  6377. }
  6378. }
  6379. /*
  6380. Function: Command_ShowHood()
  6381. Purpose : Character Settings combo box for Show Hood
  6382. Params : true/false
  6383. Dev : John Adams
  6384. Example :
  6385. */
  6386. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6387. {
  6388. Player* player = client->GetPlayer();
  6389. if (sep && sep->arg[0])
  6390. {
  6391. const char* value = sep->arg[0];
  6392. if (strncasecmp(value, "true", strlen(value)) == 0)
  6393. {
  6394. player->reset_character_flag(CF_HIDE_HOOD);
  6395. player->set_character_flag(CF_HIDE_HELM);
  6396. }
  6397. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6398. player->set_character_flag(CF_HIDE_HOOD);
  6399. else
  6400. {
  6401. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6402. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6403. }
  6404. }
  6405. }
  6406. /*
  6407. Function: Command_ShowHoodHelm()
  6408. Purpose : Character Settings combo box for Show Helm or Hood
  6409. Params : true/false
  6410. Dev : John Adams
  6411. Example :
  6412. */
  6413. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6414. {
  6415. Player* player = client->GetPlayer();
  6416. if (sep && sep->arg[0])
  6417. {
  6418. const char* value = sep->arg[0];
  6419. if (strncasecmp(value, "true", strlen(value)) == 0)
  6420. {
  6421. player->reset_character_flag(CF_HIDE_HOOD);
  6422. player->reset_character_flag(CF_HIDE_HELM);
  6423. }
  6424. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6425. {
  6426. // don't think we ever wind up in here...
  6427. player->set_character_flag(CF_HIDE_HOOD);
  6428. player->set_character_flag(CF_HIDE_HELM);
  6429. }
  6430. else
  6431. {
  6432. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6433. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6434. }
  6435. }
  6436. }
  6437. /*
  6438. Function: Command_ShowRanged()
  6439. Purpose : Character Settings combo box for Show Ranged weapon
  6440. Params : true/false
  6441. Dev : John Adams
  6442. Example :
  6443. */
  6444. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6445. {
  6446. Player* player = client->GetPlayer();
  6447. if (sep && sep->arg[0])
  6448. {
  6449. const char* value = sep->arg[0];
  6450. if (strncasecmp(value, "true", strlen(value)) == 0)
  6451. {
  6452. player->set_character_flag(CF2_SHOW_RANGED);
  6453. player->reset_character_flag(CF_SHOW_CLOAK);
  6454. }
  6455. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6456. player->reset_character_flag(CF2_SHOW_RANGED);
  6457. else
  6458. {
  6459. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6460. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6461. }
  6462. }
  6463. }
  6464. /*
  6465. Function:
  6466. Purpose :
  6467. Params :
  6468. Dev :
  6469. Example :
  6470. */
  6471. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6472. {
  6473. Player* player = 0;
  6474. Client* to_client = 0;
  6475. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6476. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6477. switch(handler)
  6478. {
  6479. case COMMAND_SKILL:
  6480. {
  6481. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6482. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6483. break;
  6484. }
  6485. case COMMAND_SKILL_ADD:
  6486. {
  6487. if (sep && sep->arg[0])
  6488. {
  6489. const char* skill_name = sep->argplus[0];
  6490. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6491. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6492. {
  6493. player = to_client->GetPlayer();
  6494. if (player)
  6495. {
  6496. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6497. {
  6498. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6499. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6500. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6501. }
  6502. else
  6503. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6504. }
  6505. }
  6506. else if (skill) // add skill to yourself
  6507. {
  6508. player = client->GetPlayer();
  6509. if (player)
  6510. {
  6511. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6512. {
  6513. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6514. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6515. }
  6516. else
  6517. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6518. }
  6519. }
  6520. else
  6521. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6522. }
  6523. else
  6524. {
  6525. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6526. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6527. }
  6528. break;
  6529. }
  6530. case COMMAND_SKILL_REMOVE:
  6531. {
  6532. if (sep && sep->arg[0])
  6533. {
  6534. const char* skill_name = sep->argplus[0];
  6535. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6536. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6537. {
  6538. player = to_client->GetPlayer();
  6539. if (player)
  6540. {
  6541. if (player->GetSkills()->HasSkill(skill->skill_id))
  6542. {
  6543. player->RemoveSkillFromDB(skill, true);
  6544. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6545. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6546. }
  6547. else
  6548. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6549. }
  6550. }
  6551. else if(skill) // remove skill from yourself
  6552. {
  6553. Player* player = client->GetPlayer();
  6554. if (player)
  6555. {
  6556. if (player->GetSkills()->HasSkill(skill->skill_id))
  6557. {
  6558. player->RemoveSkillFromDB(skill, true);
  6559. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6560. }
  6561. else
  6562. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6563. }
  6564. }
  6565. else
  6566. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6567. }
  6568. else
  6569. {
  6570. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  6571. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6572. }
  6573. break;
  6574. }
  6575. case COMMAND_SKILL_LIST:
  6576. {
  6577. if (sep && sep->arg[0])
  6578. {
  6579. const char* skill_name = sep->argplus[0];
  6580. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  6581. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  6582. map<int32, Skill*>::iterator itr;
  6583. if (skills && skills->size() > 0)
  6584. {
  6585. for (itr = skills->begin(); itr != skills->end(); itr++)
  6586. {
  6587. Skill* skill = itr->second;
  6588. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  6589. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  6590. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  6591. }
  6592. }
  6593. }
  6594. else
  6595. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  6596. break;
  6597. }
  6598. }
  6599. }
  6600. /*
  6601. Function: Command_SpawnTemplate()
  6602. Purpose : Create or Use defined Spawn Templates
  6603. Params : create, save, rempve, list
  6604. Dev : John Adams
  6605. Example : /spawn template create "Test"
  6606. */
  6607. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  6608. {
  6609. if (sep == NULL || sep->arg[0] == NULL)
  6610. {
  6611. 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.");
  6612. return;
  6613. }
  6614. // got params, continue
  6615. const char * template_cmd = sep->arg[0];
  6616. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  6617. {
  6618. if (!sep->IsSet(1))
  6619. {
  6620. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  6621. 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.");
  6622. return;
  6623. }
  6624. map<int32, string>* template_names = 0;
  6625. if (sep->IsNumber(1))
  6626. {
  6627. int32 location_id = 0;
  6628. location_id = atoi(sep->arg[1]);
  6629. template_names = database.GetSpawnTemplateListByID(location_id);
  6630. }
  6631. else
  6632. {
  6633. const char* name = 0;
  6634. name = sep->argplus[1];
  6635. template_names = database.GetSpawnTemplateListByName(name);
  6636. }
  6637. if(!template_names)
  6638. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  6639. else
  6640. {
  6641. map<int32, string>::iterator itr;
  6642. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  6643. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  6644. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  6645. safe_delete(template_names);
  6646. }
  6647. }
  6648. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  6649. {
  6650. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6651. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  6652. {
  6653. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  6654. {
  6655. // first, lookup to see if template name already exists
  6656. const char* name = 0;
  6657. name = sep->argplus[1];
  6658. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  6659. if(!template_names)
  6660. {
  6661. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  6662. if( new_template_id > 0 )
  6663. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  6664. else
  6665. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  6666. }
  6667. else
  6668. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  6669. }
  6670. else
  6671. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  6672. }
  6673. else
  6674. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  6675. }
  6676. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  6677. {
  6678. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  6679. {
  6680. int32 template_id = 0;
  6681. template_id = atoi(sep->arg[1]);
  6682. if (database.RemoveSpawnTemplate(template_id))
  6683. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  6684. else
  6685. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  6686. }
  6687. else
  6688. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  6689. }
  6690. // Renamed create to spawn
  6691. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  6692. {
  6693. if (sep && sep->arg[1][0])
  6694. {
  6695. int32 new_location = 0;
  6696. if (sep->IsNumber(1))
  6697. {
  6698. int32 template_id = 0;
  6699. template_id = atoi(sep->arg[1]);
  6700. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  6701. if( new_location > 0 )
  6702. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  6703. else
  6704. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  6705. }
  6706. else
  6707. {
  6708. const char* name = 0;
  6709. name = sep->argplus[1];
  6710. new_location = database.CreateSpawnFromTemplateByName(client, name);
  6711. if( new_location > 0 )
  6712. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  6713. else
  6714. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  6715. }
  6716. }
  6717. else
  6718. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  6719. }
  6720. else
  6721. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  6722. }
  6723. void Commands::Command_Speed(Client* client, Seperator* sep) {
  6724. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  6725. float new_speed = atof(sep->arg[0]);
  6726. if (new_speed > 0.0f)
  6727. {
  6728. client->GetPlayer()->SetSpeed(new_speed);
  6729. client->GetPlayer()->SetCharSheetChanged(true);
  6730. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  6731. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  6732. }
  6733. else
  6734. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  6735. }
  6736. else{
  6737. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  6738. }
  6739. }
  6740. /*
  6741. Function: Command_StationMarketPlace()
  6742. Purpose : just trying to eat the console spam for now
  6743. Params :
  6744. Dev : John
  6745. */
  6746. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  6747. {
  6748. PrintSep(sep, "COMMAND_SMP");
  6749. // This will reduce the spam from once every 10 sec to once every 30 sec,
  6750. // can't seem to reduce it any more get rid of it completely...
  6751. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  6752. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  6753. if (packet) {
  6754. packet->setDataByName("account_id", client->GetAccountID());
  6755. packet->setDataByName("character_id", client->GetCharacterID());
  6756. packet->setDataByName("unknown1", 1, 5);
  6757. packet->setDataByName("unknown1", 26, 6);
  6758. packet->setDataByName("unknown2", 0xFFFFFFFF);
  6759. packet->setDataByName("unknown3", 248, 1);
  6760. client->QueuePacket(packet->serialize());
  6761. }
  6762. safe_delete(packet);
  6763. }
  6764. }
  6765. /*
  6766. Function: Command_StopDrinking()
  6767. Purpose : Stops player from auto-consuming drink
  6768. Params :
  6769. Dev : Zcoretri
  6770. Example : /stopdrinking
  6771. */
  6772. void Commands::Command_StopDrinking(Client* client)
  6773. {
  6774. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  6775. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  6776. }
  6777. /*
  6778. Function: Command_StopEating()
  6779. Purpose : Stops player from auto-consuming food
  6780. Params :
  6781. Dev : Zcoretri
  6782. Example : /stopeating
  6783. */
  6784. void Commands::Command_StopEating(Client* client)
  6785. {
  6786. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  6787. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  6788. }
  6789. /*
  6790. Function: Command_Title()
  6791. Purpose : Help for /title command
  6792. Params : n/a
  6793. Dev : Zcoretri
  6794. Example : /title
  6795. */
  6796. void Commands::Command_Title(Client* client)
  6797. {
  6798. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  6799. }
  6800. /*
  6801. Function: Command_TitleList()
  6802. Purpose : List available titles for player
  6803. Params : n/a
  6804. Dev : Zcoretri
  6805. Example : /title list
  6806. */
  6807. void Commands::Command_TitleList(Client* client)
  6808. {
  6809. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  6810. list<Title*>::iterator itr;
  6811. Title* title;
  6812. int16 i = 0;
  6813. client->Message(CHANNEL_COLOR_WHITE, "Listing available titles:");
  6814. for(itr = titles->begin(); itr != titles->end(); itr++)
  6815. {
  6816. title = *itr;
  6817. client->Message(CHANNEL_COLOR_WHITE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  6818. i++;
  6819. }
  6820. }
  6821. /*
  6822. Function: Command_TitleSetPrefix()
  6823. Purpose : Set Prefix title for player
  6824. Params : Title ID
  6825. Dev : Zcoretri
  6826. Example : /title setprefix 1
  6827. */
  6828. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  6829. {
  6830. if (sep && sep->arg[0] && sep->IsNumber(0))
  6831. {
  6832. int32 index = atoul(sep->arg[0]);
  6833. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  6834. client->SendTitleUpdate();
  6835. }
  6836. }
  6837. /*
  6838. Function: Command_TitleSetSuffix()
  6839. Purpose : Set Suffix title for player
  6840. Params : Title ID
  6841. Dev : Zcoretri
  6842. Example : /title setsuffix 1
  6843. */
  6844. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  6845. {
  6846. if (sep && sep->arg[0] && sep->IsNumber(0))
  6847. {
  6848. int32 index = atoul(sep->arg[0]);
  6849. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  6850. client->SendTitleUpdate();
  6851. }
  6852. }
  6853. /*
  6854. Function: Command_TitleFix()
  6855. Purpose : Fix title for player (???)
  6856. Params :
  6857. Dev : Zcoretri
  6858. Example :
  6859. */
  6860. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  6861. {
  6862. PrintSep(sep, "COMMAND_TITLE_FIX");
  6863. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  6864. }
  6865. /*
  6866. Function: Command_Toggle_Anonymous()
  6867. Purpose : Toggles player Anonymous
  6868. Params :
  6869. Dev : paulgh
  6870. Example : /anon
  6871. */
  6872. void Commands::Command_Toggle_Anonymous(Client* client)
  6873. {
  6874. Player* player = client->GetPlayer();
  6875. player->toggle_character_flag(CF_ANONYMOUS);
  6876. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  6877. if (player->get_character_flag(CF_ANONYMOUS))
  6878. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  6879. else
  6880. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  6881. }
  6882. /*
  6883. Function: Command_Toggle_AutoConsume()
  6884. Purpose : Toggles player food/drink auto consume
  6885. Params : unknown
  6886. Dev : paulgh
  6887. Example : /set_auto_consume
  6888. */
  6889. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  6890. {
  6891. Player* player = client->GetPlayer();
  6892. if (sep && sep->arg[0])
  6893. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  6894. if (sep && sep->arg[0] && sep->IsNumber(0))
  6895. {
  6896. int8 slot = atoi(sep->arg[0]);
  6897. int8 flag = atoi(sep->arg[1]);
  6898. if (slot == EQ2_FOOD_SLOT)
  6899. {
  6900. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  6901. player->SetCharSheetChanged(true);
  6902. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  6903. if (flag == 1)
  6904. client->Message(CHANNEL_COLOR_WHITE, "You decide to eat immediately whenever you become hungry.");
  6905. else
  6906. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the hunger.");
  6907. }
  6908. else
  6909. {
  6910. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  6911. player->SetCharSheetChanged(true);
  6912. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  6913. if (flag == 1)
  6914. client->Message(CHANNEL_COLOR_WHITE, "You decide to drink immediately whenever you become thirsty.");
  6915. else
  6916. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the thirst.");
  6917. }
  6918. }
  6919. }
  6920. /*
  6921. Function: Command_Toggle_BonusXP()
  6922. Purpose : Toggles player Bonus XP
  6923. Params :
  6924. Dev : John Adams
  6925. Example : /disable_char_bonus_exp
  6926. */
  6927. void Commands::Command_Toggle_BonusXP(Client* client)
  6928. {
  6929. Player* player = client->GetPlayer();
  6930. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  6931. player->SetCharSheetChanged(true);
  6932. }
  6933. /*
  6934. Function: Command_Toggle_CombatXP()
  6935. Purpose : Toggles player Adventure XP
  6936. Params :
  6937. Dev : John Adams
  6938. Example : /disable_combat_exp
  6939. */
  6940. void Commands::Command_Toggle_CombatXP(Client* client)
  6941. {
  6942. Player* player = client->GetPlayer();
  6943. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  6944. player->SetCharSheetChanged(true);
  6945. }
  6946. /*
  6947. Function: Command_Toggle_GMHide()
  6948. Purpose : Toggles hiding player GM status
  6949. Params :
  6950. Dev : Scatman
  6951. Example : /gm_hide
  6952. */
  6953. void Commands::Command_Toggle_GMHide(Client* client)
  6954. {
  6955. Player* player = client->GetPlayer();
  6956. player->toggle_character_flag(CF_HIDE_STATUS);
  6957. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  6958. }
  6959. /*
  6960. Function: Command_Toggle_GMVanish()
  6961. Purpose : Toggles hiding GM players from /who searches
  6962. Params :
  6963. Dev : Scatman
  6964. Example : /gm_vanish
  6965. */
  6966. void Commands::Command_Toggle_GMVanish(Client* client)
  6967. {
  6968. Player* player = client->GetPlayer();
  6969. player->toggle_character_flag(CF_GM_HIDDEN);
  6970. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  6971. }
  6972. /*
  6973. Function: Command_Toggle_Illusions()
  6974. Purpose : Toggles player illusion form
  6975. Params : not sure sep is needed, testing
  6976. Dev : paulgh
  6977. Example : /hide_illusions
  6978. */
  6979. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  6980. {
  6981. if (sep && sep->arg[0])
  6982. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  6983. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  6984. }
  6985. /*
  6986. Function: Command_Toggle_LFG()
  6987. Purpose : Toggles player LFG Flag
  6988. Params :
  6989. Dev : paulgh
  6990. Example : /lfg
  6991. */
  6992. void Commands::Command_Toggle_LFG(Client* client)
  6993. {
  6994. Player* player = client->GetPlayer();
  6995. player->toggle_character_flag(CF_LFG);
  6996. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  6997. if (player->get_character_flag(CF_LFG))
  6998. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  6999. else
  7000. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7001. }
  7002. /*
  7003. Function: Command_Toggle_LFW()
  7004. Purpose : Toggles player LFW Flag
  7005. Params :
  7006. Dev : paulgh
  7007. Example : /lfw
  7008. */
  7009. void Commands::Command_Toggle_LFW(Client* client)
  7010. {
  7011. Player* player = client->GetPlayer();
  7012. player->toggle_character_flag(CF_LFW);
  7013. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7014. if (player->get_character_flag(CF_LFW))
  7015. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7016. else
  7017. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7018. }
  7019. /*
  7020. Function: Command_Toggle_QuestXP()
  7021. Purpose : Toggles player Quest XP
  7022. Params :
  7023. Dev : John Adams
  7024. Example : /disable_quest_exp
  7025. */
  7026. void Commands::Command_Toggle_QuestXP(Client* client)
  7027. {
  7028. Player* player = client->GetPlayer();
  7029. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7030. player->SetCharSheetChanged(true);
  7031. }
  7032. /*
  7033. Function: Command_Toggle_Roleplaying()
  7034. Purpose : Toggles player Roleplaying flag
  7035. Params :
  7036. Dev : paulgh
  7037. Example : /role
  7038. */
  7039. void Commands::Command_Toggle_Roleplaying(Client* client)
  7040. {
  7041. Player* player = client->GetPlayer();
  7042. player->toggle_character_flag(CF_ROLEPLAYING);
  7043. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  7044. if (player->get_character_flag(CF_ROLEPLAYING))
  7045. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  7046. else
  7047. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  7048. }
  7049. void Commands::Command_Toggle_Duels(Client* client)
  7050. {
  7051. Player* player = client->GetPlayer();
  7052. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7053. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7054. }
  7055. void Commands::Command_Toggle_Trades(Client* client)
  7056. {
  7057. Player* player = client->GetPlayer();
  7058. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7059. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7060. }
  7061. void Commands::Command_Toggle_Guilds(Client* client)
  7062. {
  7063. Player* player = client->GetPlayer();
  7064. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7065. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7066. }
  7067. void Commands::Command_Toggle_Groups(Client* client)
  7068. {
  7069. Player* player = client->GetPlayer();
  7070. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7071. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7072. }
  7073. void Commands::Command_Toggle_Raids(Client* client)
  7074. {
  7075. Player* player = client->GetPlayer();
  7076. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7077. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7078. }
  7079. void Commands::Command_Toggle_LON(Client* client)
  7080. {
  7081. Player* player = client->GetPlayer();
  7082. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7083. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7084. }
  7085. void Commands::Command_Toggle_VoiceChat(Client* client)
  7086. {
  7087. Player* player = client->GetPlayer();
  7088. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7089. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7090. }
  7091. /*
  7092. Function: Command_TradeStart()
  7093. Purpose : Starts item/coin trade between players
  7094. Params :
  7095. Dev :
  7096. Example :
  7097. */
  7098. #include "../Trade.h"
  7099. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7100. {
  7101. PrintSep(sep, "COMMAND_START_TRADE");
  7102. Entity* trader = client->GetPlayer();
  7103. Entity* trader2 = 0;
  7104. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7105. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7106. if (spawn) {
  7107. if (spawn->IsEntity())
  7108. trader2 = (Entity*)spawn;
  7109. }
  7110. }
  7111. else if (client->GetPlayer()->GetTarget()) {
  7112. if (client->GetPlayer()->GetTarget()->IsEntity())
  7113. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7114. }
  7115. // can only trade with player or bots
  7116. if (trader && trader2) {
  7117. if (trader == trader2) {
  7118. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7119. }
  7120. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7121. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7122. if (trader->trade)
  7123. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7124. else if (trader2->trade)
  7125. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7126. else {
  7127. Trade* trade = new Trade(trader, trader2);
  7128. trader->trade = trade;
  7129. trader2->trade = trade;
  7130. }
  7131. }
  7132. else {
  7133. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  7134. }
  7135. }
  7136. else
  7137. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  7138. }
  7139. /*
  7140. Function: Command_Track()
  7141. Purpose : Starts/Stops Tracking for a player
  7142. Params :
  7143. Dev : Scatman
  7144. Example : /track
  7145. */
  7146. void Commands::Command_Track(Client* client)
  7147. {
  7148. if (!client->GetPlayer()->GetIsTracking())
  7149. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7150. else
  7151. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7152. }
  7153. /*
  7154. Function: Command_TradeAccept()
  7155. Purpose : Accepts item/coin trade between players
  7156. Params :
  7157. Dev :
  7158. Example :
  7159. */
  7160. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7161. {
  7162. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7163. Trade* trade = client->GetPlayer()->trade;
  7164. if (trade) {
  7165. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7166. if (trade_complete)
  7167. safe_delete(trade);
  7168. }
  7169. else
  7170. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7171. }
  7172. /*
  7173. Function: Command_TradeReject()
  7174. Purpose : Rejects item/coin trade between players
  7175. Params :
  7176. Dev :
  7177. Example :
  7178. */
  7179. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7180. {
  7181. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7182. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7183. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7184. }
  7185. /*
  7186. Function: Command_TradeCancel()
  7187. Purpose : Cancels item/coin trade between players
  7188. Params :
  7189. Dev :
  7190. Example :
  7191. */
  7192. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7193. {
  7194. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7195. Trade* trade = client->GetPlayer()->trade;
  7196. if (trade) {
  7197. trade->CancelTrade(client->GetPlayer());
  7198. safe_delete(trade);
  7199. }
  7200. else
  7201. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7202. }
  7203. /*
  7204. Function: Command_TradeSetCoin()
  7205. Purpose : Sets coin trade between players
  7206. Params :
  7207. Dev :
  7208. Example :
  7209. */
  7210. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7211. {
  7212. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7213. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7214. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7215. }
  7216. /*
  7217. Function: Command_TradeAddCoin()
  7218. Purpose : Adds coin to trade between players
  7219. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7220. Dev :
  7221. Example :
  7222. */
  7223. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7224. {
  7225. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7226. Trade* trade = client->GetPlayer()->trade;
  7227. if (trade) {
  7228. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7229. int32 amount = atoi(sep->arg[0]);
  7230. int64 val = 0;
  7231. switch (handler) {
  7232. case COMMAND_ADD_TRADE_COPPER:
  7233. {
  7234. val = amount;
  7235. trade->AddCoinToTrade(client->GetPlayer(), val);
  7236. break;
  7237. }
  7238. case COMMAND_ADD_TRADE_SILVER:
  7239. {
  7240. val = amount * 100;
  7241. trade->AddCoinToTrade(client->GetPlayer(), val);
  7242. break;
  7243. }
  7244. case COMMAND_ADD_TRADE_GOLD:
  7245. {
  7246. val = amount * 10000;
  7247. trade->AddCoinToTrade(client->GetPlayer(), val);
  7248. break;
  7249. }
  7250. case COMMAND_ADD_TRADE_PLAT:
  7251. {
  7252. val = amount * 1000000;
  7253. trade->AddCoinToTrade(client->GetPlayer(), val);
  7254. break;
  7255. }
  7256. default:
  7257. {
  7258. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7259. break;
  7260. }
  7261. }
  7262. }
  7263. else
  7264. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7265. }
  7266. else
  7267. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7268. }
  7269. /*
  7270. Function: Command_TradeRemoveCoin()
  7271. Purpose : Removes coin from trade between players
  7272. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7273. Dev :
  7274. Example :
  7275. */
  7276. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7277. {
  7278. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7279. Trade* trade = client->GetPlayer()->trade;
  7280. if (trade) {
  7281. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7282. int32 amount = atoi(sep->arg[0]);
  7283. int64 val = 0;
  7284. switch (handler) {
  7285. case COMMAND_REMOVE_TRADE_COPPER:
  7286. {
  7287. val = amount;
  7288. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7289. break;
  7290. }
  7291. case COMMAND_REMOVE_TRADE_SILVER:
  7292. {
  7293. val = amount * 100;
  7294. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7295. break;
  7296. }
  7297. case COMMAND_REMOVE_TRADE_GOLD:
  7298. {
  7299. val = amount * 10000;
  7300. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7301. break;
  7302. }
  7303. case COMMAND_REMOVE_TRADE_PLAT:
  7304. {
  7305. val = amount * 1000000;
  7306. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7307. break;
  7308. }
  7309. default:
  7310. {
  7311. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7312. break;
  7313. }
  7314. }
  7315. }
  7316. else
  7317. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7318. }
  7319. else
  7320. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7321. }
  7322. /*
  7323. Function: Command_TradeAddItem()
  7324. Purpose : Adds item to trade between players
  7325. Params :
  7326. Dev :
  7327. Example :
  7328. */
  7329. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7330. {
  7331. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7332. /*
  7333. arg[0] = item index
  7334. arg[1] = slot
  7335. arg[2] = quantity
  7336. */
  7337. if (!client->GetPlayer()->trade) {
  7338. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7339. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7340. return;
  7341. }
  7342. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7343. Item* item = 0;
  7344. int32 index = atoi(sep->arg[0]);
  7345. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7346. if (item) {
  7347. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7348. if (result == 1)
  7349. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7350. else if (result == 2)
  7351. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7352. else if (result == 3)
  7353. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7354. else if (result == 255)
  7355. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7356. }
  7357. else {
  7358. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7359. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7360. }
  7361. }
  7362. else
  7363. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7364. }
  7365. /*
  7366. Function: Command_TradeRemoveItem()
  7367. Purpose : Removes item from trade between players
  7368. Params :
  7369. Dev :
  7370. Example :
  7371. */
  7372. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7373. {
  7374. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7375. /*
  7376. arg[0] = trade window slot
  7377. */
  7378. Trade* trade = client->GetPlayer()->trade;
  7379. if (trade) {
  7380. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7381. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7382. }
  7383. else
  7384. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7385. }
  7386. else
  7387. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7388. }
  7389. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7390. {
  7391. Item *item = 0;
  7392. sint32 crc;
  7393. if (sep) {
  7394. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7395. if (client->GetVersion() < 1096) {
  7396. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7397. {
  7398. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7399. crc = atol(sep->arg[2]);
  7400. }
  7401. }
  7402. else {
  7403. // From the broker and links in chat
  7404. if (strcmp(sep->arg[0], "crc") == 0) {
  7405. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7406. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7407. crc = atol(sep->arg[3]);
  7408. }
  7409. }
  7410. // From inventory
  7411. if (strcmp(sep->arg[0], "dbid") == 0) {
  7412. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7413. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7414. crc = atol(sep->arg[4]);
  7415. }
  7416. }
  7417. }
  7418. if (item)
  7419. client->ShowDressingRoom(item, crc);
  7420. }
  7421. }
  7422. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7423. const char *channel_name, *password = NULL;
  7424. if (sep == NULL || !sep->IsSet(0)) {
  7425. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7426. return;
  7427. }
  7428. channel_name = sep->arg[0];
  7429. if (sep->IsSet(1))
  7430. password = sep->arg[1];
  7431. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7432. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7433. return;
  7434. }
  7435. if (chat.IsInChannel(client, channel_name)) {
  7436. client->Message(CHANNEL_COLOR_WHITE, "You are already in '%s'.", channel_name);
  7437. return;
  7438. }
  7439. if (chat.HasPassword(channel_name)) {
  7440. if (password == NULL) {
  7441. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': That channel is password protected.", channel_name);
  7442. return;
  7443. }
  7444. if (!chat.PasswordMatches(channel_name, password)) {
  7445. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': The password is not correc.t", channel_name);
  7446. return;
  7447. }
  7448. }
  7449. if (!chat.JoinChannel(client, channel_name))
  7450. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7451. }
  7452. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7453. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7454. Command_JoinChannel(client, sep);
  7455. }
  7456. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7457. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7458. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7459. PrintSep(sep, "tellchannel");
  7460. return;
  7461. }
  7462. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7463. }
  7464. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7465. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  7466. if (!p) return;
  7467. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7468. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  7469. //}
  7470. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7471. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  7472. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  7473. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  7474. if (packet) {
  7475. client->QueuePacket(packet->serialize());
  7476. safe_delete(packet);
  7477. }
  7478. }*/
  7479. /*if (client->GetCurrentZone()->Grid != nullptr) {
  7480. int32 numFaces = 0;
  7481. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  7482. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  7483. map<int32, vector<Face*> >::iterator itr;
  7484. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  7485. numFaces += (*itr).second.size();
  7486. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  7487. }*/
  7488. //uchar blah[] = {
  7489. // 1208 - OP_EQUpdateStoreCmd
  7490. // /*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
  7491. // /*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
  7492. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  7493. // /*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
  7494. /*};
  7495. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7496. int8 val = 0;
  7497. int16 pos = 0;
  7498. int idx = 0;
  7499. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  7500. pos = atoi(sep2->arg[idx]);
  7501. val = atoi(sep2->arg[idx+1]);
  7502. memset(blah+pos, val, 1);
  7503. idx+=2;
  7504. }
  7505. DumpPacket(blah, sizeof(blah));
  7506. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  7507. if (client->GetPlayer()->GetTarget()) {
  7508. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  7509. if (packet) {
  7510. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7511. packet->setDataByName("size", 0);
  7512. packet->setDataByName("unknown2", 0);
  7513. EQ2Packet* app = packet->serialize();
  7514. client->QueuePacket(app);
  7515. safe_delete(packet);
  7516. }
  7517. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  7518. if (set_pov) {
  7519. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7520. EQ2Packet* app_pov = set_pov->serialize();
  7521. client->QueuePacket(app_pov);
  7522. safe_delete(set_pov);
  7523. }
  7524. }
  7525. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7526. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  7527. if (packet) {
  7528. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  7529. packet->setDataByName("Type", atoi(sep2->arg[0]));
  7530. else
  7531. packet->setDataByName("Type", 2);
  7532. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  7533. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  7534. else
  7535. packet->setDataByName("race_id", 0);
  7536. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  7537. packet->setDataByName("gender", atoi(sep2->arg[2]));
  7538. else
  7539. packet->setDataByName("gender", 2);
  7540. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  7541. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  7542. else
  7543. packet->setDataByName("unknown", 0, 0);
  7544. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  7545. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  7546. else
  7547. packet->setDataByName("unknown", 0, 1);
  7548. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  7549. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  7550. else
  7551. packet->setDataByName("unknown", 0, 2);
  7552. client->QueuePacket(packet->serialize());
  7553. }
  7554. safe_delete(packet);
  7555. safe_delete(sep2);
  7556. }
  7557. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  7558. const char *channel_name;
  7559. if (sep == NULL || !sep->IsSet(0)) {
  7560. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  7561. PrintSep(sep);
  7562. return;
  7563. }
  7564. channel_name = sep->arg[0];
  7565. if (!chat.IsInChannel(client, channel_name))
  7566. client->Message(CHANNEL_COLOR_WHITE, "Unable to leave '%s': You are not in the channel.", channel_name);
  7567. else if (!chat.LeaveChannel(client, channel_name))
  7568. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  7569. }
  7570. /*
  7571. Function:
  7572. Purpose :
  7573. Params :
  7574. Dev :
  7575. Example :
  7576. */
  7577. void Commands::Command_WeaponStats(Client* client)
  7578. {
  7579. Player* player = client->GetPlayer();
  7580. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  7581. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  7582. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  7583. client->SimpleMessage(0, "Primary:");
  7584. if (primary) {
  7585. client->Message(0, "Name: %s", primary->name.c_str());
  7586. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  7587. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7588. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  7589. client->Message(0, "Proc Percent: %d%%", 0);
  7590. client->Message(0, "Procs Per Minute: %d", 0);
  7591. }
  7592. else {
  7593. client->SimpleMessage(0, "Name: fist");
  7594. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7595. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7596. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  7597. client->Message(0, "Proc Percent: %d%%", 0);
  7598. client->Message(0, "Procs Per Minute: %d", 0);
  7599. }
  7600. client->SimpleMessage(0, " ");
  7601. client->SimpleMessage(0, " ");
  7602. if (secondary) {
  7603. client->SimpleMessage(0, "Secondary:");
  7604. client->Message(0, "Name: %s", secondary->name.c_str());
  7605. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  7606. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  7607. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  7608. client->Message(0, "Proc Percent: %d%%", 0);
  7609. client->Message(0, "Procs Per Minute: %d", 0);
  7610. client->SimpleMessage(0, " ");
  7611. client->SimpleMessage(0, " ");
  7612. }
  7613. client->SimpleMessage(0, "Ranged:");
  7614. if (ranged) {
  7615. client->Message(0, "Name: %s", ranged->name.c_str());
  7616. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  7617. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  7618. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  7619. client->Message(0, "Proc Percent: %d%%", 0);
  7620. client->Message(0, "Procs Per Minute: %d", 0);
  7621. }
  7622. else
  7623. client->SimpleMessage(0, "None");
  7624. }
  7625. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  7626. const char *channel_name;
  7627. if (sep == NULL || !sep->IsSet(0)) {
  7628. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  7629. return;
  7630. }
  7631. channel_name = sep->arg[0];
  7632. if (!chat.ChannelExists(channel_name))
  7633. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  7634. else
  7635. chat.SendChannelUserList(client, channel_name);
  7636. }
  7637. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  7638. {
  7639. ZoneServer* zone = 0;
  7640. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  7641. if (zone_id > 0)
  7642. {
  7643. zone = zone_list.Get(zone_id, false);
  7644. if (zone)
  7645. {
  7646. zone->SetSafeX(client->GetPlayer()->GetX());
  7647. zone->SetSafeY(client->GetPlayer()->GetY());
  7648. zone->SetSafeZ(client->GetPlayer()->GetZ());
  7649. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  7650. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  7651. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  7652. else
  7653. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  7654. }
  7655. }
  7656. }
  7657. /*
  7658. Function:
  7659. Purpose :
  7660. Params :
  7661. Dev :
  7662. Example :
  7663. */
  7664. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  7665. {
  7666. ZoneInfo* zone_info = new ZoneInfo;
  7667. if (sep && sep->arg[0])
  7668. {
  7669. if (sep->IsNumber(0))
  7670. zone_info->id = atoi(sep->arg[0]);
  7671. else
  7672. zone_info->id = database.GetZoneID(sep->arg[0]);
  7673. if (zone_info->id > 0)
  7674. {
  7675. database.LoadZoneInfo(zone_info);
  7676. 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);
  7677. 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);
  7678. 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);
  7679. 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);
  7680. 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);
  7681. 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);
  7682. 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);
  7683. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  7684. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  7685. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  7686. }
  7687. else
  7688. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  7689. }
  7690. else
  7691. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  7692. safe_delete(zone_info);
  7693. }
  7694. /*
  7695. Function:
  7696. Purpose :
  7697. Params :
  7698. Dev :
  7699. Example :
  7700. */
  7701. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  7702. {
  7703. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  7704. {
  7705. ZoneServer* zone = 0;
  7706. int32 zone_id = 0;
  7707. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  7708. {
  7709. zone_id = atoi(sep->arg[0]);
  7710. zone = zone_list.Get(atoi(sep->arg[0]), false);
  7711. }
  7712. else
  7713. {
  7714. zone_id = database.GetZoneID(sep->arg[0]);
  7715. if (zone_id > 0)
  7716. zone = zone_list.Get(sep->arg[0], false);
  7717. }
  7718. if (zone_id > 0)
  7719. {
  7720. if (zone_set_values.count(string(sep->arg[1])) > 0)
  7721. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  7722. else
  7723. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  7724. }
  7725. else
  7726. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  7727. }
  7728. else
  7729. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  7730. }
  7731. void Commands::Command_Rain(Client* client, Seperator* sep) {
  7732. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  7733. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  7734. return;
  7735. }
  7736. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  7737. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  7738. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  7739. }
  7740. void Commands::Command_Wind(Client* client, Seperator* sep) {
  7741. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  7742. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  7743. return;
  7744. }
  7745. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  7746. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  7747. }
  7748. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  7749. Spawn* spawn = client->GetPlayer()->GetTarget();
  7750. if(spawn) {
  7751. client->SetMerchantTransaction(spawn);
  7752. if (spawn->GetMerchantID() > 0){
  7753. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  7754. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  7755. client->SendBuyMerchantList(sell);
  7756. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  7757. client->SendSellMerchantList(sell);
  7758. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  7759. client->SendBuyBackList(sell);
  7760. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  7761. if (packet) {
  7762. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  7763. packet->setDataByName("type", 16);
  7764. EQ2Packet* outapp = packet->serialize();
  7765. if (outapp)
  7766. client->QueuePacket(outapp);
  7767. safe_delete(packet);
  7768. }
  7769. }
  7770. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  7771. client->SendRepairList();
  7772. }
  7773. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  7774. }
  7775. void Commands::Command_Weather(Client* client, Seperator* sep)
  7776. {
  7777. //PrintSep(sep, "Weather");
  7778. if( sep && sep->arg[0] )
  7779. {
  7780. ZoneServer* zsZone = client->GetCurrentZone();
  7781. const char* value = sep->arg[0];
  7782. // process single-param commands first
  7783. if( strncasecmp(value, "details", strlen(value)) == 0 )
  7784. {
  7785. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  7786. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  7787. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  7788. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  7789. }
  7790. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  7791. {
  7792. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  7793. zsZone->ProcessWeather();
  7794. }
  7795. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  7796. {
  7797. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  7798. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  7799. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  7800. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  7801. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  7802. zsZone->SetWeatherPattern(1);
  7803. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  7804. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  7805. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  7806. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  7807. zsZone->ProcessWeather();
  7808. }
  7809. // process commands with params
  7810. if( sep->arg[1] )
  7811. {
  7812. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  7813. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  7814. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  7815. zsZone->SetWeatherType(atoi(sep->arg[1]));
  7816. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  7817. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  7818. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  7819. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  7820. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  7821. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  7822. }
  7823. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  7824. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  7825. zsZone->SetRain(zsZone->GetCurrentWeather());
  7826. }
  7827. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  7828. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  7829. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  7830. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  7831. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  7832. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  7833. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  7834. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  7835. }
  7836. }
  7837. else
  7838. {
  7839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  7840. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  7841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  7842. return;
  7843. }
  7844. }
  7845. void Commands::Command_Select(Client* client, Seperator* sep) {
  7846. if (sep && sep->arg[1]) {
  7847. Spawn* spawn = client->GetPlayer()->GetTarget();
  7848. if (spawn && strlen(sep->arg[1]) > 0)
  7849. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  7850. }
  7851. }
  7852. /*
  7853. Function: Command_ConsumeFood()
  7854. Purpose : Consume Food/Drink and apply mods
  7855. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  7856. Dev : Zcoretri
  7857. Example : /consume_food 22
  7858. */
  7859. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  7860. if (sep && sep->arg[0] && sep->IsNumber(0))
  7861. {
  7862. Player* player = client->GetPlayer();
  7863. int8 slot = atoi(sep->arg[0]);
  7864. Item* item = player->GetEquipmentList()->GetItem(slot);
  7865. if(item) {
  7866. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  7867. if(item->GetItemScript() && lua_interface){
  7868. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  7869. if (slot == 22)
  7870. client->Message(CHANNEL_COLOR_WHITE, "You eat a %s.", item->name.c_str());
  7871. else
  7872. client->Message(CHANNEL_COLOR_WHITE, "You drink a %s.", item->name.c_str());
  7873. }
  7874. }
  7875. if (item->details.count > 1) {
  7876. item->details.count -= 1;
  7877. item->save_needed = true;
  7878. }
  7879. else {
  7880. player->GetEquipmentList()->RemoveItem(slot, true);
  7881. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  7882. }
  7883. client->GetPlayer()->SetCharSheetChanged(true);
  7884. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7885. }
  7886. }
  7887. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  7888. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  7889. if (atoi(sep->arg[0]) == 1) {
  7890. client->GetPlayer()->GetInfoStruct()->vision = 4;
  7891. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  7892. client->GetPlayer()->SetCharSheetChanged(true);
  7893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  7894. }
  7895. else {
  7896. client->GetPlayer()->GetInfoStruct()->vision = 0;
  7897. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  7898. client->GetPlayer()->SetCharSheetChanged(true);
  7899. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  7900. }
  7901. }
  7902. else
  7903. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  7904. }
  7905. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  7906. {
  7907. if(sep)
  7908. {
  7909. string data;
  7910. if(sep->arg[0]){
  7911. data = string(sep->arg[0]);
  7912. }
  7913. for(int i=1;i<sep->GetMaxArgNum();i++){
  7914. if(sep->arg[i])
  7915. data.append(" ").append(sep->arg[i]);
  7916. }
  7917. const char* target_name = 0;
  7918. int32 spawn_id = 0;
  7919. if(client->GetPlayer()->GetTarget())
  7920. {
  7921. target_name = client->GetPlayer()->GetTarget()->GetName();
  7922. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  7923. }
  7924. else
  7925. target_name = "N/A";
  7926. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  7927. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  7928. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  7929. else
  7930. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  7931. }
  7932. }
  7933. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  7934. PrintSep(sep, "Command_Attune_Inv");
  7935. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  7936. // Get the item index from the first parameter
  7937. int16 index = atoi(sep->arg[0]);
  7938. // Check to see if this is a valid item index for the player, if not exit out of the function
  7939. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  7940. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  7941. return;
  7942. }
  7943. // Get the item
  7944. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  7945. if(item) {
  7946. // Valid item lets check to make sure this item is attunable, if not return out
  7947. if (!item->CheckFlag(ATTUNEABLE)) {
  7948. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  7949. return;
  7950. }
  7951. // Remove the attunable flag
  7952. item->generic_info.item_flags -= ATTUNEABLE;
  7953. // Set the attuned flag
  7954. item->generic_info.item_flags += ATTUNED;
  7955. // Flag this item for saving
  7956. item->save_needed = true;
  7957. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  7958. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  7959. EQ2Packet* outapp = 0;
  7960. for (int32 i=0;i<packets.size();i++) {
  7961. outapp = packets[i];
  7962. if(outapp)
  7963. client->QueuePacket(outapp);
  7964. }
  7965. }
  7966. }
  7967. }
  7968. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  7969. PrintSep(sep, "Command_Reset_Zone_Timer");
  7970. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  7971. int32 db_id = atoul(sep->arg[0]);
  7972. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  7973. if (data) {
  7974. // TODO: add a check to timers to ensure it can be reset
  7975. // Delete the character from the instance
  7976. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  7977. data->instance_id = 0;
  7978. // Update the success time and set to 0 so the player can enter it again
  7979. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  7980. data->last_success_timestamp = 0;
  7981. }
  7982. }*/
  7983. }
  7984. void Commands::Command_Player(Client* client, Seperator* sep) {
  7985. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  7986. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  7987. }
  7988. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  7989. // /player coins add 10
  7990. // /player coins add plat 10
  7991. Player* player = client->GetPlayer();
  7992. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7993. player = (Player*)player->GetTarget();
  7994. if (sep && sep->arg[0] && sep->arg[1]) {
  7995. const char* action = sep->arg[0];
  7996. int64 value = 0;
  7997. if (strncasecmp(action, "add", strlen(action)) == 0) {
  7998. if (sep->IsNumber(1)) {
  7999. value = atoi64(sep->arg[1]);
  8000. player->AddCoins(value);
  8001. if (client->GetPlayer() == player)
  8002. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  8003. else {
  8004. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  8005. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  8006. }
  8007. return;
  8008. }
  8009. else if (sep->arg[2] && sep->IsNumber(2)) {
  8010. const char* type = sep->arg[1];
  8011. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  8012. value = atoi64(sep->arg[2]);
  8013. }
  8014. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  8015. value = atoi64(sep->arg[2]) * 100;
  8016. }
  8017. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  8018. value = atoi64(sep->arg[2]) * 10000;
  8019. }
  8020. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  8021. value = atoi64(sep->arg[2]) * 1000000;
  8022. }
  8023. player->AddCoins(value);
  8024. if (client->GetPlayer() == player)
  8025. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  8026. else {
  8027. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  8028. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  8029. }
  8030. return;
  8031. }
  8032. }
  8033. }
  8034. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  8035. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  8036. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  8037. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  8038. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  8039. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  8040. }
  8041. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  8042. PrintSep(sep, "ACHIEVEMENT_ADD");
  8043. if (sep && sep->IsSet(0)) {
  8044. int32 spell_id = atoul(sep->arg[1]);
  8045. int8 spell_tier = 0;
  8046. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  8047. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  8048. // addspellbookentry here
  8049. if (spell_tier >= data->maxRank) {
  8050. return;
  8051. }
  8052. if (!spell_tier) {
  8053. spell_tier = 1;
  8054. }
  8055. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  8056. {
  8057. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8058. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8059. client->GetPlayer()->UnlockSpell(spell);
  8060. client->SendSpellUpdate(spell);
  8061. }
  8062. else
  8063. {
  8064. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  8065. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  8066. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  8067. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8068. client->GetPlayer()->UnlockSpell(spell);
  8069. client->SendSpellUpdate(spell);
  8070. }
  8071. // cast spell here
  8072. if (!spell_tier)
  8073. spell_tier = 1;
  8074. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8075. if (spell) {
  8076. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  8077. }
  8078. }
  8079. else {
  8080. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  8081. }
  8082. master_aa_list.DisplayAA(client, 0, 0);
  8083. }
  8084. void Commands::Command_Editor(Client* client, Seperator* sep) {
  8085. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  8086. if (packet) {
  8087. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  8088. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  8089. char command[255];
  8090. url = "browser " + url;
  8091. int32 spawn_id = 0;
  8092. int32 zone_id = 0;
  8093. string type;
  8094. if (client->GetCurrentZone())
  8095. zone_id = client->GetCurrentZone()->GetZoneID();
  8096. if (client->GetPlayer()->GetTarget()) {
  8097. Spawn* target = client->GetPlayer()->GetTarget();
  8098. if (target->IsWidget())
  8099. type = "widgets";
  8100. else if (target->IsSign())
  8101. type = "signs";
  8102. else if (target->IsObject())
  8103. type = "objects";
  8104. else if (target->IsNPC())
  8105. type = "npcs";
  8106. else if (target->IsGroundSpawn())
  8107. type = "ground";
  8108. else
  8109. type = "spawn";
  8110. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  8111. }
  8112. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  8113. packet->setDataByName("accept_command", command);
  8114. }
  8115. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  8116. char command[255];
  8117. url = "browser " + url;
  8118. if (client->GetPlayer()->GetTarget())
  8119. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  8120. packet->setDataByName("accept_command", command);
  8121. }
  8122. else {
  8123. string command = "browser " + url;
  8124. packet->setDataByName("accept_command", command.c_str());
  8125. }
  8126. packet->setDataByName("text", "Open the web editor?");
  8127. packet->setDataByName("accept_text", "Open");
  8128. packet->setDataByName("cancel_text", "Cancel");
  8129. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  8130. packet->setDataByName("unknown2", 50);
  8131. packet->setDataByName("unknown4", 1);
  8132. client->QueuePacket(packet->serialize());
  8133. safe_delete(packet);
  8134. }
  8135. }
  8136. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  8137. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  8138. return;
  8139. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  8140. if(client->GetCurrentRez()->active)
  8141. client->AcceptResurrection();
  8142. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  8143. }
  8144. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  8145. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  8146. return;
  8147. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  8148. if(client->GetCurrentRez()->active)
  8149. client->GetCurrentRez()->should_delete = true;
  8150. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  8151. }
  8152. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  8153. PrintSep(sep, "Switch_AA_Profile");
  8154. if (sep && sep->IsSet(0)) {
  8155. string type = sep->arg[0];
  8156. int8 newtemplate = atoul(sep->arg[1]);
  8157. master_aa_list.DisplayAA(client, newtemplate, 1);
  8158. }
  8159. }
  8160. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  8161. PrintSep(sep, "Get_AA_Xml");
  8162. if (sep && sep->IsSet(0)) {
  8163. string tabnum = sep->arg[0];
  8164. string spellid = sep->arg[1];
  8165. }
  8166. }
  8167. void Commands::Add_AA(Client* client, Seperator* sep) {
  8168. PrintSep(sep, "Add_AA");
  8169. if (sep && sep->IsSet(0)) {
  8170. int32 spell_id = atoul(sep->arg[1]);
  8171. int8 spell_tier = 0;
  8172. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  8173. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  8174. // addspellbookentry here
  8175. if (spell_tier >= data->maxRank) {
  8176. return;
  8177. }
  8178. if (!spell_tier) {
  8179. spell_tier = 1;
  8180. }
  8181. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  8182. {
  8183. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8184. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8185. client->GetPlayer()->UnlockSpell(spell);
  8186. client->SendSpellUpdate(spell);
  8187. }
  8188. else
  8189. {
  8190. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  8191. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  8192. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  8193. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8194. client->GetPlayer()->UnlockSpell(spell);
  8195. client->SendSpellUpdate(spell);
  8196. }
  8197. // cast spell here
  8198. if (!spell_tier)
  8199. spell_tier = 1;
  8200. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8201. if (spell) {
  8202. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  8203. }
  8204. }
  8205. else {
  8206. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  8207. }
  8208. master_aa_list.DisplayAA(client, 0, 0);
  8209. }
  8210. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  8211. PrintSep(sep, "Commit_AA_Profile");
  8212. if (sep && sep->IsSet(0)) {
  8213. }
  8214. }
  8215. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  8216. PrintSep(sep, "Begin_AA_Profile");
  8217. if (sep && sep->IsSet(0)) {
  8218. master_aa_list.DisplayAA(client, 100, 2);
  8219. }
  8220. }
  8221. void Commands::Back_AA(Client* client, Seperator* sep) {
  8222. if (sep && sep->IsSet(0)) {
  8223. PrintSep(sep, "Back_AA");
  8224. }
  8225. }
  8226. void Commands::Remove_AA(Client* client, Seperator* sep) {
  8227. if (sep && sep->IsSet(0)) {
  8228. PrintSep(sep, "Remove_AA");
  8229. }
  8230. }
  8231. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  8232. MasterAAList master_aa_list;
  8233. PrintSep(sep, "Cancel_AA_Profile");
  8234. master_aa_list.DisplayAA(client, 0, 0);
  8235. }
  8236. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  8237. if (sep && sep->IsSet(0)) {
  8238. PrintSep(sep, "Save_AA_Profile");
  8239. }
  8240. }
  8241. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  8242. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  8243. if (!sep->IsNumber(0)) return;
  8244. int32 request_id = atoul(sep->arg[0]);
  8245. if (!sep->IsNumber(1)) return;
  8246. sint32 item_id = atoi(sep->arg[1]);
  8247. if (client->IsCurrentTransmuteID(request_id)) {
  8248. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  8249. }
  8250. else if (client->IsCurrentTransmuteID(item_id)) {
  8251. if (!sep->IsSet(2)) return;
  8252. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  8253. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  8254. }
  8255. }
  8256. }