Commands.cpp 364 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include "Commands.h"
  18. #include "../ClientPacketFunctions.h"
  19. #include "../../common/version.h"
  20. #include "../../common/seperator.h"
  21. #include "../../common/servertalk.h"
  22. #include "../WorldDatabase.h"
  23. #include "../World.h"
  24. #include "../../common/ConfigReader.h"
  25. #include "../VisualStates.h"
  26. #include "../../common/debug.h"
  27. #include "../LuaInterface.h"
  28. #include "../Quests.h"
  29. #include "../client.h"
  30. #include "../NPC.h"
  31. #include "../Guilds/Guild.h"
  32. #include "../SpellProcess.h"
  33. #include "../Tradeskills/Tradeskills.h"
  34. #include "../../common/Log.h"
  35. #include "../../common/MiscFunctions.h"
  36. #include "../Languages.h"
  37. #include "../IRC/IRC.h"
  38. #include "../Traits/Traits.h"
  39. #include "../Chat/Chat.h"
  40. #include "../Rules/Rules.h"
  41. #include "../AltAdvancement/AltAdvancement.h"
  42. #include "../RaceTypes/RaceTypes.h"
  43. #include "../classes.h"
  44. #include "../Transmute.h"
  45. #include "../Zone/SPGrid.h"
  46. extern WorldDatabase database;
  47. extern MasterSpellList master_spell_list;
  48. extern MasterTraitList master_trait_list;
  49. extern MasterRecipeList master_recipe_list;
  50. extern MasterRecipeBookList master_recipebook_list;
  51. extern World world;
  52. extern ClientList client_list;
  53. extern ConfigReader configReader;
  54. extern VisualStates visual_states;
  55. extern ZoneList zone_list;
  56. extern LuaInterface* lua_interface;
  57. extern MasterQuestList master_quest_list;
  58. extern MasterCollectionList master_collection_list;
  59. extern MasterSkillList master_skill_list;
  60. extern MasterFactionList master_faction_list;
  61. extern GuildList guild_list;
  62. extern MasterLanguagesList master_languages_list;
  63. extern IRC irc;
  64. extern Chat chat;
  65. extern RuleManager rule_manager;
  66. extern MasterAAList master_aa_list;
  67. extern MasterRaceTypeList race_types_list;
  68. extern Classes classes;
  69. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  70. #if defined(__GNUC__)
  71. #define stricmp strcasecmp
  72. #define strnicmp strncasecmp
  73. #endif
  74. EQ2Packet* RemoteCommands::serialize(){
  75. buffer.clear();
  76. vector<EQ2_RemoteCommandString>::iterator command_list;
  77. buffer.append((char*)&num_commands, sizeof(int16));
  78. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  79. AddDataCommand(&(*command_list));
  80. }
  81. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  82. return app;
  83. }
  84. Commands::Commands(){
  85. remote_commands = new RemoteCommands();
  86. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  87. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  88. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  89. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  90. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  91. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  92. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  93. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  94. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  95. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  96. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  97. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  98. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  99. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  100. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  101. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  102. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  103. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  104. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  105. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  106. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  107. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  108. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  109. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  110. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  111. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  112. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  113. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  114. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  115. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  116. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  117. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  118. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  119. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  120. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  121. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  122. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  123. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  124. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  125. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  126. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  127. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  128. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  129. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  130. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  131. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  132. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  133. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  134. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  135. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  136. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  137. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  138. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  139. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  140. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  141. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  142. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  143. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  144. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  145. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  146. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  147. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  148. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  149. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  150. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  151. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  152. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  153. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  154. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  155. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  156. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  157. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  158. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  159. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  160. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  161. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  162. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  163. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  164. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  165. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  166. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  167. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  168. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  169. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  170. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  171. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  172. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  173. }
  174. Commands::~Commands() {
  175. safe_delete(remote_commands);
  176. }
  177. int32 Commands::GetSpawnSetType(string val){
  178. if(spawn_set_values.count(val) > 0)
  179. return spawn_set_values[val];
  180. return 0xFFFFFFFF;
  181. }
  182. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  183. if(!target)
  184. return false;
  185. int32 val = 0;
  186. try{
  187. if(type != SPAWN_SET_VALUE_NAME && !(type >= SPAWN_SET_VALUE_SPAWN_SCRIPT && type <= SPAWN_SET_VALUE_SUB_TITLE) && !(type >= SPAWN_SET_VALUE_PREFIX && type <= SPAWN_SET_VALUE_EXPANSION_FLAG || type == SPAWN_SET_VALUE_HOLIDAY_FLAG))
  188. val = atoul(value);
  189. }
  190. catch(...){
  191. if(client)
  192. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  193. return false;
  194. }
  195. if(temporary && temp_value){
  196. char tmp[128] = {0};
  197. switch(type){
  198. case SPAWN_SET_VALUE_NAME:{
  199. sprintf(tmp, "%s", target->GetName());
  200. target->SetName(value);
  201. client->GetCurrentZone()->SendUpdateTitles(target);
  202. break;
  203. }
  204. case SPAWN_SET_VALUE_X_OFFSET:
  205. {
  206. sprintf(tmp, "%f", target->GetXOffset());
  207. target->SetXOffset(float(val));
  208. break;
  209. }
  210. case SPAWN_SET_VALUE_Y_OFFSET:
  211. {
  212. sprintf(tmp, "%f", target->GetYOffset());
  213. target->SetYOffset(float(val));
  214. break;
  215. }
  216. case SPAWN_SET_VALUE_Z_OFFSET:
  217. {
  218. sprintf(tmp, "%f", target->GetZOffset());
  219. target->SetZOffset(float(val));
  220. break;
  221. }
  222. case SPAWN_SET_VALUE_EXPIRE: {
  223. sprintf(tmp, "%u", target->GetExpireTime());
  224. target->SetExpireTime(val);
  225. break;
  226. }
  227. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  228. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  229. target->SetExpireOffsetTime(val);
  230. break;
  231. }
  232. case SPAWN_SET_VALUE_SUB_TITLE: {
  233. sprintf(tmp, "%s", target->GetSubTitle());
  234. target->SetSubTitle(value);
  235. client->GetCurrentZone()->SendUpdateTitles(target);
  236. break;
  237. }
  238. case SPAWN_SET_VALUE_LEVEL:{
  239. sprintf(tmp, "%i", target->GetLevel());
  240. target->SetLevel(val, send_update);
  241. break;
  242. }
  243. case SPAWN_SET_VALUE_DIFFICULTY:{
  244. sprintf(tmp, "%i", target->GetEncounterLevel());
  245. target->SetEncounterLevel(val, send_update);
  246. break;
  247. }
  248. case SPAWN_SET_VALUE_MODEL_TYPE:{
  249. sprintf(tmp, "%i", target->GetModelType());
  250. target->SetModelType(val, send_update);
  251. break;
  252. }
  253. case SPAWN_SET_VALUE_CLASS:{
  254. sprintf(tmp, "%i", target->GetAdventureClass());
  255. target->SetAdventureClass(val, send_update);
  256. break;
  257. }
  258. case SPAWN_SET_VALUE_GENDER:{
  259. sprintf(tmp, "%i", target->GetGender());
  260. target->SetGender(val, send_update);
  261. break;
  262. }
  263. case SPAWN_SET_VALUE_SHOW_NAME:{
  264. sprintf(tmp, "%i", target->GetShowName());
  265. target->SetShowName(val, send_update);
  266. break;
  267. }
  268. case SPAWN_SET_VALUE_ATTACKABLE:{
  269. sprintf(tmp, "%i", target->GetAttackable());
  270. target->SetAttackable(val, send_update);
  271. break;
  272. }
  273. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  274. sprintf(tmp, "%i", target->GetShowLevel());
  275. target->SetShowLevel(val, send_update);
  276. break;
  277. }
  278. case SPAWN_SET_VALUE_TARGETABLE:{
  279. sprintf(tmp, "%i", target->GetTargetable());
  280. target->SetTargetable(val, send_update);
  281. break;
  282. }
  283. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  284. sprintf(tmp, "%i", target->GetShowCommandIcon());
  285. target->SetShowCommandIcon(val, send_update);
  286. break;
  287. }
  288. case SPAWN_SET_VALUE_HAND_ICON:{
  289. sprintf(tmp, "%i", target->GetShowHandIcon());
  290. target->SetShowHandIcon(val, send_update);
  291. break;
  292. }
  293. case SPAWN_SET_VALUE_HAIR_TYPE:{
  294. if(target->IsEntity()){
  295. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  296. ((Entity*)target)->SetHairType(val, send_update);
  297. }
  298. break;
  299. }
  300. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  301. if(target->IsEntity()){
  302. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  303. ((Entity*)target)->SetHairType(val, send_update);
  304. }
  305. break;
  306. }
  307. case SPAWN_SET_VALUE_WING_TYPE:{
  308. if(target->IsEntity()){
  309. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  310. ((Entity*)target)->SetWingType(val, send_update);
  311. }
  312. break;
  313. }
  314. case SPAWN_SET_VALUE_CHEST_TYPE:{
  315. if(target->IsEntity()){
  316. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  317. ((Entity*)target)->SetChestType(val, send_update);
  318. }
  319. break;
  320. }
  321. case SPAWN_SET_VALUE_LEGS_TYPE:{
  322. if(target->IsEntity()){
  323. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  324. ((Entity*)target)->SetLegsType(val, send_update);
  325. }
  326. break;
  327. }
  328. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  329. if(target->IsEntity()){
  330. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  331. ((Entity*)target)->SetSogaHairType(val, send_update);
  332. }
  333. break;
  334. }
  335. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  336. if(target->IsEntity()){
  337. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  338. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  339. }
  340. break;
  341. }
  342. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  343. sprintf(tmp, "%i", target->GetSogaModelType());
  344. target->SetSogaModelType(val, send_update);
  345. break;
  346. }
  347. case SPAWN_SET_VALUE_SIZE:{
  348. sprintf(tmp, "%i", target->GetSize());
  349. target->SetSize(val, send_update);
  350. break;
  351. }
  352. case SPAWN_SET_VALUE_HP:{
  353. sprintf(tmp, "%i", target->GetHP());
  354. target->SetHP(val, send_update);
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_POWER:{
  358. sprintf(tmp, "%i", target->GetPower());
  359. target->SetPower(val, send_update);
  360. break;
  361. }
  362. case SPAWN_SET_VALUE_HEROIC:{
  363. sprintf(tmp, "%i", target->GetHeroic());
  364. target->SetHeroic(val, send_update);
  365. break;
  366. }
  367. case SPAWN_SET_VALUE_RESPAWN:{
  368. sprintf(tmp, "%u", target->GetRespawnTime());
  369. target->SetRespawnTime(val);
  370. break;
  371. }
  372. case SPAWN_SET_VALUE_X:{
  373. sprintf(tmp, "%f", target->GetX());
  374. target->SetX(atof(value), send_update);
  375. break;
  376. }
  377. case SPAWN_SET_VALUE_Y:{
  378. sprintf(tmp, "%f", target->GetY());
  379. target->SetY(atof(value), send_update);
  380. break;
  381. }
  382. case SPAWN_SET_VALUE_Z:{
  383. sprintf(tmp, "%f", target->GetZ());
  384. target->SetZ(atof(value), send_update);
  385. break;
  386. }
  387. case SPAWN_SET_VALUE_HEADING:{
  388. sprintf(tmp, "%f", target->GetHeading());
  389. target->SetHeading(atof(value) + 360, send_update);
  390. break;
  391. }
  392. case SPAWN_SET_VALUE_VISUAL_STATE:{
  393. sprintf(tmp, "%i", target->GetVisualState());
  394. target->SetVisualState(val, send_update);
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_ACTION_STATE:{
  398. sprintf(tmp, "%i", target->GetActionState());
  399. target->SetActionState(val, send_update);
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_MOOD_STATE:{
  403. sprintf(tmp, "%i", target->GetMoodState());
  404. target->SetMoodState(val, send_update);
  405. break;
  406. }
  407. case SPAWN_SET_VALUE_INITIAL_STATE:{
  408. sprintf(tmp, "%i", target->GetInitialState());
  409. target->SetInitialState(val, send_update);
  410. break;
  411. }
  412. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  413. sprintf(tmp, "%i", target->GetActivityStatus());
  414. target->SetActivityStatus(val, send_update);
  415. break;
  416. }
  417. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  418. sprintf(tmp, "%i", target->GetCollisionRadius());
  419. target->SetCollisionRadius(val, send_update);
  420. break;
  421. }
  422. case SPAWN_SET_VALUE_DEVICE_ID: {
  423. if (target->IsObject()) {
  424. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  425. ((Object*)target)->SetDeviceID(val);
  426. }
  427. break;
  428. }
  429. case SPAWN_SET_VALUE_PITCH: {
  430. sprintf(tmp, "%f", target->GetPitch());
  431. target->SetPitch(atof(value), send_update);
  432. break;
  433. }
  434. case SPAWN_SET_VALUE_ROLL: {
  435. sprintf(tmp, "%f", target->GetRoll());
  436. target->SetRoll(atof(value), send_update);
  437. break;
  438. }
  439. case SPAWN_SET_VALUE_HIDE_HOOD: {
  440. sprintf(tmp, "%i", target->appearance.hide_hood);
  441. target->SetHideHood(val);
  442. break;
  443. }
  444. case SPAWN_SET_VALUE_EMOTE_STATE: {
  445. sprintf(tmp, "%i", target->appearance.emote_state);
  446. target->SetEmoteState(val);
  447. break;
  448. }
  449. case SPAWN_SET_VALUE_ICON: {
  450. sprintf(tmp, "%i", target->GetIconValue());
  451. target->SetIcon(val);
  452. break;
  453. }
  454. case SPAWN_SET_VALUE_PREFIX: {
  455. sprintf(tmp, "%s", target->GetPrefixTitle());
  456. target->SetPrefixTitle(value);
  457. client->GetCurrentZone()->SendUpdateTitles(target);
  458. break;
  459. }
  460. case SPAWN_SET_VALUE_SUFFIX: {
  461. sprintf(tmp, "%s", target->GetSuffixTitle());
  462. target->SetSuffixTitle(value);
  463. client->GetCurrentZone()->SendUpdateTitles(target);
  464. break;
  465. }
  466. case SPAWN_SET_VALUE_LASTNAME: {
  467. sprintf(tmp, "%s", target->GetLastName());
  468. target->SetLastName(value);
  469. client->GetCurrentZone()->SendUpdateTitles(target);
  470. break;
  471. }
  472. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  473. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  474. // nothing to do must reload spawns
  475. break;
  476. }
  477. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  478. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  479. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  480. break;
  481. }
  482. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  483. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  484. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  485. break;
  486. }
  487. *temp_value = string(tmp);
  488. }
  489. }
  490. else{
  491. switch(type){
  492. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  493. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  494. break;
  495. }
  496. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  497. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  498. break;
  499. }
  500. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  501. if (target->GetDatabaseID() > 0)
  502. {
  503. char query[256];
  504. snprintf(query, 256, "update spawn set expansion_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  505. if (database.RunQuery(query, strnlen(query, 256)))
  506. {
  507. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  508. }
  509. }
  510. break;
  511. }
  512. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  513. if (target->GetDatabaseID() > 0)
  514. {
  515. char query[256];
  516. snprintf(query, 256, "update spawn set holiday_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  517. if (database.RunQuery(query, strnlen(query, 256)))
  518. {
  519. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  520. }
  521. }
  522. break;
  523. }
  524. case SPAWN_SET_VALUE_NAME:{
  525. target->SetName(value);
  526. client->GetCurrentZone()->SendUpdateTitles(target);
  527. break;
  528. }
  529. case SPAWN_SET_VALUE_SUB_TITLE: {
  530. target->SetSubTitle(value);
  531. client->GetCurrentZone()->SendUpdateTitles(target);
  532. break;
  533. }
  534. case SPAWN_SET_VALUE_X_OFFSET:
  535. {
  536. target->SetXOffset(atof(value));
  537. break;
  538. }
  539. case SPAWN_SET_VALUE_Y_OFFSET:
  540. {
  541. target->SetYOffset(atof(value));
  542. break;
  543. }
  544. case SPAWN_SET_VALUE_Z_OFFSET:
  545. {
  546. target->SetZOffset(atof(value));
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_EXPIRE: {
  550. target->SetExpireTime(val);
  551. break;
  552. }
  553. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  554. target->SetExpireOffsetTime(val);
  555. break;
  556. }
  557. case SPAWN_SET_VALUE_LEVEL:{
  558. target->SetLevel(val, send_update);
  559. break;
  560. }
  561. case SPAWN_SET_VALUE_DIFFICULTY:{
  562. target->SetEncounterLevel(val, send_update);
  563. break;
  564. }
  565. case SPAWN_SET_VALUE_MODEL_TYPE:{
  566. target->SetModelType(val, send_update);
  567. break;
  568. }
  569. case SPAWN_SET_VALUE_CLASS:{
  570. target->SetAdventureClass(val, send_update);
  571. break;
  572. }
  573. case SPAWN_SET_VALUE_GENDER:{
  574. target->SetGender(val, send_update);
  575. break;
  576. }
  577. case SPAWN_SET_VALUE_SHOW_NAME:{
  578. target->SetShowName(val, send_update);
  579. break;
  580. }
  581. case SPAWN_SET_VALUE_ATTACKABLE:{
  582. target->SetAttackable(val, send_update);
  583. break;
  584. }
  585. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  586. target->SetShowLevel(val, send_update);
  587. break;
  588. }
  589. case SPAWN_SET_VALUE_TARGETABLE:{
  590. target->SetTargetable(val, send_update);
  591. break;
  592. }
  593. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  594. target->SetShowCommandIcon(val, send_update);
  595. break;
  596. }
  597. case SPAWN_SET_VALUE_HAND_ICON:{
  598. target->SetShowHandIcon(val, send_update);
  599. break;
  600. }
  601. case SPAWN_SET_VALUE_HAIR_TYPE:{
  602. if(target->IsEntity())
  603. ((Entity*)target)->SetHairType(val, send_update);
  604. break;
  605. }
  606. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  607. if(target->IsEntity())
  608. ((Entity*)target)->SetHairType(val, send_update);
  609. break;
  610. }
  611. case SPAWN_SET_VALUE_WING_TYPE:{
  612. if(target->IsEntity())
  613. ((Entity*)target)->SetWingType(val, send_update);
  614. break;
  615. }
  616. case SPAWN_SET_VALUE_CHEST_TYPE:{
  617. if(target->IsEntity())
  618. ((Entity*)target)->SetChestType(val, send_update);
  619. break;
  620. }
  621. case SPAWN_SET_VALUE_LEGS_TYPE:{
  622. if(target->IsEntity())
  623. ((Entity*)target)->SetLegsType(val, send_update);
  624. break;
  625. }
  626. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  627. if(target->IsEntity())
  628. ((Entity*)target)->SetSogaHairType(val, send_update);
  629. break;
  630. }
  631. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  632. if(target->IsEntity())
  633. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  634. break;
  635. }
  636. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  637. target->SetSogaModelType(val, send_update);
  638. break;
  639. }
  640. case SPAWN_SET_VALUE_SIZE:{
  641. target->SetSize(val, send_update);
  642. break;
  643. }
  644. case SPAWN_SET_VALUE_HP:{
  645. target->SetHP(val, send_update);
  646. break;
  647. }
  648. case SPAWN_SET_VALUE_POWER:{
  649. target->SetPower(val, send_update);
  650. break;
  651. }
  652. case SPAWN_SET_VALUE_HEROIC:{
  653. target->SetHeroic(val, send_update);
  654. break;
  655. }
  656. case SPAWN_SET_VALUE_RESPAWN:{
  657. target->SetRespawnTime(val);
  658. break;
  659. }
  660. case SPAWN_SET_VALUE_X:{
  661. target->SetX(atof(value), send_update);
  662. target->SetSpawnOrigX(target->GetX());
  663. break;
  664. }
  665. case SPAWN_SET_VALUE_Y:{
  666. target->SetY(atof(value), send_update);
  667. target->SetSpawnOrigY(target->GetY());
  668. break;
  669. }
  670. case SPAWN_SET_VALUE_Z:{
  671. target->SetZ(atof(value), send_update);
  672. target->SetSpawnOrigZ(target->GetZ());
  673. break;
  674. }
  675. case SPAWN_SET_VALUE_HEADING:{
  676. target->SetHeading(atof(value), send_update);
  677. target->SetSpawnOrigHeading(target->GetHeading());
  678. break;
  679. }
  680. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  681. ZoneServer* zone = target->GetZone();
  682. if (!zone)
  683. zone = client->GetCurrentZone();
  684. if(zone->GetEntityCommandList(val))
  685. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  686. target->primary_command_list_id = val;
  687. break;
  688. }
  689. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  690. ZoneServer* zone = target->GetZone();
  691. if (!zone)
  692. zone = client->GetCurrentZone();
  693. if (zone->GetEntityCommandList(val))
  694. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  695. target->secondary_command_list_id = val;
  696. break;
  697. }
  698. case SPAWN_SET_VALUE_VISUAL_STATE:{
  699. target->SetVisualState(val, send_update);
  700. break;
  701. }
  702. case SPAWN_SET_VALUE_ACTION_STATE:{
  703. target->SetActionState(val, send_update);
  704. break;
  705. }
  706. case SPAWN_SET_VALUE_MOOD_STATE:{
  707. target->SetMoodState(val, send_update);
  708. break;
  709. }
  710. case SPAWN_SET_VALUE_INITIAL_STATE:{
  711. target->SetInitialState(val, send_update);
  712. break;
  713. }
  714. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  715. target->SetActivityStatus(val, send_update);
  716. break;
  717. }
  718. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  719. target->SetCollisionRadius(val, send_update);
  720. break;
  721. }
  722. case SPAWN_SET_VALUE_FACTION:{
  723. ZoneServer* zone = target->GetZone();
  724. if (!zone)
  725. zone = client->GetCurrentZone();
  726. target->faction_id = val;
  727. zone->RemoveDeadEnemyList(target);
  728. if(target->IsNPC())
  729. zone->AddEnemyList((NPC*)target);
  730. break;
  731. }
  732. case SPAWN_SET_VALUE_DEVICE_ID:{
  733. if (target->IsObject())
  734. ((Object*)target)->SetDeviceID(val);
  735. break;
  736. }
  737. case SPAWN_SET_VALUE_PITCH: {
  738. target->SetPitch(atof(value), send_update);
  739. target->SetSpawnOrigPitch(atof(value));
  740. break;
  741. }
  742. case SPAWN_SET_VALUE_ROLL: {
  743. target->SetRoll(atof(value), send_update);
  744. target->SetSpawnOrigRoll(atof(value));
  745. break;
  746. }
  747. case SPAWN_SET_VALUE_HIDE_HOOD: {
  748. target->SetHideHood(val);
  749. break;
  750. }
  751. case SPAWN_SET_VALUE_EMOTE_STATE: {
  752. target->SetEmoteState(val);
  753. break;
  754. }
  755. case SPAWN_SET_VALUE_ICON: {
  756. target->SetIcon(val);
  757. break;
  758. }
  759. case SPAWN_SET_VALUE_PREFIX: {
  760. target->SetPrefixTitle(value);
  761. client->GetCurrentZone()->SendUpdateTitles(target);
  762. break;
  763. }
  764. case SPAWN_SET_VALUE_SUFFIX: {
  765. target->SetSuffixTitle(value);
  766. client->GetCurrentZone()->SendUpdateTitles(target);
  767. break;
  768. }
  769. case SPAWN_SET_VALUE_LASTNAME: {
  770. target->SetLastName(value);
  771. client->GetCurrentZone()->SendUpdateTitles(target);
  772. break;
  773. }
  774. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  775. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  776. if(client){
  777. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  778. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  779. }
  780. return false;
  781. }
  782. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  783. return false;
  784. else{
  785. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  786. target->SetSpawnScript(value);
  787. }
  788. break;
  789. }
  790. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  791. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  792. if(client){
  793. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  794. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  795. }
  796. return false;
  797. }
  798. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  799. return false;
  800. else{
  801. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  802. target->SetSpawnScript(value);
  803. }
  804. break;
  805. }
  806. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  807. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  808. if(client){
  809. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  810. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  811. }
  812. return false;
  813. }
  814. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  815. return false;
  816. else
  817. target->SetSpawnScript(value);
  818. break;
  819. }
  820. }
  821. }
  822. return true;
  823. }
  824. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  825. the database fields always and also update the zone in memory if it's running. */
  826. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  827. if (client && zone_id > 0 && type > 0 && value) {
  828. sint32 int_value = 0;
  829. float float_value = 0;
  830. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  831. try {
  832. float_value = atof(value);
  833. }
  834. catch (...) {
  835. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  836. return false;
  837. }
  838. }
  839. else if (type != ZONE_SET_VALUE_NAME && type != ZONE_SET_VALUE_FILE && type != ZONE_SET_VALUE_DESCRIPTION && type != ZONE_SET_VALUE_ZONE_TYPE && type != ZONE_SET_VALUE_LUA_SCRIPT && type != ZONE_SET_VALUE_ZONE_MOTD) {
  840. try {
  841. int_value = atoi(value);
  842. }
  843. catch (...) {
  844. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  845. return false;
  846. }
  847. }
  848. switch (type) {
  849. case ZONE_SET_VALUE_EXPANSION_ID: {
  850. break;
  851. }
  852. case ZONE_SET_VALUE_NAME: {
  853. if (zone)
  854. zone->SetZoneName(const_cast<char*>(value));
  855. database.SaveZoneInfo(zone_id, "name", value);
  856. break;
  857. }
  858. case ZONE_SET_VALUE_FILE: {
  859. if (zone)
  860. zone->SetZoneFile(const_cast<char*>(value));
  861. database.SaveZoneInfo(zone_id, "file", value);
  862. break;
  863. }
  864. case ZONE_SET_VALUE_DESCRIPTION: {
  865. if (zone)
  866. zone->SetZoneDescription(const_cast<char*>(value));
  867. database.SaveZoneInfo(zone_id, "description", value);
  868. break;
  869. }
  870. case ZONE_SET_VALUE_SAFE_X: {
  871. if (zone)
  872. zone->SetSafeX(float_value);
  873. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  874. break;
  875. }
  876. case ZONE_SET_VALUE_SAFE_Y: {
  877. if (zone)
  878. zone->SetSafeY(float_value);
  879. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  880. break;
  881. }
  882. case ZONE_SET_VALUE_SAFE_Z: {
  883. if (zone)
  884. zone->SetSafeZ(float_value);
  885. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  886. break;
  887. }
  888. case ZONE_SET_VALUE_UNDERWORLD: {
  889. if (zone)
  890. zone->SetUnderWorld(float_value);
  891. database.SaveZoneInfo(zone_id, "underworld", float_value);
  892. break;
  893. }
  894. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  895. break;
  896. }
  897. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  898. break;
  899. }
  900. case ZONE_SET_VALUE_ZONE_TYPE: {
  901. break;
  902. }
  903. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  904. if (zone)
  905. zone->SetAlwaysLoaded(int_value == 1);
  906. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  907. break;
  908. }
  909. case ZONE_SET_VALUE_CITY_ZONE: {
  910. if (zone)
  911. zone->SetCityZone(int_value == 1);
  912. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  913. break;
  914. }
  915. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  916. if (zone)
  917. zone->SetWeatherAllowed(int_value == 1);
  918. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  919. break;
  920. }
  921. case ZONE_SET_VALUE_MIN_STATUS: {
  922. if (zone)
  923. zone->SetMinimumStatus(int_value);
  924. database.SaveZoneInfo(zone_id, "min_status", int_value);
  925. break;
  926. }
  927. case ZONE_SET_VALUE_MIN_LEVEL: {
  928. if (zone)
  929. zone->SetMinimumLevel(int_value);
  930. database.SaveZoneInfo(zone_id, "min_level", int_value);
  931. break;
  932. }
  933. case ZONE_SET_VALUE_MAX_LEVEL: {
  934. if (zone)
  935. zone->SetMaximumLevel(int_value);
  936. database.SaveZoneInfo(zone_id, "max_level", int_value);
  937. break;
  938. }
  939. case ZONE_SET_VALUE_START_ZONE: {
  940. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  941. break;
  942. }
  943. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  944. if (zone)
  945. zone->SetInstanceType(int_value);
  946. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  947. break;
  948. }
  949. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  950. if (zone)
  951. zone->SetDefaultReenterTime(int_value);
  952. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  953. break;
  954. }
  955. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  956. if (zone)
  957. zone->SetDefaultResetTime(int_value);
  958. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  959. break;
  960. }
  961. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  962. if (zone)
  963. zone->SetDefaultLockoutTime(int_value);
  964. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  965. break;
  966. }
  967. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  968. if (zone)
  969. zone->SetForceGroupZoneOption(int_value);
  970. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  971. break;
  972. }
  973. case ZONE_SET_VALUE_LUA_SCRIPT: {
  974. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  975. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  976. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  977. return false;
  978. }
  979. else {
  980. world.AddZoneScript(zone_id, const_cast<char*>(value));
  981. database.SaveZoneInfo(zone_id, "lua_script", value);
  982. }
  983. break;
  984. }
  985. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  986. if (zone)
  987. zone->SetShutdownTimer(int_value);
  988. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  989. break;
  990. }
  991. case ZONE_SET_VALUE_ZONE_MOTD: {
  992. if (zone)
  993. zone->SetZoneMOTD(string(value));
  994. database.SaveZoneInfo(zone_id, "zone_motd", value);
  995. break;
  996. }
  997. default: {
  998. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  999. return false;
  1000. }
  1001. }
  1002. }
  1003. else {
  1004. if (client)
  1005. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1006. return false;
  1007. }
  1008. return true;
  1009. }
  1010. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1011. if (index >= remote_commands->commands.size()) {
  1012. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1013. return;
  1014. }
  1015. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1016. EQ2_RemoteCommandString* parent_command = 0;
  1017. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1018. Seperator* sep = 0;
  1019. if (command_parms->size > 0) {
  1020. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1021. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1022. parent_command = command;
  1023. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1024. safe_delete(sep);
  1025. if (command_parms->data.length() > (command->command.data.length() + 1))
  1026. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1027. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1028. }
  1029. else
  1030. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1031. }
  1032. int ndx = 0;
  1033. if (command->required_status > client->GetAdminStatus())
  1034. {
  1035. LogWrite(COMMAND__ERROR, 0, "Command", "Player '%s' (%u) needs status %i to use command: %s", client->GetPlayer()->GetName(), client->GetAccountID(), command->required_status, command->command.data.c_str());
  1036. safe_delete(sep);
  1037. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1038. return;
  1039. }
  1040. Player* player = client->GetPlayer();
  1041. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1042. switch (command->handler) {
  1043. case COMMAND_RELOAD: {
  1044. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1045. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1047. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1048. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1049. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1051. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1053. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1054. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1057. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1058. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1060. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1061. break;
  1062. }
  1063. case COMMAND_RELOADSTRUCTS: {
  1064. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1065. configReader.ReloadStructs();
  1066. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1067. break;
  1068. }
  1069. case COMMAND_RELOAD_QUESTS: {
  1070. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1071. master_quest_list.Reload();
  1072. client_list.ReloadQuests();
  1073. zone_list.ReloadClientQuests();
  1074. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1075. break;
  1076. }
  1077. case COMMAND_RELOAD_SPAWNS: {
  1078. client->GetCurrentZone()->ReloadSpawns();
  1079. break;
  1080. }
  1081. case COMMAND_RELOAD_SPELLS: {
  1082. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1083. zone_list.DeleteSpellProcess();
  1084. master_spell_list.Reload();
  1085. if (lua_interface)
  1086. lua_interface->ReloadSpells();
  1087. zone_list.LoadSpellProcess();
  1088. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1089. break;
  1090. }
  1091. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1093. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1094. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1095. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1096. break;
  1097. }
  1098. case COMMAND_RELOAD_ZONESCRIPTS: {
  1099. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1100. world.ResetZoneScripts();
  1101. database.LoadZoneScriptData();
  1102. if (lua_interface)
  1103. lua_interface->DestroyZoneScripts();
  1104. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1105. break;
  1106. }
  1107. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1108. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1109. client->GetCurrentZone()->ClearEntityCommands();
  1110. database.LoadEntityCommands(client->GetCurrentZone());
  1111. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1112. break;
  1113. }
  1114. case COMMAND_RELOAD_FACTIONS: {
  1115. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1116. master_faction_list.Clear();
  1117. database.LoadFactionList();
  1118. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1119. break;
  1120. }
  1121. case COMMAND_RELOAD_MAIL: {
  1122. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1123. zone_list.ReloadMail();
  1124. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1125. break;
  1126. }
  1127. case COMMAND_RELOAD_GUILDS: {
  1128. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1129. world.ReloadGuilds();
  1130. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1131. break;
  1132. }
  1133. case COMMAND_RELOAD_LOCATIONS: {
  1134. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1135. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1136. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1137. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1138. break;
  1139. }
  1140. case COMMAND_RELOAD_RULES: {
  1141. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1142. database.LoadRuleSets(true);
  1143. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1144. break;
  1145. }
  1146. case COMMAND_RELOAD_TRANSPORTERS: {
  1147. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1148. database.LoadTransporters(client->GetCurrentZone());
  1149. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1150. break;
  1151. }
  1152. case COMMAND_READ: {
  1153. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1154. if (strcmp(sep->arg[0], "read") == 0) {
  1155. int32 item_index = atol(sep->arg[1]);
  1156. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1157. if (item) {
  1158. Spawn* spawn = cmdTarget;
  1159. client->SendShowBook(client->GetPlayer(), item->name, item->book_pages);
  1160. break;
  1161. }
  1162. }
  1163. }
  1164. break;
  1165. }
  1166. case COMMAND_USEABILITY:{
  1167. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1168. if (client->GetPlayer()->GetHP() == 0) {
  1169. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1170. }
  1171. else {
  1172. int32 spell_id = atoul(sep->arg[0]);
  1173. int8 spell_tier = 0;
  1174. if (sep->arg[1][0] && sep->IsNumber(1))
  1175. spell_tier = atoi(sep->arg[1]);
  1176. else
  1177. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1178. if (!spell_tier)
  1179. spell_tier = 1;
  1180. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1181. if (spell) {
  1182. 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)
  1183. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1184. else
  1185. {
  1186. if (cmdTarget)
  1187. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1188. else
  1189. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1190. }
  1191. }
  1192. }
  1193. }
  1194. else if (cmdTarget && cmdTarget->IsWidget())
  1195. {
  1196. Widget* widget = (Widget*)cmdTarget;
  1197. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1198. }
  1199. else
  1200. {
  1201. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1202. }
  1203. break;
  1204. }
  1205. case COMMAND_INFO:{
  1206. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1207. if(strcmp(sep->arg[0], "inventory") == 0){
  1208. int32 item_index = atol(sep->arg[1]);
  1209. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1210. if(item){
  1211. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1212. break;
  1213. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1214. //DumpPacket(app);
  1215. client->QueuePacket(app);
  1216. if(item->GetItemScript() && lua_interface)
  1217. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1218. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1219. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id);
  1220. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1221. client->AddPendingQuest(quest);
  1222. }
  1223. }
  1224. else
  1225. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1226. }
  1227. else if(strcmp(sep->arg[0], "equipment") == 0){
  1228. int32 item_index = atol(sep->arg[1]);
  1229. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1230. if(item){
  1231. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1232. client->QueuePacket(app);
  1233. if(item->GetItemScript() && lua_interface)
  1234. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1235. }
  1236. else
  1237. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1238. }
  1239. 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){
  1240. int32 item_id = atoul(sep->arg[1]);
  1241. Item* item = master_item_list.GetItem(item_id);
  1242. if(item){
  1243. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1244. client->QueuePacket(app);
  1245. }
  1246. else
  1247. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1248. }
  1249. else if (strcmp(sep->arg[0], "spell") == 0) {
  1250. sint32 spell_id = atol(sep->arg[1]);
  1251. int8 tier = atoi(sep->arg[3]);
  1252. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1253. if (outapp)
  1254. client->QueuePacket(outapp);
  1255. else
  1256. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1257. }
  1258. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1259. sint32 spell_id = atol(sep->arg[2]);
  1260. int8 group = atoi(sep->arg[1]);
  1261. AltAdvanceData* data = 0;
  1262. SpellBookEntry* spellentry = 0;
  1263. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1264. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1265. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1266. if (outapp)
  1267. client->QueuePacket(outapp);
  1268. else
  1269. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1270. }
  1271. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1272. sint32 spell_id = atol(sep->arg[1]);
  1273. int8 tier = atoi(sep->arg[2]);
  1274. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1275. if (outapp)
  1276. client->QueuePacket(outapp);
  1277. else
  1278. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1279. }
  1280. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1281. sint32 recipe_id = atol(sep->arg[1]);
  1282. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1283. if(outapp)
  1284. client->QueuePacket(outapp);
  1285. else
  1286. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1287. }
  1288. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1289. int32 slot = atol(sep->arg[1]);
  1290. int32 spell_id = atol(sep->arg[2]);
  1291. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1292. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1293. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1294. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1295. if(outapp)
  1296. client->QueuePacket(outapp);
  1297. else
  1298. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1299. }
  1300. else if (strcmp(sep->arg[0], "effect") == 0) {
  1301. int32 spell_id = atol(sep->arg[1]);
  1302. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1303. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1304. int8 type = 0;
  1305. if (client->GetVersion() <= 283)
  1306. type = 1;
  1307. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  1308. if (outapp){
  1309. client->QueuePacket(outapp);
  1310. }
  1311. else
  1312. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1313. }
  1314. }
  1315. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1316. Item* item = player->item_list.GetOverflowItem();
  1317. if(item) {
  1318. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1319. client->QueuePacket(app);
  1320. }
  1321. else
  1322. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1323. }
  1324. else
  1325. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1326. break;
  1327. }
  1328. case COMMAND_USE_EQUIPPED_ITEM:{
  1329. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1330. int32 slot_id = atoul(sep->arg[0]);
  1331. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1332. if (item && item->generic_info.usable && item->GetItemScript())
  1333. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1334. }
  1335. break;
  1336. }
  1337. case COMMAND_USE_ITEM: {
  1338. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1339. int32 item_index = atoul(sep->arg[0]);
  1340. Item* item = player->item_list.GetItemFromIndex(item_index);
  1341. if (item && item->GetItemScript()) {
  1342. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1343. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1344. else {
  1345. if (item->generic_info.display_charges > 0) {
  1346. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1347. item->generic_info.display_charges -= 1;
  1348. item->save_needed = true;
  1349. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1350. }
  1351. }
  1352. }
  1353. }
  1354. break;
  1355. }
  1356. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1357. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1358. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1359. if (item) {
  1360. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1361. if(item->generic_info.item_type == 6) {
  1362. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1363. int8 old_slot = 0;
  1364. if (spell) {
  1365. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1366. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1367. player->RemoveSpellBookEntry(spell->GetSpellID());
  1368. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1369. player->UnlockSpell(spell);
  1370. client->SendSpellUpdate(spell);
  1371. database.DeleteItem(client->GetCharacterID(), item, 0);
  1372. player->item_list.RemoveItem(item, true);
  1373. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1374. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1375. }
  1376. }
  1377. else
  1378. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1379. }
  1380. else if(item->generic_info.item_type == 7){
  1381. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1382. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1383. // if valid recipe book and the player doesn't have it
  1384. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1385. client->Message(CHANNEL_COLOR_WHITE, "Your tradeskill level is not high enough to scribe this book.");
  1386. safe_delete(recipe_book);
  1387. }
  1388. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1389. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1390. // Add recipe book to the players list
  1391. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1392. // Get a list of all recipes this book contains
  1393. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1394. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1395. // Create the packet to send to update the players recipe list
  1396. PacketStruct* packet = 0;
  1397. if (client->GetRecipeListSent()) {
  1398. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1399. if (packet)
  1400. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1401. }
  1402. // loop through the list
  1403. vector<Recipe*>::iterator itr;
  1404. int16 i = 0;
  1405. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1406. // check to see if the player already has this recipe some how
  1407. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1408. // Player doesn't already have this recipe so lets add it
  1409. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1410. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1411. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1412. client->Message(CHANNEL_COLOR_WHITE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1413. if (packet && client->GetRecipeListSent()) {
  1414. packet->setArrayDataByName("id", recipe->GetID(), i);
  1415. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1416. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1417. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1418. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1419. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1420. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1421. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1422. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1423. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1424. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1425. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1426. i++;
  1427. }
  1428. }
  1429. }
  1430. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1431. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1432. database.DeleteItem(client->GetCharacterID(), item, 0);
  1433. client->GetPlayer()->item_list.RemoveItem(item, true);
  1434. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1435. if (packet && client->GetRecipeListSent())
  1436. client->QueuePacket(packet->serialize());
  1437. safe_delete(packet);
  1438. }
  1439. else {
  1440. if (recipe_book)
  1441. client->Message(CHANNEL_COLOR_WHITE, "You have already learned all you can from this item.");
  1442. safe_delete(recipe_book);
  1443. }
  1444. }
  1445. }
  1446. else
  1447. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1448. }
  1449. break;
  1450. }
  1451. case COMMAND_SUMMONITEM: {
  1452. if (sep && sep->IsNumber(0)) {
  1453. int32 item_id = atol(sep->arg[0]);
  1454. int32 quantity = 1;
  1455. if (sep->arg[1] && sep->IsNumber(1))
  1456. quantity = atoi(sep->arg[1]);
  1457. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1458. client->AddItemToBank(item_id,quantity);
  1459. }
  1460. else {
  1461. client->AddItem(item_id, quantity);
  1462. }
  1463. }
  1464. else {
  1465. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1466. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1467. }
  1468. break;
  1469. }
  1470. case COMMAND_COLLECTION_ADDITEM: {
  1471. // takes 2 params: collection_id, slot
  1472. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1473. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1474. if (item)
  1475. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1476. else
  1477. 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]));
  1478. }
  1479. else
  1480. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1481. break;
  1482. }
  1483. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1484. // takes 1 param: slot
  1485. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1486. int i = 0;
  1487. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1488. printf("\t%u: %s\n", i, sep->arg[i]);
  1489. i++;
  1490. }
  1491. break;
  1492. }
  1493. case COMMAND_WHO:{
  1494. const char* who = 0;
  1495. if(sep && sep->arg[0]){
  1496. //cout << "Who query: \n";
  1497. who = sep->argplus[0];
  1498. //cout << who << endl;
  1499. }
  1500. zone_list.ProcessWhoQuery(who, client);
  1501. break;
  1502. }
  1503. case COMMAND_SELECT_JUNCTION:{
  1504. 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__);
  1505. int32 choice = 0;
  1506. if(sep && sep->arg[0] && sep->IsNumber(0))
  1507. choice = atoul(sep->arg[0]);
  1508. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1509. client->HandlePlayerRevive(choice);
  1510. }
  1511. break;
  1512. }
  1513. case COMMAND_SPAWN_MOVE: {
  1514. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  1515. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1516. if (packet) {
  1517. float unknown2_3 = 0;
  1518. int8 placement_mode = 0;
  1519. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1520. if (sep && sep->arg[0][0]) {
  1521. if (strcmp(sep->arg[0], "wall") == 0) {
  1522. placement_mode = 2;
  1523. unknown2_3 = 150;
  1524. }
  1525. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1526. placement_mode = 1;
  1527. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1528. {
  1529. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1530. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1531. }
  1532. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1533. {
  1534. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1535. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1536. }
  1537. else if (strcmp(sep->arg[0], "myloc") == 0)
  1538. {
  1539. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1540. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1541. safe_delete(packet);
  1542. break;
  1543. }
  1544. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1545. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1546. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1547. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1548. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1549. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1550. safe_delete(packet);
  1551. break;
  1552. }
  1553. }
  1554. packet->setDataByName("placement_mode", placement_mode);
  1555. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1556. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1557. packet->setDataByName("unknown", 1); //size
  1558. packet->setDataByName("unknown2", 1); //size 2
  1559. packet->setDataByName("unknown2", .5, 1); //size 3
  1560. packet->setDataByName("unknown2", 3, 2);
  1561. packet->setDataByName("unknown2", unknown2_3, 3);
  1562. packet->setDataByName("max_distance", 500);
  1563. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1564. client->QueuePacket(packet->serialize());
  1565. safe_delete(packet);
  1566. }
  1567. }
  1568. else {
  1569. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1570. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1571. }
  1572. break;
  1573. }
  1574. case COMMAND_HAIL:{
  1575. Spawn* spawn = cmdTarget;
  1576. if(spawn && spawn->GetTargetable())
  1577. {
  1578. char tmp[75] = {0};
  1579. sprintf(tmp, "Hail, %s", spawn->GetName());
  1580. bool show_bubble = true;
  1581. if (spawn->IsNPC())
  1582. show_bubble = false;
  1583. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1584. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < 30){
  1585. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1586. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1587. else
  1588. spawn->ProcessMovement();
  1589. LogWrite(MISC__TODO, 0, "Check", "ProcessMovement has been called");
  1590. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer());
  1591. }
  1592. }
  1593. else {
  1594. string tmp = "Hail";
  1595. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1596. }
  1597. break;
  1598. }
  1599. case COMMAND_SAY:{
  1600. if (sep && sep->arg[0][0]) {
  1601. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1602. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1603. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1604. }
  1605. else
  1606. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1607. break;
  1608. }
  1609. case COMMAND_TELL:{
  1610. if(sep && sep->arg[0] && sep->argplus[1]){
  1611. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_TELL, sep->argplus[1]))
  1612. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1613. }else
  1614. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1615. break;
  1616. }
  1617. case COMMAND_SHOUT:{
  1618. if(sep && sep->arg[0][0])
  1619. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1620. else
  1621. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1622. break;
  1623. }
  1624. case COMMAND_AUCTION:{
  1625. if(sep && sep->arg[0][0])
  1626. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1627. else
  1628. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1629. break;
  1630. }
  1631. case COMMAND_OOC:{
  1632. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  1633. if(sep && sep->arg[0][0])
  1634. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OOC, sep->argplus[0]);
  1635. else
  1636. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  1637. break;
  1638. }
  1639. case COMMAND_EMOTE:{
  1640. if(sep && sep->arg[0][0])
  1641. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  1642. else
  1643. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  1644. break;
  1645. }
  1646. case COMMAND_RACE:{
  1647. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  1648. if(sep->arg[1][0] && sep->IsNumber(1)){
  1649. client->GetPlayer()->GetInfoStruct()->race = atoi(sep->arg[1]);
  1650. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  1651. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  1652. client->GetPlayer()->SetCharSheetChanged(true);
  1653. }
  1654. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  1655. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  1656. //client->QueuePacket(outapp);
  1657. }
  1658. else{
  1659. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  1660. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  1661. }
  1662. break;
  1663. }
  1664. case COMMAND_BANK_DEPOSIT:{
  1665. if(client->GetBanker() && sep && sep->arg[0]){
  1666. int64 amount = 0;
  1667. string deposit = string(sep->arg[0]);
  1668. amount = atoi64(deposit.c_str());
  1669. client->BankDeposit(amount);
  1670. }
  1671. break;
  1672. }
  1673. case COMMAND_BANK_WITHDRAWAL:{
  1674. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  1675. int64 amount = 0;
  1676. string deposit = string(sep->arg[0]);
  1677. amount = atoi64(deposit.c_str());
  1678. client->BankWithdrawal(amount);
  1679. }
  1680. break;
  1681. }
  1682. case COMMAND_BANK_CANCEL:{
  1683. Spawn* banker = cmdTarget;
  1684. client->Bank(banker, true);
  1685. break;
  1686. }
  1687. case COMMAND_BANK:{
  1688. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  1689. Spawn* banker = cmdTarget;
  1690. client->Bank(banker);
  1691. break;
  1692. }
  1693. case COMMAND_GUILD_BANK:{
  1694. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  1695. //Spawn* banker = client->GetPlayer()->GetTarget();
  1696. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  1697. break;
  1698. }
  1699. case COMMAND_START_MAIL: {
  1700. client->SetMailTransaction(cmdTarget);
  1701. client->SendMailList();
  1702. break;
  1703. }
  1704. case COMMAND_CANCEL_MAIL: {
  1705. client->SetMailTransaction(0);
  1706. break;
  1707. }
  1708. case COMMAND_GET_MAIL_MESSAGE: {
  1709. if (sep && sep->arg[0] && sep->IsNumber(0))
  1710. client->DisplayMailMessage(atoul(sep->arg[0]));
  1711. break;
  1712. }
  1713. case COMMAND_ADD_MAIL_PLAT: {
  1714. if (sep && sep->arg[0] && sep->IsNumber(0))
  1715. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1716. break;
  1717. }
  1718. case COMMAND_ADD_MAIL_GOLD: {
  1719. if (sep && sep->arg[0] && sep->IsNumber(0))
  1720. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  1721. break;
  1722. }
  1723. case COMMAND_ADD_MAIL_SILVER: {
  1724. if (sep && sep->arg[0] && sep->IsNumber(0))
  1725. client->AddMailCoin(0, atoul(sep->arg[0]));
  1726. break;
  1727. }
  1728. case COMMAND_ADD_MAIL_COPPER: {
  1729. if (sep && sep->arg[0] && sep->IsNumber(0))
  1730. client->AddMailCoin(atoul(sep->arg[0]));
  1731. break;
  1732. }
  1733. case COMMAND_SET_MAIL_ITEM: {
  1734. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1735. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1736. break;
  1737. }
  1738. case COMMAND_REMOVE_MAIL_PLAT: {
  1739. if (sep && sep->arg[0] && sep->IsNumber(0))
  1740. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1741. break;
  1742. }
  1743. case COMMAND_REMOVE_MAIL_GOLD: {
  1744. if (sep && sep->arg[0] && sep->IsNumber(0))
  1745. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  1746. break;
  1747. }
  1748. case COMMAND_REMOVE_MAIL_SILVER: {
  1749. if (sep && sep->arg[0] && sep->IsNumber(0))
  1750. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  1751. break;
  1752. }
  1753. case COMMAND_REMOVE_MAIL_COPPER: {
  1754. if (sep && sep->arg[0] && sep->IsNumber(0))
  1755. client->RemoveMailCoin(atoul(sep->arg[0]));
  1756. break;
  1757. }
  1758. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  1759. if (sep && sep->arg[0] && sep->IsNumber(0))
  1760. client->TakeMailAttachments(atoul(sep->arg[0]));
  1761. break;
  1762. }
  1763. case COMMAND_CANCEL_SEND_MAIL: {
  1764. client->CancelSendMail();
  1765. break;
  1766. }
  1767. case COMMAND_DELETE_MAIL_MESSAGE: {
  1768. if (sep && sep->arg[0] && sep->IsNumber(0))
  1769. client->DeleteMail(atoul(sep->arg[0]), true);
  1770. break;
  1771. }
  1772. case COMMAND_REPORT_SPAM: {
  1773. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1774. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1775. break;
  1776. }
  1777. case COMMAND_KILL:{
  1778. Spawn* dead = 0;
  1779. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  1780. dead=client->GetPlayer();
  1781. client->GetPlayer()->SetHP(0);
  1782. client->GetPlayer()->KillSpawn(dead);
  1783. }else{
  1784. dead= cmdTarget;
  1785. if(dead && dead->IsPlayer() == false){
  1786. dead->SetHP(0);
  1787. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  1788. client->GetCurrentZone()->RemoveSpawn(false, dead, true);
  1789. else
  1790. client->GetPlayer()->KillSpawn(dead);
  1791. }else{
  1792. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  1793. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  1794. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  1795. }
  1796. }
  1797. break;
  1798. }
  1799. case COMMAND_LEVEL:{
  1800. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  1801. int16 new_level = atoi(sep->arg[ndx]);
  1802. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  1803. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  1804. else {
  1805. if (new_level < 1)
  1806. new_level = 1;
  1807. if (new_level > 255)
  1808. new_level = 255;
  1809. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  1810. client->GetPlayer()->SetXP(1);
  1811. client->GetPlayer()->SetNeededXP();
  1812. }
  1813. }else
  1814. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  1815. break;
  1816. }
  1817. case COMMAND_SIT: {
  1818. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1819. if(client->GetPlayer()->GetHP() > 0){
  1820. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  1821. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  1822. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  1823. }
  1824. break;
  1825. }
  1826. case COMMAND_STAND: {
  1827. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1828. if(client->GetPlayer()->GetHP() > 0){
  1829. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  1830. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  1831. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  1832. }
  1833. break;
  1834. }
  1835. case COMMAND_CLASS:{
  1836. if(sep && sep->arg[ndx][0]){
  1837. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  1838. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  1839. }else
  1840. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  1841. break;
  1842. }
  1843. case COMMAND_GENDER:{
  1844. if(sep && sep->arg[ndx][0]){
  1845. client->GetPlayer()->GetInfoStruct()->gender = atoi(sep->arg[ndx]);
  1846. client->GetPlayer()->SetCharSheetChanged(true);
  1847. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  1848. }else{
  1849. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  1850. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  1851. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  1852. }
  1853. break;
  1854. }
  1855. case COMMAND_FLYMODE:{
  1856. if(sep && sep->arg[0] && sep->IsNumber(0)){
  1857. PrintSep(sep, "COMMAND_FLYMODE");
  1858. int8 val = atoi(sep->arg[0]);
  1859. ClientPacketFunctions::SendFlyMode(client, val);
  1860. }
  1861. else{
  1862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  1863. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  1864. }
  1865. break;
  1866. }
  1867. case COMMAND_LOOT_LIST:{
  1868. Spawn* spawn = cmdTarget;
  1869. if(spawn && spawn->IsEntity()){
  1870. if (sep && sep->arg[0]) {
  1871. if (!spawn->GetDatabaseID())
  1872. {
  1873. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  1874. break;
  1875. }
  1876. else if (!spawn->IsNPC())
  1877. {
  1878. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  1879. break;
  1880. }
  1881. bool reloadLoot = false;
  1882. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  1883. {
  1884. int32 loottable_id = atoul(sep->arg[1]);
  1885. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  1886. {
  1887. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  1888. reloadLoot = true;
  1889. }
  1890. else
  1891. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  1892. }
  1893. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  1894. {
  1895. int32 loottable_id = atoul(sep->arg[1]);
  1896. if (loottable_id > 0)
  1897. {
  1898. database.AddLootTableToSpawn(spawn, loottable_id);
  1899. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  1900. reloadLoot = true;
  1901. }
  1902. else
  1903. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  1904. }
  1905. else if (!stricmp(sep->arg[0], "clearall"))
  1906. {
  1907. if (database.RemoveSpawnLootTable(spawn, 0))
  1908. {
  1909. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  1910. reloadLoot = true;
  1911. }
  1912. else
  1913. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  1914. }
  1915. else
  1916. {
  1917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  1918. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  1919. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  1920. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  1921. break;
  1922. }
  1923. if (reloadLoot)
  1924. {
  1925. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  1926. if (spawn->IsNPC())
  1927. {
  1928. Entity* ent = (Entity*)spawn;
  1929. ent->SetLootCoins(0);
  1930. ent->ClearLootList();
  1931. spawn->GetZone()->AddLoot((NPC*)spawn);
  1932. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  1933. }
  1934. }
  1935. break; // nothing further this is the end of these sub commands
  1936. }
  1937. else
  1938. {
  1939. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  1940. if (loot_list.size() > 0) {
  1941. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  1942. vector<int32>::iterator list_itr;
  1943. LootTable* table = 0;
  1944. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  1945. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  1946. if (table)
  1947. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  1948. }
  1949. }
  1950. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  1951. vector<Item*>* items = spawn->GetLootItems();
  1952. if (items) {
  1953. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  1954. vector<Item*>::iterator itr;
  1955. Item* item = 0;
  1956. for (itr = items->begin(); itr != items->end(); itr++) {
  1957. item = *itr;
  1958. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  1959. }
  1960. }
  1961. else
  1962. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  1963. }
  1964. }
  1965. break;
  1966. }
  1967. case COMMAND_LOOT_SETCOIN:{
  1968. Spawn* spawn = cmdTarget;
  1969. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1970. spawn->SetLootCoins(atoul(sep->arg[0]));
  1971. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  1972. }
  1973. else
  1974. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  1975. break;
  1976. }
  1977. case COMMAND_LOOT_ADDITEM:{
  1978. Spawn* spawn = cmdTarget;
  1979. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1980. int16 charges = 1;
  1981. if(sep->arg[1] && sep->IsNumber(1))
  1982. charges = atoi(sep->arg[1]);
  1983. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  1984. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  1985. }
  1986. else
  1987. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  1988. break;
  1989. }
  1990. case COMMAND_LOOT_REMOVEITEM:{
  1991. Spawn* spawn = cmdTarget;
  1992. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1993. spawn->LootItem(atoul(sep->arg[0]));
  1994. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  1995. }
  1996. else
  1997. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  1998. break;
  1999. }
  2000. case COMMAND_LOOT_CORPSE:
  2001. case COMMAND_DISARM:
  2002. case COMMAND_LOOT:{
  2003. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2004. {
  2005. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2006. break;
  2007. }
  2008. if(cmdTarget && cmdTarget->IsEntity()){
  2009. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2010. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2011. client->OpenChest(cmdTarget, true);
  2012. else
  2013. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2014. if (!(cmdTarget)->HasLoot()){
  2015. if (((Entity*)cmdTarget)->IsNPC())
  2016. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2017. }
  2018. }
  2019. else
  2020. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2021. }
  2022. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2023. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2024. break;
  2025. }
  2026. case COMMAND_RELOADSPAWNSCRIPTS:{
  2027. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2028. if (lua_interface)
  2029. lua_interface->SetSpawnScriptsReloading(true);
  2030. world.ResetSpawnScripts();
  2031. database.LoadSpawnScriptData();
  2032. if(lua_interface) {
  2033. lua_interface->DestroySpawnScripts();
  2034. lua_interface->SetSpawnScriptsReloading(false);
  2035. }
  2036. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2037. break;
  2038. }
  2039. case COMMAND_RELOADLUASYSTEM:{
  2040. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2041. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2042. safe_delete(lua_interface);
  2043. lua_interface = new LuaInterface();
  2044. if(lua_interface)
  2045. lua_interface->SetSpawnScriptsReloading(true);
  2046. if(lua_interface && debug_clients.size() > 0){
  2047. map<Client*, int32>::iterator itr;
  2048. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2049. if(lua_interface)
  2050. lua_interface->UpdateDebugClients(itr->first);
  2051. }
  2052. }
  2053. world.ResetSpawnScripts();
  2054. database.LoadSpawnScriptData();
  2055. world.ResetZoneScripts();
  2056. database.LoadZoneScriptData();
  2057. int32 quest_count = database.LoadQuests();
  2058. zone_list.DeleteSpellProcess();
  2059. master_spell_list.Reload();
  2060. int32 spell_count = 0;
  2061. if(lua_interface) {
  2062. lua_interface->DestroySpawnScripts();
  2063. lua_interface->DestroySpells();
  2064. spell_count = database.LoadSpellScriptData();
  2065. lua_interface->SetSpawnScriptsReloading(false);
  2066. }
  2067. zone_list.LoadSpellProcess();
  2068. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2069. break;
  2070. }
  2071. case COMMAND_DECLINE_QUEST:{
  2072. int32 quest_id = 0;
  2073. if(sep && sep->arg[0] && sep->IsNumber(0))
  2074. quest_id = atoul(sep->arg[0]);
  2075. if(quest_id > 0){
  2076. Quest* quest = client->GetPendingQuest(quest_id);
  2077. if(quest){
  2078. client->RemovePendingQuest(quest);
  2079. if(lua_interface)
  2080. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2081. safe_delete(quest);
  2082. client->GetCurrentZone()->SendQuestUpdates(client);
  2083. }
  2084. }
  2085. break;
  2086. }
  2087. case COMMAND_DELETE_QUEST:{
  2088. int32 quest_id = 0;
  2089. if(sep && sep->arg[0] && sep->IsNumber(0))
  2090. quest_id = atoul(sep->arg[0]);
  2091. if(quest_id > 0){
  2092. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2093. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2094. if (quest)
  2095. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2096. }
  2097. client->RemovePlayerQuest(quest_id);
  2098. client->GetCurrentZone()->SendQuestUpdates(client);
  2099. }
  2100. break;
  2101. }
  2102. case COMMAND_ACCEPT_QUEST:{
  2103. int32 quest_id = 0;
  2104. if(sep && sep->arg[0] && sep->IsNumber(0))
  2105. quest_id = atoul(sep->arg[0]);
  2106. if(quest_id > 0){
  2107. client->AcceptQuest(quest_id);
  2108. }
  2109. break;
  2110. }
  2111. case COMMAND_NAME:{
  2112. if(sep && sep->arg[ndx][0]){
  2113. memset(client->GetPlayer()->GetInfoStruct()->name, 0, 40);
  2114. strncpy(client->GetPlayer()->GetInfoStruct()->name, sep->arg[ndx], 39);
  2115. client->GetPlayer()->SetCharSheetChanged(true);
  2116. }else
  2117. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2118. break;
  2119. }
  2120. case COMMAND_GROUPSAY:{
  2121. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2122. if(sep && sep->arg[0] && gmi)
  2123. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2124. break;
  2125. }
  2126. case COMMAND_GROUPINVITE: {
  2127. Entity* target = 0;
  2128. Client* target_client = 0;
  2129. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2130. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2131. return;
  2132. }
  2133. // name provided with command so it has to be a player, npc not supported here
  2134. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2135. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2136. if (target_client) {
  2137. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2138. target = 0;
  2139. else
  2140. target = target_client->GetPlayer();
  2141. }
  2142. }
  2143. // if name was not provided use the players target, npc or player supported here
  2144. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2145. target = (Entity*)client->GetPlayer()->GetTarget();
  2146. if (target->IsPlayer()) {
  2147. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2148. }
  2149. }
  2150. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2151. if (result == 0) {
  2152. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2153. if (target_client) {
  2154. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2155. if (packet) {
  2156. packet->setDataByName("type", 1);
  2157. packet->setDataByName("name", client->GetPlayer()->GetName());
  2158. packet->setDataByName("unknown2", 1);
  2159. target_client->QueuePacket(packet->serialize());
  2160. safe_delete(packet);
  2161. }
  2162. }
  2163. }
  2164. else if (result == 1)
  2165. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2166. else if (result == 2)
  2167. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2168. else if (result == 3)
  2169. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2170. else if (result == 4)
  2171. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2172. else if (result == 5)
  2173. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2174. else if (result == 6)
  2175. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2176. else
  2177. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2178. break;
  2179. }
  2180. case COMMAND_GROUPDISBAND: {
  2181. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2182. if (gmi) { // TODO: Leader check
  2183. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2184. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2185. }
  2186. break;
  2187. }
  2188. case COMMAND_GROUP_LEAVE: {
  2189. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2190. if (gmi) {
  2191. int32 group_id = gmi->group_id;
  2192. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2193. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2194. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2195. }
  2196. else {
  2197. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2198. }
  2199. client->SimpleMessage(CHANNEL_COLOR_GROUP, "You have left the group");
  2200. }
  2201. break;
  2202. }
  2203. case COMMAND_FRIEND_ADD:{
  2204. string name = "";
  2205. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2206. name = database.GetPlayerName(sep->arg[0]);
  2207. else if(cmdTarget && cmdTarget->IsPlayer())
  2208. name = string(cmdTarget->GetName());
  2209. if(name.length() > 0){
  2210. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2211. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2212. client->GetPlayer()->RemoveIgnore(name.c_str());
  2213. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2214. client->SendChatRelationship(3, name.c_str());
  2215. }
  2216. client->GetPlayer()->AddFriend(name.c_str(), true);
  2217. client->SendChatRelationship(0, name.c_str());
  2218. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2219. if(zone_list.GetClientByCharName(name))
  2220. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2221. }
  2222. else
  2223. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2224. }
  2225. else
  2226. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2227. break;
  2228. }
  2229. case COMMAND_FRIEND_REMOVE:{
  2230. string name = "";
  2231. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2232. name = database.GetPlayerName(sep->arg[0]);
  2233. else if(cmdTarget && cmdTarget->IsPlayer())
  2234. name = string(cmdTarget->GetName());
  2235. if(name.length() > 0){
  2236. client->GetPlayer()->RemoveFriend(name.c_str());
  2237. client->SendChatRelationship(1, name.c_str());
  2238. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2239. }
  2240. else
  2241. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2242. break;
  2243. }
  2244. case COMMAND_FRIENDS:{
  2245. break;
  2246. }
  2247. case COMMAND_IGNORE_ADD:{
  2248. string name = "";
  2249. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2250. name = database.GetPlayerName(sep->arg[0]);
  2251. else if(cmdTarget && cmdTarget->IsPlayer())
  2252. name = string(cmdTarget->GetName());
  2253. if(name.length() > 0){
  2254. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2255. if(client->GetPlayer()->IsFriend(name.c_str())){
  2256. client->GetPlayer()->RemoveFriend(name.c_str());
  2257. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2258. client->SendChatRelationship(1, name.c_str());
  2259. }
  2260. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2261. client->SendChatRelationship(2, name.c_str());
  2262. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2263. }
  2264. else
  2265. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2266. }
  2267. else
  2268. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2269. break;
  2270. }
  2271. case COMMAND_IGNORE_REMOVE:{
  2272. string name = "";
  2273. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2274. name = database.GetPlayerName(sep->arg[0]);
  2275. else if(cmdTarget && cmdTarget->IsPlayer())
  2276. name = string(cmdTarget->GetName());
  2277. if(name.length() > 0){
  2278. client->GetPlayer()->RemoveIgnore(name.c_str());
  2279. client->SendChatRelationship(3, name.c_str());
  2280. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2281. }
  2282. break;
  2283. }
  2284. case COMMAND_IGNORES:{
  2285. break;
  2286. }
  2287. case COMMAND_GROUP_KICK:{
  2288. Entity* kicked = 0;
  2289. Client* kicked_client = 0;
  2290. int32 group_id = 0;
  2291. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2292. return;
  2293. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2294. if (sep && sep->arg[0]) {
  2295. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2296. if (kicked_client)
  2297. kicked = kicked_client->GetPlayer();
  2298. }
  2299. else if (cmdTarget && cmdTarget->IsEntity()) {
  2300. kicked = (Entity*)cmdTarget;
  2301. }
  2302. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2303. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2304. if (kicked)
  2305. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2306. if(send_kicked_message)
  2307. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2308. else
  2309. client->Message(CHANNEL_COLOR_GROUP, "You kicked %s from the group", kicked->GetName());
  2310. if (kicked_client)
  2311. kicked_client->SimpleMessage(CHANNEL_COLOR_GROUP, "You were kicked from the group");
  2312. break;
  2313. }
  2314. case COMMAND_GROUP_MAKE_LEADER:{
  2315. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2316. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2317. return;
  2318. }
  2319. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2320. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2321. if (new_leader) {
  2322. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2323. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2324. }
  2325. }
  2326. else
  2327. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2328. }
  2329. else if (cmdTarget && cmdTarget->IsPlayer())
  2330. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2331. else
  2332. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2333. break;
  2334. }
  2335. case COMMAND_GROUP_ACCEPT_INVITE: {
  2336. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2337. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2338. if (result == 0)
  2339. client->SimpleMessage(CHANNEL_GROUP, "You have joined the group.");
  2340. else if (result == 1)
  2341. client->SimpleMessage(CHANNEL_GROUP, "You do not have a pending invite.");
  2342. else if (result == 2)
  2343. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - could not find leader.");
  2344. else
  2345. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - unknown error.");
  2346. }
  2347. break;
  2348. }
  2349. case COMMAND_GROUP_DECLINE_INVITE: {
  2350. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2351. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2352. }
  2353. break;
  2354. }
  2355. case COMMAND_SUMMON:{
  2356. char* search_name = 0;
  2357. if(sep && sep->arg[0][0])
  2358. search_name = sep->arg[0];
  2359. if(!search_name && !cmdTarget){
  2360. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2361. 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.");
  2362. }
  2363. else{
  2364. if(!client->Summon(search_name))
  2365. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2366. }
  2367. break;
  2368. }
  2369. case COMMAND_GOTO:{
  2370. const char* search_name = 0;
  2371. if(sep && sep->arg[0][0])
  2372. search_name = sep->argplus[0];
  2373. if(!search_name && !cmdTarget){
  2374. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2375. 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.");
  2376. }
  2377. else{
  2378. if(!client->GotoSpawn(search_name))
  2379. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2380. }
  2381. break;
  2382. }
  2383. case COMMAND_MOVE:{
  2384. bool success = false;
  2385. try{
  2386. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2387. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2388. if(app){
  2389. client->QueuePacket(app);
  2390. success = true;
  2391. }
  2392. }
  2393. }
  2394. catch(...){}
  2395. if(!success){
  2396. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2397. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2398. }
  2399. break;
  2400. }
  2401. case COMMAND_SETTIME:{
  2402. if(sep && sep->arg[0]){
  2403. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2404. if(sep->arg[1] && sep->IsNumber(1))
  2405. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2406. if(sep->arg[2] && sep->IsNumber(2))
  2407. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2408. if(sep->arg[3] && sep->IsNumber(3))
  2409. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2410. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2411. }
  2412. else{
  2413. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2414. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2415. }
  2416. break;
  2417. }
  2418. case COMMAND_VERSION:{
  2419. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2420. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2421. break;
  2422. }
  2423. case COMMAND_ZONE:{
  2424. string* zonename = 0;
  2425. int32 instanceID = 0;
  2426. const char* zone = 0;
  2427. int32 zone_id = 0;
  2428. bool listSearch = false;
  2429. bool isInstance = false;
  2430. ZoneServer* zsZone = 0;
  2431. if(sep && sep->arg[0][0])
  2432. {
  2433. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2434. listSearch = true;
  2435. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2436. {
  2437. zone_list.SendZoneList(client);
  2438. break;
  2439. }
  2440. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2441. {
  2442. if(sep->IsNumber(1))
  2443. instanceID = atol(sep->arg[1]);
  2444. }
  2445. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2446. {
  2447. PrintSep(sep, "ZONE LOCK");
  2448. if(sep->IsNumber(1))
  2449. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2450. else
  2451. zsZone = zone_list.Get(sep->arg[1], false);
  2452. if( zsZone )
  2453. {
  2454. zsZone->SetZoneLockState(true);
  2455. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2456. }
  2457. else
  2458. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2459. break;
  2460. }
  2461. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2462. {
  2463. PrintSep(sep, "ZONE UNLOCK");
  2464. if(sep->IsNumber(1))
  2465. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2466. else
  2467. zsZone = zone_list.Get(sep->arg[1], false);
  2468. if( zsZone )
  2469. {
  2470. zsZone->SetZoneLockState(false);
  2471. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2472. }
  2473. else
  2474. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2475. break;
  2476. }
  2477. else
  2478. {
  2479. if(sep->IsNumber(0))
  2480. {
  2481. zone_id = atoul(sep->arg[0]);
  2482. zonename = database.GetZoneName(zone_id);
  2483. if(zonename)
  2484. zone = zonename->c_str();
  2485. }
  2486. else
  2487. zone = sep->arg[0];
  2488. }
  2489. if(instanceID > 0)
  2490. {
  2491. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2492. if(zsInstance != NULL)
  2493. {
  2494. instanceID = zsInstance->GetInstanceID();
  2495. zone = zsInstance->GetZoneName();
  2496. zone_id = zsInstance->GetZoneID();
  2497. isInstance = true;
  2498. }
  2499. }
  2500. }
  2501. if(!listSearch)
  2502. {
  2503. if(!zone)
  2504. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2505. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2506. zone_id != client->GetCurrentZone()->GetZoneID())
  2507. {
  2508. if(database.VerifyZone(zone))
  2509. {
  2510. if(client->CheckZoneAccess(zone))
  2511. {
  2512. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zone);
  2513. if(isInstance)
  2514. client->Zone(instanceID,true,true);
  2515. else
  2516. client->Zone(zone);
  2517. }
  2518. }
  2519. else
  2520. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zone);
  2521. }
  2522. else
  2523. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2524. }
  2525. else
  2526. {
  2527. const char* name = 0;
  2528. if(sep && sep->arg[1][0])
  2529. {
  2530. map<int32, string>* zone_names;
  2531. name = sep->argplus[1];
  2532. sint16 status = client->GetAdminStatus();
  2533. if( status > 0 )
  2534. {
  2535. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2536. zone_names = database.GetZoneList(name, true);
  2537. }
  2538. else
  2539. zone_names = database.GetZoneList(name);
  2540. if(!zone_names)
  2541. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2542. else
  2543. {
  2544. map<int32, string>::iterator itr;
  2545. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2546. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2547. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2548. safe_delete(zone_names);
  2549. }
  2550. }
  2551. else
  2552. {
  2553. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2554. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2555. }
  2556. }
  2557. safe_delete(zonename);
  2558. break;
  2559. }
  2560. case COMMAND_USE: {
  2561. Spawn* target = cmdTarget;
  2562. if (target->IsWidget())
  2563. ((Widget*)target)->HandleUse(client, "use");
  2564. break;
  2565. }
  2566. case COMMAND_OPEN: {
  2567. Spawn* target = cmdTarget;
  2568. if (target->IsWidget())
  2569. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2570. break;
  2571. }
  2572. case COMMAND_CASTSPELL: {
  2573. if (sep && sep->arg[0] && sep->IsNumber(0))
  2574. {
  2575. int8 tier = 1;
  2576. if (sep->arg[1] && sep->IsNumber(1))
  2577. tier = atoul(sep->arg[1]);
  2578. int32 spellid = atoul(sep->arg[0]);
  2579. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2580. if (spell)
  2581. {
  2582. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2583. SpellProcess* spellProcess = 0;
  2584. // Get the current zones spell process
  2585. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2586. spellProcess->CastInstant(spell, (Entity*)client->GetPlayer(), (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2587. }
  2588. else
  2589. {
  2590. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2591. }
  2592. }
  2593. else if (sep && sep->arg[0])
  2594. {
  2595. database.FindSpell(client, (char*)sep->argplus[0]);
  2596. }
  2597. else
  2598. {
  2599. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2600. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2601. }
  2602. break;
  2603. }
  2604. case COMMAND_KNOWLEDGEWINDOWSORT: {
  2605. if (client->GetVersion() <= 546)
  2606. break;
  2607. if (sep && sep->GetArgNumber() == 4)
  2608. {
  2609. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  2610. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  2611. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  2612. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  2613. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  2614. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  2615. ClientPacketFunctions::SendSkillSlotMappings(client);
  2616. }
  2617. else
  2618. {
  2619. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  2620. }
  2621. break;
  2622. }
  2623. case COMMAND_MOVE_ITEM:
  2624. {
  2625. int32 id = 0;
  2626. if (sep->IsNumber(0))
  2627. id = atoul(sep->arg[0]);
  2628. Spawn* spawn = 0;
  2629. if (id == 0)
  2630. {
  2631. spawn = cmdTarget;
  2632. }
  2633. else
  2634. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2635. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2636. break;
  2637. client->SendMoveObjectMode(spawn, 0);
  2638. break;
  2639. }
  2640. case COMMAND_PICKUP:
  2641. {
  2642. int32 id = 0;
  2643. if (sep->IsNumber(0))
  2644. id = atoul(sep->arg[0]);
  2645. Spawn* spawn = 0;
  2646. if (id == 0)
  2647. {
  2648. spawn = cmdTarget;
  2649. }
  2650. else
  2651. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2652. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2653. break;
  2654. client->AddItem(spawn->GetPickupItemID(), 1);
  2655. Query query;
  2656. query.RunQuery2(Q_INSERT, "delete from spawn_instance_data where spawn_id = %u and spawn_location_id = %u and pickup_item_id = %u", spawn->GetDatabaseID(), spawn->GetSpawnLocationID(), spawn->GetPickupItemID());
  2657. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  2658. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, true);
  2659. }
  2660. // we had a UI Window displayed, update the house items
  2661. if ( id > 0 )
  2662. client->GetCurrentZone()->SendHouseItems(client);
  2663. break;
  2664. }
  2665. case COMMAND_HOUSE_DEPOSIT:
  2666. {
  2667. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  2668. // arg0 = ??? (set to 3)
  2669. // arg1 = coin (in copper)
  2670. // arg2 = status? (not implemented yet)
  2671. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2672. if (ph && sep && sep->IsNumber(1))
  2673. {
  2674. int64 outVal = strtoull(sep->arg[1], NULL, 0);
  2675. if (client->GetPlayer()->RemoveCoins(outVal))
  2676. {
  2677. char query[256];
  2678. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  2679. if (itr != ph->depositsMap.end())
  2680. {
  2681. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %I64u, last_amount = %I64u where house_id = %u and instance_id = %u and name='%s'", Timer::GetUnixTimeStamp(), outVal, outVal, ph->house_id, ph->instance_id, client->GetPlayer()->GetName());
  2682. }
  2683. else
  2684. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %I64u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outVal);
  2685. if (database.RunQuery(query, strnlen(query, 256)))
  2686. {
  2687. ph->escrow_coins += outVal;
  2688. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins);
  2689. database.LoadDeposits(ph);
  2690. client->PlaySound("coin_cha_ching");
  2691. HouseZone* hz = world.GetHouseZone(ph->house_id);
  2692. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2693. }
  2694. else
  2695. {
  2696. client->GetPlayer()->AddCoins(outVal);
  2697. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  2698. }
  2699. }
  2700. }
  2701. break;
  2702. }
  2703. case COMMAND_HOUSE:
  2704. {
  2705. if (sep && sep->IsNumber(0))
  2706. {
  2707. int32 unique_id = atoi(sep->arg[0]);
  2708. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2709. HouseZone* hz = 0;
  2710. if (ph)
  2711. hz = world.GetHouseZone(ph->house_id);
  2712. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2713. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2714. }
  2715. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  2716. {
  2717. // inside a house or something? Send the access window
  2718. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2719. HouseZone* hz = 0;
  2720. if ( ph )
  2721. hz = world.GetHouseZone(ph->house_id);
  2722. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2723. client->GetCurrentZone()->SendHouseItems(client);
  2724. }
  2725. break;
  2726. }
  2727. case COMMAND_HOUSE_UI:
  2728. {
  2729. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  2730. {
  2731. int32 unique_id = atoi(sep->arg[0]);
  2732. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2733. HouseZone* hz = 0;
  2734. if ( ph )
  2735. hz = world.GetHouseZone(ph->house_id);
  2736. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2737. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  2738. }
  2739. break;
  2740. }
  2741. case COMMAND_PLACE_HOUSE_ITEM: {
  2742. if (sep && sep->IsNumber(0))
  2743. {
  2744. int32 uniqueid = atoi(sep->arg[0]);
  2745. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  2746. //Item* item = player->GetEquipmentList()->GetItem(slot);
  2747. if (item && item->IsHouseItem())
  2748. {
  2749. if (!client->HasOwnerOrEditAccess())
  2750. {
  2751. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  2752. break;
  2753. }
  2754. else if (!item->generic_info.appearance_id)
  2755. {
  2756. client->Message(CHANNEL_COLOR_RED, "This item has not been configured in the database, %s (%u) needs an entry where ?? has the model type id, eg. insert into item_appearances set item_id=%u,equip_type=??;", item->name.c_str(), item->details.item_id, item->details.item_id);
  2757. break;
  2758. }
  2759. if (client->GetTempPlacementSpawn())
  2760. {
  2761. Spawn* tmp = client->GetTempPlacementSpawn();
  2762. client->GetCurrentZone()->RemoveSpawn(false, tmp);
  2763. delete tmp;
  2764. client->SetTempPlacementSpawn(nullptr);
  2765. }
  2766. Spawn* spawn = new Object();
  2767. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2768. spawn->SetID(Spawn::NextID());
  2769. spawn->SetX(client->GetPlayer()->GetX());
  2770. spawn->SetY(client->GetPlayer()->GetY());
  2771. spawn->SetZ(client->GetPlayer()->GetZ());
  2772. spawn->SetHeading(client->GetPlayer()->GetHeading());
  2773. spawn->SetSpawnOrigX(spawn->GetX());
  2774. spawn->SetSpawnOrigY(spawn->GetY());
  2775. spawn->SetSpawnOrigZ(spawn->GetZ());
  2776. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  2777. spawn->appearance.targetable = 1;
  2778. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  2779. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  2780. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  2781. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  2782. spawn->SetZone(client->GetCurrentZone());
  2783. client->GetCurrentZone()->SendSpawn(spawn, client);
  2784. client->SetTempPlacementSpawn(spawn);
  2785. client->SetPlacementUniqueItemID(uniqueid);
  2786. client->SendMoveObjectMode(spawn, 0);
  2787. }
  2788. }
  2789. break;
  2790. }
  2791. case COMMAND_GM:
  2792. {
  2793. if (sep->arg[0] && sep->arg[1])
  2794. {
  2795. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  2796. if (strcmp(sep->arg[0], "vision") == 0)
  2797. {
  2798. client->GetPlayer()->SetGMVision(onOff);
  2799. #if defined(__GNUC__)
  2800. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  2801. #else
  2802. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  2803. #endif
  2804. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  2805. if (onOff)
  2806. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  2807. else
  2808. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  2809. }
  2810. else if (strcmp(sep->arg[0], "luadebug") == 0)
  2811. {
  2812. client->SetLuaDebugClient(onOff);
  2813. #if defined(__GNUC__)
  2814. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  2815. #else
  2816. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  2817. #endif
  2818. if (onOff)
  2819. {
  2820. if (lua_interface)
  2821. lua_interface->UpdateDebugClients(client);
  2822. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  2823. }
  2824. else
  2825. {
  2826. if (lua_interface)
  2827. lua_interface->RemoveDebugClients(client);
  2828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  2829. }
  2830. }
  2831. }
  2832. break;
  2833. }
  2834. case COMMAND_ATTACK:
  2835. case COMMAND_AUTO_ATTACK:{
  2836. int8 type = 1;
  2837. Player* player = client->GetPlayer();
  2838. if(!player)
  2839. break;
  2840. bool incombat = player->EngagedInCombat();
  2841. if(sep && sep->arg[0] && sep->IsNumber(0))
  2842. type = atoi(sep->arg[0]);
  2843. if(client->GetPlayer()->GetHP() == 0){
  2844. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  2845. break;
  2846. }
  2847. if(type == 0){
  2848. if(incombat)
  2849. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2850. player->InCombat(false);
  2851. player->InCombat(false, true);
  2852. player->SetRangeAttack(false);
  2853. }
  2854. else {
  2855. if(type == 2){
  2856. player->InCombat(false);
  2857. if(incombat && player->GetRangeAttack()){
  2858. player->SetRangeAttack(false);
  2859. player->InCombat(false, true);
  2860. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2861. }
  2862. else{
  2863. player->SetRangeAttack(true);
  2864. player->InCombat(true, true);
  2865. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2866. }
  2867. }
  2868. else {
  2869. player->InCombat(false, true);
  2870. player->SetRangeAttack(false);
  2871. player->InCombat(true);
  2872. if(!incombat)
  2873. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2874. }
  2875. /*else
  2876. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  2877. }
  2878. player->SetCharSheetChanged(true);
  2879. break;
  2880. }
  2881. case COMMAND_DEPOP:{
  2882. bool allow_respawns = false;
  2883. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2884. if(atoi(sep->arg[0]) == 1)
  2885. allow_respawns = true;
  2886. }
  2887. client->GetCurrentZone()->Depop(allow_respawns);
  2888. break;
  2889. }
  2890. case COMMAND_REPOP:{
  2891. client->GetCurrentZone()->Depop(false, true);
  2892. break;
  2893. }
  2894. case COMMAND_BUYBACK:{
  2895. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2896. // 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
  2897. int64 id = atoi64(sep->arg[0]);
  2898. // get the first int32, the item id
  2899. //int32 item_id = (int32)id;
  2900. // get the second int32, the unique id
  2901. int32 unique_id = (int32)(id>>32);
  2902. int8 quantity = atoi(sep->arg[1]);
  2903. if(quantity == 255)
  2904. quantity = 1;
  2905. client->BuyBack(unique_id, quantity);
  2906. }
  2907. break;
  2908. }
  2909. case COMMAND_MERCHANT_BUY:{
  2910. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2911. int32 item_id = atoul(sep->arg[0]);
  2912. int8 quantity = atoi(sep->arg[1]);
  2913. client->BuyItem(item_id, quantity);
  2914. }
  2915. break;
  2916. }
  2917. case COMMAND_MERCHANT_SELL:{
  2918. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2919. // 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
  2920. int64 id = atoi64(sep->arg[0]);
  2921. // get the first int32, the item id
  2922. int32 item_id = (int32)id;
  2923. // get the second int32, the unique id
  2924. int32 unique_id = (int32)(id>>32);
  2925. int8 quantity = atoi(sep->arg[1]);
  2926. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  2927. client->SellItem(item_id, quantity, unique_id);
  2928. }
  2929. break;
  2930. }
  2931. case COMMAND_MENDER_REPAIR: {
  2932. if (sep && sep->arg[0] && sep->IsNumber(0))
  2933. client->RepairItem(atoul(sep->arg[0]));
  2934. break;
  2935. }
  2936. case COMMAND_MENDER_REPAIR_ALL: {
  2937. client->RepairAllItems();
  2938. break;
  2939. }
  2940. case COMMAND_CANCEL_MERCHANT:{
  2941. client->SetMerchantTransaction(0);
  2942. break;
  2943. }
  2944. case COMMAND_START_MERCHANT:{
  2945. break;
  2946. }
  2947. case COMMAND_INVULNERABLE:{
  2948. sint8 val = -1;
  2949. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2950. val = atoi(sep->arg[0]);
  2951. //devn00b: Fix for linux builds
  2952. #if defined(__GNUC__)
  2953. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  2954. #else
  2955. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2956. #endif
  2957. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2958. client->GetPlayer()->SetInvulnerable(val==1);
  2959. if(client->GetPlayer()->GetInvulnerable())
  2960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  2961. else
  2962. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  2963. }
  2964. if(val == -1)
  2965. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  2966. break;
  2967. }
  2968. case COMMAND_REPAIR: {
  2969. Spawn* spawn = cmdTarget;
  2970. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  2971. client->SendHailCommand(spawn);
  2972. client->SetMerchantTransaction(spawn);
  2973. client->SendRepairList();
  2974. }
  2975. break;
  2976. }
  2977. case COMMAND_LOTTO: {
  2978. Spawn* spawn = cmdTarget;
  2979. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  2980. client->SetMerchantTransaction(spawn);
  2981. client->ShowLottoWindow();
  2982. }
  2983. break;
  2984. }
  2985. case COMMAND_ACCEPT_REWARD:{
  2986. int32 unknown = 0;
  2987. int32 selectable_item_id = 0;
  2988. //Quest *quest = 0;
  2989. Collection *collection = 0;
  2990. /* no idea what the first argument is for (faction maybe?)
  2991. if the reward has a selectable item reward, it's sent as the second argument
  2992. if neither of these are included in the reward, there is no sep
  2993. 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
  2994. only 1 quest or collection reward may be displayed at a time */
  2995. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2996. unknown = atoul(sep->arg[0]);
  2997. selectable_item_id = atoul(sep->arg[1]);
  2998. }
  2999. //if ((quest = player->GetPendingQuestReward()))
  3000. // client->AcceptQuestRewards(quest, selectable_item_id);
  3001. /* the below needs to go away eventually and be redone */
  3002. int32 item_id = 0;
  3003. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3004. item_id = atoul(sep->arg[0]);
  3005. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3006. if(quest){
  3007. client->AcceptQuestReward(quest, item_id);
  3008. break;
  3009. }
  3010. if (collection = player->GetPendingCollectionReward())
  3011. client->AcceptCollectionRewards(collection, selectable_item_id);
  3012. else
  3013. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  3014. break;
  3015. }
  3016. case COMMAND_BUY_FROM_BROKER:{
  3017. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3018. int32 item_id = atoul(sep->arg[0]);
  3019. int16 quantity = atoul(sep->arg[1]);
  3020. client->AddItem(item_id, quantity);
  3021. }
  3022. break;
  3023. }
  3024. case COMMAND_SEARCH_STORES_PAGE:{
  3025. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3026. int32 page = atoul(sep->arg[0]);
  3027. client->SearchStore(page);
  3028. }
  3029. break;
  3030. }
  3031. case COMMAND_SEARCH_STORES:{
  3032. if(sep && sep->arg[0][0]){
  3033. const char* values = sep->argplus[0];
  3034. if(values){
  3035. map<string, string> str_values = TranslateBrokerRequest(values);
  3036. vector<Item*>* items = master_item_list.GetItems(str_values);
  3037. if(items){
  3038. client->SetItemSearch(items);
  3039. client->SearchStore(0);
  3040. }
  3041. }
  3042. }
  3043. break;
  3044. }
  3045. case COMMAND_LUADEBUG:{
  3046. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  3047. client->SetLuaDebugClient(true);
  3048. if(lua_interface)
  3049. lua_interface->UpdateDebugClients(client);
  3050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3051. }
  3052. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  3053. client->SetLuaDebugClient(false);
  3054. if(lua_interface)
  3055. lua_interface->RemoveDebugClients(client);
  3056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3057. }
  3058. else{
  3059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  3060. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  3061. }
  3062. break;
  3063. }
  3064. case COMMAND_SPAWN_GROUP:
  3065. {
  3066. Spawn* target = cmdTarget;
  3067. if(target && target->IsPlayer() == false)
  3068. {
  3069. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  3070. {
  3071. if(target->GetSpawnLocationPlacementID() > 0)
  3072. {
  3073. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  3074. {
  3075. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  3076. if(id > 0)
  3077. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  3078. else
  3079. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  3080. target->SetSpawnGroupID(id);
  3081. target->AddSpawnToGroup(target);
  3082. }
  3083. else
  3084. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  3085. }
  3086. else
  3087. 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.");
  3088. }
  3089. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  3090. {
  3091. if(sep->arg[1] && sep->IsNumber(1))
  3092. {
  3093. int32 group_id = atoul(sep->arg[1]);
  3094. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  3095. if(leader)
  3096. {
  3097. leader->AddSpawnToGroup(target);
  3098. target->SetSpawnGroupID(group_id);
  3099. if(database.SpawnGroupAddSpawn(target, group_id))
  3100. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  3101. else
  3102. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  3103. }
  3104. else
  3105. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  3106. }
  3107. else
  3108. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  3109. }
  3110. else if(target->GetSpawnGroupID() == 0)
  3111. {
  3112. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  3113. }
  3114. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  3115. {
  3116. int32 group_id = target->GetSpawnGroupID();
  3117. target->RemoveSpawnFromGroup();
  3118. if(database.SpawnGroupRemoveSpawn(target, group_id))
  3119. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  3120. else
  3121. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  3122. }
  3123. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  3124. {
  3125. int32 group_id = target->GetSpawnGroupID();
  3126. if(sep->arg[1] && sep->IsNumber(1))
  3127. {
  3128. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  3129. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  3130. else
  3131. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  3132. }
  3133. else
  3134. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  3135. }
  3136. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  3137. {
  3138. int32 group_id = target->GetSpawnGroupID();
  3139. if(sep->arg[1] && sep->IsNumber(1))
  3140. {
  3141. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  3142. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  3143. else
  3144. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  3145. }
  3146. else
  3147. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  3148. }
  3149. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  3150. {
  3151. if(sep->arg[1] && sep->IsNumber(1))
  3152. {
  3153. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  3154. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  3155. else
  3156. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  3157. }
  3158. else
  3159. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  3160. }
  3161. else
  3162. {
  3163. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  3164. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  3165. }
  3166. }
  3167. else
  3168. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  3169. break;
  3170. }
  3171. case COMMAND_SPAWN_COMBINE:{
  3172. Spawn* spawn = cmdTarget;
  3173. float radius = 0;
  3174. bool failed = true;
  3175. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  3176. failed = false;
  3177. if(spawn->GetSpawnGroupID() > 0){
  3178. 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.");
  3179. }
  3180. else if(sep->IsNumber(0)){
  3181. radius = atof(sep->arg[0]);
  3182. client->CombineSpawns(radius, spawn);
  3183. }
  3184. else{
  3185. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  3186. client->AddCombineSpawn(spawn);
  3187. }
  3188. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  3189. client->RemoveCombineSpawn(spawn);
  3190. }
  3191. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  3192. const char* name = 0;
  3193. if(sep->arg[1] && sep->arg[1][0])
  3194. name = sep->argplus[1];
  3195. client->SaveCombineSpawns(name);
  3196. }
  3197. else
  3198. failed = true;
  3199. }
  3200. }
  3201. if(failed){
  3202. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  3203. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  3204. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  3205. }
  3206. break;
  3207. }
  3208. case COMMAND_SPAWN_CREATE:{
  3209. Spawn* spawn = 0;
  3210. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3211. spawn = new Object();
  3212. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3213. }
  3214. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3215. spawn = new GroundSpawn();
  3216. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3217. }
  3218. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3219. spawn = new Sign();
  3220. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3221. }
  3222. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3223. spawn = new NPC();
  3224. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3225. spawn->appearance.pos.collision_radius = 32;
  3226. spawn->secondary_command_list_id = 0;
  3227. spawn->primary_command_list_id = 0;
  3228. spawn->appearance.display_name = 1;
  3229. spawn->appearance.show_level = 1;
  3230. spawn->appearance.attackable = 1;
  3231. }
  3232. else{
  3233. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  3234. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  3235. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  3236. break;
  3237. }
  3238. spawn->SetID(Spawn::NextID());
  3239. spawn->SetX(client->GetPlayer()->GetX());
  3240. spawn->SetY(client->GetPlayer()->GetY());
  3241. spawn->SetZ(client->GetPlayer()->GetZ());
  3242. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3243. spawn->SetSpawnOrigX(spawn->GetX());
  3244. spawn->SetSpawnOrigY(spawn->GetY());
  3245. spawn->SetSpawnOrigZ(spawn->GetZ());
  3246. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3247. spawn->appearance.targetable = 1;
  3248. spawn->appearance.race = 255;
  3249. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3250. spawn->SetModelType(atoi(sep->arg[1]));
  3251. spawn->SetAdventureClass(atoi(sep->arg[2]));
  3252. spawn->SetLevel(atoi(sep->arg[3]));
  3253. spawn->SetName(sep->arg[4]);
  3254. if(sep->arg[5][0] && sep->IsNumber(5))
  3255. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  3256. if(sep->arg[6][0] && sep->IsNumber(6))
  3257. spawn->size = atoi(sep->arg[6]);
  3258. if(spawn->GetTotalHP() == 0){
  3259. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  3260. spawn->SetHP(25*spawn->GetLevel() + 1);
  3261. }
  3262. if(spawn->GetTotalPower() == 0){
  3263. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3264. spawn->SetPower(25*spawn->GetLevel() + 1);
  3265. }
  3266. client->GetCurrentZone()->AddSpawn(spawn);
  3267. break;
  3268. }
  3269. case COMMAND_SPAWN_EQUIPMENT:{
  3270. Spawn* spawn = cmdTarget;
  3271. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3272. int8 slot = atoi(sep->arg[0]);
  3273. int16 type = atoi(sep->arg[1]);
  3274. int8 red = 0;
  3275. int8 green = 0;
  3276. int8 blue = 0;
  3277. int8 h_red = 0;
  3278. int8 h_green = 0;
  3279. int8 h_blue = 0;
  3280. if(sep->arg[2])
  3281. red = atoi(sep->arg[2]);
  3282. if(sep->arg[3])
  3283. green = atoi(sep->arg[3]);
  3284. if(sep->arg[4])
  3285. blue = atoi(sep->arg[4]);
  3286. if(sep->arg[5])
  3287. h_red = atoi(sep->arg[5]);
  3288. if(sep->arg[6])
  3289. h_green = atoi(sep->arg[6]);
  3290. if(sep->arg[7])
  3291. h_blue = atoi(sep->arg[7]);
  3292. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3293. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3294. }
  3295. else{
  3296. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3297. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3298. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3299. }
  3300. break;
  3301. }
  3302. case COMMAND_SPAWN_DETAILS: {
  3303. Spawn* spawn = cmdTarget;
  3304. if (sep && sep->arg[0][0]) {
  3305. if (cmdTarget)
  3306. {
  3307. if (ToLower(string(sep->arg[0])) == "los")
  3308. {
  3309. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3310. if (hasLOS)
  3311. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3312. else
  3313. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3314. break;
  3315. }
  3316. else if (ToLower(string(sep->arg[0])) == "bestz")
  3317. {
  3318. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3319. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3320. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3321. break;
  3322. }
  3323. else if (ToLower(string(sep->arg[0])) == "pathto")
  3324. {
  3325. break;
  3326. }
  3327. else if (ToLower(string(sep->arg[0])) == "pathfrom")
  3328. {
  3329. break;
  3330. }
  3331. }
  3332. if (sep->IsNumber(0))
  3333. {
  3334. float radius = atof(sep->arg[0]);
  3335. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3336. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3337. break;
  3338. }
  3339. }
  3340. if (spawn) {
  3341. const char* type = "NPC";
  3342. if (spawn->IsObject())
  3343. type = "Object";
  3344. else if (spawn->IsSign())
  3345. type = "Sign";
  3346. else if (spawn->IsWidget())
  3347. type = "Widget";
  3348. else if (spawn->IsGroundSpawn())
  3349. type = "GroundSpawn";
  3350. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3351. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3352. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3353. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3354. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3355. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3356. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3357. 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());
  3358. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3359. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3360. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3361. if (spawn->IsEntity()) {
  3362. 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());
  3363. 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());
  3364. }
  3365. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3366. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3367. 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());
  3368. 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);
  3369. if (spawn->IsNPC())
  3370. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3371. string details;
  3372. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3373. details += "Type: " + string(type) + "\n";
  3374. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3375. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3376. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3377. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3378. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3379. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3380. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3381. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3382. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3383. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3384. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3385. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3386. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3387. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3388. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3389. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3390. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3391. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3392. char x[16];
  3393. sprintf(x, "%.2f", spawn->GetX());
  3394. char y[16];
  3395. sprintf(y, "%.2f", spawn->GetY());
  3396. char z[16];
  3397. sprintf(z, "%.2f", spawn->GetZ());
  3398. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3399. string details2;
  3400. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3401. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3402. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3403. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3404. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3405. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3406. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3407. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3408. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3409. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3410. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3411. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3412. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3413. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3414. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3415. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3416. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3417. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3418. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3419. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3420. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3421. string details3;
  3422. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3423. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3424. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3425. string details4;
  3426. if (spawn->IsEntity()) {
  3427. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3428. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3429. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3430. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3431. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3432. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3433. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3434. if (spawn->IsNPC()) {
  3435. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3436. }
  3437. }
  3438. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3439. client->SendShowBook(client->GetPlayer(), title, 4, details, details2, details3, details4);
  3440. }
  3441. else {
  3442. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3443. 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.");
  3444. }
  3445. break;
  3446. }
  3447. case COMMAND_SPAWN_TARGET:{
  3448. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3449. int32 spawn_id = atoul(sep->arg[0]);
  3450. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3451. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3452. }
  3453. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3454. float distance = atof(sep->arg[1]);
  3455. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3456. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3457. }
  3458. else{
  3459. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3460. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3461. }
  3462. break;
  3463. }
  3464. case COMMAND_SPAWN_SET:
  3465. {
  3466. Spawn* spawn = cmdTarget;
  3467. sint16 set_type = -1;
  3468. string type_str;
  3469. if (spawn)
  3470. {
  3471. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3472. 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)
  3473. {
  3474. // set the type, which will be 0 if location or list or invalid
  3475. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3476. }
  3477. if(set_type > 0)
  3478. {
  3479. // check if spawn set is NOT a char update, or not location, or isn't a number
  3480. if(!(set_type >= SPAWN_SET_VALUE_PREFIX) && !(set_type <= SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL) && set_type != SPAWN_SET_VALUE_NAME && ((set_type < SPAWN_SET_VALUE_SPAWN_SCRIPT) || (set_type > SPAWN_SET_VALUE_SUB_TITLE)) && set_type != SPAWN_SET_VALUE_LOCATION && sep->IsNumber(1) == false)
  3481. {
  3482. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3483. }
  3484. else
  3485. {
  3486. string name = string(spawn->GetName());
  3487. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1]))
  3488. {
  3489. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  3490. {
  3491. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  3492. }
  3493. else if(set_type == SPAWN_SET_VALUE_NAME)
  3494. {
  3495. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3496. }
  3497. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3498. {
  3499. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3500. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3501. }
  3502. else
  3503. {
  3504. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3505. }
  3506. switch (set_type)
  3507. {
  3508. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  3509. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  3510. case SPAWN_SET_VALUE_FACTION:
  3511. {
  3512. // not applicable
  3513. break;
  3514. }
  3515. default:
  3516. {
  3517. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->arg[1]);
  3518. break;
  3519. }
  3520. }
  3521. 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))
  3522. {
  3523. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3524. {
  3525. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3526. }
  3527. else if(spawn->GetSpawnLocationID() > 0)
  3528. {
  3529. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3530. }
  3531. }
  3532. else
  3533. {
  3534. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3535. {
  3536. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3537. }
  3538. else if(spawn->GetDatabaseID() > 0)
  3539. {
  3540. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3541. }
  3542. }
  3543. }
  3544. }
  3545. }
  3546. else if(set_type == 0)
  3547. {
  3548. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3549. map<string, int8>::iterator itr;
  3550. int i=0;
  3551. string list;
  3552. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3553. {
  3554. if(i==10)
  3555. {
  3556. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3557. i = 0;
  3558. }
  3559. if(i>0)
  3560. {
  3561. list.append(", ").append(itr->first);
  3562. }
  3563. else
  3564. {
  3565. list = itr->first;
  3566. }
  3567. }
  3568. if(list.length() > 0)
  3569. {
  3570. // if 1 or more, display in client.
  3571. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3572. }
  3573. }
  3574. else
  3575. {
  3576. // syntax fail
  3577. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3578. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3579. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3580. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3581. }
  3582. }
  3583. break;
  3584. }
  3585. case COMMAND_SPAWN_REMOVE:{
  3586. Spawn* spawn = cmdTarget;
  3587. if(spawn && !spawn->IsPlayer()){
  3588. if(spawn->GetSpawnLocationID() > 0){
  3589. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3590. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, false);
  3591. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3592. }
  3593. else
  3594. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3595. }
  3596. else
  3597. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3598. }
  3599. else{
  3600. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3601. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3602. }
  3603. break;
  3604. }
  3605. case COMMAND_SPAWN_LIST:{
  3606. if(sep && sep->arg[0][0]){
  3607. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3608. vector<string>::iterator itr;
  3609. if(results){
  3610. for(itr=results->begin();itr!=results->end();itr++){
  3611. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3612. }
  3613. safe_delete(results);
  3614. }
  3615. else
  3616. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3617. }
  3618. else{
  3619. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3620. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3621. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3622. }
  3623. break;
  3624. }
  3625. case COMMAND_SPAWN_ADD:{
  3626. Spawn* spawn = cmdTarget;
  3627. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3628. if(spawn->GetSpawnLocationID() > 0){
  3629. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3630. break;
  3631. }
  3632. if(spawn->GetDatabaseID() == 0){
  3633. if(database.SaveSpawnInfo(spawn)) {
  3634. char spawn_type[32];
  3635. memset(spawn_type, 0, sizeof(spawn_type));
  3636. if (spawn->IsNPC())
  3637. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3638. else if (spawn->IsObject())
  3639. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3640. else if (spawn->IsSign())
  3641. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3642. else if (spawn->IsGroundSpawn())
  3643. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3644. else
  3645. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3646. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3647. }
  3648. else
  3649. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3650. }
  3651. int32 spawn_group_id = 0;
  3652. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3653. spawn_group_id = database.GetNextSpawnLocation();
  3654. else
  3655. spawn_group_id = atol(sep->arg[0]);
  3656. int8 percent = 100;
  3657. if(sep->arg[2] && sep->IsNumber(2))
  3658. percent = atoi(sep->arg[2]);
  3659. spawn->SetSpawnLocationID(spawn_group_id);
  3660. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3661. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3662. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3663. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3664. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3665. else
  3666. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3667. }
  3668. else{
  3669. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3670. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3671. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3672. }
  3673. break;
  3674. }
  3675. case COMMAND_SPAWN:{
  3676. int32 id = 0;
  3677. Spawn* spawn = 0;
  3678. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3679. id = atol(sep->arg[0]);
  3680. spawn = client->GetCurrentZone()->GetSpawn(id);
  3681. }
  3682. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3683. id = 0;
  3684. if(!id || !spawn){
  3685. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3686. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3687. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3688. safe_delete(sep);
  3689. return;
  3690. }
  3691. if(sep && sep->arg[1][0]){
  3692. float x = atof(sep->arg[1]);
  3693. spawn->appearance.pos.X = x;
  3694. }
  3695. else
  3696. spawn->SetX(client->GetPlayer()->GetX(), false);
  3697. if(sep && sep->arg[2][0]){
  3698. float y = atof(sep->arg[2]);
  3699. spawn->appearance.pos.Y = y;
  3700. }
  3701. else
  3702. spawn->SetY(client->GetPlayer()->GetY(), false);
  3703. if(sep && sep->arg[3][0]){
  3704. float z = atof(sep->arg[3]);
  3705. spawn->appearance.pos.Z = z;
  3706. }
  3707. else
  3708. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3709. if(sep && sep->arg[4][0]){
  3710. float heading = atof(sep->arg[4]);
  3711. spawn->SetHeading(heading);
  3712. }
  3713. else
  3714. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3715. spawn->SetSpawnOrigX(spawn->GetX());
  3716. spawn->SetSpawnOrigY(spawn->GetY());
  3717. spawn->SetSpawnOrigZ(spawn->GetZ());
  3718. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3719. if(sep && sep->arg[5][0])
  3720. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3721. else
  3722. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3723. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3724. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3725. spawn->SetHP(spawn->GetTotalHP());
  3726. }
  3727. if(spawn->GetTotalPower() == 0){
  3728. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3729. spawn->SetPower(spawn->GetTotalPower());
  3730. }
  3731. const char* script = world.GetSpawnScript(id);
  3732. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3733. spawn->SetSpawnScript(string(script));
  3734. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  3735. client->GetCurrentZone()->AddSpawn(spawn);
  3736. if(spawn->IsNPC())
  3737. spawn->GetZone()->AddLoot((NPC*)spawn);
  3738. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3739. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3740. break;
  3741. }
  3742. case COMMAND_ADMINFLAG:
  3743. {
  3744. if(sep && sep->arg[0]){
  3745. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3746. sint16 new_status = atoi(sep->arg[1]);
  3747. if(tmp_status == -10)
  3748. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3749. else if(tmp_status >= client->GetAdminStatus())
  3750. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3751. else if (new_status > client->GetAdminStatus())
  3752. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3753. else{
  3754. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3755. if (!client2)
  3756. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3757. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3758. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3759. if (client2) {
  3760. client2->SetAdminStatus(new_status);
  3761. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3762. }
  3763. }
  3764. else
  3765. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3766. }
  3767. }else{
  3768. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3769. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3770. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3771. }
  3772. break;
  3773. }
  3774. case COMMAND_CANNEDEMOTE:{
  3775. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3776. break;
  3777. }
  3778. case COMMAND_BROADCAST: {
  3779. if (sep && sep->arg[0])
  3780. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3781. else
  3782. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3783. break;
  3784. }
  3785. case COMMAND_ANNOUNCE: {
  3786. if (sep && sep->arg[0])
  3787. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3788. else
  3789. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3790. break;
  3791. }
  3792. case COMMAND_RELOAD_ITEMS:{
  3793. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3794. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3795. database.ReloadItemList();
  3796. database.LoadMerchantInformation();
  3797. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3798. break;
  3799. }
  3800. case COMMAND_ENABLE_ABILITY_QUE:{
  3801. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3802. if(app)
  3803. client->QueuePacket(app);
  3804. break;
  3805. }
  3806. case COMMAND_ITEMSEARCH:{
  3807. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3808. if (packet) {
  3809. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3810. //packet->setDataByName("unknown", 1);
  3811. packet->setDataByName("unknown2", 5, 0);
  3812. packet->setDataByName("unknown2", 20, 1);
  3813. packet->setDataByName("unknown2", 58, 3);
  3814. packet->setDataByName("unknown2", 40, 4);
  3815. client->QueuePacket(packet->serialize());
  3816. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3817. if (packet2) {
  3818. packet2->setDataByName("char_id", client->GetCharacterID());
  3819. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3820. safe_delete(packet2);
  3821. }
  3822. safe_delete(packet);
  3823. }
  3824. break;
  3825. }
  3826. case COMMAND_ANIMTEST:{
  3827. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3828. if(command_packet){
  3829. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  3830. if (cmdTarget)
  3831. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  3832. command_packet->setDataByName ( "spawn_id" , id);
  3833. int animID = 1;
  3834. if(sep && sep->arg[0] && sep->IsNumber(0))
  3835. animID = atoi(sep->arg[0]);
  3836. VisualState* vs = NULL;
  3837. if(animID == 0)
  3838. {
  3839. vs = visual_states.FindVisualState(sep->arg[0]);
  3840. }
  3841. char msg[128];
  3842. sprintf(msg,"Animation Test ID: %i",animID);
  3843. command_packet->setMediumStringByName ( "emote_msg" , msg );
  3844. if(vs != NULL)
  3845. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  3846. else
  3847. command_packet->setDataByName ( "anim_type", animID );
  3848. command_packet->setDataByName ( "unknown0", 0 );
  3849. EQ2Packet* outapp = command_packet->serialize();
  3850. client->QueuePacket(outapp);
  3851. safe_delete(command_packet);
  3852. }
  3853. break;
  3854. }
  3855. case COMMAND_KICK:
  3856. {
  3857. if( sep == 0 || sep->arg[0] == 0)
  3858. {
  3859. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  3860. }
  3861. else
  3862. {
  3863. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  3864. if ( kickClient == client )
  3865. {
  3866. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  3867. break;
  3868. }
  3869. else if(kickClient != NULL)
  3870. {
  3871. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3872. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  3873. {
  3874. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3875. break;
  3876. }
  3877. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  3878. kickClient->Disconnect();
  3879. }
  3880. else
  3881. {
  3882. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3883. }
  3884. }
  3885. break;
  3886. }
  3887. case COMMAND_LOCK:
  3888. {
  3889. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  3890. int worldLocked = atoi(sep->arg[0]);
  3891. net.world_locked = worldLocked;
  3892. if ( worldLocked )
  3893. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  3894. else
  3895. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  3896. }
  3897. else
  3898. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  3899. break;
  3900. }
  3901. case COMMAND_BAN:{
  3902. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  3903. {
  3904. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  3905. }
  3906. else
  3907. {
  3908. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  3909. if ( kickClient == client )
  3910. {
  3911. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  3912. break;
  3913. }
  3914. else if(kickClient != NULL)
  3915. {
  3916. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3917. if ( maxStatus > client->GetAdminStatus( ) ||
  3918. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  3919. {
  3920. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3921. break;
  3922. }
  3923. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  3924. int perm = atol(sep->arg[1]);
  3925. if ( perm == 1 )
  3926. database.UpdateAdminStatus(sep->arg[0],-2);
  3927. else
  3928. database.UpdateAdminStatus(sep->arg[0],-1);
  3929. kickClient->Disconnect();
  3930. }
  3931. else
  3932. {
  3933. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3934. }
  3935. }
  3936. break;
  3937. }
  3938. case COMMAND_SET_COMBAT_VOICE:{
  3939. int32 value = 0;
  3940. if(sep && sep->arg[0] && sep->IsNumber(0))
  3941. value = atoi(sep->arg[0]);
  3942. client->GetPlayer()->SetCombatVoice(value);
  3943. break;
  3944. }
  3945. case COMMAND_SET_EMOTE_VOICE:{
  3946. int32 value = 0;
  3947. if(sep && sep->arg[0] && sep->IsNumber(0))
  3948. value = atoi(sep->arg[0]);
  3949. client->GetPlayer()->SetEmoteVoice(value);
  3950. break;
  3951. }
  3952. case COMMAND_GIVEITEM:{
  3953. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  3954. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  3955. if ( itemToClient == NULL )
  3956. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  3957. else
  3958. {
  3959. int32 item_id = atol(sep->arg[1]);
  3960. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  3961. itemToClient->AddItem(item_id);
  3962. }
  3963. }
  3964. else
  3965. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  3966. break;
  3967. }
  3968. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  3969. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  3970. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  3971. case COMMAND_SKILL :
  3972. case COMMAND_SKILL_ADD :
  3973. case COMMAND_SKILL_REMOVE :
  3974. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  3975. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  3976. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  3977. case COMMAND_ENTITYCOMMAND :
  3978. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  3979. case COMMAND_MERCHANT :
  3980. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  3981. case COMMAND_APPEARANCE :
  3982. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  3983. case COMMAND_TRACK : { Command_Track(client); break; }
  3984. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  3985. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  3986. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  3987. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  3988. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  3989. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  3990. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  3991. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  3992. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  3993. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  3994. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  3995. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  3996. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  3997. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  3998. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  3999. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  4000. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  4001. case COMMAND_LOCATION : { Command_Location(client); break; }
  4002. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  4003. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  4004. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  4005. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  4006. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  4007. case COMMAND_GRID : { Command_Grid(client); break; }
  4008. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  4009. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  4010. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  4011. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  4012. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  4013. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  4014. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  4015. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  4016. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  4017. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  4018. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  4019. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  4020. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  4021. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  4022. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  4023. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  4024. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  4025. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  4026. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  4027. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  4028. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  4029. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  4030. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  4031. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  4032. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  4033. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  4034. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  4035. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  4036. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  4037. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  4038. case COMMAND_MOTD : { Command_MOTD(client); break; }
  4039. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  4040. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  4041. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  4042. case COMMAND_TITLE : { Command_Title(client); break; }
  4043. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  4044. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  4045. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  4046. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  4047. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  4048. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  4049. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  4050. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  4051. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  4052. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  4053. case COMMAND_PET : { Command_Pet(client, sep); break; }
  4054. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  4055. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  4056. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  4057. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  4058. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  4059. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  4060. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  4061. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  4062. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  4063. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  4064. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  4065. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  4066. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  4067. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  4068. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  4069. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  4070. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  4071. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  4072. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  4073. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  4074. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  4075. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  4076. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  4077. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  4078. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  4079. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  4080. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  4081. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  4082. case COMMAND_MODIFY : { Command_Modify(client); break; }
  4083. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  4084. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  4085. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  4086. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  4087. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  4088. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  4089. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  4090. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  4091. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  4092. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  4093. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  4094. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  4095. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  4096. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  4097. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  4098. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  4099. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  4100. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  4101. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  4102. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  4103. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  4104. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  4105. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  4106. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  4107. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  4108. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  4109. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  4110. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  4111. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  4112. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  4113. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  4114. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  4115. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  4116. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  4117. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  4118. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  4119. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  4120. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  4121. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  4122. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  4123. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  4124. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  4125. case ADD_AA : { Add_AA(client, sep); break; }
  4126. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  4127. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  4128. case BACK_AA : { Back_AA(client, sep); break; }
  4129. case REMOVE_AA : { Remove_AA(client, sep); break; }
  4130. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  4131. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  4132. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  4133. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  4134. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  4135. default:
  4136. {
  4137. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  4138. break;
  4139. }
  4140. }
  4141. safe_delete(sep);
  4142. }
  4143. /******************** New COMMAND Handler Functions ********************/
  4144. /*
  4145. Started breaking apart the huge switch() for commands into sepErate
  4146. functions so it is easier to locate the blocks of code by command
  4147. -- JA 2012.03.03
  4148. */
  4149. // sample function header
  4150. /*
  4151. Function:
  4152. Purpose :
  4153. Params :
  4154. Dev :
  4155. Example :
  4156. */
  4157. //void Commands::Command()
  4158. //{
  4159. //}
  4160. /*
  4161. Function: Command_AcceptAdvancement()
  4162. Purpose : Player accepts a new advancement option
  4163. Params : Spell ID
  4164. Dev : Jabantiz
  4165. */
  4166. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4167. {
  4168. Player *player = client->GetPlayer();
  4169. if (sep && sep->IsSet(0)) {
  4170. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4171. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4172. if (!player->HasSpell(trait->spellID, 0, true))
  4173. {
  4174. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4175. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4176. }
  4177. else
  4178. {
  4179. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4180. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4181. player->RemoveSpellBookEntry(spell->GetSpellID());
  4182. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4183. player->UnlockSpell(spell);
  4184. client->SendSpellUpdate(spell);
  4185. }
  4186. // Spell book update
  4187. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4188. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4189. }
  4190. }
  4191. /*
  4192. Function:
  4193. Purpose :
  4194. Params :
  4195. Dev :
  4196. Example :
  4197. */
  4198. void Commands::Command_AFK(Client* client, Seperator* sep)
  4199. {
  4200. Player* player = client->GetPlayer();
  4201. player->toggle_character_flag(CF_AFK);
  4202. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4203. if (player->get_character_flag(CF_AFK))
  4204. {
  4205. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4206. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  4207. if (sep && sep->argplus[0])
  4208. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4209. else
  4210. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4211. string message = string(player->GetName()) + " is going afk.";
  4212. Spawn* target = player->GetTarget();
  4213. if (target && target != player)
  4214. {
  4215. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4216. player->GetGender() == 1 ? message += "he" : message += "she";
  4217. message += " is going afk.";
  4218. }
  4219. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4220. }
  4221. /*else
  4222. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  4223. }
  4224. /*
  4225. Function: Command_Appearance()
  4226. Purpose : Handles /appearance commands
  4227. Params : list
  4228. Dev : Scatman
  4229. Example : /appearance list
  4230. */
  4231. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4232. {
  4233. if( handler == COMMAND_APPEARANCE )
  4234. {
  4235. // /appearance command by itself shows help (to be extended)
  4236. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4237. return;
  4238. }
  4239. else if( handler == COMMAND_APPEARANCE_LIST )
  4240. {
  4241. // /appearance list command expects "name" param
  4242. if (sep && sep->arg[0])
  4243. {
  4244. const char* appearance_name = sep->argplus[0];
  4245. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4246. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4247. if (appearances)
  4248. {
  4249. vector<int16>::iterator itr;
  4250. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4251. {
  4252. int16 id = *itr;
  4253. string name = database.GetAppearanceName(id);
  4254. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4255. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4256. }
  4257. safe_delete(appearances);
  4258. }
  4259. }
  4260. else // no param
  4261. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4262. }
  4263. }
  4264. /*
  4265. Function: Command_Claim()
  4266. Purpose :
  4267. Params :
  4268. Dev :
  4269. Example :
  4270. */
  4271. void Commands::Command_Claim(Client* client, Seperator* sep)
  4272. {
  4273. if (sep && sep->arg[0] && sep->IsNumber(0))
  4274. {
  4275. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4276. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4277. }
  4278. else
  4279. client->ShowClaimWindow();
  4280. }
  4281. /*
  4282. Function: Command_ClearAllQueued()
  4283. Purpose :
  4284. Params :
  4285. Dev :
  4286. Example :
  4287. */
  4288. void Commands::Command_ClearAllQueued(Client* client)
  4289. {
  4290. ZoneServer* zone = client->GetPlayer()->GetZone();
  4291. if (zone && zone->GetSpellProcess())
  4292. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4293. }
  4294. /*
  4295. Function: Command_CancelMaintained()
  4296. Purpose : Cancels maintained spells
  4297. Params : Maintained Spell Index
  4298. Dev : Zcoretri
  4299. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4300. */
  4301. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4302. {
  4303. if (sep && sep->arg[0] && sep->IsNumber(0))
  4304. {
  4305. int32 spell_index = atoul(sep->arg[0]);
  4306. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4307. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4308. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4309. // just not spelleffects/dets - Foof
  4310. //{
  4311. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell))
  4312. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4313. // }
  4314. //else
  4315. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4316. }
  4317. }
  4318. /*
  4319. Function: Command_Create()
  4320. Purpose : Handler for starting Tradeskilling table
  4321. Params :
  4322. Dev : Zcoretri
  4323. Example :
  4324. */
  4325. void Commands::Command_Create(Client* client, Seperator* sep)
  4326. {
  4327. PrintSep(sep, "COMMAND_CREATE");
  4328. client->SendRecipeList();
  4329. client->ShowRecipeBook();
  4330. }
  4331. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4332. {
  4333. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4334. if (sep && sep->arg[0] && sep->IsNumber(0))
  4335. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4336. }
  4337. /*
  4338. Function: Command_Distance()
  4339. Purpose : Displays distance from targeted spawn
  4340. Params :
  4341. Dev : Scatman
  4342. Example : /distance
  4343. */
  4344. void Commands::Command_Distance(Client* client)
  4345. {
  4346. Spawn* target = client->GetPlayer()->GetTarget();
  4347. if (target)
  4348. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4349. else
  4350. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4351. }
  4352. /*
  4353. Function: Command_Duel()
  4354. Purpose : Handle the /duel commands - not yet implemented
  4355. Params : unknown
  4356. Dev :
  4357. Example :
  4358. */
  4359. void Commands::Command_Duel(Client* client, Seperator* sep)
  4360. {
  4361. PrintSep(sep, "COMMAND_DUEL");
  4362. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4363. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4364. }
  4365. /*
  4366. Function: Command_DuelBet()
  4367. Purpose : Handle the /duel commands - not yet implemented
  4368. Params : unknown
  4369. Dev :
  4370. Example :
  4371. */
  4372. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4373. {
  4374. PrintSep(sep, "COMMAND_DUELBET");
  4375. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4376. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4377. }
  4378. /*
  4379. Function: Command_DuelAccept()
  4380. Purpose : Handle the /duel commands - not yet implemented
  4381. Params : unknown
  4382. Dev :
  4383. Example :
  4384. */
  4385. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4386. {
  4387. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4388. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4389. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4390. }
  4391. /*
  4392. Function: Command_DuelDecline()
  4393. Purpose : Handle the /duel commands - not yet implemented
  4394. Params : unknown
  4395. Dev :
  4396. Example :
  4397. */
  4398. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4399. {
  4400. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4401. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4402. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4403. }
  4404. /*
  4405. Function: Command_DuelSurrender()
  4406. Purpose : Handle the /duel commands - not yet implemented
  4407. Params : unknown
  4408. Dev :
  4409. Example :
  4410. */
  4411. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4412. {
  4413. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4414. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4415. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4416. // JA, just messin around ;)
  4417. char surrender[64];
  4418. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4419. zone_list.HandleGlobalAnnouncement(surrender);
  4420. }
  4421. /*
  4422. Function: Command_DuelToggle()
  4423. Purpose : Handle the /duel commands - not yet implemented
  4424. Params : unknown
  4425. Dev :
  4426. Example :
  4427. */
  4428. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4429. {
  4430. PrintSep(sep, "COMMAND_DUEL");
  4431. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4432. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4433. }
  4434. /*
  4435. Function:
  4436. Purpose :
  4437. Params :
  4438. Dev :
  4439. Example :
  4440. */
  4441. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4442. {
  4443. if( handler == COMMAND_ENTITYCOMMAND )
  4444. {
  4445. // /entitycommand command by itself shows help (to be extended)
  4446. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4447. return;
  4448. }
  4449. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4450. {
  4451. // /entitycommand list command expects "name" param
  4452. if (sep && sep->arg[0])
  4453. {
  4454. const char* entity_command_name = sep->argplus[0];
  4455. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4456. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4457. map<int32, vector<EntityCommand*>*>::iterator itr;
  4458. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4459. {
  4460. vector<EntityCommand*>* entity_command_list = itr->second;
  4461. vector<EntityCommand*>::iterator itr2;
  4462. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4463. {
  4464. EntityCommand* entity_command = *itr2;
  4465. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4466. 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);
  4467. }
  4468. }
  4469. }
  4470. else // no command name
  4471. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4472. }
  4473. }
  4474. /*
  4475. Function: Command_Follow()
  4476. Purpose : Handle the /follow command - not yet implemented
  4477. Params :
  4478. Dev :
  4479. Example :
  4480. */
  4481. void Commands::Command_Follow(Client* client, Seperator* sep)
  4482. {
  4483. PrintSep(sep, "COMMAND_FOLLOW");
  4484. // flag to toggle if the players target is in the players group
  4485. bool targetInGroup = false;
  4486. // get a pointer to the players group
  4487. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4488. // If the player has a group and has a target
  4489. if (gmi && client->GetPlayer()->GetTarget()) {
  4490. deque<GroupMemberInfo*>::iterator itr;
  4491. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4492. deque<GroupMemberInfo*>* members = world.GetGroupManager()->GetGroupMembers(gmi->group_id);
  4493. // Loop through the group members
  4494. for (itr = members->begin(); itr != members->end(); itr++) {
  4495. // If a group member matches a target
  4496. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4497. // toggle the flag and break the loop
  4498. targetInGroup = true;
  4499. break;
  4500. }
  4501. }
  4502. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4503. }
  4504. if (targetInGroup) {
  4505. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4506. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4507. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4508. client->GetPlayer()->info_changed = true;
  4509. client->GetPlayer()->changed = true;
  4510. }
  4511. else
  4512. client->Message(CHANNEL_COLOR_WHITE, "You must first select a group member to follow.");
  4513. }
  4514. /*
  4515. Function: Command_StopFollow()
  4516. Purpose : Handle the /stop_follow command - not yet implemented
  4517. Params :
  4518. Dev :
  4519. Example :
  4520. */
  4521. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4522. {
  4523. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4524. if (client->GetPlayer()->GetFollowTarget()) {
  4525. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4526. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4527. client->GetPlayer()->SetFollowTarget(0);
  4528. client->GetPlayer()->info_changed = true;
  4529. client->GetPlayer()->changed = true;
  4530. }
  4531. }
  4532. #include "../Zone/SPGrid.h"
  4533. /*
  4534. Function: Command_Grid()
  4535. Purpose : Show player's current Grid ID
  4536. Params :
  4537. Dev : Scatman
  4538. Example : /grid
  4539. */
  4540. void Commands::Command_Grid(Client* client)
  4541. {
  4542. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4543. if (client->GetCurrentZone()->Grid != nullptr) {
  4544. int32 grid = client->GetCurrentZone()->Grid->GetGridID(client->GetPlayer());
  4545. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4546. }
  4547. }
  4548. /*
  4549. Function: Command_Guild()
  4550. Purpose : Handler for all UI-related guild commands
  4551. Dev : Scatman
  4552. */
  4553. void Commands::Command_Guild(Client* client, Seperator* sep)
  4554. {
  4555. Guild* guild = client->GetPlayer()->GetGuild();
  4556. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  4557. {
  4558. const char* command = sep->arg[0];
  4559. int32 length = strlen(command);
  4560. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4561. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4562. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4563. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4564. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4565. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4566. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4567. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4568. guild->KickGuildMember(client, sep->arg[1]);
  4569. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4570. guild->DemoteGuildMember(client, sep->arg[1]);
  4571. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4572. guild->PromoteGuildMember(client, sep->arg[1]);
  4573. else if (strncmp(command, "points", length) == 0 && guild)
  4574. {
  4575. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4576. {
  4577. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4578. {
  4579. float points = atof(sep->arg[2]);
  4580. const char* option = sep->arg[3];
  4581. const char* comment = sep->argplus[4];
  4582. if (strncmp(option, "all", strlen(option)) == 0)
  4583. guild->AddPointsToAll(client, points, comment);
  4584. else if (strncmp(option, "online", strlen(option)) == 0)
  4585. guild->AddPointsToAllOnline(client, points, comment);
  4586. else if (strncmp(option, "group", strlen(option)) == 0)
  4587. guild->AddPointsToGroup(client, points, comment);
  4588. else if (strncmp(option, "raid", strlen(option)) == 0)
  4589. guild->AddPointsToRaid(client, points, comment);
  4590. else
  4591. guild->AddPointsToGuildMember(client, points, option, comment);
  4592. }
  4593. }
  4594. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4595. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4596. else
  4597. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4598. }
  4599. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4600. guild->SetMOTD(sep->argplus[1]);
  4601. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4602. {
  4603. if (sep->arg[1])
  4604. {
  4605. const char* option = sep->arg[1];
  4606. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4607. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4608. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4609. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4610. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4611. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4612. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4613. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4614. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4615. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4616. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4617. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4618. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4619. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4620. else
  4621. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4622. }
  4623. else
  4624. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4625. }
  4626. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4627. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4628. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4629. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4630. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4631. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4632. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4633. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4634. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4635. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4636. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4637. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4638. else if (strncmp(command, "invite", length) == 0 && guild)
  4639. {
  4640. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4641. guild->InvitePlayer(client, sep->arg[1]);
  4642. else
  4643. {
  4644. Spawn* target = client->GetPlayer()->GetTarget();
  4645. if (target)
  4646. {
  4647. if (target->IsPlayer())
  4648. guild->InvitePlayer(client, target->GetName());
  4649. else
  4650. client->Message(CHANNEL_COLOR_WHITE, "%s is not a player.", target->GetName());
  4651. }
  4652. }
  4653. }
  4654. else if (strncmp(command, "accept", length) == 0)
  4655. {
  4656. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4657. if (pgi && pgi->guild && pgi->invited_by)
  4658. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4659. client->SetPendingGuildInvite(0);
  4660. }
  4661. else if (strncmp(command, "decline", length) == 0)
  4662. {
  4663. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4664. if (pgi && pgi->guild && pgi->invited_by)
  4665. {
  4666. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4667. if (client_inviter)
  4668. client_inviter->Message(CHANNEL_COLOR_WHITE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4669. }
  4670. client->SetPendingGuildInvite(0);
  4671. }
  4672. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4673. {
  4674. const char* guild_name = sep->argplus[1];
  4675. if (!guild_list.GetGuild(guild_name))
  4676. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  4677. else
  4678. client->SimpleMessage(CHANNEL_COLOR_WHITE, "A guild with that name already exists.");
  4679. }
  4680. else if (strncmp(command, "search", length) == 0)
  4681. client->ShowGuildSearchWindow();
  4682. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4683. {
  4684. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4685. if (to_guild)
  4686. to_guild->SendGuildRecruitingDetails(client);
  4687. }
  4688. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4689. {
  4690. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4691. if (to_guild)
  4692. to_guild->SendGuildRecruitingImages(client);
  4693. }
  4694. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4695. {
  4696. if (sep->arg[1])
  4697. {
  4698. const char* option = sep->arg[1];
  4699. if (strncmp(option, "toggle", strlen(option)) == 0)
  4700. guild->ToggleGuildRecruiterAdventureClass(client);
  4701. }
  4702. else
  4703. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4704. }
  4705. else if (strncmp(command, "display_heraldry", length) == 0)
  4706. {
  4707. // JA: not sure this is right...
  4708. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4709. client->GetPlayer()->SetCharSheetChanged(true);
  4710. }
  4711. else
  4712. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4713. }
  4714. }
  4715. /*
  4716. Function: Command_GuildCreate()
  4717. Purpose : Display's in-game Guild Creation window
  4718. Dev : Scatman
  4719. */
  4720. void Commands::Command_CreateGuild(Client* client)
  4721. {
  4722. client->SendGuildCreateWindow();
  4723. }
  4724. /*
  4725. Function: Command_SetGuildOfficerNote()
  4726. Purpose :
  4727. Dev : Scatman
  4728. */
  4729. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4730. {
  4731. if (sep && sep->arg[0] && sep->arg[1])
  4732. {
  4733. Guild* guild = client->GetPlayer()->GetGuild();
  4734. if (guild)
  4735. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4736. }
  4737. }
  4738. /*
  4739. Function: Command_SetGuildMemberNote()
  4740. Purpose :
  4741. Dev : Scatman
  4742. */
  4743. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4744. {
  4745. if (sep && sep->arg[0] && sep->arg[1])
  4746. {
  4747. Guild* guild = client->GetPlayer()->GetGuild();
  4748. if (guild)
  4749. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4750. }
  4751. }
  4752. /*
  4753. Function: Command_GuildSay()
  4754. Purpose :
  4755. Dev : Scatman
  4756. */
  4757. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4758. {
  4759. Guild* guild = client->GetPlayer()->GetGuild();
  4760. if (guild)
  4761. {
  4762. if (sep && sep->arg[0])
  4763. guild->HandleGuildSay(client, sep->argplus[0]);
  4764. }
  4765. else
  4766. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4767. }
  4768. /*
  4769. Function: Command_OfficerSay()
  4770. Purpose :
  4771. Dev : Scatman
  4772. */
  4773. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4774. {
  4775. Guild* guild = client->GetPlayer()->GetGuild();
  4776. if (guild)
  4777. {
  4778. if (sep && sep->arg[0])
  4779. guild->HandleOfficerSay(client, sep->argplus[0]);
  4780. }
  4781. else
  4782. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4783. }
  4784. /*
  4785. Function: Command_Guilds()
  4786. Purpose : Shows help for /guild command
  4787. Params :
  4788. Dev : Scatman
  4789. Example :
  4790. */
  4791. void Commands::Command_Guilds(Client* client)
  4792. {
  4793. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4794. }
  4795. /*
  4796. Function: Command_GuildsAdd()
  4797. Purpose : Add's players to a guild
  4798. Params : guild_name|guild_id, player name
  4799. Dev : Scatman
  4800. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4801. */
  4802. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4803. {
  4804. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4805. {
  4806. Guild* guild = 0;
  4807. bool found = true;
  4808. if (sep->IsNumber(0))
  4809. {
  4810. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4811. if (!guild)
  4812. {
  4813. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4814. found = false;
  4815. }
  4816. }
  4817. else
  4818. {
  4819. guild = guild_list.GetGuild(sep->arg[0]);
  4820. if (!guild)
  4821. {
  4822. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4823. found = false;
  4824. }
  4825. }
  4826. if (found)
  4827. {
  4828. Client* to_client = 0;
  4829. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4830. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4831. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4832. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4833. if (to_client)
  4834. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  4835. else
  4836. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4837. }
  4838. }
  4839. else
  4840. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  4841. }
  4842. /*
  4843. Function: Command_GuildsCreate()
  4844. Purpose : Creates a guild
  4845. Params : guild_name, player_name (optional)
  4846. Dev : Scatman
  4847. Example : /guilds create [guild name] (player name)
  4848. */
  4849. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  4850. {
  4851. if (sep && sep->arg[0])
  4852. {
  4853. const char* guild_name = sep->arg[0];
  4854. if (!guild_list.GetGuild(guild_name))
  4855. {
  4856. bool ret = false;
  4857. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4858. {
  4859. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4860. if (to_client)
  4861. {
  4862. world.CreateGuild(guild_name, to_client);
  4863. ret = true;
  4864. }
  4865. else
  4866. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  4867. }
  4868. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4869. {
  4870. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4871. if (to_client)
  4872. {
  4873. world.CreateGuild(guild_name, to_client);
  4874. ret = true;
  4875. }
  4876. }
  4877. else
  4878. {
  4879. world.CreateGuild(guild_name);
  4880. ret = true;
  4881. }
  4882. if (ret)
  4883. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  4884. else
  4885. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  4886. }
  4887. else
  4888. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  4889. }
  4890. else
  4891. 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.");
  4892. }
  4893. /*
  4894. Function: Command_GuildsDelete()
  4895. Purpose : Delete's a guild
  4896. Params : guild name
  4897. Dev : Scatman
  4898. Example : /guilds delete Test
  4899. */
  4900. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  4901. {
  4902. if (sep && sep->arg[0])
  4903. {
  4904. Guild* guild = 0;
  4905. bool found = true;
  4906. if (sep->IsNumber(0))
  4907. {
  4908. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4909. if (!guild)
  4910. {
  4911. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4912. found = false;
  4913. }
  4914. }
  4915. else
  4916. {
  4917. guild = guild_list.GetGuild(sep->arg[0]);
  4918. if (!guild)
  4919. {
  4920. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4921. found = false;
  4922. }
  4923. }
  4924. if (found)
  4925. {
  4926. guild->RemoveAllGuildMembers();
  4927. database.DeleteGuild(guild);
  4928. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  4929. guild_list.RemoveGuild(guild, true);
  4930. }
  4931. }
  4932. else
  4933. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  4934. }
  4935. /*
  4936. Function: Command_GuildsList()
  4937. Purpose : Lists current guilds on server
  4938. Params :
  4939. Dev : Scatman
  4940. Example : /guilds list
  4941. */
  4942. void Commands::Command_GuildsList(Client* client)
  4943. {
  4944. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  4945. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  4946. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  4947. if (guilds->size() == 0)
  4948. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  4949. else {
  4950. while (itr.Next()) {
  4951. Guild* guild = itr.second;
  4952. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  4953. }
  4954. }
  4955. }
  4956. /*
  4957. Function: Command_GuildsRemove()
  4958. Purpose : Removes a player from a guild
  4959. Params : guild name|guild id, player name
  4960. Dev : Scatman
  4961. Example : /guilds remove 1 Admin = removes Admin from guild 1
  4962. */
  4963. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  4964. {
  4965. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4966. {
  4967. Guild* guild = 0;
  4968. bool found = true;
  4969. if (sep->IsNumber(0))
  4970. {
  4971. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4972. if (!guild)
  4973. {
  4974. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4975. found = false;
  4976. }
  4977. }
  4978. else
  4979. {
  4980. guild = guild_list.GetGuild(sep->arg[0]);
  4981. if (!guild)
  4982. {
  4983. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4984. found = false;
  4985. }
  4986. }
  4987. if (found)
  4988. {
  4989. Client* to_client = 0;
  4990. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4991. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4992. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4993. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4994. if (to_client)
  4995. {
  4996. Player* to_player = to_client->GetPlayer();
  4997. if (to_player->GetGuild())
  4998. {
  4999. if (to_player->GetGuild() == guild)
  5000. {
  5001. guild->KickGuildMember(client, to_player->GetName());
  5002. }
  5003. else
  5004. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  5005. }
  5006. else
  5007. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  5008. }
  5009. else
  5010. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5011. }
  5012. }
  5013. else
  5014. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  5015. }
  5016. /*
  5017. Function: Command_InspectPlayer()
  5018. Purpose : Handle the Inspect functions
  5019. Params : Client to inspect
  5020. Dev : Scatman
  5021. Example : /inspect Scatman
  5022. */
  5023. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  5024. {
  5025. if (sep && sep->arg[0])
  5026. {
  5027. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  5028. if (inspect_client)
  5029. client->InspectPlayer(inspect_client->GetPlayer());
  5030. }
  5031. else
  5032. {
  5033. Spawn* target = client->GetPlayer()->GetTarget();
  5034. if (target && target->IsPlayer())
  5035. client->InspectPlayer((Player*)target);
  5036. }
  5037. }
  5038. /*
  5039. Function: Command_Inventory()
  5040. Purpose : Handle changes in player inventory
  5041. Params : <TBD>
  5042. Dev : All
  5043. Example : /inventory delete item_id
  5044. */
  5045. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  5046. {
  5047. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  5048. Player* player = client->GetPlayer();
  5049. if(sep && sep->arg[0][0])
  5050. {
  5051. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  5052. if(client->GetPlayer()->GetHP() == 0)
  5053. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  5054. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5055. {
  5056. int16 index = atoi(sep->arg[1]);
  5057. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5058. if(item)
  5059. {
  5060. if(item->GetItemScript() && lua_interface)
  5061. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  5062. int32 bag_id = item->details.inv_slot_id;
  5063. database.DeleteItem(client->GetCharacterID(), item, 0);
  5064. client->GetPlayer()->item_list.DestroyItem(index);
  5065. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  5066. client->QueuePacket(outapp);
  5067. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  5068. if (outapp)
  5069. client->QueuePacket(outapp);
  5070. }
  5071. }
  5072. 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))
  5073. {
  5074. int16 from_index = atoi(sep->arg[1]);
  5075. sint16 to_slot = atoi(sep->arg[2]);
  5076. sint32 bag_id = atol(sep->arg[3]);
  5077. int8 charges = atoi(sep->arg[4]);
  5078. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  5079. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  5080. {
  5081. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  5082. return;
  5083. }
  5084. sint32 old_inventory_id = 0;
  5085. if(item)
  5086. old_inventory_id = item->details.inv_slot_id;
  5087. //autobank
  5088. if (bag_id == -3 && to_slot == -1)
  5089. {
  5090. if (player->HasFreeBankSlot())
  5091. to_slot = player->FindFreeBankSlot();
  5092. else
  5093. {
  5094. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  5095. return;
  5096. }
  5097. }
  5098. //auto inventory
  5099. if (bag_id == 0 && to_slot == -1)
  5100. {
  5101. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5102. {
  5103. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  5104. return;
  5105. }
  5106. }
  5107. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  5108. client->QueuePacket(outapp);
  5109. //removed from bag send update
  5110. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  5111. {
  5112. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  5113. if(outapp)
  5114. client->QueuePacket(outapp);
  5115. }
  5116. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  5117. {
  5118. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  5119. if(outapp)
  5120. client->QueuePacket(outapp);
  5121. }
  5122. }
  5123. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  5124. {
  5125. if(client->GetPlayer()->EngagedInCombat())
  5126. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  5127. else
  5128. {
  5129. int16 index = atoi(sep->arg[1]);
  5130. int8 slot_id = 255;
  5131. if(sep->arg[2][0] && sep->IsNumber(2))
  5132. slot_id = atoi(sep->arg[2]);
  5133. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  5134. EQ2Packet* outapp = 0;
  5135. for(int32 i=0;i<packets.size();i++)
  5136. {
  5137. outapp = packets[i];
  5138. if(outapp)
  5139. client->QueuePacket(outapp);
  5140. }
  5141. client->GetPlayer()->ChangePrimaryWeapon();
  5142. client->GetPlayer()->ChangeSecondaryWeapon();
  5143. client->GetPlayer()->ChangeRangedWeapon();
  5144. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5145. client->QueuePacket(characterSheetPackets);
  5146. }
  5147. }
  5148. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5149. {
  5150. if (client->GetPlayer()->EngagedInCombat())
  5151. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5152. else {
  5153. int16 index = atoi(sep->arg[1]);
  5154. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5155. if (item) {
  5156. // client->GetPlayer()->item_list.DestroyItem(index);
  5157. if (item->item_sets.size() > 0) {
  5158. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5159. ItemSet* set = item->item_sets[i];
  5160. if (set->item_stack_size == 0)
  5161. set->item_stack_size += 1;
  5162. client->AddItem(set->item_id, set->item_stack_size);
  5163. }
  5164. }
  5165. }
  5166. client->RemoveItem(item, 1);
  5167. }
  5168. }
  5169. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5170. {
  5171. if(client->GetPlayer()->EngagedInCombat())
  5172. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5173. else
  5174. {
  5175. int16 index = atoi(sep->arg[1]);
  5176. sint32 bag_id = -999;
  5177. int8 to_slot = 255;
  5178. if(sep->arg[3][0])
  5179. {
  5180. if(sep->IsNumber(2))
  5181. bag_id = atol(sep->arg[2]);
  5182. if(sep->IsNumber(3))
  5183. to_slot = atoi(sep->arg[3]);
  5184. }
  5185. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  5186. EQ2Packet* outapp = 0;
  5187. for(int32 i=0;i<packets.size();i++)
  5188. {
  5189. outapp = packets[i];
  5190. if(outapp)
  5191. client->QueuePacket(outapp);
  5192. }
  5193. client->GetPlayer()->ChangePrimaryWeapon();
  5194. client->GetPlayer()->ChangeSecondaryWeapon();
  5195. client->GetPlayer()->ChangeRangedWeapon();
  5196. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5197. client->QueuePacket(characterSheetPackets);
  5198. }
  5199. }
  5200. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5201. {
  5202. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5203. int16 index1 = atoi(sep->arg[1]);
  5204. int16 index2 = atoi(sep->arg[2]);
  5205. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  5206. if(outapp)
  5207. client->QueuePacket(outapp);
  5208. else
  5209. {
  5210. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5211. return;
  5212. }
  5213. }
  5214. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5215. {
  5216. sint16 to_slot = atoi(sep->arg[1]);
  5217. sint32 bag_id = atoi(sep->arg[2]);
  5218. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5219. if (item) {
  5220. //auto inventory
  5221. if (bag_id == 0 && to_slot == -1)
  5222. {
  5223. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5224. {
  5225. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5226. return;
  5227. }
  5228. // Set the slot for the item
  5229. item->details.inv_slot_id = bag_id;
  5230. item->details.slot_id = to_slot;
  5231. // Flag the item so it gets saved in its new location
  5232. item->save_needed = true;
  5233. // Add the item to its new location
  5234. player->item_list.AddItem(item);
  5235. // Remove the item from the overflow list
  5236. player->item_list.RemoveOverflowItem(item);
  5237. // Send the inventory update packet
  5238. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5239. return;
  5240. }
  5241. else if (bag_id == -3 && to_slot == -1) {
  5242. // Auto Bank
  5243. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5244. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5245. return;
  5246. }
  5247. item->details.inv_slot_id = bag_id;
  5248. item->details.slot_id = to_slot;
  5249. item->save_needed = true;
  5250. player->item_list.AddItem(item);
  5251. player->item_list.RemoveOverflowItem(item);
  5252. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5253. }
  5254. else if (bag_id == -4) {
  5255. // Shared Bank
  5256. if (!player->item_list.SharedBankAddAllowed(item)) {
  5257. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5258. return;
  5259. }
  5260. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5261. if (tmp_item) {
  5262. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5263. return;
  5264. }
  5265. else {
  5266. item->details.inv_slot_id = bag_id;
  5267. item->details.slot_id = to_slot;
  5268. item->save_needed = true;
  5269. player->item_list.AddItem(item);
  5270. player->item_list.RemoveOverflowItem(item);
  5271. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5272. return;
  5273. }
  5274. }
  5275. else {
  5276. // Try to get an item from the given bag id and slot id
  5277. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5278. // Check to see if we got an item, if we do send an error,
  5279. // if we don't put the overflow item into this slot
  5280. if (tmp_item) {
  5281. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5282. }
  5283. else {
  5284. item->details.inv_slot_id = bag_id;
  5285. item->details.slot_id = to_slot;
  5286. item->save_needed = true;
  5287. player->item_list.AddItem(item);
  5288. player->item_list.RemoveOverflowItem(item);
  5289. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5290. return;
  5291. }
  5292. }
  5293. }
  5294. }
  5295. }
  5296. else
  5297. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5298. }
  5299. /*
  5300. Function: Command_IRC()
  5301. Purpose : Handle the IRC functions
  5302. Params : IRC Commands
  5303. Dev : Scatman
  5304. Example : /irc say #Channel Hello World!
  5305. */
  5306. void Commands::Command_IRC(Client* client, Seperator* sep)
  5307. {
  5308. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5309. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5310. return;
  5311. }
  5312. if (sep && sep->arg[0][0]) {
  5313. if (strcasecmp(sep->arg[0], "say") == 0) {
  5314. if (sep->arg[1][0] && sep->arg[2][0]) {
  5315. if (sep->IsNumber(sep->arg[1]))
  5316. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5317. else
  5318. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5319. }
  5320. else
  5321. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5322. }
  5323. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5324. if (sep->arg[1][0])
  5325. irc.JoinChannel(client, sep->arg[1]);
  5326. else
  5327. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5328. }
  5329. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5330. if (sep->arg[1][0])
  5331. irc.LeaveChannel(client, sep->arg[1]);
  5332. else
  5333. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5334. }
  5335. else if (strcasecmp(sep->arg[0], "list") == 0)
  5336. irc.ListChannels(client);
  5337. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5338. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5339. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5340. else
  5341. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5342. }
  5343. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5344. irc.DisconnectFromServer(client);
  5345. else
  5346. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5347. }
  5348. else
  5349. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5350. }
  5351. /*
  5352. Function: Command_Languages()
  5353. Purpose : Show's languages the player knows
  5354. Params :
  5355. Dev : Zcoretri
  5356. Example :
  5357. */
  5358. void Commands::Command_Languages(Client* client, Seperator* sep)
  5359. {
  5360. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5361. list<Language*>::iterator itr;
  5362. Language* language;
  5363. client->Message(CHANNEL_COLOR_WHITE, "You know the following languages:");
  5364. for(itr = languages->begin(); itr != languages->end(); itr++)
  5365. {
  5366. language = *itr;
  5367. client->Message(CHANNEL_COLOR_WHITE, "%s", language->GetName());
  5368. }
  5369. }
  5370. /*
  5371. Function: Command_SetLanguage()
  5372. Purpose : Handles language commands
  5373. Params : Language ID
  5374. Dev : Zcoretri
  5375. Example :
  5376. */
  5377. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5378. {
  5379. Player* player = client->GetPlayer();
  5380. if (sep && sep->arg[0])
  5381. {
  5382. if(!sep->IsNumber(0))
  5383. {
  5384. //String passed in
  5385. const char* value = sep->arg[0];
  5386. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5387. {
  5388. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5389. client->SendLanguagesUpdate(0);
  5390. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", value);
  5391. }
  5392. else
  5393. {
  5394. if(player->HasLanguage(value))
  5395. {
  5396. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5397. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5398. client->SendLanguagesUpdate(language->GetID());
  5399. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5400. }
  5401. else
  5402. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", value);
  5403. }
  5404. }
  5405. else
  5406. {
  5407. //Number passed in
  5408. int32 id = atoul(sep->arg[0]);
  5409. if(player->HasLanguage(id))
  5410. {
  5411. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5412. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5413. client->SendLanguagesUpdate(id);
  5414. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5415. }
  5416. else
  5417. {
  5418. Language* language = master_languages_list.GetLanguage(id);
  5419. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", language->GetName());
  5420. }
  5421. }
  5422. }
  5423. else
  5424. {
  5425. //No value was passed in
  5426. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5427. if(id > 0)
  5428. {
  5429. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5430. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking %s ", language->GetName());
  5431. }
  5432. else
  5433. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking Common");
  5434. }
  5435. }
  5436. /*
  5437. Function: Command_LastName()
  5438. Purpose : Sets player surname
  5439. Params : Name text
  5440. Dev : theFoof
  5441. Example :
  5442. */
  5443. void Commands::Command_LastName(Client* client, Seperator* sep)
  5444. {
  5445. if (!client)
  5446. return;
  5447. if (sep && sep->arg[0])
  5448. {
  5449. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5450. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5451. return;
  5452. }
  5453. client->RemovePendingLastName();
  5454. uchar* checkname = (uchar*)sep->arg[0];
  5455. bool valid_name = true;
  5456. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5457. if (!alpha_check(checkname[i])) {
  5458. valid_name = false;
  5459. break;
  5460. }
  5461. }
  5462. if (!valid_name) {
  5463. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5464. return;
  5465. }
  5466. string last_name = (string)sep->arg[0];
  5467. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5468. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5469. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5470. client->SetPendingLastName(last_name);
  5471. client->SendLastNameConfirmation();
  5472. }
  5473. else
  5474. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5475. }
  5476. }
  5477. /*
  5478. Function: Command_ConfirmLastName()
  5479. Purpose : Confirms setting of player surname
  5480. Params : Name text
  5481. Dev : theFoof
  5482. Example :
  5483. */
  5484. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5485. {
  5486. if (!client)
  5487. return;
  5488. string* name = client->GetPendingLastName();
  5489. if (name){
  5490. Player* player = client->GetPlayer();
  5491. player->SetLastName(name->c_str(), false);
  5492. client->SendTitleUpdate();
  5493. player->SetCharSheetChanged(true);
  5494. client->RemovePendingLastName();
  5495. }
  5496. }
  5497. /*
  5498. Function: Command_Location()
  5499. Purpose : Display's Help for /location commands
  5500. Params :
  5501. Dev : Scatman
  5502. Example : /location = show's help for command
  5503. */
  5504. void Commands::Command_Location(Client* client)
  5505. {
  5506. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5507. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5508. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5509. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5510. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5511. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5512. }
  5513. /*
  5514. Function: Command_LocationAdd()
  5515. Purpose : Add's a location to an existing location config
  5516. Params : location_id
  5517. Dev : Scatman
  5518. Example : /location add {location_id}
  5519. */
  5520. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5521. {
  5522. if (sep && sep->arg[0] && sep->IsNumber(0))
  5523. {
  5524. int32 location_id = atoul(sep->arg[0]);
  5525. float x = client->GetPlayer()->GetX();
  5526. float y = client->GetPlayer()->GetY();
  5527. float z = client->GetPlayer()->GetZ();
  5528. if (database.AddLocationPoint(location_id, x, y, z))
  5529. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5530. else
  5531. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5532. }
  5533. else
  5534. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5535. }
  5536. /*
  5537. Function: Command_LocationCreate()
  5538. Purpose : Creates a new location config
  5539. Params : location name, 0/1 for include_y (optional)
  5540. Dev : Scatman
  5541. Example : /location create Test 1 = creates a new location named Test with include_y True
  5542. */
  5543. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5544. {
  5545. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5546. {
  5547. const char* name = sep->arg[0];
  5548. bool include_y = false;
  5549. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5550. include_y = true;
  5551. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5552. if (location_id > 0)
  5553. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5554. else
  5555. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5556. }
  5557. else
  5558. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5559. }
  5560. /*
  5561. Function: Command_LocationDelete()
  5562. Purpose : Delete's a location config and all it's location points
  5563. Params : location_id
  5564. Dev : Scatman
  5565. Example : /location delete {location_id}
  5566. */
  5567. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5568. {
  5569. if (sep && sep->arg[0] && sep->IsNumber(0))
  5570. {
  5571. int32 location_id = atoul(sep->arg[0]);
  5572. if (database.DeleteLocation(location_id))
  5573. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5574. else
  5575. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5576. }
  5577. else
  5578. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5579. }
  5580. /*
  5581. Function: Command_LocationList()
  5582. Purpose : Display's a list of location points
  5583. Params : location_id
  5584. Dev : Scatman
  5585. Example : /location list {location_id}
  5586. */
  5587. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5588. {
  5589. if (sep && sep->arg[0])
  5590. {
  5591. const char* option = sep->arg[0];
  5592. if (strncmp(option, "locations", strlen(option)) == 0)
  5593. database.ListLocations(client);
  5594. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5595. {
  5596. int32 location_id = atoul(sep->arg[1]);
  5597. database.ListLocationPoints(client, location_id);
  5598. }
  5599. else
  5600. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5601. }
  5602. else
  5603. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5604. }
  5605. /*
  5606. Function: Command_LocationRemove()
  5607. Purpose : Removes a single location point from a location config
  5608. Params : location_point_id (gotten from /location list {id})
  5609. Dev : Scatman
  5610. Example : /location remove 1 = will remove location_point_id 1
  5611. */
  5612. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5613. {
  5614. if (sep && sep->arg[0] && sep->IsNumber(0))
  5615. {
  5616. int32 location_point_id = atoul(sep->arg[0]);
  5617. if (database.DeleteLocationPoint(location_point_id))
  5618. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5619. else
  5620. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5621. }
  5622. else
  5623. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5624. }
  5625. /*
  5626. Function: Command_Merchant()
  5627. Purpose : Handles Merchant commands
  5628. Params : list
  5629. Dev : Scatman
  5630. Example : /merchant list
  5631. */
  5632. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5633. {
  5634. if( handler == COMMAND_MERCHANT )
  5635. {
  5636. // /merchant command by itself shows help (to be extended)
  5637. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5638. return;
  5639. }
  5640. else if( handler == COMMAND_MERCHANT_LIST )
  5641. {
  5642. // /merchant list command expects "description" param
  5643. if (sep && sep->arg[0])
  5644. {
  5645. const char* merchant_description = sep->argplus[0];
  5646. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5647. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5648. map<int32, MerchantInfo*>::iterator itr;
  5649. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5650. {
  5651. string description = database.GetMerchantDescription(itr->first);
  5652. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5653. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5654. }
  5655. }
  5656. else // no description
  5657. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5658. }
  5659. }
  5660. /*
  5661. Function: Command_Modify()
  5662. Purpose : to replace our other "set" commands
  5663. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5664. Dev : John Adams
  5665. Example : /modify spell set name "Aegolism III"
  5666. */
  5667. void Commands::Command_Modify(Client* client)
  5668. {
  5669. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5670. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5671. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5672. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5673. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5674. }
  5675. /*
  5676. Function: Command_ModifySpawn()
  5677. Purpose : replace "spawn set" commands
  5678. Params : Action : the action to perform (or special handler)
  5679. : Field : the DB field to change
  5680. : Value : what to set the value to
  5681. : Target : what object to change (my target, or spawn_id)
  5682. Dev : John Adams
  5683. Example : /modify spawn set name "Lady Vox"
  5684. :
  5685. Note : Special Handlers, like "zoneto" for Signs
  5686. : /modify spawn zoneto
  5687. : Will set a sign's zone x/y/z to my current coords
  5688. */
  5689. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5690. {
  5691. PrintSep(sep, "COMMAND_MODIFY");
  5692. // need at least 2 args for a valid command
  5693. if( sep && sep->arg[1] )
  5694. {
  5695. // JA: just a quick implementation because I need it :)
  5696. if (strcmp(sep->arg[0], "zoneto") == 0)
  5697. {
  5698. if( sep->IsNumber(1) )
  5699. {
  5700. int32 spawn_id = atoul(sep->arg[1]);
  5701. float x_coord = client->GetPlayer()->GetX();
  5702. float y_coord = client->GetPlayer()->GetY();
  5703. float z_coord = client->GetPlayer()->GetZ();
  5704. float h_coord = client->GetPlayer()->GetHeading();
  5705. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5706. }
  5707. else
  5708. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5709. }
  5710. }
  5711. else
  5712. Command_Modify(client);
  5713. }
  5714. /*
  5715. Function: Command_ModifyCharacter()
  5716. Purpose : to replace our other "set" commands
  5717. Params : Action : Add, Remove
  5718. : Field : copper, silver, gold, plat
  5719. : Value : min 1, max unlimited
  5720. : Target : Self, Player
  5721. Dev : Cynnar
  5722. Example : /modify character add gold 50
  5723. : /modify character remove silver 25
  5724. */
  5725. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5726. {
  5727. PrintSep(sep, "COMMAND_MODIFY");
  5728. int64 value = 0;
  5729. Player* player = client->GetPlayer();
  5730. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5731. player = (Player*)player->GetTarget();
  5732. // need at least 2 args for a valid command
  5733. if( sep && sep->arg[1] )
  5734. {
  5735. if (strcmp(sep->arg[0], "add") == 0)
  5736. {
  5737. if (strcmp(sep->arg[1], "copper") == 0)
  5738. {
  5739. value = atoi64(sep->arg[2]);
  5740. player->AddCoins(value);
  5741. if (client->GetPlayer() == player)
  5742. {
  5743. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5744. }
  5745. else {
  5746. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5747. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5748. }
  5749. }
  5750. else if (strcmp(sep->arg[1], "silver") == 0)
  5751. {
  5752. value = atoi64(sep->arg[2]) * 100;
  5753. player->AddCoins(value);
  5754. if (client->GetPlayer() == player)
  5755. {
  5756. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5757. }
  5758. else {
  5759. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5760. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5761. }
  5762. }
  5763. else if (strcmp(sep->arg[1], "gold") == 0)
  5764. {
  5765. value = atoi64(sep->arg[2]) * 10000;
  5766. player->AddCoins(value);
  5767. if (client->GetPlayer() == player)
  5768. {
  5769. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5770. }
  5771. else {
  5772. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5773. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5774. }
  5775. }
  5776. else if (strcmp(sep->arg[1], "plat") == 0)
  5777. {
  5778. value = atoi64(sep->arg[2]) * 1000000;
  5779. player->AddCoins(value);
  5780. if (client->GetPlayer() == player)
  5781. {
  5782. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5783. }
  5784. else {
  5785. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5786. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5787. }
  5788. }
  5789. else
  5790. {
  5791. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5792. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5793. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5794. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5795. }
  5796. }
  5797. else if (strcmp(sep->arg[0], "remove") == 0)
  5798. {
  5799. if (strcmp(sep->arg[1], "copper") == 0)
  5800. {
  5801. value = atoi64(sep->arg[2]);
  5802. player->RemoveCoins(value);
  5803. if (client->GetPlayer() == player)
  5804. {
  5805. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5806. }
  5807. else {
  5808. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5809. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5810. }
  5811. }
  5812. else if (strcmp(sep->arg[1], "silver") == 0)
  5813. {
  5814. value = atoi64(sep->arg[2]) * 100;
  5815. player->RemoveCoins(value);
  5816. if (client->GetPlayer() == player)
  5817. {
  5818. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5819. }
  5820. else {
  5821. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5822. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5823. }
  5824. }
  5825. else if (strcmp(sep->arg[1], "gold") == 0)
  5826. {
  5827. value = atoi64(sep->arg[2]) * 10000;
  5828. player->RemoveCoins(value);
  5829. if (client->GetPlayer() == player)
  5830. {
  5831. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  5832. }
  5833. else {
  5834. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  5835. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5836. }
  5837. }
  5838. else if (strcmp(sep->arg[1], "plat") == 0)
  5839. {
  5840. value = atoi64(sep->arg[2]) * 1000000;
  5841. player->RemoveCoins(value);
  5842. if (client->GetPlayer() == player)
  5843. {
  5844. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  5845. }
  5846. else {
  5847. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  5848. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5849. }
  5850. }
  5851. else
  5852. {
  5853. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5854. }
  5855. }
  5856. else if (strcmp(sep->arg[0], "set") == 0) {
  5857. if (strcmp(sep->arg[1], "tslevel") == 0) {
  5858. int8 level = atoi(sep->arg[2]);
  5859. if (level > 0 && level < 256) {
  5860. if (player) {
  5861. if (client->GetPlayer() == player)
  5862. client->ChangeTSLevel(player->GetTSLevel(), level);
  5863. else
  5864. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  5865. }
  5866. }
  5867. else
  5868. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  5869. }
  5870. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  5871. int8 tsclass = atoi(sep->arg[2]);
  5872. player->SetTradeskillClass(tsclass);
  5873. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  5874. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  5875. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  5876. player->SetCharSheetChanged(true);
  5877. }
  5878. }
  5879. }
  5880. else
  5881. {
  5882. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5883. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5884. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5885. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5886. }
  5887. }
  5888. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  5889. {
  5890. PrintSep(sep, "COMMAND_MODIFY");
  5891. // need at least 2 args for a valid command
  5892. if( sep && sep->arg[1] )
  5893. {
  5894. }
  5895. else
  5896. Command_Modify(client);
  5897. }
  5898. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  5899. {
  5900. PrintSep(sep, "COMMAND_MODIFY");
  5901. // need at least 2 args for a valid command
  5902. if( sep && sep->arg[1] )
  5903. {
  5904. }
  5905. else
  5906. Command_Modify(client);
  5907. }
  5908. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  5909. {
  5910. PrintSep(sep, "COMMAND_MODIFY");
  5911. // need at least 2 args for a valid command
  5912. if( sep && sep->arg[1] )
  5913. {
  5914. }
  5915. else
  5916. Command_Modify(client);
  5917. }
  5918. /*
  5919. Function: Command_ModifyQuest()
  5920. Purpose : to list players quest and completed quests
  5921. Params : Action : list, completed
  5922. : Target : Self, Player
  5923. Dev : Cynnar
  5924. Example : /modify quest list
  5925. : /modify quest completed
  5926. */
  5927. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  5928. {
  5929. PrintSep(sep, "COMMAND_MODIFY");
  5930. int64 value = 0;
  5931. Player* player = client->GetPlayer();
  5932. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5933. player = (Player*)player->GetTarget();
  5934. // need at least 2 args for a valid command
  5935. if (sep && sep->arg[1])
  5936. {
  5937. if (strcmp(sep->arg[0], "list") == 0)
  5938. {
  5939. map<int32, Quest*>* quests = player->GetPlayerQuests();
  5940. map<int32, Quest*>::iterator itr;
  5941. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  5942. if (quests->size() == 0)
  5943. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  5944. else
  5945. {
  5946. for (itr = quests->begin(); itr != quests->end(); itr++)
  5947. {
  5948. Quest* quest = itr->second;
  5949. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5950. }
  5951. }
  5952. }
  5953. else if (strcmp(sep->arg[0], "completed") == 0)
  5954. {
  5955. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  5956. map<int32, Quest*>::iterator itr;
  5957. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  5958. if (quests->size() == 0)
  5959. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  5960. else
  5961. {
  5962. for (itr = quests->begin(); itr != quests->end(); itr++)
  5963. {
  5964. Quest* quest = itr->second;
  5965. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5966. }
  5967. }
  5968. }
  5969. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  5970. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  5971. else if (strcmp(sep->arg[0], "remove") == 0)
  5972. {
  5973. int32 quest_id = 0;
  5974. if (sep && sep->arg[1] && sep->IsNumber(1))
  5975. quest_id = atoul(sep->arg[1]);
  5976. if (quest_id > 0)
  5977. {
  5978. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  5979. {
  5980. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5981. if (quest)
  5982. if (client->GetPlayer() == player)
  5983. {
  5984. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  5985. }
  5986. else
  5987. {
  5988. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  5989. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  5990. }
  5991. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  5992. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  5993. }
  5994. client->RemovePlayerQuest(quest_id);
  5995. client->GetCurrentZone()->SendQuestUpdates(client);
  5996. }
  5997. }
  5998. else if (strcmp(sep->arg[0], "advance") == 0)
  5999. {
  6000. int32 quest_id = 0;
  6001. int32 step = 0;
  6002. if (sep && sep->arg[1] && sep->IsNumber(1))
  6003. {
  6004. quest_id = atoul(sep->arg[1]);
  6005. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6006. if (sep && sep->arg[2] && sep->IsNumber(1))
  6007. {
  6008. step = atoul(sep->arg[2]);
  6009. if (quest_id > 0 && step > 0)
  6010. {
  6011. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  6012. {
  6013. if (client)
  6014. {
  6015. client->AddPendingQuestUpdate(quest_id, step);
  6016. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  6017. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  6018. }
  6019. }
  6020. }
  6021. else
  6022. {
  6023. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  6024. }
  6025. }
  6026. else
  6027. {
  6028. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  6029. }
  6030. }
  6031. else
  6032. {
  6033. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  6034. }
  6035. }
  6036. else
  6037. {
  6038. Command_Modify(client);
  6039. }
  6040. }
  6041. else
  6042. {
  6043. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  6044. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  6045. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  6046. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  6047. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  6048. }
  6049. }
  6050. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  6051. {
  6052. PrintSep(sep, "COMMAND_MODIFY");
  6053. // need at least 2 args for a valid command
  6054. if( sep && sep->arg[1] )
  6055. {
  6056. if (strcmp(sep->arg[0], "add") == 0) {
  6057. const char* skill_name = sep->argplus[1];
  6058. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6059. if (skill) {
  6060. Player* player = 0;
  6061. Client* to_client = 0;
  6062. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6063. player = (Player*)client->GetPlayer()->GetTarget();
  6064. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6065. }
  6066. else {
  6067. player = client->GetPlayer();
  6068. to_client = client;
  6069. }
  6070. if (player)
  6071. {
  6072. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6073. {
  6074. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6075. if (to_client == client) {
  6076. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  6077. }
  6078. else {
  6079. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6080. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6081. }
  6082. }
  6083. else
  6084. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  6085. }
  6086. }
  6087. else
  6088. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6089. }
  6090. else if (strcmp(sep->arg[0], "remove") == 0) {
  6091. const char* skill_name = sep->argplus[1];
  6092. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6093. if (skill) {
  6094. Player* player = 0;
  6095. Client* to_client = 0;
  6096. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6097. player = (Player*)client->GetPlayer()->GetTarget();
  6098. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6099. }
  6100. else {
  6101. player = client->GetPlayer();
  6102. to_client = client;
  6103. }
  6104. if (player)
  6105. {
  6106. if (player->GetSkills()->HasSkill(skill->skill_id))
  6107. {
  6108. player->RemoveSkillFromDB(skill, true);
  6109. if (client == to_client) {
  6110. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  6111. }
  6112. else {
  6113. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6114. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6115. }
  6116. }
  6117. else {
  6118. if (client == to_client)
  6119. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  6120. else
  6121. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6122. }
  6123. }
  6124. }
  6125. else
  6126. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6127. }
  6128. else if (strcmp(sep->arg[0], "set") == 0) {
  6129. if (!sep->IsNumber(2)) {
  6130. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  6131. return;
  6132. }
  6133. const char* skill_name = sep->arg[1];
  6134. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6135. if (skill) {
  6136. int16 val = atoi(sep->arg[2]);
  6137. Player* player = 0;
  6138. Client* to_client = 0;
  6139. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6140. player = (Player*)client->GetPlayer()->GetTarget();
  6141. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6142. }
  6143. else {
  6144. player = client->GetPlayer();
  6145. to_client = client;
  6146. }
  6147. if (player)
  6148. {
  6149. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6150. player->GetSkills()->SetSkill(skill->skill_id, val);
  6151. if (client != to_client)
  6152. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6153. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6154. }
  6155. else {
  6156. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6157. }
  6158. }
  6159. }
  6160. else {
  6161. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6162. }
  6163. }
  6164. else {
  6165. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6166. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6167. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6168. }
  6169. }
  6170. else {
  6171. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6172. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6173. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6174. }
  6175. }
  6176. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6177. {
  6178. PrintSep(sep, "COMMAND_MODIFY");
  6179. // need at least 2 args for a valid command
  6180. if( sep && sep->arg[1] )
  6181. {
  6182. }
  6183. else
  6184. Command_Modify(client);
  6185. }
  6186. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6187. {
  6188. PrintSep(sep, "COMMAND_MODIFY");
  6189. // need at least 2 args for a valid command
  6190. if( sep && sep->arg[1] )
  6191. {
  6192. }
  6193. else
  6194. Command_Modify(client);
  6195. }
  6196. /*
  6197. Function: Command_MOTD()
  6198. Purpose : Displays server MOTD
  6199. Params :
  6200. Dev : LethalEncounter
  6201. Example : /motd
  6202. */
  6203. void Commands::Command_MOTD(Client* client)
  6204. {
  6205. if (client)
  6206. ClientPacketFunctions::SendMOTD(client);
  6207. }
  6208. /*
  6209. Function: Command_Pet()
  6210. Purpose : Handle Pet {Command} commands
  6211. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6212. Dev :
  6213. Example : /pet preserve_master
  6214. */
  6215. void Commands::Command_Pet(Client* client, Seperator* sep)
  6216. {
  6217. PrintSep(sep, "COMMAND_PET");
  6218. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6219. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6220. if (strcmp(sep->arg[0], "hide") == 0) {
  6221. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6222. Entity* pet = client->GetPlayer()->GetDeityPet();
  6223. if (pet) {
  6224. if (pet->IsPrivateSpawn())
  6225. client->GetPlayer()->HideDeityPet(false);
  6226. else
  6227. client->GetPlayer()->HideDeityPet(true);
  6228. }
  6229. pet = client->GetPlayer()->GetCosmeticPet();
  6230. if (pet) {
  6231. if (pet->IsPrivateSpawn())
  6232. client->GetPlayer()->HideCosmeticPet(false);
  6233. else
  6234. client->GetPlayer()->HideCosmeticPet(true);
  6235. }
  6236. return;
  6237. }
  6238. // below is for all combat pets
  6239. if (!client->GetPlayer()->HasPet()) {
  6240. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6241. return;
  6242. }
  6243. if (strcmp(sep->arg[0], "stay") == 0) {
  6244. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6245. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  6246. client->GetPlayer()->SetCharSheetChanged(true);
  6247. if (client->GetPlayer()->GetPet())
  6248. client->GetPlayer()->GetPet()->following = false;
  6249. if (client->GetPlayer()->GetCharmedPet())
  6250. client->GetPlayer()->GetCharmedPet()->following = false;
  6251. }
  6252. else if (strcmp(sep->arg[0], "follow") == 0) {
  6253. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6254. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  6255. client->GetPlayer()->SetCharSheetChanged(true);
  6256. }
  6257. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6258. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  6259. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6260. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  6261. }
  6262. else {
  6263. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6264. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  6265. }
  6266. client->GetPlayer()->SetCharSheetChanged(true);
  6267. }
  6268. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6269. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  6270. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6271. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  6272. }
  6273. else {
  6274. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6275. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  6276. }
  6277. client->GetPlayer()->SetCharSheetChanged(true);
  6278. }
  6279. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6280. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6281. if (client->GetPlayer()->GetPet())
  6282. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6283. if (client->GetPlayer()->GetCharmedPet())
  6284. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6285. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  6286. client->GetPlayer()->SetCharSheetChanged(true);
  6287. }
  6288. else if (strcmp(sep->arg[0], "attack") == 0) {
  6289. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6290. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6291. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6292. if (client->GetPlayer()->GetPet())
  6293. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6294. if (client->GetPlayer()->GetCharmedPet())
  6295. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6296. }
  6297. else
  6298. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6299. }
  6300. else
  6301. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6302. }
  6303. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6304. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6305. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6306. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6307. }
  6308. else
  6309. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6310. }
  6311. /*
  6312. Function: Command_PetName()
  6313. Purpose : Pet your name (???)
  6314. Params :
  6315. Dev :
  6316. Example :
  6317. */
  6318. void Commands::Command_PetName(Client* client, Seperator* sep)
  6319. {
  6320. PrintSep(sep, "COMMAND_PETNAME");
  6321. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6322. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6323. }
  6324. /*
  6325. Function: Command_NamePet()
  6326. Purpose : Name your pet
  6327. Params :
  6328. Dev :
  6329. Example :
  6330. */
  6331. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6332. {
  6333. PrintSep(sep, "COMMAND_NAME_PET");
  6334. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6335. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6336. }
  6337. /*
  6338. Function: Command_Rename()
  6339. Purpose : Renames existing pet
  6340. Params :
  6341. Dev :
  6342. Example :
  6343. */
  6344. void Commands::Command_Rename(Client* client, Seperator* sep)
  6345. {
  6346. PrintSep(sep, "COMMAND_RENAME");
  6347. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6348. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6349. }
  6350. /*
  6351. Function: Command_ConfirmRename()
  6352. Purpose : Confirms renaming your pet
  6353. Params :
  6354. Dev :
  6355. Example :
  6356. */
  6357. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6358. {
  6359. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6360. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6361. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6362. }
  6363. /*
  6364. Function: Command_PetOptions()
  6365. Purpose : Sets various pet options
  6366. Params :
  6367. Dev :
  6368. Example :
  6369. */
  6370. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6371. {
  6372. PrintSep(sep, "COMMAND_PETOPTIONS");
  6373. Player* player = client->GetPlayer();
  6374. Spawn* target = player->GetTarget();
  6375. if (!target)
  6376. return;
  6377. if (target == player->GetPet())
  6378. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6379. else if (target == player->GetCharmedPet())
  6380. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6381. else if (target == player->GetCosmeticPet())
  6382. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6383. else if (target == player->GetDeityPet())
  6384. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6385. }
  6386. /*
  6387. Function: Command_Random()
  6388. Purpose : Handles /random dice roll in-game
  6389. Params : 1-100
  6390. Dev : Scatman
  6391. Example : /randon 1 100
  6392. */
  6393. void Commands::Command_Random(Client* client, Seperator* sep)
  6394. {
  6395. char message[256] = {0};
  6396. if (sep)
  6397. {
  6398. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6399. 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])));
  6400. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6401. 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])));
  6402. else
  6403. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6404. }
  6405. else
  6406. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6407. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6408. }
  6409. /*
  6410. Function: Command_Randomize()
  6411. Purpose : Sets randomize (appearance) values for NPCs
  6412. Params : Attrib Name
  6413. Dev : Scatman
  6414. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6415. */
  6416. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6417. {
  6418. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6419. if (target)
  6420. {
  6421. if (target->IsNPC())
  6422. {
  6423. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6424. {
  6425. const char* value = sep->arg[0];
  6426. if (strncasecmp(value, "show", strlen(value)) == 0)
  6427. {
  6428. client->DisplayRandomizeFeatures(target->GetRandomize());
  6429. }
  6430. else
  6431. {
  6432. if (sep->arg[1] && sep->IsNumber(1))
  6433. {
  6434. int8 option = atoi(sep->arg[1]);
  6435. if (option == 0 || option == 1)
  6436. {
  6437. int32 feature = 0;
  6438. char feature_text[32] = {0};
  6439. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6440. feature = RANDOMIZE_GENDER;
  6441. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6442. }
  6443. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6444. feature = RANDOMIZE_RACE;
  6445. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6446. }
  6447. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6448. feature = RANDOMIZE_MODEL_TYPE;
  6449. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6450. }
  6451. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6452. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6453. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6454. }
  6455. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6456. feature = RANDOMIZE_HAIR_TYPE;
  6457. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6458. }
  6459. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6460. feature = RANDOMIZE_WING_TYPE;
  6461. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6462. }
  6463. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6464. feature = RANDOMIZE_CHEEK_TYPE;
  6465. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6466. }
  6467. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6468. feature = RANDOMIZE_CHIN_TYPE;
  6469. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6470. }
  6471. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6472. feature = RANDOMIZE_EAR_TYPE;
  6473. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6474. }
  6475. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6476. feature = RANDOMIZE_EYE_BROW_TYPE;
  6477. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6478. }
  6479. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6480. feature = RANDOMIZE_EYE_TYPE;
  6481. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6482. }
  6483. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6484. feature = RANDOMIZE_LIP_TYPE;
  6485. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6486. }
  6487. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6488. feature = RANDOMIZE_NOSE_TYPE;
  6489. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6490. }
  6491. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6492. feature = RANDOMIZE_EYE_COLOR;
  6493. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6494. }
  6495. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6496. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6497. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6498. }
  6499. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6500. feature = RANDOMIZE_HAIR_COLOR1;
  6501. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6502. }
  6503. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6504. feature = RANDOMIZE_HAIR_COLOR2;
  6505. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6506. }
  6507. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6508. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6509. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6510. }
  6511. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6512. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6513. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6514. }
  6515. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6516. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6517. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6518. }
  6519. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6520. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6521. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6522. }
  6523. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6524. feature = RANDOMIZE_SKIN_COLOR;
  6525. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6526. }
  6527. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6528. feature = RANDOMIZE_WING_COLOR1;
  6529. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6530. }
  6531. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6532. feature = RANDOMIZE_WING_COLOR2;
  6533. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6534. }
  6535. else {
  6536. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6537. 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'.");
  6538. }
  6539. if (feature > 0) {
  6540. if (option == 1) {
  6541. if (target->GetRandomize() & feature)
  6542. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6543. else {
  6544. target->AddRandomize(feature);
  6545. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6546. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6547. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6548. }
  6549. }
  6550. else {
  6551. if (target->GetRandomize() & feature) {
  6552. target->AddRandomize(-feature);
  6553. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6554. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6555. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6556. }
  6557. else
  6558. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6559. }
  6560. }
  6561. }
  6562. else
  6563. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6564. }
  6565. else
  6566. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6567. }
  6568. }
  6569. else {
  6570. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6571. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6572. 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'.");
  6573. }
  6574. }
  6575. else
  6576. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6577. }
  6578. else
  6579. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6580. }
  6581. /*
  6582. Function: Command_ShowCloak()
  6583. Purpose : Character Settings combo box for Show Cloak
  6584. Params : true/false
  6585. Dev : John Adams
  6586. Example :
  6587. */
  6588. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6589. {
  6590. Player* player = client->GetPlayer();
  6591. if (sep && sep->arg[0])
  6592. {
  6593. const char* value = sep->arg[0];
  6594. if (strncasecmp(value, "true", strlen(value)) == 0)
  6595. {
  6596. player->set_character_flag(CF_SHOW_CLOAK);
  6597. player->reset_character_flag(CF2_SHOW_RANGED);
  6598. }
  6599. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6600. player->reset_character_flag(CF_SHOW_CLOAK);
  6601. else
  6602. {
  6603. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6604. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6605. }
  6606. }
  6607. }
  6608. /*
  6609. Function: Command_ShowHelm()
  6610. Purpose : Character Settings combo box for Show Helm
  6611. Params : true/false
  6612. Dev : John Adams
  6613. Example :
  6614. */
  6615. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6616. {
  6617. Player* player = client->GetPlayer();
  6618. if (sep && sep->arg[0])
  6619. {
  6620. const char* value = sep->arg[0];
  6621. if (strncasecmp(value, "true", strlen(value)) == 0)
  6622. {
  6623. player->reset_character_flag(CF_HIDE_HELM);
  6624. player->set_character_flag(CF_HIDE_HOOD);
  6625. }
  6626. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6627. player->set_character_flag(CF_HIDE_HELM);
  6628. else
  6629. {
  6630. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6631. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6632. }
  6633. }
  6634. }
  6635. /*
  6636. Function: Command_ShowHood()
  6637. Purpose : Character Settings combo box for Show Hood
  6638. Params : true/false
  6639. Dev : John Adams
  6640. Example :
  6641. */
  6642. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6643. {
  6644. Player* player = client->GetPlayer();
  6645. if (sep && sep->arg[0])
  6646. {
  6647. const char* value = sep->arg[0];
  6648. if (strncasecmp(value, "true", strlen(value)) == 0)
  6649. {
  6650. player->reset_character_flag(CF_HIDE_HOOD);
  6651. player->set_character_flag(CF_HIDE_HELM);
  6652. }
  6653. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6654. player->set_character_flag(CF_HIDE_HOOD);
  6655. else
  6656. {
  6657. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6658. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6659. }
  6660. }
  6661. }
  6662. /*
  6663. Function: Command_ShowHoodHelm()
  6664. Purpose : Character Settings combo box for Show Helm or Hood
  6665. Params : true/false
  6666. Dev : John Adams
  6667. Example :
  6668. */
  6669. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6670. {
  6671. Player* player = client->GetPlayer();
  6672. if (sep && sep->arg[0])
  6673. {
  6674. const char* value = sep->arg[0];
  6675. if (strncasecmp(value, "true", strlen(value)) == 0)
  6676. {
  6677. player->reset_character_flag(CF_HIDE_HOOD);
  6678. player->reset_character_flag(CF_HIDE_HELM);
  6679. }
  6680. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6681. {
  6682. // don't think we ever wind up in here...
  6683. player->set_character_flag(CF_HIDE_HOOD);
  6684. player->set_character_flag(CF_HIDE_HELM);
  6685. }
  6686. else
  6687. {
  6688. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6689. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6690. }
  6691. }
  6692. }
  6693. /*
  6694. Function: Command_ShowRanged()
  6695. Purpose : Character Settings combo box for Show Ranged weapon
  6696. Params : true/false
  6697. Dev : John Adams
  6698. Example :
  6699. */
  6700. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6701. {
  6702. Player* player = client->GetPlayer();
  6703. if (sep && sep->arg[0])
  6704. {
  6705. const char* value = sep->arg[0];
  6706. if (strncasecmp(value, "true", strlen(value)) == 0)
  6707. {
  6708. player->set_character_flag(CF2_SHOW_RANGED);
  6709. player->reset_character_flag(CF_SHOW_CLOAK);
  6710. }
  6711. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6712. player->reset_character_flag(CF2_SHOW_RANGED);
  6713. else
  6714. {
  6715. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6716. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6717. }
  6718. }
  6719. }
  6720. /*
  6721. Function:
  6722. Purpose :
  6723. Params :
  6724. Dev :
  6725. Example :
  6726. */
  6727. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6728. {
  6729. Player* player = 0;
  6730. Client* to_client = 0;
  6731. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6732. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6733. switch(handler)
  6734. {
  6735. case COMMAND_SKILL:
  6736. {
  6737. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6738. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6739. break;
  6740. }
  6741. case COMMAND_SKILL_ADD:
  6742. {
  6743. if (sep && sep->arg[0])
  6744. {
  6745. const char* skill_name = sep->argplus[0];
  6746. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6747. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6748. {
  6749. player = to_client->GetPlayer();
  6750. if (player)
  6751. {
  6752. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6753. {
  6754. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6755. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6756. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6757. }
  6758. else
  6759. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6760. }
  6761. }
  6762. else if (skill) // add skill to yourself
  6763. {
  6764. player = client->GetPlayer();
  6765. if (player)
  6766. {
  6767. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6768. {
  6769. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6770. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6771. }
  6772. else
  6773. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6774. }
  6775. }
  6776. else
  6777. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6778. }
  6779. else
  6780. {
  6781. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6782. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6783. }
  6784. break;
  6785. }
  6786. case COMMAND_SKILL_REMOVE:
  6787. {
  6788. if (sep && sep->arg[0])
  6789. {
  6790. const char* skill_name = sep->argplus[0];
  6791. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6792. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6793. {
  6794. player = to_client->GetPlayer();
  6795. if (player)
  6796. {
  6797. if (player->GetSkills()->HasSkill(skill->skill_id))
  6798. {
  6799. player->RemoveSkillFromDB(skill, true);
  6800. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6801. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6802. }
  6803. else
  6804. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6805. }
  6806. }
  6807. else if(skill) // remove skill from yourself
  6808. {
  6809. Player* player = client->GetPlayer();
  6810. if (player)
  6811. {
  6812. if (player->GetSkills()->HasSkill(skill->skill_id))
  6813. {
  6814. player->RemoveSkillFromDB(skill, true);
  6815. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6816. }
  6817. else
  6818. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6819. }
  6820. }
  6821. else
  6822. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6823. }
  6824. else
  6825. {
  6826. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  6827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6828. }
  6829. break;
  6830. }
  6831. case COMMAND_SKILL_LIST:
  6832. {
  6833. if (sep && sep->arg[0])
  6834. {
  6835. const char* skill_name = sep->argplus[0];
  6836. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  6837. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  6838. map<int32, Skill*>::iterator itr;
  6839. if (skills && skills->size() > 0)
  6840. {
  6841. for (itr = skills->begin(); itr != skills->end(); itr++)
  6842. {
  6843. Skill* skill = itr->second;
  6844. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  6845. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  6846. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  6847. }
  6848. }
  6849. }
  6850. else
  6851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  6852. break;
  6853. }
  6854. }
  6855. }
  6856. /*
  6857. Function: Command_SpawnTemplate()
  6858. Purpose : Create or Use defined Spawn Templates
  6859. Params : create, save, rempve, list
  6860. Dev : John Adams
  6861. Example : /spawn template create "Test"
  6862. */
  6863. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  6864. {
  6865. if (sep == NULL || sep->arg[0] == NULL)
  6866. {
  6867. 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.");
  6868. return;
  6869. }
  6870. // got params, continue
  6871. const char * template_cmd = sep->arg[0];
  6872. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  6873. {
  6874. if (!sep->IsSet(1))
  6875. {
  6876. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  6877. 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.");
  6878. return;
  6879. }
  6880. map<int32, string>* template_names = 0;
  6881. if (sep->IsNumber(1))
  6882. {
  6883. int32 location_id = 0;
  6884. location_id = atoi(sep->arg[1]);
  6885. template_names = database.GetSpawnTemplateListByID(location_id);
  6886. }
  6887. else
  6888. {
  6889. const char* name = 0;
  6890. name = sep->argplus[1];
  6891. template_names = database.GetSpawnTemplateListByName(name);
  6892. }
  6893. if(!template_names)
  6894. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  6895. else
  6896. {
  6897. map<int32, string>::iterator itr;
  6898. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  6899. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  6900. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  6901. safe_delete(template_names);
  6902. }
  6903. }
  6904. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  6905. {
  6906. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6907. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  6908. {
  6909. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  6910. {
  6911. // first, lookup to see if template name already exists
  6912. const char* name = 0;
  6913. name = sep->argplus[1];
  6914. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  6915. if(!template_names)
  6916. {
  6917. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  6918. if( new_template_id > 0 )
  6919. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  6920. else
  6921. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  6922. }
  6923. else
  6924. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  6925. }
  6926. else
  6927. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  6928. }
  6929. else
  6930. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  6931. }
  6932. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  6933. {
  6934. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  6935. {
  6936. int32 template_id = 0;
  6937. template_id = atoi(sep->arg[1]);
  6938. if (database.RemoveSpawnTemplate(template_id))
  6939. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  6940. else
  6941. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  6942. }
  6943. else
  6944. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  6945. }
  6946. // Renamed create to spawn
  6947. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  6948. {
  6949. if (sep && sep->arg[1][0])
  6950. {
  6951. int32 new_location = 0;
  6952. if (sep->IsNumber(1))
  6953. {
  6954. int32 template_id = 0;
  6955. template_id = atoi(sep->arg[1]);
  6956. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  6957. if( new_location > 0 )
  6958. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  6959. else
  6960. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  6961. }
  6962. else
  6963. {
  6964. const char* name = 0;
  6965. name = sep->argplus[1];
  6966. new_location = database.CreateSpawnFromTemplateByName(client, name);
  6967. if( new_location > 0 )
  6968. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  6969. else
  6970. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  6971. }
  6972. }
  6973. else
  6974. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  6975. }
  6976. else
  6977. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  6978. }
  6979. void Commands::Command_Speed(Client* client, Seperator* sep) {
  6980. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  6981. float new_speed = atof(sep->arg[0]);
  6982. if (new_speed > 0.0f)
  6983. {
  6984. client->GetPlayer()->SetSpeed(new_speed, true);
  6985. client->GetPlayer()->SetCharSheetChanged(true);
  6986. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  6987. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  6988. }
  6989. else
  6990. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  6991. }
  6992. else{
  6993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  6994. }
  6995. }
  6996. /*
  6997. Function: Command_StationMarketPlace()
  6998. Purpose : just trying to eat the console spam for now
  6999. Params :
  7000. Dev : John
  7001. */
  7002. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  7003. {
  7004. PrintSep(sep, "COMMAND_SMP");
  7005. // This will reduce the spam from once every 10 sec to once every 30 sec,
  7006. // can't seem to reduce it any more get rid of it completely...
  7007. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  7008. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  7009. if (packet) {
  7010. packet->setDataByName("account_id", client->GetAccountID());
  7011. packet->setDataByName("character_id", client->GetCharacterID());
  7012. packet->setDataByName("unknown1", 1, 5);
  7013. packet->setDataByName("unknown1", 26, 6);
  7014. packet->setDataByName("unknown2", 0xFFFFFFFF);
  7015. packet->setDataByName("unknown3", 248, 1);
  7016. client->QueuePacket(packet->serialize());
  7017. }
  7018. safe_delete(packet);
  7019. }
  7020. }
  7021. /*
  7022. Function: Command_StopDrinking()
  7023. Purpose : Stops player from auto-consuming drink
  7024. Params :
  7025. Dev : Zcoretri
  7026. Example : /stopdrinking
  7027. */
  7028. void Commands::Command_StopDrinking(Client* client)
  7029. {
  7030. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  7031. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  7032. }
  7033. /*
  7034. Function: Command_StopEating()
  7035. Purpose : Stops player from auto-consuming food
  7036. Params :
  7037. Dev : Zcoretri
  7038. Example : /stopeating
  7039. */
  7040. void Commands::Command_StopEating(Client* client)
  7041. {
  7042. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  7043. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  7044. }
  7045. /*
  7046. Function: Command_Title()
  7047. Purpose : Help for /title command
  7048. Params : n/a
  7049. Dev : Zcoretri
  7050. Example : /title
  7051. */
  7052. void Commands::Command_Title(Client* client)
  7053. {
  7054. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  7055. }
  7056. /*
  7057. Function: Command_TitleList()
  7058. Purpose : List available titles for player
  7059. Params : n/a
  7060. Dev : Zcoretri
  7061. Example : /title list
  7062. */
  7063. void Commands::Command_TitleList(Client* client)
  7064. {
  7065. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  7066. list<Title*>::iterator itr;
  7067. Title* title;
  7068. int16 i = 0;
  7069. client->Message(CHANNEL_COLOR_WHITE, "Listing available titles:");
  7070. for(itr = titles->begin(); itr != titles->end(); itr++)
  7071. {
  7072. title = *itr;
  7073. client->Message(CHANNEL_COLOR_WHITE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  7074. i++;
  7075. }
  7076. }
  7077. /*
  7078. Function: Command_TitleSetPrefix()
  7079. Purpose : Set Prefix title for player
  7080. Params : Title ID
  7081. Dev : Zcoretri
  7082. Example : /title setprefix 1
  7083. */
  7084. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  7085. {
  7086. if (sep && sep->arg[0] && sep->IsNumber(0))
  7087. {
  7088. int32 index = atoul(sep->arg[0]);
  7089. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  7090. client->SendTitleUpdate();
  7091. }
  7092. }
  7093. /*
  7094. Function: Command_TitleSetSuffix()
  7095. Purpose : Set Suffix title for player
  7096. Params : Title ID
  7097. Dev : Zcoretri
  7098. Example : /title setsuffix 1
  7099. */
  7100. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  7101. {
  7102. if (sep && sep->arg[0] && sep->IsNumber(0))
  7103. {
  7104. int32 index = atoul(sep->arg[0]);
  7105. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  7106. client->SendTitleUpdate();
  7107. }
  7108. }
  7109. /*
  7110. Function: Command_TitleFix()
  7111. Purpose : Fix title for player (???)
  7112. Params :
  7113. Dev : Zcoretri
  7114. Example :
  7115. */
  7116. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  7117. {
  7118. PrintSep(sep, "COMMAND_TITLE_FIX");
  7119. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  7120. }
  7121. /*
  7122. Function: Command_Toggle_Anonymous()
  7123. Purpose : Toggles player Anonymous
  7124. Params :
  7125. Dev : paulgh
  7126. Example : /anon
  7127. */
  7128. void Commands::Command_Toggle_Anonymous(Client* client)
  7129. {
  7130. Player* player = client->GetPlayer();
  7131. player->toggle_character_flag(CF_ANONYMOUS);
  7132. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  7133. if (player->get_character_flag(CF_ANONYMOUS))
  7134. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  7135. else
  7136. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  7137. }
  7138. /*
  7139. Function: Command_Toggle_AutoConsume()
  7140. Purpose : Toggles player food/drink auto consume
  7141. Params : unknown
  7142. Dev : paulgh
  7143. Example : /set_auto_consume
  7144. */
  7145. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7146. {
  7147. Player* player = client->GetPlayer();
  7148. if (sep && sep->arg[0])
  7149. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7150. if (sep && sep->arg[0] && sep->IsNumber(0))
  7151. {
  7152. int8 slot = atoi(sep->arg[0]);
  7153. int8 flag = atoi(sep->arg[1]);
  7154. if (slot == EQ2_FOOD_SLOT)
  7155. {
  7156. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7157. player->SetCharSheetChanged(true);
  7158. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7159. if (flag == 1)
  7160. client->Message(CHANNEL_COLOR_WHITE, "You decide to eat immediately whenever you become hungry.");
  7161. else
  7162. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the hunger.");
  7163. }
  7164. else
  7165. {
  7166. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7167. player->SetCharSheetChanged(true);
  7168. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7169. if (flag == 1)
  7170. client->Message(CHANNEL_COLOR_WHITE, "You decide to drink immediately whenever you become thirsty.");
  7171. else
  7172. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the thirst.");
  7173. }
  7174. }
  7175. }
  7176. /*
  7177. Function: Command_Toggle_BonusXP()
  7178. Purpose : Toggles player Bonus XP
  7179. Params :
  7180. Dev : John Adams
  7181. Example : /disable_char_bonus_exp
  7182. */
  7183. void Commands::Command_Toggle_BonusXP(Client* client)
  7184. {
  7185. Player* player = client->GetPlayer();
  7186. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7187. player->SetCharSheetChanged(true);
  7188. }
  7189. /*
  7190. Function: Command_Toggle_CombatXP()
  7191. Purpose : Toggles player Adventure XP
  7192. Params :
  7193. Dev : John Adams
  7194. Example : /disable_combat_exp
  7195. */
  7196. void Commands::Command_Toggle_CombatXP(Client* client)
  7197. {
  7198. Player* player = client->GetPlayer();
  7199. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7200. player->SetCharSheetChanged(true);
  7201. }
  7202. /*
  7203. Function: Command_Toggle_GMHide()
  7204. Purpose : Toggles hiding player GM status
  7205. Params :
  7206. Dev : Scatman
  7207. Example : /gm_hide
  7208. */
  7209. void Commands::Command_Toggle_GMHide(Client* client)
  7210. {
  7211. Player* player = client->GetPlayer();
  7212. player->toggle_character_flag(CF_HIDE_STATUS);
  7213. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7214. }
  7215. /*
  7216. Function: Command_Toggle_GMVanish()
  7217. Purpose : Toggles hiding GM players from /who searches
  7218. Params :
  7219. Dev : Scatman
  7220. Example : /gm_vanish
  7221. */
  7222. void Commands::Command_Toggle_GMVanish(Client* client)
  7223. {
  7224. Player* player = client->GetPlayer();
  7225. player->toggle_character_flag(CF_GM_HIDDEN);
  7226. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7227. }
  7228. /*
  7229. Function: Command_Toggle_Illusions()
  7230. Purpose : Toggles player illusion form
  7231. Params : not sure sep is needed, testing
  7232. Dev : paulgh
  7233. Example : /hide_illusions
  7234. */
  7235. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7236. {
  7237. if (sep && sep->arg[0])
  7238. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7239. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7240. }
  7241. /*
  7242. Function: Command_Toggle_LFG()
  7243. Purpose : Toggles player LFG Flag
  7244. Params :
  7245. Dev : paulgh
  7246. Example : /lfg
  7247. */
  7248. void Commands::Command_Toggle_LFG(Client* client)
  7249. {
  7250. Player* player = client->GetPlayer();
  7251. player->toggle_character_flag(CF_LFG);
  7252. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7253. if (player->get_character_flag(CF_LFG))
  7254. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7255. else
  7256. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7257. }
  7258. /*
  7259. Function: Command_Toggle_LFW()
  7260. Purpose : Toggles player LFW Flag
  7261. Params :
  7262. Dev : paulgh
  7263. Example : /lfw
  7264. */
  7265. void Commands::Command_Toggle_LFW(Client* client)
  7266. {
  7267. Player* player = client->GetPlayer();
  7268. player->toggle_character_flag(CF_LFW);
  7269. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7270. if (player->get_character_flag(CF_LFW))
  7271. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7272. else
  7273. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7274. }
  7275. /*
  7276. Function: Command_Toggle_QuestXP()
  7277. Purpose : Toggles player Quest XP
  7278. Params :
  7279. Dev : John Adams
  7280. Example : /disable_quest_exp
  7281. */
  7282. void Commands::Command_Toggle_QuestXP(Client* client)
  7283. {
  7284. Player* player = client->GetPlayer();
  7285. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7286. player->SetCharSheetChanged(true);
  7287. }
  7288. /*
  7289. Function: Command_Toggle_Roleplaying()
  7290. Purpose : Toggles player Roleplaying flag
  7291. Params :
  7292. Dev : paulgh
  7293. Example : /role
  7294. */
  7295. void Commands::Command_Toggle_Roleplaying(Client* client)
  7296. {
  7297. Player* player = client->GetPlayer();
  7298. player->toggle_character_flag(CF_ROLEPLAYING);
  7299. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  7300. if (player->get_character_flag(CF_ROLEPLAYING))
  7301. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  7302. else
  7303. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  7304. }
  7305. void Commands::Command_Toggle_Duels(Client* client)
  7306. {
  7307. Player* player = client->GetPlayer();
  7308. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7309. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7310. }
  7311. void Commands::Command_Toggle_Trades(Client* client)
  7312. {
  7313. Player* player = client->GetPlayer();
  7314. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7315. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7316. }
  7317. void Commands::Command_Toggle_Guilds(Client* client)
  7318. {
  7319. Player* player = client->GetPlayer();
  7320. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7321. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7322. }
  7323. void Commands::Command_Toggle_Groups(Client* client)
  7324. {
  7325. Player* player = client->GetPlayer();
  7326. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7327. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7328. }
  7329. void Commands::Command_Toggle_Raids(Client* client)
  7330. {
  7331. Player* player = client->GetPlayer();
  7332. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7333. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7334. }
  7335. void Commands::Command_Toggle_LON(Client* client)
  7336. {
  7337. Player* player = client->GetPlayer();
  7338. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7339. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7340. }
  7341. void Commands::Command_Toggle_VoiceChat(Client* client)
  7342. {
  7343. Player* player = client->GetPlayer();
  7344. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7345. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7346. }
  7347. /*
  7348. Function: Command_TradeStart()
  7349. Purpose : Starts item/coin trade between players
  7350. Params :
  7351. Dev :
  7352. Example :
  7353. */
  7354. #include "../Trade.h"
  7355. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7356. {
  7357. PrintSep(sep, "COMMAND_START_TRADE");
  7358. Entity* trader = client->GetPlayer();
  7359. Entity* trader2 = 0;
  7360. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7361. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7362. if (spawn) {
  7363. if (spawn->IsEntity())
  7364. trader2 = (Entity*)spawn;
  7365. }
  7366. }
  7367. else if (client->GetPlayer()->GetTarget()) {
  7368. if (client->GetPlayer()->GetTarget()->IsEntity())
  7369. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7370. }
  7371. // can only trade with player or bots
  7372. if (trader && trader2) {
  7373. if (trader == trader2) {
  7374. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7375. }
  7376. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7377. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7378. if (trader->trade)
  7379. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7380. else if (trader2->trade)
  7381. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7382. else {
  7383. Trade* trade = new Trade(trader, trader2);
  7384. trader->trade = trade;
  7385. trader2->trade = trade;
  7386. }
  7387. }
  7388. else {
  7389. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  7390. }
  7391. }
  7392. else
  7393. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  7394. }
  7395. /*
  7396. Function: Command_Track()
  7397. Purpose : Starts/Stops Tracking for a player
  7398. Params :
  7399. Dev : Scatman
  7400. Example : /track
  7401. */
  7402. void Commands::Command_Track(Client* client)
  7403. {
  7404. if (!client->GetPlayer()->GetIsTracking())
  7405. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7406. else
  7407. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7408. }
  7409. /*
  7410. Function: Command_TradeAccept()
  7411. Purpose : Accepts item/coin trade between players
  7412. Params :
  7413. Dev :
  7414. Example :
  7415. */
  7416. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7417. {
  7418. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7419. Trade* trade = client->GetPlayer()->trade;
  7420. if (trade) {
  7421. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7422. if (trade_complete)
  7423. safe_delete(trade);
  7424. }
  7425. else
  7426. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7427. }
  7428. /*
  7429. Function: Command_TradeReject()
  7430. Purpose : Rejects item/coin trade between players
  7431. Params :
  7432. Dev :
  7433. Example :
  7434. */
  7435. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7436. {
  7437. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7438. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7439. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7440. }
  7441. /*
  7442. Function: Command_TradeCancel()
  7443. Purpose : Cancels item/coin trade between players
  7444. Params :
  7445. Dev :
  7446. Example :
  7447. */
  7448. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7449. {
  7450. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7451. Trade* trade = client->GetPlayer()->trade;
  7452. if (trade) {
  7453. trade->CancelTrade(client->GetPlayer());
  7454. safe_delete(trade);
  7455. }
  7456. else
  7457. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7458. }
  7459. /*
  7460. Function: Command_TradeSetCoin()
  7461. Purpose : Sets coin trade between players
  7462. Params :
  7463. Dev :
  7464. Example :
  7465. */
  7466. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7467. {
  7468. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7469. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7470. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7471. }
  7472. /*
  7473. Function: Command_TradeAddCoin()
  7474. Purpose : Adds coin to trade between players
  7475. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7476. Dev :
  7477. Example :
  7478. */
  7479. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7480. {
  7481. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7482. Trade* trade = client->GetPlayer()->trade;
  7483. if (trade) {
  7484. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7485. int32 amount = atoi(sep->arg[0]);
  7486. int64 val = 0;
  7487. switch (handler) {
  7488. case COMMAND_ADD_TRADE_COPPER:
  7489. {
  7490. val = amount;
  7491. trade->AddCoinToTrade(client->GetPlayer(), val);
  7492. break;
  7493. }
  7494. case COMMAND_ADD_TRADE_SILVER:
  7495. {
  7496. val = amount * 100;
  7497. trade->AddCoinToTrade(client->GetPlayer(), val);
  7498. break;
  7499. }
  7500. case COMMAND_ADD_TRADE_GOLD:
  7501. {
  7502. val = amount * 10000;
  7503. trade->AddCoinToTrade(client->GetPlayer(), val);
  7504. break;
  7505. }
  7506. case COMMAND_ADD_TRADE_PLAT:
  7507. {
  7508. val = amount * 1000000;
  7509. trade->AddCoinToTrade(client->GetPlayer(), val);
  7510. break;
  7511. }
  7512. default:
  7513. {
  7514. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7515. break;
  7516. }
  7517. }
  7518. }
  7519. else
  7520. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7521. }
  7522. else
  7523. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7524. }
  7525. /*
  7526. Function: Command_TradeRemoveCoin()
  7527. Purpose : Removes coin from trade between players
  7528. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7529. Dev :
  7530. Example :
  7531. */
  7532. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7533. {
  7534. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7535. Trade* trade = client->GetPlayer()->trade;
  7536. if (trade) {
  7537. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7538. int32 amount = atoi(sep->arg[0]);
  7539. int64 val = 0;
  7540. switch (handler) {
  7541. case COMMAND_REMOVE_TRADE_COPPER:
  7542. {
  7543. val = amount;
  7544. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7545. break;
  7546. }
  7547. case COMMAND_REMOVE_TRADE_SILVER:
  7548. {
  7549. val = amount * 100;
  7550. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7551. break;
  7552. }
  7553. case COMMAND_REMOVE_TRADE_GOLD:
  7554. {
  7555. val = amount * 10000;
  7556. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7557. break;
  7558. }
  7559. case COMMAND_REMOVE_TRADE_PLAT:
  7560. {
  7561. val = amount * 1000000;
  7562. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7563. break;
  7564. }
  7565. default:
  7566. {
  7567. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7568. break;
  7569. }
  7570. }
  7571. }
  7572. else
  7573. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7574. }
  7575. else
  7576. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7577. }
  7578. /*
  7579. Function: Command_TradeAddItem()
  7580. Purpose : Adds item to trade between players
  7581. Params :
  7582. Dev :
  7583. Example :
  7584. */
  7585. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7586. {
  7587. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7588. /*
  7589. arg[0] = item index
  7590. arg[1] = slot
  7591. arg[2] = quantity
  7592. */
  7593. if (!client->GetPlayer()->trade) {
  7594. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7595. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7596. return;
  7597. }
  7598. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7599. Item* item = 0;
  7600. int32 index = atoi(sep->arg[0]);
  7601. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7602. if (item) {
  7603. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7604. if (result == 1)
  7605. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7606. else if (result == 2)
  7607. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7608. else if (result == 3)
  7609. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7610. else if (result == 255)
  7611. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7612. }
  7613. else {
  7614. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7615. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7616. }
  7617. }
  7618. else
  7619. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7620. }
  7621. /*
  7622. Function: Command_TradeRemoveItem()
  7623. Purpose : Removes item from trade between players
  7624. Params :
  7625. Dev :
  7626. Example :
  7627. */
  7628. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7629. {
  7630. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7631. /*
  7632. arg[0] = trade window slot
  7633. */
  7634. Trade* trade = client->GetPlayer()->trade;
  7635. if (trade) {
  7636. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7637. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7638. }
  7639. else
  7640. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7641. }
  7642. else
  7643. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7644. }
  7645. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7646. {
  7647. Item *item = 0;
  7648. sint32 crc;
  7649. if (sep) {
  7650. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7651. if (client->GetVersion() < 1096) {
  7652. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7653. {
  7654. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7655. crc = atol(sep->arg[2]);
  7656. }
  7657. }
  7658. else {
  7659. // From the broker and links in chat
  7660. if (strcmp(sep->arg[0], "crc") == 0) {
  7661. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7662. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7663. crc = atol(sep->arg[3]);
  7664. }
  7665. }
  7666. // From inventory
  7667. if (strcmp(sep->arg[0], "dbid") == 0) {
  7668. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7669. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7670. crc = atol(sep->arg[4]);
  7671. }
  7672. }
  7673. }
  7674. if (item)
  7675. client->ShowDressingRoom(item, crc);
  7676. }
  7677. }
  7678. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7679. const char *channel_name, *password = NULL;
  7680. if (sep == NULL || !sep->IsSet(0)) {
  7681. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7682. return;
  7683. }
  7684. channel_name = sep->arg[0];
  7685. if (sep->IsSet(1))
  7686. password = sep->arg[1];
  7687. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7688. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7689. return;
  7690. }
  7691. if (chat.IsInChannel(client, channel_name)) {
  7692. client->Message(CHANNEL_COLOR_WHITE, "You are already in '%s'.", channel_name);
  7693. return;
  7694. }
  7695. if (chat.HasPassword(channel_name)) {
  7696. if (password == NULL) {
  7697. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': That channel is password protected.", channel_name);
  7698. return;
  7699. }
  7700. if (!chat.PasswordMatches(channel_name, password)) {
  7701. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': The password is not correc.t", channel_name);
  7702. return;
  7703. }
  7704. }
  7705. if (!chat.JoinChannel(client, channel_name))
  7706. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7707. }
  7708. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7709. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7710. Command_JoinChannel(client, sep);
  7711. }
  7712. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7713. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7714. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7715. PrintSep(sep, "tellchannel");
  7716. return;
  7717. }
  7718. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7719. }
  7720. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7721. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7722. if (sep->IsSet(0)) {
  7723. if (atoi(sep->arg[0]) == 1) {
  7724. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  7725. if (packet2) {
  7726. packet2->setDataByName("spell_type", 2);
  7727. packet2->setDataByName("spell_id", 8308);
  7728. packet2->setDataByName("spell_name", "Sprint");
  7729. packet2->setDataByName("add_silently", 0);
  7730. packet2->setDataByName("tier", 1);
  7731. packet2->setDataByName("blah1", 1);
  7732. packet2->setDataByName("blah2", 1);
  7733. EQ2Packet* outapp = packet2->serialize();
  7734. DumpPacket(outapp);
  7735. client->QueuePacket(outapp);
  7736. safe_delete(packet2);
  7737. }
  7738. }
  7739. else if (atoi(sep->arg[0]) == 2) {
  7740. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  7741. if (packet2) {
  7742. packet2->setDataByName("guild_name", "Test");
  7743. packet2->setDataByName("guild_motd", "Test MOTD");
  7744. packet2->setDataByName("guild_id", 1234);
  7745. packet2->setDataByName("guild_level", 1);
  7746. packet2->setDataByName("unknown", 2);
  7747. packet2->setDataByName("unknown2", 3);
  7748. packet2->setDataByName("exp_current", 1);
  7749. packet2->setDataByName("exp_to_next_level", 4);
  7750. EQ2Packet* outapp = packet2->serialize();
  7751. DumpPacket(outapp);
  7752. client->QueuePacket(outapp);
  7753. safe_delete(packet2);
  7754. }
  7755. }
  7756. else if (atoi(sep->arg[0]) == 3) {
  7757. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  7758. if (packet2) {
  7759. packet2->setDataByName("guild_id", 1234);
  7760. packet2->setDataByName("character_id", 1);
  7761. packet2->setDataByName("account_id", 2);
  7762. packet2->setDataByName("guild_level", 1);
  7763. packet2->setDataByName("name", "Test");
  7764. packet2->setDataByName("unknown2", 0);
  7765. packet2->setDataByName("unknown3", 1);
  7766. packet2->setDataByName("adventure_class", 6);
  7767. packet2->setDataByName("adventure_level", 7);
  7768. packet2->setDataByName("tradeskill_class", 4);
  7769. packet2->setDataByName("tradeskill_level", 5);
  7770. packet2->setDataByName("rank", 0);
  7771. packet2->setDataByName("member_flags", 2);
  7772. packet2->setDataByName("join_date", 1591112273);
  7773. packet2->setDataByName("guild_status", 2);
  7774. packet2->setDataByName("last_login", 1591132273);
  7775. packet2->setDataByName("recruiter_id", 1);
  7776. packet2->setDataByName("points", 2345);
  7777. packet2->setDataByName("note", "note");
  7778. packet2->setMediumStringByName("officer_note", "O note");
  7779. packet2->setMediumStringByName("zone", "Blah");
  7780. EQ2Packet* outapp = packet2->serialize();
  7781. DumpPacket(outapp);
  7782. client->QueuePacket(outapp);
  7783. safe_delete(packet2);
  7784. }
  7785. }
  7786. else if (atoi(sep->arg[0]) == 5) {
  7787. client->GetPlayer()->GetTarget();
  7788. int16 offset = atoi(sep->arg[2]);
  7789. int32 value1 = atol(sep->arg[4]);
  7790. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  7791. client->QueuePacket(outapp);
  7792. }
  7793. else if (atoi(sep->arg[0]) == 6) {
  7794. Spawn* spawn = client->GetPlayer()->GetTarget();
  7795. if (!spawn)
  7796. spawn = client->GetPlayer();
  7797. else if (spawn->IsEntity())
  7798. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  7799. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  7800. }
  7801. else if (atoi(sep->arg[0]) == 7) {
  7802. int32 id = 0;
  7803. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  7804. if (spawn) {
  7805. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7806. spawn->SetY(client->GetPlayer()->GetY(), false);
  7807. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7808. float heading = client->GetPlayer()->GetHeading() + 180;
  7809. if (heading > 360)
  7810. heading -= 360;
  7811. spawn->SetLevel(5);
  7812. spawn->SetAdventureClass(4);
  7813. spawn->SetHeading(heading, false);
  7814. spawn->SetSpawnOrigX(spawn->GetX());
  7815. spawn->SetSpawnOrigY(spawn->GetY());
  7816. spawn->SetSpawnOrigZ(spawn->GetZ());
  7817. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  7818. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  7819. spawn->appearance.targetable = 1;
  7820. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  7821. spawn->SetTotalHP(spawn->GetLevel() * 15);
  7822. spawn->SetHP(spawn->GetTotalHP());
  7823. }
  7824. if (spawn->GetTotalPower() == 0) {
  7825. spawn->SetTotalPower(spawn->GetLevel() * 15);
  7826. spawn->SetPower(spawn->GetTotalPower());
  7827. }
  7828. int16 offset = atoi(sep->arg[1]);
  7829. int32 value1 = atol(sep->arg[2]);
  7830. sprintf(spawn->appearance.name, "Offset %i", offset);
  7831. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  7832. DumpPacket(ret);
  7833. client->QueuePacket(ret);
  7834. }
  7835. }
  7836. else if (atoi(sep->arg[0]) == 8) {
  7837. int32 id = atoi(sep->arg[1]);
  7838. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  7839. if (spawn) {
  7840. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7841. spawn->SetY(client->GetPlayer()->GetY(), false);
  7842. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7843. float heading = client->GetPlayer()->GetHeading() + 180;
  7844. if (heading > 360)
  7845. heading -= 360;
  7846. spawn->SetLevel(5);
  7847. spawn->SetAdventureClass(4);
  7848. spawn->SetHeading(heading, false);
  7849. spawn->SetSpawnOrigX(spawn->GetX());
  7850. spawn->SetSpawnOrigY(spawn->GetY());
  7851. spawn->SetSpawnOrigZ(spawn->GetZ());
  7852. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  7853. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  7854. spawn->appearance.targetable = 1;
  7855. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  7856. spawn->SetTotalHP(spawn->GetLevel() * 15);
  7857. spawn->SetHP(spawn->GetTotalHP());
  7858. }
  7859. if (spawn->GetTotalPower() == 0) {
  7860. spawn->SetTotalPower(spawn->GetLevel() * 15);
  7861. spawn->SetPower(spawn->GetTotalPower());
  7862. }
  7863. int16 offset = atoi(sep->arg[2]);
  7864. int16 offset2 = atoi(sep->arg[3]);
  7865. int32 value1 = atol(sep->arg[4]);
  7866. int16 offset3 = 0;
  7867. int16 offset4 = 0;
  7868. int32 value2 = 0;
  7869. if (sep->IsSet(7)) {
  7870. offset3 = atoi(sep->arg[5]);
  7871. offset4 = atoi(sep->arg[6]);
  7872. value2 = atol(sep->arg[7]);
  7873. }
  7874. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  7875. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  7876. DumpPacket(ret);
  7877. client->QueuePacket(ret);
  7878. }
  7879. }
  7880. else if (atoi(sep->arg[0]) == 9) {
  7881. Item* item = master_item_list.GetItem(70007);
  7882. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  7883. if (sep->IsSet(2)) {
  7884. int8 offset = atoi(sep->arg[1]);
  7885. uchar* ptr2 = app->pBuffer;
  7886. ptr2 += offset;
  7887. if (sep->IsNumber(2)) {
  7888. int32 value1 = atol(sep->arg[2]);
  7889. if (value1 > 0xFFFF)
  7890. memcpy(ptr2, (uchar*)&value1, 4);
  7891. else if (value1 > 0xFF)
  7892. memcpy(ptr2, (uchar*)&value1, 2);
  7893. else
  7894. memcpy(ptr2, (uchar*)&value1, 1);
  7895. }
  7896. else {
  7897. int8 len = strlen(sep->arg[2]);
  7898. memcpy(ptr2, (uchar*)&len, 1);
  7899. ptr2 += 1;
  7900. memcpy(ptr2, sep->arg[2], len);
  7901. }
  7902. }
  7903. if (sep->IsSet(4)) {
  7904. int8 offset = atoi(sep->arg[3]);
  7905. uchar* ptr2 = app->pBuffer;
  7906. ptr2 += offset;
  7907. if (sep->IsNumber(4)) {
  7908. int32 value1 = atol(sep->arg[4]);
  7909. if (value1 > 0xFFFF)
  7910. memcpy(ptr2, (uchar*)&value1, 4);
  7911. else if (value1 > 0xFF)
  7912. memcpy(ptr2, (uchar*)&value1, 2);
  7913. else
  7914. memcpy(ptr2, (uchar*)&value1, 1);
  7915. }
  7916. else {
  7917. int8 len = strlen(sep->arg[4]);
  7918. memcpy(ptr2, (uchar*)&len, 1);
  7919. ptr2 += 1;
  7920. memcpy(ptr2, sep->arg[4], len);
  7921. }
  7922. }
  7923. DumpPacket(app);
  7924. client->QueuePacket(app);
  7925. }
  7926. else if (atoi(sep->arg[0]) == 10) {
  7927. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  7928. if (packet2) {
  7929. packet2->setArrayLengthByName("num_quests", 1);
  7930. packet2->setArrayDataByName("active", 1);
  7931. packet2->setArrayDataByName("name", "Archetype Selection");
  7932. packet2->setArrayDataByName("quest_type", "Hallmark");
  7933. packet2->setArrayDataByName("quest_zone", "Hallmark");
  7934. packet2->setArrayDataByName("journal_updated", 1);
  7935. packet2->setArrayDataByName("quest_id", 5);
  7936. packet2->setArrayDataByName("day", 19);
  7937. packet2->setArrayDataByName("month", 6);
  7938. packet2->setArrayDataByName("year", 20);
  7939. packet2->setArrayDataByName("level", 2);
  7940. packet2->setArrayDataByName("encounter_level", 4);
  7941. packet2->setArrayDataByName("difficulty", 3);
  7942. packet2->setArrayDataByName("visible", 1);
  7943. packet2->setDataByName("visible_quest_id", 5);
  7944. packet2->setDataByName("player_crc", 2900677088);
  7945. packet2->setDataByName("player_name", "LethalEncounter");
  7946. EQ2Packet* app = packet2->serialize();
  7947. if (sep->IsSet(2)) {
  7948. int8 offset = atoi(sep->arg[1]);
  7949. uchar* ptr2 = app->pBuffer;
  7950. ptr2 += offset;
  7951. if (sep->IsNumber(2)) {
  7952. int32 value1 = atol(sep->arg[2]);
  7953. if (value1 > 0xFFFF)
  7954. memcpy(ptr2, (uchar*)&value1, 4);
  7955. else if (value1 > 0xFF)
  7956. memcpy(ptr2, (uchar*)&value1, 2);
  7957. else
  7958. memcpy(ptr2, (uchar*)&value1, 1);
  7959. }
  7960. else {
  7961. int8 len = strlen(sep->arg[2]);
  7962. memcpy(ptr2, (uchar*)&len, 1);
  7963. ptr2 += 1;
  7964. memcpy(ptr2, sep->arg[2], len);
  7965. }
  7966. }
  7967. DumpPacket(app);
  7968. client->QueuePacket(app);
  7969. safe_delete(packet2);
  7970. }
  7971. }
  7972. else if (atoi(sep->arg[0]) == 11) {
  7973. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  7974. if (packet2) {
  7975. packet2->setDataByName("quest_id", 5);
  7976. packet2->setDataByName("player_crc", 2900677088);
  7977. packet2->setDataByName("name", "Archetype Selection");
  7978. packet2->setDataByName("description", "I have reported my profession to Garven Tralk");
  7979. packet2->setDataByName("type", "Hallmark");
  7980. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  7981. packet2->setDataByName("day", 19);
  7982. packet2->setDataByName("month", 6);
  7983. packet2->setDataByName("year", 20);
  7984. packet2->setDataByName("level", 2);
  7985. packet2->setDataByName("encounter_level", 4);
  7986. packet2->setDataByName("difficulty", 3);
  7987. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  7988. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  7989. packet2->setDataByName("timer_duration", 300);
  7990. packet2->setDataByName("timer_running", 1);
  7991. packet2->setArrayLengthByName("task_groups_completed", 0);
  7992. packet2->setArrayLengthByName("num_task_groups", 1);
  7993. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  7994. packet2->setSubArrayLengthByName("num_tasks", 1);
  7995. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  7996. packet2->setSubArrayLengthByName("num_updates", 1);
  7997. packet2->setSubArrayDataByName("update_currentval", 0);
  7998. packet2->setSubArrayDataByName("update_maxval", 1);
  7999. packet2->setSubArrayDataByName("icon", 11);
  8000. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8001. packet2->setDataByName("journal_updated", 1);
  8002. EQ2Packet* app = packet2->serialize();
  8003. if (sep->IsSet(2)) {
  8004. int16 offset = atoi(sep->arg[1]);
  8005. uchar* ptr2 = app->pBuffer;
  8006. ptr2 += offset;
  8007. if (sep->IsNumber(2)) {
  8008. int32 value1 = atol(sep->arg[2]);
  8009. if (value1 > 0xFFFF)
  8010. memcpy(ptr2, (uchar*)&value1, 4);
  8011. else if (value1 > 0xFF)
  8012. memcpy(ptr2, (uchar*)&value1, 2);
  8013. else
  8014. memcpy(ptr2, (uchar*)&value1, 1);
  8015. }
  8016. else {
  8017. int16 len = strlen(sep->arg[2]);
  8018. memcpy(ptr2, (uchar*)&len, 2);
  8019. ptr2 += 2;
  8020. memcpy(ptr2, sep->arg[2], len);
  8021. }
  8022. }
  8023. DumpPacket(app);
  8024. client->QueuePacket(app);
  8025. safe_delete(packet2);
  8026. }
  8027. }
  8028. else if (atoi(sep->arg[0]) == 12) {
  8029. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8030. if (packet2) {
  8031. packet2->setDataByName("quest_id", 5);
  8032. packet2->setDataByName("player_crc", 2900677088);
  8033. packet2->setDataByName("name", "Archetype Selection");
  8034. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  8035. packet2->setDataByName("type", "Hallmark");
  8036. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8037. packet2->setDataByName("day", 19);
  8038. packet2->setDataByName("month", 6);
  8039. packet2->setDataByName("year", 20);
  8040. packet2->setDataByName("level", 2);
  8041. packet2->setDataByName("encounter_level", 4);
  8042. packet2->setDataByName("difficulty", 3);
  8043. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8044. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8045. packet2->setDataByName("timer_duration", 300);
  8046. packet2->setDataByName("timer_running", 1);
  8047. packet2->setArrayLengthByName("task_groups_completed", 0);
  8048. packet2->setArrayLengthByName("num_task_groups", 1);
  8049. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8050. packet2->setSubArrayLengthByName("num_tasks", 1);
  8051. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8052. packet2->setSubArrayLengthByName("num_updates", 1);
  8053. packet2->setSubArrayDataByName("update_currentval", 0);
  8054. packet2->setSubArrayDataByName("update_maxval", 1);
  8055. packet2->setSubArrayDataByName("icon", 11);
  8056. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8057. packet2->setDataByName("journal_updated", 1);
  8058. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8059. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8060. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  8061. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8062. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8063. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8064. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  8065. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  8066. Item* item = master_item_list.GetItem(152755);
  8067. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8068. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8069. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  8070. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  8071. packet2->setSubstructDataByName("item", "icon", 0xe7);
  8072. packet2->setSubstructDataByName("item", "tier", 4);
  8073. packet2->setSubstructDataByName("item", "flags", 0x60);
  8074. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  8075. packet2->setSubstructDataByName("item", "stat_type", 1);
  8076. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  8077. packet2->setSubstructDataByName("item", "value", 3);
  8078. packet2->setSubstructDataByName("item", "condition", 100);
  8079. packet2->setSubstructDataByName("item", "weight", 1);
  8080. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  8081. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  8082. packet2->setSubstructDataByName("item", "skill_min", 1);
  8083. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  8084. packet2->setSubstructDataByName("item", "adventure_class", 1);
  8085. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  8086. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  8087. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  8088. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  8089. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  8090. packet2->setSubstructDataByName("item", "level", 0x1e);
  8091. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  8092. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  8093. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  8094. //packet2->PrintPacket();
  8095. EQ2Packet* app = packet2->serialize();
  8096. if (sep->IsSet(2)) {
  8097. int16 offset = atoi(sep->arg[1]);
  8098. uchar* ptr2 = app->pBuffer;
  8099. ptr2 += offset;
  8100. if (sep->IsNumber(2)) {
  8101. int32 value1 = atol(sep->arg[2]);
  8102. if (value1 > 0xFFFF)
  8103. memcpy(ptr2, (uchar*)&value1, 4);
  8104. else if (value1 > 0xFF)
  8105. memcpy(ptr2, (uchar*)&value1, 2);
  8106. else
  8107. memcpy(ptr2, (uchar*)&value1, 1);
  8108. }
  8109. else {
  8110. int16 len = strlen(sep->arg[2]);
  8111. memcpy(ptr2, (uchar*)&len, 2);
  8112. ptr2 += 2;
  8113. memcpy(ptr2, sep->arg[2], len);
  8114. }
  8115. }
  8116. DumpPacket(app);
  8117. client->QueuePacket(app);
  8118. safe_delete(packet2);
  8119. }
  8120. }
  8121. else if (atoi(sep->arg[0]) == 13) {
  8122. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  8123. if (packet2 && sep->IsSet(7)) {
  8124. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  8125. char blah[128];
  8126. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  8127. packet2->setDataByName("text", blah);
  8128. packet2->setDataByName("message_type", sep->arg[3]);
  8129. packet2->setDataByName("size", atof(sep->arg[4]));
  8130. packet2->setDataByName("red", atoi(sep->arg[5]));
  8131. packet2->setDataByName("green", atoi(sep->arg[6]));
  8132. packet2->setDataByName("blue", atoi(sep->arg[7]));
  8133. EQ2Packet* app = packet2->serialize();
  8134. DumpPacket(app);
  8135. client->QueuePacket(app);
  8136. safe_delete(packet2);
  8137. }
  8138. }
  8139. else if (atoi(sep->arg[0]) == 14) {
  8140. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  8141. if (packet2 && sep->IsSet(3)) {
  8142. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  8143. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  8144. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  8145. packet2->setDataByName("text", "Welcome to Norrath, the world of EverQuest II. Left click on the help button at any time for more detailed help and information.");
  8146. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  8147. packet2->setArrayLengthByName("num_goals", 1);
  8148. //packet2->setArrayDataByName("goal_text", )
  8149. packet2->setSubArrayLengthByName("num_tasks", 1);
  8150. packet2->setSubArrayDataByName("task_text", "continue");
  8151. packet2->setDataByName("complete_sound", "click");
  8152. packet2->setDataByName("signal", "introduction");
  8153. packet2->setDataByName("voice_key1", 0xcda65173);
  8154. packet2->setDataByName("voice_key2", 0x984bfc6d);
  8155. EQ2Packet* app = packet2->serialize();
  8156. DumpPacket(app);
  8157. client->QueuePacket(app);
  8158. safe_delete(packet2);
  8159. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  8160. packet2->setDataByName("window", "MainHUD.StartMenu");
  8161. packet2->setDataByName("show", 1);
  8162. app = packet2->serialize();
  8163. DumpPacket(app);
  8164. client->QueuePacket(app);
  8165. safe_delete(packet2);
  8166. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  8167. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  8168. packet2->setDataByName("flash_seconds", 10);
  8169. app = packet2->serialize();
  8170. DumpPacket(app);
  8171. client->QueuePacket(app);
  8172. safe_delete(packet2);
  8173. }
  8174. }
  8175. else if (atoi(sep->arg[0]) == 15) {
  8176. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8177. if (packet2) {
  8178. packet2->setArrayLengthByName("loot_count", 1);
  8179. packet2->setArrayDataByName("name", "Test");
  8180. packet2->setArrayDataByName("item_id", 1234);
  8181. packet2->setArrayDataByName("count", 1);
  8182. packet2->setArrayDataByName("icon", 258);
  8183. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  8184. Spawn* spawn = client->GetPlayer()->GetTarget();
  8185. if (spawn)
  8186. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8187. packet2->setDataByName("unknown3", 1);
  8188. packet2->setDataByName("unknown4", 1);
  8189. packet2->setDataByName("unknown5", 60);
  8190. EQ2Packet* app = packet2->serialize();
  8191. DumpPacket(app);
  8192. client->QueuePacket(app);
  8193. safe_delete(packet2);
  8194. }
  8195. }
  8196. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  8197. char blah[32];
  8198. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  8199. client->SimpleMessage(atoi(sep->arg[1]), blah);
  8200. }
  8201. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  8202. if (sep->IsSet(2)) {
  8203. int16 offset = atoi(sep->arg[1]);
  8204. if (sep->IsNumber(2)) {
  8205. int32 value1 = atol(sep->arg[2]);
  8206. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  8207. cout << "Sent" << endl;
  8208. }
  8209. }
  8210. }
  8211. else if (atoi(sep->arg[0]) == 18) {
  8212. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  8213. if (packet2) {
  8214. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8215. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8216. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8217. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8218. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8219. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  8220. Item* item = new Item(master_item_list.GetItem(36212));
  8221. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8222. item->stack_count = 20;
  8223. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8224. safe_delete(item);
  8225. item = new Item(master_item_list.GetItem(36685));
  8226. item->stack_count = 20;
  8227. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8228. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  8229. safe_delete(item);
  8230. item = master_item_list.GetItem(1414);
  8231. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8232. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  8233. item = master_item_list.GetItem(75057);
  8234. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8235. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  8236. EQ2Packet* app = packet2->serialize();
  8237. if (sep->IsSet(2)) {
  8238. int16 offset = atoi(sep->arg[1]);
  8239. uchar* ptr2 = app->pBuffer;
  8240. ptr2 += offset;
  8241. if (sep->IsNumber(2)) {
  8242. int32 value1 = atol(sep->arg[2]);
  8243. if (value1 > 0xFFFF)
  8244. memcpy(ptr2, (uchar*)&value1, 4);
  8245. else if (value1 > 0xFF)
  8246. memcpy(ptr2, (uchar*)&value1, 2);
  8247. else
  8248. memcpy(ptr2, (uchar*)&value1, 1);
  8249. }
  8250. else {
  8251. int16 len = strlen(sep->arg[2]);
  8252. memcpy(ptr2, (uchar*)&len, 2);
  8253. ptr2 += 2;
  8254. memcpy(ptr2, sep->arg[2], len);
  8255. }
  8256. }
  8257. DumpPacket(app);
  8258. client->QueuePacket(app);
  8259. safe_delete(packet2);
  8260. }
  8261. }
  8262. else if (atoi(sep->arg[0]) == 19) {
  8263. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8264. Spawn* spawn = client->GetPlayer()->GetTarget();
  8265. if (packet2 && spawn) {
  8266. Item* item = master_item_list.GetItem(130053);
  8267. packet2->setArrayLengthByName("loot_count", 1);
  8268. packet2->setArrayDataByName("loot_id", item->details.item_id);
  8269. packet2->setArrayDataByName("unknown2", 1);
  8270. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  8271. packet2->setDataByName("display", 1);
  8272. packet2->setDataByName("unknown2b", 1);
  8273. packet2->setDataByName("unknown3", 0x3c);
  8274. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8275. packet2->PrintPacket();
  8276. EQ2Packet* app = packet2->serialize();
  8277. if (sep->IsSet(2)) {
  8278. int16 offset = atoi(sep->arg[1]);
  8279. int16 offset2 = 0;
  8280. int32 value1 = 0;
  8281. if (sep->IsSet(3)) {
  8282. offset2 = atoi(sep->arg[2]);
  8283. value1 = atol(sep->arg[3]);
  8284. }
  8285. else
  8286. value1 = atol(sep->arg[2]);
  8287. int16 offset3 = 0;
  8288. int16 offset4 = 0;
  8289. int32 value2 = 0;
  8290. if (sep->IsSet(6)) {
  8291. offset3 = atoi(sep->arg[4]);
  8292. offset4 = atoi(sep->arg[5]);
  8293. value2 = atol(sep->arg[6]);
  8294. }
  8295. offset--;
  8296. if (offset2 > 0 && offset2 >= offset) {
  8297. offset2--;
  8298. uchar* ptr2 = app->pBuffer;
  8299. ptr2 += offset;
  8300. for (int i = offset; i <= offset2; i++) {
  8301. if (value1 > 0xFFFF) {
  8302. memcpy(ptr2, (uchar*)&value1, 4);
  8303. i += 3;
  8304. ptr2 += 3;
  8305. }
  8306. else if (value1 > 0xFF) {
  8307. memcpy(ptr2, (uchar*)&value1, 2);
  8308. i++;
  8309. ptr2++;
  8310. }
  8311. else
  8312. memcpy(ptr2, (uchar*)&value1, 1);
  8313. ptr2++;
  8314. }
  8315. }
  8316. if (offset4 > 0 && offset4 >= offset3) {
  8317. offset3--;
  8318. offset4--;
  8319. uchar* ptr2 = app->pBuffer;
  8320. ptr2 += offset3;
  8321. for (int i = offset3; i <= offset4; i++) {
  8322. if (value2 > 0xFFFF) {
  8323. memcpy(ptr2, (uchar*)&value2, 4);
  8324. i += 3;
  8325. ptr2 += 3;
  8326. }
  8327. else if (value2 > 0xFF) {
  8328. memcpy(ptr2, (uchar*)&value2, 2);
  8329. i++;
  8330. ptr2++;
  8331. }
  8332. else
  8333. memcpy(ptr2, (uchar*)&value2, 1);
  8334. ptr2++;
  8335. }
  8336. }
  8337. }
  8338. DumpPacket(app);
  8339. client->QueuePacket(app);
  8340. safe_delete(packet2);
  8341. }
  8342. }
  8343. else if (atoi(sep->arg[0]) == 21) {
  8344. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8345. if (packet2) {
  8346. packet2->setDataByName("unknown0", 255);
  8347. packet2->setDataByName("reward", "New Quest");
  8348. packet2->setDataByName("title", "Title");
  8349. packet2->setDataByName("description", "description");
  8350. packet2->setDataByName("quest_difficulty", 3);
  8351. packet2->setDataByName("unknown1", 5);
  8352. packet2->setDataByName("level", 3);
  8353. packet2->setDataByName("coin", 150);
  8354. packet2->setDataByName("status_points", 5);
  8355. packet2->setDataByName("exp_bonus", 10);
  8356. packet2->setArrayLengthByName("num_rewards", 1);
  8357. Item* item = new Item(master_item_list.GetItem(36212));
  8358. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8359. item->stack_count = 20;
  8360. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8361. safe_delete(item);
  8362. char accept[35] = { 0 };
  8363. char decline[35] = { 0 };
  8364. sprintf(accept, "q_accept_pending_quest %u", 0);
  8365. sprintf(decline, "q_deny_pending_quest %u", 0);
  8366. packet2->setDataByName("accept_command", accept);
  8367. packet2->setDataByName("decline_command", decline);
  8368. EQ2Packet* app = packet2->serialize();
  8369. if (sep->IsSet(2)) {
  8370. int16 offset = atoi(sep->arg[1]);
  8371. uchar* ptr2 = app->pBuffer;
  8372. ptr2 += offset;
  8373. if (sep->IsNumber(2)) {
  8374. int32 value1 = atol(sep->arg[2]);
  8375. if (value1 > 0xFFFF)
  8376. memcpy(ptr2, (uchar*)&value1, 4);
  8377. else if (value1 > 0xFF)
  8378. memcpy(ptr2, (uchar*)&value1, 2);
  8379. else
  8380. memcpy(ptr2, (uchar*)&value1, 1);
  8381. }
  8382. DumpPacket(app);
  8383. client->QueuePacket(app);
  8384. safe_delete(packet2);
  8385. }
  8386. }
  8387. }
  8388. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  8389. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8390. if (packet2) {
  8391. packet2->setDataByName("unknown0", 255);
  8392. packet2->setDataByName("reward", "New Quest");
  8393. packet2->setDataByName("title", "Title");
  8394. packet2->setDataByName("description", "description");
  8395. packet2->setDataByName("quest_difficulty", 3);
  8396. packet2->setDataByName("unknown1", 5);
  8397. packet2->setDataByName("level", 3);
  8398. packet2->setDataByName("coin", 150);
  8399. packet2->setDataByName("status_points", 5);
  8400. packet2->setDataByName("exp_bonus", 10);
  8401. packet2->setArrayLengthByName("num_rewards", 1);
  8402. Item* item = new Item(master_item_list.GetItem(36212));
  8403. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8404. item->stack_count = 20;
  8405. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8406. safe_delete(item);
  8407. char accept[35] = { 0 };
  8408. char decline[35] = { 0 };
  8409. sprintf(accept, "q_accept_pending_quest %u", 0);
  8410. sprintf(decline, "q_deny_pending_quest %u", 0);
  8411. packet2->setDataByName("accept_command", accept);
  8412. packet2->setDataByName("decline_command", decline);
  8413. EQ2Packet* app = packet2->serialize();
  8414. if (sep->IsSet(2)) {
  8415. int16 offset = atoi(sep->arg[1]);
  8416. uchar* ptr2 = app->pBuffer;
  8417. ptr2 += offset;
  8418. if (sep->IsNumber(2)) {
  8419. int32 value1 = atol(sep->arg[2]);
  8420. if (value1 > 0xFFFF)
  8421. memcpy(ptr2, (uchar*)&value1, 4);
  8422. else if (value1 > 0xFF)
  8423. memcpy(ptr2, (uchar*)&value1, 2);
  8424. else
  8425. memcpy(ptr2, (uchar*)&value1, 1);
  8426. }
  8427. else {
  8428. int8 len = strlen(sep->arg[2]);
  8429. memcpy(ptr2, (uchar*)&len, 1);
  8430. ptr2 += 1;
  8431. memcpy(ptr2, sep->arg[2], len);
  8432. }
  8433. }
  8434. DumpPacket(app);
  8435. client->QueuePacket(app);
  8436. safe_delete(packet2);
  8437. }
  8438. }
  8439. else if (atoi(sep->arg[0]) == 23) {
  8440. if (client->GetPlayer()->GetTarget()) {
  8441. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  8442. if (packet2) {
  8443. Spawn* target = client->GetPlayer()->GetTarget();
  8444. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8445. Item* item = new Item(master_item_list.GetItem(12565));
  8446. int8 i = 0;
  8447. packet2->setArrayLengthByName("num_items", 1);
  8448. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  8449. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  8450. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  8451. packet2->setArrayDataByName("icon", item->details.icon, i);
  8452. int8 tmp_level = 0;
  8453. if (item->generic_info.adventure_default_level > 0)
  8454. tmp_level = item->generic_info.adventure_default_level;
  8455. else
  8456. tmp_level = item->generic_info.tradeskill_default_level;
  8457. packet2->setArrayDataByName("level", tmp_level, i);
  8458. packet2->setArrayDataByName("tier", item->details.tier, i);
  8459. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  8460. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  8461. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  8462. item_difficulty = ARROW_COLOR_WHITE;
  8463. item_difficulty -= 6;
  8464. if (item_difficulty < 0)
  8465. item_difficulty *= -1;
  8466. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  8467. packet2->setArrayDataByName("quantity", 2, i);
  8468. packet2->setArrayDataByName("unknown5", 255, i);
  8469. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  8470. packet2->setArrayDataByName("description", item->description.c_str(), i);
  8471. packet2->setDataByName("type", 2);
  8472. EQ2Packet* app = packet2->serialize();
  8473. if (sep->IsSet(2)) {
  8474. int16 offset = atoi(sep->arg[1]);
  8475. uchar* ptr2 = app->pBuffer;
  8476. ptr2 += offset;
  8477. if (sep->IsNumber(2)) {
  8478. int32 value1 = atol(sep->arg[2]);
  8479. if (value1 > 0xFFFF)
  8480. memcpy(ptr2, (uchar*)&value1, 4);
  8481. else if (value1 > 0xFF)
  8482. memcpy(ptr2, (uchar*)&value1, 2);
  8483. else
  8484. memcpy(ptr2, (uchar*)&value1, 1);
  8485. }
  8486. else {
  8487. int8 len = strlen(sep->arg[2]);
  8488. memcpy(ptr2, (uchar*)&len, 1);
  8489. ptr2 += 1;
  8490. memcpy(ptr2, sep->arg[2], len);
  8491. }
  8492. }
  8493. DumpPacket(app);
  8494. client->QueuePacket(app);
  8495. safe_delete(packet2);
  8496. }
  8497. }
  8498. }
  8499. else if (atoi(sep->arg[0]) == 24) {
  8500. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  8501. if (packet2) {
  8502. if (sep->IsSet(2)) {
  8503. packet2->setDataByName("event_name", sep->arg[1]);
  8504. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  8505. EQ2Packet* app = packet2->serialize();
  8506. DumpPacket(app);
  8507. client->QueuePacket(app);
  8508. safe_delete(packet2);
  8509. }
  8510. }
  8511. }
  8512. else if (atoi(sep->arg[0]) == 25) {
  8513. if (sep->IsSet(1)) {
  8514. Widget* new_spawn = new Widget();
  8515. int32 id = atoul(sep->arg[1]);
  8516. new_spawn->SetWidgetID(id);
  8517. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  8518. client->QueuePacket(ret);
  8519. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  8520. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  8521. if (packet2) {
  8522. packet2->setDataByName("spawn_index", index);
  8523. packet2->setDataByName("delete", 1);
  8524. EQ2Packet* app = packet2->serialize();
  8525. client->QueuePacket(app);
  8526. safe_delete(packet2);
  8527. }
  8528. }
  8529. }
  8530. else if (atoi(sep->arg[0]) == 26) {
  8531. if (sep->IsSet(4)) {
  8532. Widget* new_spawn = new Widget();
  8533. int32 id = atoul(sep->arg[1]);
  8534. new_spawn->SetWidgetID(id);
  8535. float x = atof(sep->arg[2]);
  8536. float y = atof(sep->arg[3]);
  8537. float z = atof(sep->arg[4]);
  8538. new_spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8539. new_spawn->SetWidgetX(x);
  8540. new_spawn->SetWidgetY(y);
  8541. new_spawn->SetWidgetZ(z);
  8542. new_spawn->SetX(x);
  8543. new_spawn->SetY(y);
  8544. new_spawn->SetZ(z);
  8545. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  8546. client->QueuePacket(ret);
  8547. }
  8548. }
  8549. else if (atoi(sep->arg[0]) == 27) {
  8550. Spawn* target = client->GetPlayer()->GetTarget();
  8551. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  8552. if (packet2 && target && sep->IsSet(2)) {
  8553. packet2->setSubstructDataByName("header", "defender", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8554. packet2->setSubstructDataByName("header", "defender_proxy", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8555. packet2->setSubstructDataByName("header", "attacker", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  8556. packet2->setArrayLengthByName("num_dmg", 1);
  8557. packet2->setArrayDataByName("damage_type", atoi(sep->arg[1]));
  8558. packet2->setArrayDataByName("damage", atoi(sep->arg[2]));
  8559. packet2->setDataByName("spell", 1);
  8560. packet2->setDataByName("spell_name", "Testing");
  8561. EQ2Packet* app = packet2->serialize();
  8562. if (sep->IsSet(4)) {
  8563. int16 offset = atoi(sep->arg[3]);
  8564. uchar* ptr2 = app->pBuffer;
  8565. ptr2 += offset;
  8566. if (sep->IsNumber(4)) {
  8567. int32 value1 = atol(sep->arg[4]);
  8568. if (value1 > 0xFFFF)
  8569. memcpy(ptr2, (uchar*)&value1, 4);
  8570. else if (value1 > 0xFF)
  8571. memcpy(ptr2, (uchar*)&value1, 2);
  8572. else
  8573. memcpy(ptr2, (uchar*)&value1, 1);
  8574. }
  8575. else {
  8576. int8 len = strlen(sep->arg[4]);
  8577. memcpy(ptr2, (uchar*)&len, 1);
  8578. ptr2 += 1;
  8579. memcpy(ptr2, sep->arg[4], len);
  8580. }
  8581. }
  8582. if (sep->IsSet(6)) {
  8583. int16 offset = atoi(sep->arg[5]);
  8584. uchar* ptr2 = app->pBuffer;
  8585. ptr2 += offset;
  8586. if (sep->IsNumber(6)) {
  8587. int32 value1 = atol(sep->arg[6]);
  8588. if (value1 > 0xFFFF)
  8589. memcpy(ptr2, (uchar*)&value1, 4);
  8590. else if (value1 > 0xFF)
  8591. memcpy(ptr2, (uchar*)&value1, 2);
  8592. else
  8593. memcpy(ptr2, (uchar*)&value1, 1);
  8594. }
  8595. else {
  8596. int8 len = strlen(sep->arg[6]);
  8597. memcpy(ptr2, (uchar*)&len, 1);
  8598. ptr2 += 1;
  8599. memcpy(ptr2, sep->arg[6], len);
  8600. }
  8601. }
  8602. DumpPacket(app);
  8603. client->QueuePacket(app);
  8604. safe_delete(packet2);
  8605. }
  8606. }
  8607. }
  8608. else {
  8609. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  8610. if (packet2) {
  8611. packet2->setSubstructDataByName("info_header", "show_name", 1);
  8612. packet2->setSubstructDataByName("info_header", "unknown", 7);
  8613. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  8614. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  8615. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  8616. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  8617. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  8618. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  8619. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  8620. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  8621. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  8622. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  8623. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  8624. packet2->setSubstructDataByName("info_header", "packettype", 3);
  8625. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  8626. packet2->setSubstructDataByName("spell_info", "level", 19);
  8627. packet2->setSubstructDataByName("spell_info", "tier", 1);
  8628. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  8629. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  8630. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  8631. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  8632. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  8633. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  8634. packet2->setSubstructDataByName("spell_info", "recast", 280);
  8635. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  8636. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  8637. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  8638. packet2->setSubstructDataByName("spell_info", "quality", 3);
  8639. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  8640. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  8641. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  8642. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  8643. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  8644. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  8645. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  8646. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  8647. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  8648. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  8649. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  8650. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  8651. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  8652. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  8653. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  8654. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  8655. packet2->setArrayDataByName("reagent", "Alcohol");
  8656. packet2->setArrayDataByName("consumed", "123");
  8657. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  8658. packet2->setSubstructDataByName("spell_info", "id", 8308);
  8659. packet2->setSubstructDataByName("spell_info", "icon", 303);
  8660. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  8661. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  8662. packet2->setSubstructDataByName("spell_info", "type", 2);
  8663. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  8664. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  8665. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  8666. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  8667. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  8668. EQ2Packet* outapp = packet2->serialize();
  8669. DumpPacket(outapp);
  8670. client->QueuePacket(outapp);
  8671. safe_delete(packet2);
  8672. }
  8673. }
  8674. return;
  8675. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  8676. if (!p) return;
  8677. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8678. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  8679. //}
  8680. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8681. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  8682. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  8683. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  8684. if (packet) {
  8685. client->QueuePacket(packet->serialize());
  8686. safe_delete(packet);
  8687. }
  8688. }*/
  8689. /*if (client->GetCurrentZone()->Grid != nullptr) {
  8690. int32 numFaces = 0;
  8691. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  8692. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  8693. map<int32, vector<Face*> >::iterator itr;
  8694. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  8695. numFaces += (*itr).second.size();
  8696. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  8697. }*/
  8698. //uchar blah[] = {
  8699. // 1208 - OP_EQUpdateStoreCmd
  8700. // /*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
  8701. // /*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
  8702. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  8703. // /*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
  8704. /*};
  8705. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8706. int8 val = 0;
  8707. int16 pos = 0;
  8708. int idx = 0;
  8709. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  8710. pos = atoi(sep2->arg[idx]);
  8711. val = atoi(sep2->arg[idx+1]);
  8712. memset(blah+pos, val, 1);
  8713. idx+=2;
  8714. }
  8715. DumpPacket(blah, sizeof(blah));
  8716. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  8717. if (client->GetPlayer()->GetTarget()) {
  8718. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  8719. if (packet) {
  8720. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8721. packet->setDataByName("size", 0);
  8722. packet->setDataByName("unknown2", 0);
  8723. EQ2Packet* app = packet->serialize();
  8724. client->QueuePacket(app);
  8725. safe_delete(packet);
  8726. }
  8727. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  8728. if (set_pov) {
  8729. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8730. EQ2Packet* app_pov = set_pov->serialize();
  8731. client->QueuePacket(app_pov);
  8732. safe_delete(set_pov);
  8733. }
  8734. }
  8735. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8736. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  8737. if (packet) {
  8738. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  8739. packet->setDataByName("Type", atoi(sep2->arg[0]));
  8740. else
  8741. packet->setDataByName("Type", 2);
  8742. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  8743. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  8744. else
  8745. packet->setDataByName("race_id", 0);
  8746. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  8747. packet->setDataByName("gender", atoi(sep2->arg[2]));
  8748. else
  8749. packet->setDataByName("gender", 2);
  8750. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  8751. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  8752. else
  8753. packet->setDataByName("unknown", 0, 0);
  8754. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  8755. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  8756. else
  8757. packet->setDataByName("unknown", 0, 1);
  8758. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  8759. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  8760. else
  8761. packet->setDataByName("unknown", 0, 2);
  8762. client->QueuePacket(packet->serialize());
  8763. }
  8764. safe_delete(packet);
  8765. safe_delete(sep2);
  8766. }
  8767. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  8768. const char *channel_name;
  8769. if (sep == NULL || !sep->IsSet(0)) {
  8770. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  8771. PrintSep(sep);
  8772. return;
  8773. }
  8774. channel_name = sep->arg[0];
  8775. if (!chat.IsInChannel(client, channel_name))
  8776. client->Message(CHANNEL_COLOR_WHITE, "Unable to leave '%s': You are not in the channel.", channel_name);
  8777. else if (!chat.LeaveChannel(client, channel_name))
  8778. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  8779. }
  8780. /*
  8781. Function:
  8782. Purpose :
  8783. Params :
  8784. Dev :
  8785. Example :
  8786. */
  8787. void Commands::Command_WeaponStats(Client* client)
  8788. {
  8789. Player* player = client->GetPlayer();
  8790. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  8791. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  8792. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  8793. client->SimpleMessage(0, "Primary:");
  8794. if (primary) {
  8795. client->Message(0, "Name: %s", primary->name.c_str());
  8796. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  8797. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8798. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  8799. client->Message(0, "Proc Percent: %d%%", 0);
  8800. client->Message(0, "Procs Per Minute: %d", 0);
  8801. }
  8802. else {
  8803. client->SimpleMessage(0, "Name: fist");
  8804. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8805. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8806. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  8807. client->Message(0, "Proc Percent: %d%%", 0);
  8808. client->Message(0, "Procs Per Minute: %d", 0);
  8809. }
  8810. client->SimpleMessage(0, " ");
  8811. client->SimpleMessage(0, " ");
  8812. if (secondary) {
  8813. client->SimpleMessage(0, "Secondary:");
  8814. client->Message(0, "Name: %s", secondary->name.c_str());
  8815. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  8816. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  8817. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  8818. client->Message(0, "Proc Percent: %d%%", 0);
  8819. client->Message(0, "Procs Per Minute: %d", 0);
  8820. client->SimpleMessage(0, " ");
  8821. client->SimpleMessage(0, " ");
  8822. }
  8823. client->SimpleMessage(0, "Ranged:");
  8824. if (ranged) {
  8825. client->Message(0, "Name: %s", ranged->name.c_str());
  8826. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  8827. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  8828. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  8829. client->Message(0, "Proc Percent: %d%%", 0);
  8830. client->Message(0, "Procs Per Minute: %d", 0);
  8831. }
  8832. else
  8833. client->SimpleMessage(0, "None");
  8834. }
  8835. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  8836. const char *channel_name;
  8837. if (sep == NULL || !sep->IsSet(0)) {
  8838. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  8839. return;
  8840. }
  8841. channel_name = sep->arg[0];
  8842. if (!chat.ChannelExists(channel_name))
  8843. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  8844. else
  8845. chat.SendChannelUserList(client, channel_name);
  8846. }
  8847. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  8848. {
  8849. ZoneServer* zone = 0;
  8850. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  8851. if (zone_id > 0)
  8852. {
  8853. zone = zone_list.Get(zone_id, false);
  8854. if (zone)
  8855. {
  8856. zone->SetSafeX(client->GetPlayer()->GetX());
  8857. zone->SetSafeY(client->GetPlayer()->GetY());
  8858. zone->SetSafeZ(client->GetPlayer()->GetZ());
  8859. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  8860. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  8861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  8862. else
  8863. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  8864. }
  8865. }
  8866. }
  8867. /*
  8868. Function:
  8869. Purpose :
  8870. Params :
  8871. Dev :
  8872. Example :
  8873. */
  8874. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  8875. {
  8876. ZoneInfo* zone_info = new ZoneInfo;
  8877. if (sep && sep->arg[0])
  8878. {
  8879. if (sep->IsNumber(0))
  8880. zone_info->id = atoi(sep->arg[0]);
  8881. else
  8882. zone_info->id = database.GetZoneID(sep->arg[0]);
  8883. if (zone_info->id > 0)
  8884. {
  8885. database.LoadZoneInfo(zone_info);
  8886. 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);
  8887. 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);
  8888. 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);
  8889. 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);
  8890. 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);
  8891. 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);
  8892. 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);
  8893. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  8894. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  8895. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  8896. }
  8897. else
  8898. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  8899. }
  8900. else
  8901. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  8902. safe_delete(zone_info);
  8903. }
  8904. /*
  8905. Function:
  8906. Purpose :
  8907. Params :
  8908. Dev :
  8909. Example :
  8910. */
  8911. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  8912. {
  8913. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  8914. {
  8915. ZoneServer* zone = 0;
  8916. int32 zone_id = 0;
  8917. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  8918. {
  8919. zone_id = atoi(sep->arg[0]);
  8920. zone = zone_list.Get(atoi(sep->arg[0]), false);
  8921. }
  8922. else
  8923. {
  8924. zone_id = database.GetZoneID(sep->arg[0]);
  8925. if (zone_id > 0)
  8926. zone = zone_list.Get(sep->arg[0], false);
  8927. }
  8928. if (zone_id > 0)
  8929. {
  8930. if (zone_set_values.count(string(sep->arg[1])) > 0)
  8931. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  8932. else
  8933. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  8934. }
  8935. else
  8936. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  8937. }
  8938. else
  8939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  8940. }
  8941. void Commands::Command_Rain(Client* client, Seperator* sep) {
  8942. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8943. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  8944. return;
  8945. }
  8946. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  8947. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  8948. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  8949. }
  8950. void Commands::Command_Wind(Client* client, Seperator* sep) {
  8951. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8952. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  8953. return;
  8954. }
  8955. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  8956. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  8957. }
  8958. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  8959. Spawn* spawn = client->GetPlayer()->GetTarget();
  8960. if(spawn) {
  8961. client->SetMerchantTransaction(spawn);
  8962. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  8963. client->SendHailCommand(spawn);
  8964. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  8965. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  8966. client->SendBuyMerchantList(sell);
  8967. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  8968. client->SendSellMerchantList(sell);
  8969. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  8970. client->SendBuyBackList(sell);
  8971. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  8972. if (packet) {
  8973. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  8974. packet->setDataByName("type", 16);
  8975. EQ2Packet* outapp = packet->serialize();
  8976. if (outapp)
  8977. client->QueuePacket(outapp);
  8978. safe_delete(packet);
  8979. }
  8980. }
  8981. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  8982. client->SendRepairList();
  8983. }
  8984. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  8985. }
  8986. void Commands::Command_Weather(Client* client, Seperator* sep)
  8987. {
  8988. //PrintSep(sep, "Weather");
  8989. if( sep && sep->arg[0] )
  8990. {
  8991. ZoneServer* zsZone = client->GetCurrentZone();
  8992. const char* value = sep->arg[0];
  8993. // process single-param commands first
  8994. if( strncasecmp(value, "details", strlen(value)) == 0 )
  8995. {
  8996. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  8997. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  8998. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  8999. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  9000. }
  9001. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  9002. {
  9003. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9004. zsZone->ProcessWeather();
  9005. }
  9006. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  9007. {
  9008. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  9009. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  9010. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  9011. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  9012. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  9013. zsZone->SetWeatherPattern(1);
  9014. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  9015. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  9016. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  9017. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9018. zsZone->ProcessWeather();
  9019. }
  9020. // process commands with params
  9021. if( sep->arg[1] )
  9022. {
  9023. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  9024. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  9025. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  9026. zsZone->SetWeatherType(atoi(sep->arg[1]));
  9027. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  9028. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  9029. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  9030. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  9031. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  9032. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  9033. }
  9034. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  9035. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  9036. zsZone->SetRain(zsZone->GetCurrentWeather());
  9037. }
  9038. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  9039. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  9040. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  9041. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  9042. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9043. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  9044. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9045. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  9046. }
  9047. }
  9048. else
  9049. {
  9050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  9051. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  9052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  9053. return;
  9054. }
  9055. }
  9056. void Commands::Command_Select(Client* client, Seperator* sep) {
  9057. if (sep && sep->arg[1]) {
  9058. Spawn* spawn = client->GetPlayer()->GetTarget();
  9059. if (spawn && strlen(sep->arg[1]) > 0)
  9060. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  9061. }
  9062. }
  9063. /*
  9064. Function: Command_ConsumeFood()
  9065. Purpose : Consume Food/Drink and apply mods
  9066. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  9067. Dev : Zcoretri
  9068. Example : /consume_food 22
  9069. */
  9070. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  9071. if (sep && sep->arg[0] && sep->IsNumber(0))
  9072. {
  9073. Player* player = client->GetPlayer();
  9074. int8 slot = atoi(sep->arg[0]);
  9075. Item* item = player->GetEquipmentList()->GetItem(slot);
  9076. if(item) {
  9077. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  9078. if(item->GetItemScript() && lua_interface){
  9079. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  9080. if (slot == 22)
  9081. client->Message(CHANNEL_COLOR_WHITE, "You eat a %s.", item->name.c_str());
  9082. else
  9083. client->Message(CHANNEL_COLOR_WHITE, "You drink a %s.", item->name.c_str());
  9084. }
  9085. }
  9086. if (item->details.count > 1) {
  9087. item->details.count -= 1;
  9088. item->save_needed = true;
  9089. }
  9090. else {
  9091. player->GetEquipmentList()->RemoveItem(slot, true);
  9092. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  9093. }
  9094. client->GetPlayer()->SetCharSheetChanged(true);
  9095. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  9096. }
  9097. }
  9098. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  9099. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9100. if (atoi(sep->arg[0]) == 1) {
  9101. client->GetPlayer()->GetInfoStruct()->vision = 4;
  9102. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  9103. client->GetPlayer()->SetCharSheetChanged(true);
  9104. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  9105. }
  9106. else {
  9107. client->GetPlayer()->GetInfoStruct()->vision = 0;
  9108. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  9109. client->GetPlayer()->SetCharSheetChanged(true);
  9110. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  9111. }
  9112. }
  9113. else
  9114. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  9115. }
  9116. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  9117. {
  9118. if(sep)
  9119. {
  9120. string data;
  9121. if(sep->arg[0]){
  9122. data = string(sep->arg[0]);
  9123. }
  9124. for(int i=1;i<sep->GetMaxArgNum();i++){
  9125. if(sep->arg[i])
  9126. data.append(" ").append(sep->arg[i]);
  9127. }
  9128. const char* target_name = 0;
  9129. int32 spawn_id = 0;
  9130. if(client->GetPlayer()->GetTarget())
  9131. {
  9132. target_name = client->GetPlayer()->GetTarget()->GetName();
  9133. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9134. }
  9135. else
  9136. target_name = "N/A";
  9137. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  9138. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  9139. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  9140. else
  9141. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  9142. }
  9143. }
  9144. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  9145. PrintSep(sep, "Command_Attune_Inv");
  9146. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9147. // Get the item index from the first parameter
  9148. int16 index = atoi(sep->arg[0]);
  9149. // Check to see if this is a valid item index for the player, if not exit out of the function
  9150. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  9151. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  9152. return;
  9153. }
  9154. // Get the item
  9155. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  9156. if(item) {
  9157. // Valid item lets check to make sure this item is attunable, if not return out
  9158. if (!item->CheckFlag(ATTUNEABLE)) {
  9159. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  9160. return;
  9161. }
  9162. // Remove the attunable flag
  9163. item->generic_info.item_flags -= ATTUNEABLE;
  9164. // Set the attuned flag
  9165. item->generic_info.item_flags += ATTUNED;
  9166. // Flag this item for saving
  9167. item->save_needed = true;
  9168. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  9169. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  9170. EQ2Packet* outapp = 0;
  9171. for (int32 i=0;i<packets.size();i++) {
  9172. outapp = packets[i];
  9173. if(outapp)
  9174. client->QueuePacket(outapp);
  9175. }
  9176. }
  9177. }
  9178. }
  9179. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  9180. PrintSep(sep, "Command_Reset_Zone_Timer");
  9181. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9182. int32 db_id = atoul(sep->arg[0]);
  9183. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  9184. if (data) {
  9185. // TODO: add a check to timers to ensure it can be reset
  9186. // Delete the character from the instance
  9187. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  9188. data->instance_id = 0;
  9189. // Update the success time and set to 0 so the player can enter it again
  9190. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  9191. data->last_success_timestamp = 0;
  9192. }
  9193. }*/
  9194. }
  9195. void Commands::Command_Player(Client* client, Seperator* sep) {
  9196. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  9197. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  9198. }
  9199. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  9200. // /player coins add 10
  9201. // /player coins add plat 10
  9202. Player* player = client->GetPlayer();
  9203. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  9204. player = (Player*)player->GetTarget();
  9205. if (sep && sep->arg[0] && sep->arg[1]) {
  9206. const char* action = sep->arg[0];
  9207. int64 value = 0;
  9208. if (strncasecmp(action, "add", strlen(action)) == 0) {
  9209. if (sep->IsNumber(1)) {
  9210. value = atoi64(sep->arg[1]);
  9211. player->AddCoins(value);
  9212. if (client->GetPlayer() == player)
  9213. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9214. else {
  9215. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9216. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9217. }
  9218. return;
  9219. }
  9220. else if (sep->arg[2] && sep->IsNumber(2)) {
  9221. const char* type = sep->arg[1];
  9222. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  9223. value = atoi64(sep->arg[2]);
  9224. }
  9225. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  9226. value = atoi64(sep->arg[2]) * 100;
  9227. }
  9228. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  9229. value = atoi64(sep->arg[2]) * 10000;
  9230. }
  9231. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  9232. value = atoi64(sep->arg[2]) * 1000000;
  9233. }
  9234. player->AddCoins(value);
  9235. if (client->GetPlayer() == player)
  9236. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9237. else {
  9238. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9239. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9240. }
  9241. return;
  9242. }
  9243. }
  9244. }
  9245. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  9246. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  9247. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  9248. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  9249. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  9250. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  9251. }
  9252. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  9253. PrintSep(sep, "ACHIEVEMENT_ADD");
  9254. if (sep && sep->IsSet(0)) {
  9255. int32 spell_id = atoul(sep->arg[1]);
  9256. int8 spell_tier = 0;
  9257. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9258. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9259. // addspellbookentry here
  9260. if (spell_tier >= data->maxRank) {
  9261. return;
  9262. }
  9263. if (!spell_tier) {
  9264. spell_tier = 1;
  9265. }
  9266. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9267. {
  9268. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9269. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9270. client->GetPlayer()->UnlockSpell(spell);
  9271. client->SendSpellUpdate(spell);
  9272. }
  9273. else
  9274. {
  9275. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  9276. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9277. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9278. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9279. client->GetPlayer()->UnlockSpell(spell);
  9280. client->SendSpellUpdate(spell);
  9281. }
  9282. // cast spell here
  9283. if (!spell_tier)
  9284. spell_tier = 1;
  9285. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9286. if (spell) {
  9287. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9288. }
  9289. }
  9290. else {
  9291. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9292. }
  9293. master_aa_list.DisplayAA(client, 0, 0);
  9294. }
  9295. void Commands::Command_Editor(Client* client, Seperator* sep) {
  9296. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  9297. if (packet) {
  9298. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  9299. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  9300. char command[255];
  9301. url = "browser " + url;
  9302. int32 spawn_id = 0;
  9303. int32 zone_id = 0;
  9304. string type;
  9305. if (client->GetCurrentZone())
  9306. zone_id = client->GetCurrentZone()->GetZoneID();
  9307. if (client->GetPlayer()->GetTarget()) {
  9308. Spawn* target = client->GetPlayer()->GetTarget();
  9309. if (target->IsWidget())
  9310. type = "widgets";
  9311. else if (target->IsSign())
  9312. type = "signs";
  9313. else if (target->IsObject())
  9314. type = "objects";
  9315. else if (target->IsNPC())
  9316. type = "npcs";
  9317. else if (target->IsGroundSpawn())
  9318. type = "ground";
  9319. else
  9320. type = "spawn";
  9321. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9322. }
  9323. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  9324. packet->setDataByName("accept_command", command);
  9325. }
  9326. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  9327. char command[255];
  9328. url = "browser " + url;
  9329. if (client->GetPlayer()->GetTarget())
  9330. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  9331. packet->setDataByName("accept_command", command);
  9332. }
  9333. else {
  9334. string command = "browser " + url;
  9335. packet->setDataByName("accept_command", command.c_str());
  9336. }
  9337. packet->setDataByName("text", "Open the web editor?");
  9338. packet->setDataByName("accept_text", "Open");
  9339. packet->setDataByName("cancel_text", "Cancel");
  9340. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  9341. packet->setDataByName("unknown2", 50);
  9342. packet->setDataByName("unknown4", 1);
  9343. client->QueuePacket(packet->serialize());
  9344. safe_delete(packet);
  9345. }
  9346. }
  9347. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  9348. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9349. return;
  9350. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9351. if(client->GetCurrentRez()->active)
  9352. client->AcceptResurrection();
  9353. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9354. }
  9355. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  9356. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9357. return;
  9358. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9359. if(client->GetCurrentRez()->active)
  9360. client->GetCurrentRez()->should_delete = true;
  9361. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9362. }
  9363. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  9364. PrintSep(sep, "Switch_AA_Profile");
  9365. if (sep && sep->IsSet(0)) {
  9366. string type = sep->arg[0];
  9367. int8 newtemplate = atoul(sep->arg[1]);
  9368. master_aa_list.DisplayAA(client, newtemplate, 1);
  9369. }
  9370. }
  9371. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  9372. PrintSep(sep, "Get_AA_Xml");
  9373. if (sep && sep->IsSet(0)) {
  9374. string tabnum = sep->arg[0];
  9375. string spellid = sep->arg[1];
  9376. }
  9377. }
  9378. void Commands::Add_AA(Client* client, Seperator* sep) {
  9379. PrintSep(sep, "Add_AA");
  9380. if (sep && sep->IsSet(0)) {
  9381. int32 spell_id = atoul(sep->arg[1]);
  9382. int8 spell_tier = 0;
  9383. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9384. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9385. // addspellbookentry here
  9386. if (spell_tier >= data->maxRank) {
  9387. return;
  9388. }
  9389. if (!spell_tier) {
  9390. spell_tier = 1;
  9391. }
  9392. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9393. {
  9394. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9395. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9396. client->GetPlayer()->UnlockSpell(spell);
  9397. client->SendSpellUpdate(spell);
  9398. }
  9399. else
  9400. {
  9401. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  9402. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9403. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9404. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9405. client->GetPlayer()->UnlockSpell(spell);
  9406. client->SendSpellUpdate(spell);
  9407. }
  9408. // cast spell here
  9409. if (!spell_tier)
  9410. spell_tier = 1;
  9411. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9412. if (spell) {
  9413. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9414. }
  9415. }
  9416. else {
  9417. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9418. }
  9419. master_aa_list.DisplayAA(client, 0, 0);
  9420. }
  9421. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  9422. PrintSep(sep, "Commit_AA_Profile");
  9423. if (sep && sep->IsSet(0)) {
  9424. }
  9425. }
  9426. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  9427. PrintSep(sep, "Begin_AA_Profile");
  9428. if (sep && sep->IsSet(0)) {
  9429. master_aa_list.DisplayAA(client, 100, 2);
  9430. }
  9431. }
  9432. void Commands::Back_AA(Client* client, Seperator* sep) {
  9433. if (sep && sep->IsSet(0)) {
  9434. PrintSep(sep, "Back_AA");
  9435. }
  9436. }
  9437. void Commands::Remove_AA(Client* client, Seperator* sep) {
  9438. if (sep && sep->IsSet(0)) {
  9439. PrintSep(sep, "Remove_AA");
  9440. }
  9441. }
  9442. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  9443. MasterAAList master_aa_list;
  9444. PrintSep(sep, "Cancel_AA_Profile");
  9445. master_aa_list.DisplayAA(client, 0, 0);
  9446. }
  9447. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  9448. if (sep && sep->IsSet(0)) {
  9449. PrintSep(sep, "Save_AA_Profile");
  9450. }
  9451. }
  9452. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  9453. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  9454. if (!sep->IsNumber(0)) return;
  9455. int32 request_id = atoul(sep->arg[0]);
  9456. if (!sep->IsNumber(1)) return;
  9457. sint32 item_id = atoi(sep->arg[1]);
  9458. if (client->IsCurrentTransmuteID(request_id)) {
  9459. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  9460. }
  9461. else if (client->IsCurrentTransmuteID(item_id)) {
  9462. if (!sep->IsSet(2)) return;
  9463. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  9464. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  9465. }
  9466. }
  9467. }
  9468. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  9469. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  9470. }