Commands.cpp 319 KB

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