Commands.cpp 310 KB

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