Commands.cpp 365 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194
  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. bool delete_spawn = false;
  3591. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3592. if(atoi(sep->arg[0]) == 1)
  3593. delete_spawn = true;
  3594. }
  3595. if(delete_spawn)
  3596. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, false);
  3597. else
  3598. spawn->SetSpawnLocationID(0);
  3599. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3600. }
  3601. else
  3602. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3603. }
  3604. else
  3605. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3606. }
  3607. else{
  3608. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3609. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3610. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Optionally, you can supply a 1 after the command to despawn it as well. IE /spawn remove 1");
  3611. }
  3612. break;
  3613. }
  3614. case COMMAND_SPAWN_LIST:{
  3615. if(sep && sep->arg[0][0]){
  3616. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3617. vector<string>::iterator itr;
  3618. if(results){
  3619. for(itr=results->begin();itr!=results->end();itr++){
  3620. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3621. }
  3622. safe_delete(results);
  3623. }
  3624. else
  3625. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3626. }
  3627. else{
  3628. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3629. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3630. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3631. }
  3632. break;
  3633. }
  3634. case COMMAND_SPAWN_ADD:{
  3635. Spawn* spawn = cmdTarget;
  3636. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3637. if(spawn->GetSpawnLocationID() > 0){
  3638. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3639. break;
  3640. }
  3641. if(spawn->GetDatabaseID() == 0){
  3642. if(database.SaveSpawnInfo(spawn)) {
  3643. char spawn_type[32];
  3644. memset(spawn_type, 0, sizeof(spawn_type));
  3645. if (spawn->IsNPC())
  3646. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3647. else if (spawn->IsObject())
  3648. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3649. else if (spawn->IsSign())
  3650. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3651. else if (spawn->IsGroundSpawn())
  3652. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3653. else
  3654. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3655. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3656. }
  3657. else
  3658. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3659. }
  3660. int32 spawn_group_id = 0;
  3661. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3662. spawn_group_id = database.GetNextSpawnLocation();
  3663. else
  3664. spawn_group_id = atol(sep->arg[0]);
  3665. int8 percent = 100;
  3666. if(sep->arg[2] && sep->IsNumber(2))
  3667. percent = atoi(sep->arg[2]);
  3668. spawn->SetSpawnLocationID(spawn_group_id);
  3669. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3670. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3671. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3672. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3673. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3674. else
  3675. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3676. }
  3677. else{
  3678. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3679. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3680. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3681. }
  3682. break;
  3683. }
  3684. case COMMAND_SPAWN:{
  3685. int32 id = 0;
  3686. Spawn* spawn = 0;
  3687. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3688. id = atol(sep->arg[0]);
  3689. spawn = client->GetCurrentZone()->GetSpawn(id);
  3690. }
  3691. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3692. id = 0;
  3693. if(!id || !spawn){
  3694. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3695. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3696. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3697. safe_delete(sep);
  3698. return;
  3699. }
  3700. if(sep && sep->arg[1][0]){
  3701. float x = atof(sep->arg[1]);
  3702. spawn->appearance.pos.X = x;
  3703. }
  3704. else
  3705. spawn->SetX(client->GetPlayer()->GetX(), false);
  3706. if(sep && sep->arg[2][0]){
  3707. float y = atof(sep->arg[2]);
  3708. spawn->appearance.pos.Y = y;
  3709. }
  3710. else
  3711. spawn->SetY(client->GetPlayer()->GetY(), false);
  3712. if(sep && sep->arg[3][0]){
  3713. float z = atof(sep->arg[3]);
  3714. spawn->appearance.pos.Z = z;
  3715. }
  3716. else
  3717. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3718. if(sep && sep->arg[4][0]){
  3719. float heading = atof(sep->arg[4]);
  3720. spawn->SetHeading(heading);
  3721. }
  3722. else
  3723. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3724. spawn->SetSpawnOrigX(spawn->GetX());
  3725. spawn->SetSpawnOrigY(spawn->GetY());
  3726. spawn->SetSpawnOrigZ(spawn->GetZ());
  3727. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3728. if(sep && sep->arg[5][0])
  3729. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3730. else
  3731. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3732. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3733. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3734. spawn->SetHP(spawn->GetTotalHP());
  3735. }
  3736. if(spawn->GetTotalPower() == 0){
  3737. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3738. spawn->SetPower(spawn->GetTotalPower());
  3739. }
  3740. const char* script = world.GetSpawnScript(id);
  3741. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3742. spawn->SetSpawnScript(string(script));
  3743. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  3744. client->GetCurrentZone()->AddSpawn(spawn);
  3745. if(spawn->IsNPC())
  3746. spawn->GetZone()->AddLoot((NPC*)spawn);
  3747. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3748. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3749. break;
  3750. }
  3751. case COMMAND_ADMINFLAG:
  3752. {
  3753. if(sep && sep->arg[0]){
  3754. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3755. sint16 new_status = atoi(sep->arg[1]);
  3756. if(tmp_status == -10)
  3757. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3758. else if(tmp_status >= client->GetAdminStatus())
  3759. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3760. else if (new_status > client->GetAdminStatus())
  3761. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3762. else{
  3763. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3764. if (!client2)
  3765. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3766. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3767. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3768. if (client2) {
  3769. client2->SetAdminStatus(new_status);
  3770. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3771. }
  3772. }
  3773. else
  3774. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3775. }
  3776. }else{
  3777. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3778. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3779. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3780. }
  3781. break;
  3782. }
  3783. case COMMAND_CANNEDEMOTE:{
  3784. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3785. break;
  3786. }
  3787. case COMMAND_BROADCAST: {
  3788. if (sep && sep->arg[0])
  3789. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3790. else
  3791. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3792. break;
  3793. }
  3794. case COMMAND_ANNOUNCE: {
  3795. if (sep && sep->arg[0])
  3796. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3797. else
  3798. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3799. break;
  3800. }
  3801. case COMMAND_RELOAD_ITEMS:{
  3802. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3803. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3804. database.ReloadItemList();
  3805. database.LoadMerchantInformation();
  3806. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3807. break;
  3808. }
  3809. case COMMAND_ENABLE_ABILITY_QUE:{
  3810. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3811. if(app)
  3812. client->QueuePacket(app);
  3813. break;
  3814. }
  3815. case COMMAND_ITEMSEARCH:{
  3816. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3817. if (packet) {
  3818. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3819. //packet->setDataByName("unknown", 1);
  3820. packet->setDataByName("unknown2", 5, 0);
  3821. packet->setDataByName("unknown2", 20, 1);
  3822. packet->setDataByName("unknown2", 58, 3);
  3823. packet->setDataByName("unknown2", 40, 4);
  3824. client->QueuePacket(packet->serialize());
  3825. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3826. if (packet2) {
  3827. packet2->setDataByName("char_id", client->GetCharacterID());
  3828. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3829. safe_delete(packet2);
  3830. }
  3831. safe_delete(packet);
  3832. }
  3833. break;
  3834. }
  3835. case COMMAND_ANIMTEST:{
  3836. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3837. if(command_packet){
  3838. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  3839. if (cmdTarget)
  3840. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  3841. command_packet->setDataByName ( "spawn_id" , id);
  3842. int animID = 1;
  3843. if(sep && sep->arg[0] && sep->IsNumber(0))
  3844. animID = atoi(sep->arg[0]);
  3845. VisualState* vs = NULL;
  3846. if(animID == 0)
  3847. {
  3848. vs = visual_states.FindVisualState(sep->arg[0]);
  3849. }
  3850. char msg[128];
  3851. sprintf(msg,"Animation Test ID: %i",animID);
  3852. command_packet->setMediumStringByName ( "emote_msg" , msg );
  3853. if(vs != NULL)
  3854. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  3855. else
  3856. command_packet->setDataByName ( "anim_type", animID );
  3857. command_packet->setDataByName ( "unknown0", 0 );
  3858. EQ2Packet* outapp = command_packet->serialize();
  3859. client->QueuePacket(outapp);
  3860. safe_delete(command_packet);
  3861. }
  3862. break;
  3863. }
  3864. case COMMAND_KICK:
  3865. {
  3866. if( sep == 0 || sep->arg[0] == 0)
  3867. {
  3868. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  3869. }
  3870. else
  3871. {
  3872. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  3873. if ( kickClient == client )
  3874. {
  3875. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  3876. break;
  3877. }
  3878. else if(kickClient != NULL)
  3879. {
  3880. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3881. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  3882. {
  3883. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3884. break;
  3885. }
  3886. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  3887. kickClient->Disconnect();
  3888. }
  3889. else
  3890. {
  3891. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3892. }
  3893. }
  3894. break;
  3895. }
  3896. case COMMAND_LOCK:
  3897. {
  3898. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  3899. int worldLocked = atoi(sep->arg[0]);
  3900. net.world_locked = worldLocked;
  3901. if ( worldLocked )
  3902. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  3903. else
  3904. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  3905. }
  3906. else
  3907. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  3908. break;
  3909. }
  3910. case COMMAND_BAN:{
  3911. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  3912. {
  3913. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  3914. }
  3915. else
  3916. {
  3917. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  3918. if ( kickClient == client )
  3919. {
  3920. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  3921. break;
  3922. }
  3923. else if(kickClient != NULL)
  3924. {
  3925. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3926. if ( maxStatus > client->GetAdminStatus( ) ||
  3927. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  3928. {
  3929. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3930. break;
  3931. }
  3932. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  3933. int perm = atol(sep->arg[1]);
  3934. if ( perm == 1 )
  3935. database.UpdateAdminStatus(sep->arg[0],-2);
  3936. else
  3937. database.UpdateAdminStatus(sep->arg[0],-1);
  3938. kickClient->Disconnect();
  3939. }
  3940. else
  3941. {
  3942. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3943. }
  3944. }
  3945. break;
  3946. }
  3947. case COMMAND_SET_COMBAT_VOICE:{
  3948. int32 value = 0;
  3949. if(sep && sep->arg[0] && sep->IsNumber(0))
  3950. value = atoi(sep->arg[0]);
  3951. client->GetPlayer()->SetCombatVoice(value);
  3952. break;
  3953. }
  3954. case COMMAND_SET_EMOTE_VOICE:{
  3955. int32 value = 0;
  3956. if(sep && sep->arg[0] && sep->IsNumber(0))
  3957. value = atoi(sep->arg[0]);
  3958. client->GetPlayer()->SetEmoteVoice(value);
  3959. break;
  3960. }
  3961. case COMMAND_GIVEITEM:{
  3962. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  3963. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  3964. if ( itemToClient == NULL )
  3965. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  3966. else
  3967. {
  3968. int32 item_id = atol(sep->arg[1]);
  3969. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  3970. itemToClient->AddItem(item_id);
  3971. }
  3972. }
  3973. else
  3974. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  3975. break;
  3976. }
  3977. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  3978. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  3979. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  3980. case COMMAND_SKILL :
  3981. case COMMAND_SKILL_ADD :
  3982. case COMMAND_SKILL_REMOVE :
  3983. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  3984. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  3985. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  3986. case COMMAND_ENTITYCOMMAND :
  3987. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  3988. case COMMAND_MERCHANT :
  3989. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  3990. case COMMAND_APPEARANCE :
  3991. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  3992. case COMMAND_TRACK : { Command_Track(client); break; }
  3993. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  3994. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  3995. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  3996. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  3997. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  3998. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  3999. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  4000. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  4001. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  4002. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  4003. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  4004. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  4005. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  4006. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  4007. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  4008. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  4009. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  4010. case COMMAND_LOCATION : { Command_Location(client); break; }
  4011. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  4012. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  4013. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  4014. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  4015. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  4016. case COMMAND_GRID : { Command_Grid(client); break; }
  4017. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  4018. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  4019. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  4020. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  4021. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  4022. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  4023. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  4024. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  4025. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  4026. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  4027. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  4028. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  4029. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  4030. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  4031. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  4032. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  4033. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  4034. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  4035. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  4036. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  4037. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  4038. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  4039. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  4040. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  4041. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  4042. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  4043. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  4044. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  4045. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  4046. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  4047. case COMMAND_MOTD : { Command_MOTD(client); break; }
  4048. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  4049. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  4050. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  4051. case COMMAND_TITLE : { Command_Title(client); break; }
  4052. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  4053. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  4054. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  4055. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  4056. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  4057. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  4058. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  4059. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  4060. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  4061. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  4062. case COMMAND_PET : { Command_Pet(client, sep); break; }
  4063. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  4064. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  4065. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  4066. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  4067. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  4068. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  4069. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  4070. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  4071. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  4072. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  4073. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  4074. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  4075. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  4076. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  4077. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  4078. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  4079. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  4080. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  4081. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  4082. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  4083. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  4084. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  4085. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  4086. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  4087. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  4088. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  4089. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  4090. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  4091. case COMMAND_MODIFY : { Command_Modify(client); break; }
  4092. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  4093. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  4094. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  4095. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  4096. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  4097. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  4098. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  4099. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  4100. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  4101. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  4102. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  4103. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  4104. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  4105. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  4106. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  4107. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  4108. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  4109. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  4110. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  4111. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  4112. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  4113. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  4114. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  4115. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  4116. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  4117. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  4118. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  4119. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  4120. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  4121. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  4122. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  4123. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  4124. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  4125. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  4126. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  4127. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  4128. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  4129. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  4130. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  4131. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  4132. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  4133. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  4134. case ADD_AA : { Add_AA(client, sep); break; }
  4135. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  4136. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  4137. case BACK_AA : { Back_AA(client, sep); break; }
  4138. case REMOVE_AA : { Remove_AA(client, sep); break; }
  4139. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  4140. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  4141. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  4142. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  4143. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  4144. default:
  4145. {
  4146. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  4147. break;
  4148. }
  4149. }
  4150. safe_delete(sep);
  4151. }
  4152. /******************** New COMMAND Handler Functions ********************/
  4153. /*
  4154. Started breaking apart the huge switch() for commands into sepErate
  4155. functions so it is easier to locate the blocks of code by command
  4156. -- JA 2012.03.03
  4157. */
  4158. // sample function header
  4159. /*
  4160. Function:
  4161. Purpose :
  4162. Params :
  4163. Dev :
  4164. Example :
  4165. */
  4166. //void Commands::Command()
  4167. //{
  4168. //}
  4169. /*
  4170. Function: Command_AcceptAdvancement()
  4171. Purpose : Player accepts a new advancement option
  4172. Params : Spell ID
  4173. Dev : Jabantiz
  4174. */
  4175. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4176. {
  4177. Player *player = client->GetPlayer();
  4178. if (sep && sep->IsSet(0)) {
  4179. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4180. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4181. if (!player->HasSpell(trait->spellID, 0, true))
  4182. {
  4183. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4184. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4185. }
  4186. else
  4187. {
  4188. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4189. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4190. player->RemoveSpellBookEntry(spell->GetSpellID());
  4191. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4192. player->UnlockSpell(spell);
  4193. client->SendSpellUpdate(spell);
  4194. }
  4195. // Spell book update
  4196. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4197. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4198. }
  4199. }
  4200. /*
  4201. Function:
  4202. Purpose :
  4203. Params :
  4204. Dev :
  4205. Example :
  4206. */
  4207. void Commands::Command_AFK(Client* client, Seperator* sep)
  4208. {
  4209. Player* player = client->GetPlayer();
  4210. player->toggle_character_flag(CF_AFK);
  4211. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4212. if (player->get_character_flag(CF_AFK))
  4213. {
  4214. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4215. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  4216. if (sep && sep->argplus[0])
  4217. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4218. else
  4219. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4220. string message = string(player->GetName()) + " is going afk.";
  4221. Spawn* target = player->GetTarget();
  4222. if (target && target != player)
  4223. {
  4224. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4225. player->GetGender() == 1 ? message += "he" : message += "she";
  4226. message += " is going afk.";
  4227. }
  4228. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4229. }
  4230. /*else
  4231. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  4232. }
  4233. /*
  4234. Function: Command_Appearance()
  4235. Purpose : Handles /appearance commands
  4236. Params : list
  4237. Dev : Scatman
  4238. Example : /appearance list
  4239. */
  4240. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4241. {
  4242. if( handler == COMMAND_APPEARANCE )
  4243. {
  4244. // /appearance command by itself shows help (to be extended)
  4245. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4246. return;
  4247. }
  4248. else if( handler == COMMAND_APPEARANCE_LIST )
  4249. {
  4250. // /appearance list command expects "name" param
  4251. if (sep && sep->arg[0])
  4252. {
  4253. const char* appearance_name = sep->argplus[0];
  4254. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4255. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4256. if (appearances)
  4257. {
  4258. vector<int16>::iterator itr;
  4259. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4260. {
  4261. int16 id = *itr;
  4262. string name = database.GetAppearanceName(id);
  4263. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4264. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4265. }
  4266. safe_delete(appearances);
  4267. }
  4268. }
  4269. else // no param
  4270. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4271. }
  4272. }
  4273. /*
  4274. Function: Command_Claim()
  4275. Purpose :
  4276. Params :
  4277. Dev :
  4278. Example :
  4279. */
  4280. void Commands::Command_Claim(Client* client, Seperator* sep)
  4281. {
  4282. if (sep && sep->arg[0] && sep->IsNumber(0))
  4283. {
  4284. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4285. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4286. }
  4287. else
  4288. client->ShowClaimWindow();
  4289. }
  4290. /*
  4291. Function: Command_ClearAllQueued()
  4292. Purpose :
  4293. Params :
  4294. Dev :
  4295. Example :
  4296. */
  4297. void Commands::Command_ClearAllQueued(Client* client)
  4298. {
  4299. ZoneServer* zone = client->GetPlayer()->GetZone();
  4300. if (zone && zone->GetSpellProcess())
  4301. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4302. }
  4303. /*
  4304. Function: Command_CancelMaintained()
  4305. Purpose : Cancels maintained spells
  4306. Params : Maintained Spell Index
  4307. Dev : Zcoretri
  4308. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4309. */
  4310. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4311. {
  4312. if (sep && sep->arg[0] && sep->IsNumber(0))
  4313. {
  4314. int32 spell_index = atoul(sep->arg[0]);
  4315. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4316. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4317. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4318. // just not spelleffects/dets - Foof
  4319. //{
  4320. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell))
  4321. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4322. // }
  4323. //else
  4324. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4325. }
  4326. }
  4327. /*
  4328. Function: Command_Create()
  4329. Purpose : Handler for starting Tradeskilling table
  4330. Params :
  4331. Dev : Zcoretri
  4332. Example :
  4333. */
  4334. void Commands::Command_Create(Client* client, Seperator* sep)
  4335. {
  4336. PrintSep(sep, "COMMAND_CREATE");
  4337. client->SendRecipeList();
  4338. client->ShowRecipeBook();
  4339. }
  4340. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4341. {
  4342. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4343. if (sep && sep->arg[0] && sep->IsNumber(0))
  4344. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4345. }
  4346. /*
  4347. Function: Command_Distance()
  4348. Purpose : Displays distance from targeted spawn
  4349. Params :
  4350. Dev : Scatman
  4351. Example : /distance
  4352. */
  4353. void Commands::Command_Distance(Client* client)
  4354. {
  4355. Spawn* target = client->GetPlayer()->GetTarget();
  4356. if (target)
  4357. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4358. else
  4359. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4360. }
  4361. /*
  4362. Function: Command_Duel()
  4363. Purpose : Handle the /duel commands - not yet implemented
  4364. Params : unknown
  4365. Dev :
  4366. Example :
  4367. */
  4368. void Commands::Command_Duel(Client* client, Seperator* sep)
  4369. {
  4370. PrintSep(sep, "COMMAND_DUEL");
  4371. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4372. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4373. }
  4374. /*
  4375. Function: Command_DuelBet()
  4376. Purpose : Handle the /duel commands - not yet implemented
  4377. Params : unknown
  4378. Dev :
  4379. Example :
  4380. */
  4381. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4382. {
  4383. PrintSep(sep, "COMMAND_DUELBET");
  4384. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4385. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4386. }
  4387. /*
  4388. Function: Command_DuelAccept()
  4389. Purpose : Handle the /duel commands - not yet implemented
  4390. Params : unknown
  4391. Dev :
  4392. Example :
  4393. */
  4394. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4395. {
  4396. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4397. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4398. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4399. }
  4400. /*
  4401. Function: Command_DuelDecline()
  4402. Purpose : Handle the /duel commands - not yet implemented
  4403. Params : unknown
  4404. Dev :
  4405. Example :
  4406. */
  4407. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4408. {
  4409. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4410. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4411. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4412. }
  4413. /*
  4414. Function: Command_DuelSurrender()
  4415. Purpose : Handle the /duel commands - not yet implemented
  4416. Params : unknown
  4417. Dev :
  4418. Example :
  4419. */
  4420. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4421. {
  4422. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4423. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4424. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4425. // JA, just messin around ;)
  4426. char surrender[64];
  4427. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4428. zone_list.HandleGlobalAnnouncement(surrender);
  4429. }
  4430. /*
  4431. Function: Command_DuelToggle()
  4432. Purpose : Handle the /duel commands - not yet implemented
  4433. Params : unknown
  4434. Dev :
  4435. Example :
  4436. */
  4437. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4438. {
  4439. PrintSep(sep, "COMMAND_DUEL");
  4440. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4441. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4442. }
  4443. /*
  4444. Function:
  4445. Purpose :
  4446. Params :
  4447. Dev :
  4448. Example :
  4449. */
  4450. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4451. {
  4452. if( handler == COMMAND_ENTITYCOMMAND )
  4453. {
  4454. // /entitycommand command by itself shows help (to be extended)
  4455. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4456. return;
  4457. }
  4458. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4459. {
  4460. // /entitycommand list command expects "name" param
  4461. if (sep && sep->arg[0])
  4462. {
  4463. const char* entity_command_name = sep->argplus[0];
  4464. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4465. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4466. map<int32, vector<EntityCommand*>*>::iterator itr;
  4467. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4468. {
  4469. vector<EntityCommand*>* entity_command_list = itr->second;
  4470. vector<EntityCommand*>::iterator itr2;
  4471. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4472. {
  4473. EntityCommand* entity_command = *itr2;
  4474. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4475. 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);
  4476. }
  4477. }
  4478. }
  4479. else // no command name
  4480. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4481. }
  4482. }
  4483. /*
  4484. Function: Command_Follow()
  4485. Purpose : Handle the /follow command - not yet implemented
  4486. Params :
  4487. Dev :
  4488. Example :
  4489. */
  4490. void Commands::Command_Follow(Client* client, Seperator* sep)
  4491. {
  4492. PrintSep(sep, "COMMAND_FOLLOW");
  4493. // flag to toggle if the players target is in the players group
  4494. bool targetInGroup = false;
  4495. // get a pointer to the players group
  4496. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4497. // If the player has a group and has a target
  4498. if (gmi && client->GetPlayer()->GetTarget()) {
  4499. deque<GroupMemberInfo*>::iterator itr;
  4500. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4501. deque<GroupMemberInfo*>* members = world.GetGroupManager()->GetGroupMembers(gmi->group_id);
  4502. // Loop through the group members
  4503. for (itr = members->begin(); itr != members->end(); itr++) {
  4504. // If a group member matches a target
  4505. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4506. // toggle the flag and break the loop
  4507. targetInGroup = true;
  4508. break;
  4509. }
  4510. }
  4511. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4512. }
  4513. if (targetInGroup) {
  4514. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4515. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4516. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4517. client->GetPlayer()->info_changed = true;
  4518. client->GetPlayer()->changed = true;
  4519. }
  4520. else
  4521. client->Message(CHANNEL_COLOR_WHITE, "You must first select a group member to follow.");
  4522. }
  4523. /*
  4524. Function: Command_StopFollow()
  4525. Purpose : Handle the /stop_follow command - not yet implemented
  4526. Params :
  4527. Dev :
  4528. Example :
  4529. */
  4530. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4531. {
  4532. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4533. if (client->GetPlayer()->GetFollowTarget()) {
  4534. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4535. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4536. client->GetPlayer()->SetFollowTarget(0);
  4537. client->GetPlayer()->info_changed = true;
  4538. client->GetPlayer()->changed = true;
  4539. }
  4540. }
  4541. #include "../Zone/SPGrid.h"
  4542. /*
  4543. Function: Command_Grid()
  4544. Purpose : Show player's current Grid ID
  4545. Params :
  4546. Dev : Scatman
  4547. Example : /grid
  4548. */
  4549. void Commands::Command_Grid(Client* client)
  4550. {
  4551. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4552. if (client->GetCurrentZone()->Grid != nullptr) {
  4553. int32 grid = client->GetCurrentZone()->Grid->GetGridID(client->GetPlayer());
  4554. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4555. }
  4556. }
  4557. /*
  4558. Function: Command_Guild()
  4559. Purpose : Handler for all UI-related guild commands
  4560. Dev : Scatman
  4561. */
  4562. void Commands::Command_Guild(Client* client, Seperator* sep)
  4563. {
  4564. Guild* guild = client->GetPlayer()->GetGuild();
  4565. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  4566. {
  4567. const char* command = sep->arg[0];
  4568. int32 length = strlen(command);
  4569. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4570. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4571. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4572. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4573. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4574. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4575. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4576. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4577. guild->KickGuildMember(client, sep->arg[1]);
  4578. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4579. guild->DemoteGuildMember(client, sep->arg[1]);
  4580. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4581. guild->PromoteGuildMember(client, sep->arg[1]);
  4582. else if (strncmp(command, "points", length) == 0 && guild)
  4583. {
  4584. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4585. {
  4586. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4587. {
  4588. float points = atof(sep->arg[2]);
  4589. const char* option = sep->arg[3];
  4590. const char* comment = sep->argplus[4];
  4591. if (strncmp(option, "all", strlen(option)) == 0)
  4592. guild->AddPointsToAll(client, points, comment);
  4593. else if (strncmp(option, "online", strlen(option)) == 0)
  4594. guild->AddPointsToAllOnline(client, points, comment);
  4595. else if (strncmp(option, "group", strlen(option)) == 0)
  4596. guild->AddPointsToGroup(client, points, comment);
  4597. else if (strncmp(option, "raid", strlen(option)) == 0)
  4598. guild->AddPointsToRaid(client, points, comment);
  4599. else
  4600. guild->AddPointsToGuildMember(client, points, option, comment);
  4601. }
  4602. }
  4603. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4604. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4605. else
  4606. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4607. }
  4608. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4609. guild->SetMOTD(sep->argplus[1]);
  4610. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4611. {
  4612. if (sep->arg[1])
  4613. {
  4614. const char* option = sep->arg[1];
  4615. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4616. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4617. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4618. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4619. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4620. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4621. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4622. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4623. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4624. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4625. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4626. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4627. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4628. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4629. else
  4630. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4631. }
  4632. else
  4633. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4634. }
  4635. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4636. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4637. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4638. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4639. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4640. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4641. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4642. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4643. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4644. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4645. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4646. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4647. else if (strncmp(command, "invite", length) == 0 && guild)
  4648. {
  4649. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4650. guild->InvitePlayer(client, sep->arg[1]);
  4651. else
  4652. {
  4653. Spawn* target = client->GetPlayer()->GetTarget();
  4654. if (target)
  4655. {
  4656. if (target->IsPlayer())
  4657. guild->InvitePlayer(client, target->GetName());
  4658. else
  4659. client->Message(CHANNEL_COLOR_WHITE, "%s is not a player.", target->GetName());
  4660. }
  4661. }
  4662. }
  4663. else if (strncmp(command, "accept", length) == 0)
  4664. {
  4665. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4666. if (pgi && pgi->guild && pgi->invited_by)
  4667. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4668. client->SetPendingGuildInvite(0);
  4669. }
  4670. else if (strncmp(command, "decline", length) == 0)
  4671. {
  4672. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4673. if (pgi && pgi->guild && pgi->invited_by)
  4674. {
  4675. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4676. if (client_inviter)
  4677. client_inviter->Message(CHANNEL_COLOR_WHITE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4678. }
  4679. client->SetPendingGuildInvite(0);
  4680. }
  4681. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4682. {
  4683. const char* guild_name = sep->argplus[1];
  4684. if (!guild_list.GetGuild(guild_name))
  4685. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  4686. else
  4687. client->SimpleMessage(CHANNEL_COLOR_WHITE, "A guild with that name already exists.");
  4688. }
  4689. else if (strncmp(command, "search", length) == 0)
  4690. client->ShowGuildSearchWindow();
  4691. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4692. {
  4693. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4694. if (to_guild)
  4695. to_guild->SendGuildRecruitingDetails(client);
  4696. }
  4697. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4698. {
  4699. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4700. if (to_guild)
  4701. to_guild->SendGuildRecruitingImages(client);
  4702. }
  4703. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4704. {
  4705. if (sep->arg[1])
  4706. {
  4707. const char* option = sep->arg[1];
  4708. if (strncmp(option, "toggle", strlen(option)) == 0)
  4709. guild->ToggleGuildRecruiterAdventureClass(client);
  4710. }
  4711. else
  4712. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4713. }
  4714. else if (strncmp(command, "display_heraldry", length) == 0)
  4715. {
  4716. // JA: not sure this is right...
  4717. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4718. client->GetPlayer()->SetCharSheetChanged(true);
  4719. }
  4720. else
  4721. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4722. }
  4723. }
  4724. /*
  4725. Function: Command_GuildCreate()
  4726. Purpose : Display's in-game Guild Creation window
  4727. Dev : Scatman
  4728. */
  4729. void Commands::Command_CreateGuild(Client* client)
  4730. {
  4731. client->SendGuildCreateWindow();
  4732. }
  4733. /*
  4734. Function: Command_SetGuildOfficerNote()
  4735. Purpose :
  4736. Dev : Scatman
  4737. */
  4738. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4739. {
  4740. if (sep && sep->arg[0] && sep->arg[1])
  4741. {
  4742. Guild* guild = client->GetPlayer()->GetGuild();
  4743. if (guild)
  4744. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4745. }
  4746. }
  4747. /*
  4748. Function: Command_SetGuildMemberNote()
  4749. Purpose :
  4750. Dev : Scatman
  4751. */
  4752. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4753. {
  4754. if (sep && sep->arg[0] && sep->arg[1])
  4755. {
  4756. Guild* guild = client->GetPlayer()->GetGuild();
  4757. if (guild)
  4758. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4759. }
  4760. }
  4761. /*
  4762. Function: Command_GuildSay()
  4763. Purpose :
  4764. Dev : Scatman
  4765. */
  4766. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4767. {
  4768. Guild* guild = client->GetPlayer()->GetGuild();
  4769. if (guild)
  4770. {
  4771. if (sep && sep->arg[0])
  4772. guild->HandleGuildSay(client, sep->argplus[0]);
  4773. }
  4774. else
  4775. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4776. }
  4777. /*
  4778. Function: Command_OfficerSay()
  4779. Purpose :
  4780. Dev : Scatman
  4781. */
  4782. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4783. {
  4784. Guild* guild = client->GetPlayer()->GetGuild();
  4785. if (guild)
  4786. {
  4787. if (sep && sep->arg[0])
  4788. guild->HandleOfficerSay(client, sep->argplus[0]);
  4789. }
  4790. else
  4791. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4792. }
  4793. /*
  4794. Function: Command_Guilds()
  4795. Purpose : Shows help for /guild command
  4796. Params :
  4797. Dev : Scatman
  4798. Example :
  4799. */
  4800. void Commands::Command_Guilds(Client* client)
  4801. {
  4802. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4803. }
  4804. /*
  4805. Function: Command_GuildsAdd()
  4806. Purpose : Add's players to a guild
  4807. Params : guild_name|guild_id, player name
  4808. Dev : Scatman
  4809. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4810. */
  4811. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4812. {
  4813. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4814. {
  4815. Guild* guild = 0;
  4816. bool found = true;
  4817. if (sep->IsNumber(0))
  4818. {
  4819. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4820. if (!guild)
  4821. {
  4822. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4823. found = false;
  4824. }
  4825. }
  4826. else
  4827. {
  4828. guild = guild_list.GetGuild(sep->arg[0]);
  4829. if (!guild)
  4830. {
  4831. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4832. found = false;
  4833. }
  4834. }
  4835. if (found)
  4836. {
  4837. Client* to_client = 0;
  4838. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4839. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4840. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4841. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4842. if (to_client)
  4843. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  4844. else
  4845. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4846. }
  4847. }
  4848. else
  4849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  4850. }
  4851. /*
  4852. Function: Command_GuildsCreate()
  4853. Purpose : Creates a guild
  4854. Params : guild_name, player_name (optional)
  4855. Dev : Scatman
  4856. Example : /guilds create [guild name] (player name)
  4857. */
  4858. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  4859. {
  4860. if (sep && sep->arg[0])
  4861. {
  4862. const char* guild_name = sep->arg[0];
  4863. if (!guild_list.GetGuild(guild_name))
  4864. {
  4865. bool ret = false;
  4866. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4867. {
  4868. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4869. if (to_client)
  4870. {
  4871. world.CreateGuild(guild_name, to_client);
  4872. ret = true;
  4873. }
  4874. else
  4875. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  4876. }
  4877. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4878. {
  4879. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4880. if (to_client)
  4881. {
  4882. world.CreateGuild(guild_name, to_client);
  4883. ret = true;
  4884. }
  4885. }
  4886. else
  4887. {
  4888. world.CreateGuild(guild_name);
  4889. ret = true;
  4890. }
  4891. if (ret)
  4892. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  4893. else
  4894. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  4895. }
  4896. else
  4897. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  4898. }
  4899. else
  4900. 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.");
  4901. }
  4902. /*
  4903. Function: Command_GuildsDelete()
  4904. Purpose : Delete's a guild
  4905. Params : guild name
  4906. Dev : Scatman
  4907. Example : /guilds delete Test
  4908. */
  4909. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  4910. {
  4911. if (sep && sep->arg[0])
  4912. {
  4913. Guild* guild = 0;
  4914. bool found = true;
  4915. if (sep->IsNumber(0))
  4916. {
  4917. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4918. if (!guild)
  4919. {
  4920. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4921. found = false;
  4922. }
  4923. }
  4924. else
  4925. {
  4926. guild = guild_list.GetGuild(sep->arg[0]);
  4927. if (!guild)
  4928. {
  4929. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4930. found = false;
  4931. }
  4932. }
  4933. if (found)
  4934. {
  4935. guild->RemoveAllGuildMembers();
  4936. database.DeleteGuild(guild);
  4937. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  4938. guild_list.RemoveGuild(guild, true);
  4939. }
  4940. }
  4941. else
  4942. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  4943. }
  4944. /*
  4945. Function: Command_GuildsList()
  4946. Purpose : Lists current guilds on server
  4947. Params :
  4948. Dev : Scatman
  4949. Example : /guilds list
  4950. */
  4951. void Commands::Command_GuildsList(Client* client)
  4952. {
  4953. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  4954. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  4955. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  4956. if (guilds->size() == 0)
  4957. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  4958. else {
  4959. while (itr.Next()) {
  4960. Guild* guild = itr.second;
  4961. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  4962. }
  4963. }
  4964. }
  4965. /*
  4966. Function: Command_GuildsRemove()
  4967. Purpose : Removes a player from a guild
  4968. Params : guild name|guild id, player name
  4969. Dev : Scatman
  4970. Example : /guilds remove 1 Admin = removes Admin from guild 1
  4971. */
  4972. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  4973. {
  4974. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4975. {
  4976. Guild* guild = 0;
  4977. bool found = true;
  4978. if (sep->IsNumber(0))
  4979. {
  4980. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4981. if (!guild)
  4982. {
  4983. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4984. found = false;
  4985. }
  4986. }
  4987. else
  4988. {
  4989. guild = guild_list.GetGuild(sep->arg[0]);
  4990. if (!guild)
  4991. {
  4992. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4993. found = false;
  4994. }
  4995. }
  4996. if (found)
  4997. {
  4998. Client* to_client = 0;
  4999. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5000. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5001. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5002. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5003. if (to_client)
  5004. {
  5005. Player* to_player = to_client->GetPlayer();
  5006. if (to_player->GetGuild())
  5007. {
  5008. if (to_player->GetGuild() == guild)
  5009. {
  5010. guild->KickGuildMember(client, to_player->GetName());
  5011. }
  5012. else
  5013. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  5014. }
  5015. else
  5016. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  5017. }
  5018. else
  5019. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5020. }
  5021. }
  5022. else
  5023. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  5024. }
  5025. /*
  5026. Function: Command_InspectPlayer()
  5027. Purpose : Handle the Inspect functions
  5028. Params : Client to inspect
  5029. Dev : Scatman
  5030. Example : /inspect Scatman
  5031. */
  5032. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  5033. {
  5034. if (sep && sep->arg[0])
  5035. {
  5036. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  5037. if (inspect_client)
  5038. client->InspectPlayer(inspect_client->GetPlayer());
  5039. }
  5040. else
  5041. {
  5042. Spawn* target = client->GetPlayer()->GetTarget();
  5043. if (target && target->IsPlayer())
  5044. client->InspectPlayer((Player*)target);
  5045. }
  5046. }
  5047. /*
  5048. Function: Command_Inventory()
  5049. Purpose : Handle changes in player inventory
  5050. Params : <TBD>
  5051. Dev : All
  5052. Example : /inventory delete item_id
  5053. */
  5054. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  5055. {
  5056. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  5057. Player* player = client->GetPlayer();
  5058. if(sep && sep->arg[0][0])
  5059. {
  5060. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  5061. if(client->GetPlayer()->GetHP() == 0)
  5062. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  5063. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5064. {
  5065. int16 index = atoi(sep->arg[1]);
  5066. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5067. if(item)
  5068. {
  5069. if(item->GetItemScript() && lua_interface)
  5070. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  5071. int32 bag_id = item->details.inv_slot_id;
  5072. database.DeleteItem(client->GetCharacterID(), item, 0);
  5073. client->GetPlayer()->item_list.DestroyItem(index);
  5074. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  5075. client->QueuePacket(outapp);
  5076. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  5077. if (outapp)
  5078. client->QueuePacket(outapp);
  5079. }
  5080. }
  5081. 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))
  5082. {
  5083. int16 from_index = atoi(sep->arg[1]);
  5084. sint16 to_slot = atoi(sep->arg[2]);
  5085. sint32 bag_id = atol(sep->arg[3]);
  5086. int8 charges = atoi(sep->arg[4]);
  5087. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  5088. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  5089. {
  5090. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  5091. return;
  5092. }
  5093. sint32 old_inventory_id = 0;
  5094. if(item)
  5095. old_inventory_id = item->details.inv_slot_id;
  5096. //autobank
  5097. if (bag_id == -3 && to_slot == -1)
  5098. {
  5099. if (player->HasFreeBankSlot())
  5100. to_slot = player->FindFreeBankSlot();
  5101. else
  5102. {
  5103. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  5104. return;
  5105. }
  5106. }
  5107. //auto inventory
  5108. if (bag_id == 0 && to_slot == -1)
  5109. {
  5110. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5111. {
  5112. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  5113. return;
  5114. }
  5115. }
  5116. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  5117. client->QueuePacket(outapp);
  5118. //removed from bag send update
  5119. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  5120. {
  5121. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  5122. if(outapp)
  5123. client->QueuePacket(outapp);
  5124. }
  5125. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  5126. {
  5127. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  5128. if(outapp)
  5129. client->QueuePacket(outapp);
  5130. }
  5131. }
  5132. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  5133. {
  5134. if(client->GetPlayer()->EngagedInCombat())
  5135. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  5136. else
  5137. {
  5138. int16 index = atoi(sep->arg[1]);
  5139. int8 slot_id = 255;
  5140. if(sep->arg[2][0] && sep->IsNumber(2))
  5141. slot_id = atoi(sep->arg[2]);
  5142. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  5143. EQ2Packet* outapp = 0;
  5144. for(int32 i=0;i<packets.size();i++)
  5145. {
  5146. outapp = packets[i];
  5147. if(outapp)
  5148. client->QueuePacket(outapp);
  5149. }
  5150. client->GetPlayer()->ChangePrimaryWeapon();
  5151. client->GetPlayer()->ChangeSecondaryWeapon();
  5152. client->GetPlayer()->ChangeRangedWeapon();
  5153. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5154. client->QueuePacket(characterSheetPackets);
  5155. }
  5156. }
  5157. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5158. {
  5159. if (client->GetPlayer()->EngagedInCombat())
  5160. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5161. else {
  5162. int16 index = atoi(sep->arg[1]);
  5163. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5164. if (item) {
  5165. // client->GetPlayer()->item_list.DestroyItem(index);
  5166. if (item->item_sets.size() > 0) {
  5167. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5168. ItemSet* set = item->item_sets[i];
  5169. if (set->item_stack_size == 0)
  5170. set->item_stack_size += 1;
  5171. client->AddItem(set->item_id, set->item_stack_size);
  5172. }
  5173. }
  5174. }
  5175. client->RemoveItem(item, 1);
  5176. }
  5177. }
  5178. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5179. {
  5180. if(client->GetPlayer()->EngagedInCombat())
  5181. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5182. else
  5183. {
  5184. int16 index = atoi(sep->arg[1]);
  5185. sint32 bag_id = -999;
  5186. int8 to_slot = 255;
  5187. if(sep->arg[3][0])
  5188. {
  5189. if(sep->IsNumber(2))
  5190. bag_id = atol(sep->arg[2]);
  5191. if(sep->IsNumber(3))
  5192. to_slot = atoi(sep->arg[3]);
  5193. }
  5194. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  5195. EQ2Packet* outapp = 0;
  5196. for(int32 i=0;i<packets.size();i++)
  5197. {
  5198. outapp = packets[i];
  5199. if(outapp)
  5200. client->QueuePacket(outapp);
  5201. }
  5202. client->GetPlayer()->ChangePrimaryWeapon();
  5203. client->GetPlayer()->ChangeSecondaryWeapon();
  5204. client->GetPlayer()->ChangeRangedWeapon();
  5205. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5206. client->QueuePacket(characterSheetPackets);
  5207. }
  5208. }
  5209. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5210. {
  5211. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5212. int16 index1 = atoi(sep->arg[1]);
  5213. int16 index2 = atoi(sep->arg[2]);
  5214. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  5215. if(outapp)
  5216. client->QueuePacket(outapp);
  5217. else
  5218. {
  5219. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5220. return;
  5221. }
  5222. }
  5223. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5224. {
  5225. sint16 to_slot = atoi(sep->arg[1]);
  5226. sint32 bag_id = atoi(sep->arg[2]);
  5227. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5228. if (item) {
  5229. //auto inventory
  5230. if (bag_id == 0 && to_slot == -1)
  5231. {
  5232. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5233. {
  5234. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5235. return;
  5236. }
  5237. // Set the slot for the item
  5238. item->details.inv_slot_id = bag_id;
  5239. item->details.slot_id = to_slot;
  5240. // Flag the item so it gets saved in its new location
  5241. item->save_needed = true;
  5242. // Add the item to its new location
  5243. player->item_list.AddItem(item);
  5244. // Remove the item from the overflow list
  5245. player->item_list.RemoveOverflowItem(item);
  5246. // Send the inventory update packet
  5247. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5248. return;
  5249. }
  5250. else if (bag_id == -3 && to_slot == -1) {
  5251. // Auto Bank
  5252. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5253. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5254. return;
  5255. }
  5256. item->details.inv_slot_id = bag_id;
  5257. item->details.slot_id = to_slot;
  5258. item->save_needed = true;
  5259. player->item_list.AddItem(item);
  5260. player->item_list.RemoveOverflowItem(item);
  5261. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5262. }
  5263. else if (bag_id == -4) {
  5264. // Shared Bank
  5265. if (!player->item_list.SharedBankAddAllowed(item)) {
  5266. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5267. return;
  5268. }
  5269. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5270. if (tmp_item) {
  5271. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5272. return;
  5273. }
  5274. else {
  5275. item->details.inv_slot_id = bag_id;
  5276. item->details.slot_id = to_slot;
  5277. item->save_needed = true;
  5278. player->item_list.AddItem(item);
  5279. player->item_list.RemoveOverflowItem(item);
  5280. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5281. return;
  5282. }
  5283. }
  5284. else {
  5285. // Try to get an item from the given bag id and slot id
  5286. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5287. // Check to see if we got an item, if we do send an error,
  5288. // if we don't put the overflow item into this slot
  5289. if (tmp_item) {
  5290. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5291. }
  5292. else {
  5293. item->details.inv_slot_id = bag_id;
  5294. item->details.slot_id = to_slot;
  5295. item->save_needed = true;
  5296. player->item_list.AddItem(item);
  5297. player->item_list.RemoveOverflowItem(item);
  5298. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5299. return;
  5300. }
  5301. }
  5302. }
  5303. }
  5304. }
  5305. else
  5306. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5307. }
  5308. /*
  5309. Function: Command_IRC()
  5310. Purpose : Handle the IRC functions
  5311. Params : IRC Commands
  5312. Dev : Scatman
  5313. Example : /irc say #Channel Hello World!
  5314. */
  5315. void Commands::Command_IRC(Client* client, Seperator* sep)
  5316. {
  5317. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5318. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5319. return;
  5320. }
  5321. if (sep && sep->arg[0][0]) {
  5322. if (strcasecmp(sep->arg[0], "say") == 0) {
  5323. if (sep->arg[1][0] && sep->arg[2][0]) {
  5324. if (sep->IsNumber(sep->arg[1]))
  5325. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5326. else
  5327. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5328. }
  5329. else
  5330. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5331. }
  5332. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5333. if (sep->arg[1][0])
  5334. irc.JoinChannel(client, sep->arg[1]);
  5335. else
  5336. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5337. }
  5338. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5339. if (sep->arg[1][0])
  5340. irc.LeaveChannel(client, sep->arg[1]);
  5341. else
  5342. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5343. }
  5344. else if (strcasecmp(sep->arg[0], "list") == 0)
  5345. irc.ListChannels(client);
  5346. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5347. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5348. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5349. else
  5350. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5351. }
  5352. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5353. irc.DisconnectFromServer(client);
  5354. else
  5355. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5356. }
  5357. else
  5358. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5359. }
  5360. /*
  5361. Function: Command_Languages()
  5362. Purpose : Show's languages the player knows
  5363. Params :
  5364. Dev : Zcoretri
  5365. Example :
  5366. */
  5367. void Commands::Command_Languages(Client* client, Seperator* sep)
  5368. {
  5369. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5370. list<Language*>::iterator itr;
  5371. Language* language;
  5372. client->Message(CHANNEL_COLOR_WHITE, "You know the following languages:");
  5373. for(itr = languages->begin(); itr != languages->end(); itr++)
  5374. {
  5375. language = *itr;
  5376. client->Message(CHANNEL_COLOR_WHITE, "%s", language->GetName());
  5377. }
  5378. }
  5379. /*
  5380. Function: Command_SetLanguage()
  5381. Purpose : Handles language commands
  5382. Params : Language ID
  5383. Dev : Zcoretri
  5384. Example :
  5385. */
  5386. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5387. {
  5388. Player* player = client->GetPlayer();
  5389. if (sep && sep->arg[0])
  5390. {
  5391. if(!sep->IsNumber(0))
  5392. {
  5393. //String passed in
  5394. const char* value = sep->arg[0];
  5395. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5396. {
  5397. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5398. client->SendLanguagesUpdate(0);
  5399. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", value);
  5400. }
  5401. else
  5402. {
  5403. if(player->HasLanguage(value))
  5404. {
  5405. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5406. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5407. client->SendLanguagesUpdate(language->GetID());
  5408. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5409. }
  5410. else
  5411. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", value);
  5412. }
  5413. }
  5414. else
  5415. {
  5416. //Number passed in
  5417. int32 id = atoul(sep->arg[0]);
  5418. if(player->HasLanguage(id))
  5419. {
  5420. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5421. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5422. client->SendLanguagesUpdate(id);
  5423. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5424. }
  5425. else
  5426. {
  5427. Language* language = master_languages_list.GetLanguage(id);
  5428. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", language->GetName());
  5429. }
  5430. }
  5431. }
  5432. else
  5433. {
  5434. //No value was passed in
  5435. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5436. if(id > 0)
  5437. {
  5438. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5439. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking %s ", language->GetName());
  5440. }
  5441. else
  5442. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking Common");
  5443. }
  5444. }
  5445. /*
  5446. Function: Command_LastName()
  5447. Purpose : Sets player surname
  5448. Params : Name text
  5449. Dev : theFoof
  5450. Example :
  5451. */
  5452. void Commands::Command_LastName(Client* client, Seperator* sep)
  5453. {
  5454. if (!client)
  5455. return;
  5456. if (sep && sep->arg[0])
  5457. {
  5458. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5459. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5460. return;
  5461. }
  5462. client->RemovePendingLastName();
  5463. uchar* checkname = (uchar*)sep->arg[0];
  5464. bool valid_name = true;
  5465. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5466. if (!alpha_check(checkname[i])) {
  5467. valid_name = false;
  5468. break;
  5469. }
  5470. }
  5471. if (!valid_name) {
  5472. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5473. return;
  5474. }
  5475. string last_name = (string)sep->arg[0];
  5476. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5477. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5478. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5479. client->SetPendingLastName(last_name);
  5480. client->SendLastNameConfirmation();
  5481. }
  5482. else
  5483. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5484. }
  5485. }
  5486. /*
  5487. Function: Command_ConfirmLastName()
  5488. Purpose : Confirms setting of player surname
  5489. Params : Name text
  5490. Dev : theFoof
  5491. Example :
  5492. */
  5493. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5494. {
  5495. if (!client)
  5496. return;
  5497. string* name = client->GetPendingLastName();
  5498. if (name){
  5499. Player* player = client->GetPlayer();
  5500. player->SetLastName(name->c_str(), false);
  5501. client->SendTitleUpdate();
  5502. player->SetCharSheetChanged(true);
  5503. client->RemovePendingLastName();
  5504. }
  5505. }
  5506. /*
  5507. Function: Command_Location()
  5508. Purpose : Display's Help for /location commands
  5509. Params :
  5510. Dev : Scatman
  5511. Example : /location = show's help for command
  5512. */
  5513. void Commands::Command_Location(Client* client)
  5514. {
  5515. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5516. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5517. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5518. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5519. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5520. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5521. }
  5522. /*
  5523. Function: Command_LocationAdd()
  5524. Purpose : Add's a location to an existing location config
  5525. Params : location_id
  5526. Dev : Scatman
  5527. Example : /location add {location_id}
  5528. */
  5529. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5530. {
  5531. if (sep && sep->arg[0] && sep->IsNumber(0))
  5532. {
  5533. int32 location_id = atoul(sep->arg[0]);
  5534. float x = client->GetPlayer()->GetX();
  5535. float y = client->GetPlayer()->GetY();
  5536. float z = client->GetPlayer()->GetZ();
  5537. if (database.AddLocationPoint(location_id, x, y, z))
  5538. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5539. else
  5540. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5541. }
  5542. else
  5543. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5544. }
  5545. /*
  5546. Function: Command_LocationCreate()
  5547. Purpose : Creates a new location config
  5548. Params : location name, 0/1 for include_y (optional)
  5549. Dev : Scatman
  5550. Example : /location create Test 1 = creates a new location named Test with include_y True
  5551. */
  5552. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5553. {
  5554. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5555. {
  5556. const char* name = sep->arg[0];
  5557. bool include_y = false;
  5558. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5559. include_y = true;
  5560. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5561. if (location_id > 0)
  5562. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5563. else
  5564. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5565. }
  5566. else
  5567. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5568. }
  5569. /*
  5570. Function: Command_LocationDelete()
  5571. Purpose : Delete's a location config and all it's location points
  5572. Params : location_id
  5573. Dev : Scatman
  5574. Example : /location delete {location_id}
  5575. */
  5576. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5577. {
  5578. if (sep && sep->arg[0] && sep->IsNumber(0))
  5579. {
  5580. int32 location_id = atoul(sep->arg[0]);
  5581. if (database.DeleteLocation(location_id))
  5582. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5583. else
  5584. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5585. }
  5586. else
  5587. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5588. }
  5589. /*
  5590. Function: Command_LocationList()
  5591. Purpose : Display's a list of location points
  5592. Params : location_id
  5593. Dev : Scatman
  5594. Example : /location list {location_id}
  5595. */
  5596. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5597. {
  5598. if (sep && sep->arg[0])
  5599. {
  5600. const char* option = sep->arg[0];
  5601. if (strncmp(option, "locations", strlen(option)) == 0)
  5602. database.ListLocations(client);
  5603. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5604. {
  5605. int32 location_id = atoul(sep->arg[1]);
  5606. database.ListLocationPoints(client, location_id);
  5607. }
  5608. else
  5609. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5610. }
  5611. else
  5612. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5613. }
  5614. /*
  5615. Function: Command_LocationRemove()
  5616. Purpose : Removes a single location point from a location config
  5617. Params : location_point_id (gotten from /location list {id})
  5618. Dev : Scatman
  5619. Example : /location remove 1 = will remove location_point_id 1
  5620. */
  5621. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5622. {
  5623. if (sep && sep->arg[0] && sep->IsNumber(0))
  5624. {
  5625. int32 location_point_id = atoul(sep->arg[0]);
  5626. if (database.DeleteLocationPoint(location_point_id))
  5627. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5628. else
  5629. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5630. }
  5631. else
  5632. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5633. }
  5634. /*
  5635. Function: Command_Merchant()
  5636. Purpose : Handles Merchant commands
  5637. Params : list
  5638. Dev : Scatman
  5639. Example : /merchant list
  5640. */
  5641. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5642. {
  5643. if( handler == COMMAND_MERCHANT )
  5644. {
  5645. // /merchant command by itself shows help (to be extended)
  5646. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5647. return;
  5648. }
  5649. else if( handler == COMMAND_MERCHANT_LIST )
  5650. {
  5651. // /merchant list command expects "description" param
  5652. if (sep && sep->arg[0])
  5653. {
  5654. const char* merchant_description = sep->argplus[0];
  5655. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5656. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5657. map<int32, MerchantInfo*>::iterator itr;
  5658. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5659. {
  5660. string description = database.GetMerchantDescription(itr->first);
  5661. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5662. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5663. }
  5664. }
  5665. else // no description
  5666. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5667. }
  5668. }
  5669. /*
  5670. Function: Command_Modify()
  5671. Purpose : to replace our other "set" commands
  5672. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5673. Dev : John Adams
  5674. Example : /modify spell set name "Aegolism III"
  5675. */
  5676. void Commands::Command_Modify(Client* client)
  5677. {
  5678. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5679. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5680. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5681. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5682. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5683. }
  5684. /*
  5685. Function: Command_ModifySpawn()
  5686. Purpose : replace "spawn set" commands
  5687. Params : Action : the action to perform (or special handler)
  5688. : Field : the DB field to change
  5689. : Value : what to set the value to
  5690. : Target : what object to change (my target, or spawn_id)
  5691. Dev : John Adams
  5692. Example : /modify spawn set name "Lady Vox"
  5693. :
  5694. Note : Special Handlers, like "zoneto" for Signs
  5695. : /modify spawn zoneto
  5696. : Will set a sign's zone x/y/z to my current coords
  5697. */
  5698. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5699. {
  5700. PrintSep(sep, "COMMAND_MODIFY");
  5701. // need at least 2 args for a valid command
  5702. if( sep && sep->arg[1] )
  5703. {
  5704. // JA: just a quick implementation because I need it :)
  5705. if (strcmp(sep->arg[0], "zoneto") == 0)
  5706. {
  5707. if( sep->IsNumber(1) )
  5708. {
  5709. int32 spawn_id = atoul(sep->arg[1]);
  5710. float x_coord = client->GetPlayer()->GetX();
  5711. float y_coord = client->GetPlayer()->GetY();
  5712. float z_coord = client->GetPlayer()->GetZ();
  5713. float h_coord = client->GetPlayer()->GetHeading();
  5714. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5715. }
  5716. else
  5717. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5718. }
  5719. }
  5720. else
  5721. Command_Modify(client);
  5722. }
  5723. /*
  5724. Function: Command_ModifyCharacter()
  5725. Purpose : to replace our other "set" commands
  5726. Params : Action : Add, Remove
  5727. : Field : copper, silver, gold, plat
  5728. : Value : min 1, max unlimited
  5729. : Target : Self, Player
  5730. Dev : Cynnar
  5731. Example : /modify character add gold 50
  5732. : /modify character remove silver 25
  5733. */
  5734. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5735. {
  5736. PrintSep(sep, "COMMAND_MODIFY");
  5737. int64 value = 0;
  5738. Player* player = client->GetPlayer();
  5739. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5740. player = (Player*)player->GetTarget();
  5741. // need at least 2 args for a valid command
  5742. if( sep && sep->arg[1] )
  5743. {
  5744. if (strcmp(sep->arg[0], "add") == 0)
  5745. {
  5746. if (strcmp(sep->arg[1], "copper") == 0)
  5747. {
  5748. value = atoi64(sep->arg[2]);
  5749. player->AddCoins(value);
  5750. if (client->GetPlayer() == player)
  5751. {
  5752. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5753. }
  5754. else {
  5755. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5756. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5757. }
  5758. }
  5759. else if (strcmp(sep->arg[1], "silver") == 0)
  5760. {
  5761. value = atoi64(sep->arg[2]) * 100;
  5762. player->AddCoins(value);
  5763. if (client->GetPlayer() == player)
  5764. {
  5765. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5766. }
  5767. else {
  5768. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5769. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5770. }
  5771. }
  5772. else if (strcmp(sep->arg[1], "gold") == 0)
  5773. {
  5774. value = atoi64(sep->arg[2]) * 10000;
  5775. player->AddCoins(value);
  5776. if (client->GetPlayer() == player)
  5777. {
  5778. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5779. }
  5780. else {
  5781. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5782. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5783. }
  5784. }
  5785. else if (strcmp(sep->arg[1], "plat") == 0)
  5786. {
  5787. value = atoi64(sep->arg[2]) * 1000000;
  5788. player->AddCoins(value);
  5789. if (client->GetPlayer() == player)
  5790. {
  5791. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5792. }
  5793. else {
  5794. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5795. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5796. }
  5797. }
  5798. else
  5799. {
  5800. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5801. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5802. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5803. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5804. }
  5805. }
  5806. else if (strcmp(sep->arg[0], "remove") == 0)
  5807. {
  5808. if (strcmp(sep->arg[1], "copper") == 0)
  5809. {
  5810. value = atoi64(sep->arg[2]);
  5811. player->RemoveCoins(value);
  5812. if (client->GetPlayer() == player)
  5813. {
  5814. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5815. }
  5816. else {
  5817. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5818. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5819. }
  5820. }
  5821. else if (strcmp(sep->arg[1], "silver") == 0)
  5822. {
  5823. value = atoi64(sep->arg[2]) * 100;
  5824. player->RemoveCoins(value);
  5825. if (client->GetPlayer() == player)
  5826. {
  5827. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5828. }
  5829. else {
  5830. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5831. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5832. }
  5833. }
  5834. else if (strcmp(sep->arg[1], "gold") == 0)
  5835. {
  5836. value = atoi64(sep->arg[2]) * 10000;
  5837. player->RemoveCoins(value);
  5838. if (client->GetPlayer() == player)
  5839. {
  5840. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  5841. }
  5842. else {
  5843. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  5844. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5845. }
  5846. }
  5847. else if (strcmp(sep->arg[1], "plat") == 0)
  5848. {
  5849. value = atoi64(sep->arg[2]) * 1000000;
  5850. player->RemoveCoins(value);
  5851. if (client->GetPlayer() == player)
  5852. {
  5853. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  5854. }
  5855. else {
  5856. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  5857. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5858. }
  5859. }
  5860. else
  5861. {
  5862. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5863. }
  5864. }
  5865. else if (strcmp(sep->arg[0], "set") == 0) {
  5866. if (strcmp(sep->arg[1], "tslevel") == 0) {
  5867. int8 level = atoi(sep->arg[2]);
  5868. if (level > 0 && level < 256) {
  5869. if (player) {
  5870. if (client->GetPlayer() == player)
  5871. client->ChangeTSLevel(player->GetTSLevel(), level);
  5872. else
  5873. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  5874. }
  5875. }
  5876. else
  5877. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  5878. }
  5879. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  5880. int8 tsclass = atoi(sep->arg[2]);
  5881. player->SetTradeskillClass(tsclass);
  5882. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  5883. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  5884. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  5885. player->SetCharSheetChanged(true);
  5886. }
  5887. }
  5888. }
  5889. else
  5890. {
  5891. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5892. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5893. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5894. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5895. }
  5896. }
  5897. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  5898. {
  5899. PrintSep(sep, "COMMAND_MODIFY");
  5900. // need at least 2 args for a valid command
  5901. if( sep && sep->arg[1] )
  5902. {
  5903. }
  5904. else
  5905. Command_Modify(client);
  5906. }
  5907. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  5908. {
  5909. PrintSep(sep, "COMMAND_MODIFY");
  5910. // need at least 2 args for a valid command
  5911. if( sep && sep->arg[1] )
  5912. {
  5913. }
  5914. else
  5915. Command_Modify(client);
  5916. }
  5917. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  5918. {
  5919. PrintSep(sep, "COMMAND_MODIFY");
  5920. // need at least 2 args for a valid command
  5921. if( sep && sep->arg[1] )
  5922. {
  5923. }
  5924. else
  5925. Command_Modify(client);
  5926. }
  5927. /*
  5928. Function: Command_ModifyQuest()
  5929. Purpose : to list players quest and completed quests
  5930. Params : Action : list, completed
  5931. : Target : Self, Player
  5932. Dev : Cynnar
  5933. Example : /modify quest list
  5934. : /modify quest completed
  5935. */
  5936. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  5937. {
  5938. PrintSep(sep, "COMMAND_MODIFY");
  5939. int64 value = 0;
  5940. Player* player = client->GetPlayer();
  5941. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5942. player = (Player*)player->GetTarget();
  5943. // need at least 2 args for a valid command
  5944. if (sep && sep->arg[1])
  5945. {
  5946. if (strcmp(sep->arg[0], "list") == 0)
  5947. {
  5948. map<int32, Quest*>* quests = player->GetPlayerQuests();
  5949. map<int32, Quest*>::iterator itr;
  5950. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  5951. if (quests->size() == 0)
  5952. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  5953. else
  5954. {
  5955. for (itr = quests->begin(); itr != quests->end(); itr++)
  5956. {
  5957. Quest* quest = itr->second;
  5958. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5959. }
  5960. }
  5961. }
  5962. else if (strcmp(sep->arg[0], "completed") == 0)
  5963. {
  5964. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  5965. map<int32, Quest*>::iterator itr;
  5966. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  5967. if (quests->size() == 0)
  5968. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  5969. else
  5970. {
  5971. for (itr = quests->begin(); itr != quests->end(); itr++)
  5972. {
  5973. Quest* quest = itr->second;
  5974. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5975. }
  5976. }
  5977. }
  5978. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  5979. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  5980. else if (strcmp(sep->arg[0], "remove") == 0)
  5981. {
  5982. int32 quest_id = 0;
  5983. if (sep && sep->arg[1] && sep->IsNumber(1))
  5984. quest_id = atoul(sep->arg[1]);
  5985. if (quest_id > 0)
  5986. {
  5987. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  5988. {
  5989. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5990. if (quest)
  5991. if (client->GetPlayer() == player)
  5992. {
  5993. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  5994. }
  5995. else
  5996. {
  5997. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  5998. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  5999. }
  6000. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  6001. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  6002. }
  6003. client->RemovePlayerQuest(quest_id);
  6004. client->GetCurrentZone()->SendQuestUpdates(client);
  6005. }
  6006. }
  6007. else if (strcmp(sep->arg[0], "advance") == 0)
  6008. {
  6009. int32 quest_id = 0;
  6010. int32 step = 0;
  6011. if (sep && sep->arg[1] && sep->IsNumber(1))
  6012. {
  6013. quest_id = atoul(sep->arg[1]);
  6014. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6015. if (sep && sep->arg[2] && sep->IsNumber(1))
  6016. {
  6017. step = atoul(sep->arg[2]);
  6018. if (quest_id > 0 && step > 0)
  6019. {
  6020. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  6021. {
  6022. if (client)
  6023. {
  6024. client->AddPendingQuestUpdate(quest_id, step);
  6025. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  6026. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  6027. }
  6028. }
  6029. }
  6030. else
  6031. {
  6032. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  6033. }
  6034. }
  6035. else
  6036. {
  6037. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  6038. }
  6039. }
  6040. else
  6041. {
  6042. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  6043. }
  6044. }
  6045. else
  6046. {
  6047. Command_Modify(client);
  6048. }
  6049. }
  6050. else
  6051. {
  6052. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  6053. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  6054. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  6055. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  6056. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  6057. }
  6058. }
  6059. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  6060. {
  6061. PrintSep(sep, "COMMAND_MODIFY");
  6062. // need at least 2 args for a valid command
  6063. if( sep && sep->arg[1] )
  6064. {
  6065. if (strcmp(sep->arg[0], "add") == 0) {
  6066. const char* skill_name = sep->argplus[1];
  6067. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6068. if (skill) {
  6069. Player* player = 0;
  6070. Client* to_client = 0;
  6071. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6072. player = (Player*)client->GetPlayer()->GetTarget();
  6073. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6074. }
  6075. else {
  6076. player = client->GetPlayer();
  6077. to_client = client;
  6078. }
  6079. if (player)
  6080. {
  6081. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6082. {
  6083. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6084. if (to_client == client) {
  6085. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  6086. }
  6087. else {
  6088. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6089. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6090. }
  6091. }
  6092. else
  6093. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  6094. }
  6095. }
  6096. else
  6097. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6098. }
  6099. else if (strcmp(sep->arg[0], "remove") == 0) {
  6100. const char* skill_name = sep->argplus[1];
  6101. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6102. if (skill) {
  6103. Player* player = 0;
  6104. Client* to_client = 0;
  6105. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6106. player = (Player*)client->GetPlayer()->GetTarget();
  6107. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6108. }
  6109. else {
  6110. player = client->GetPlayer();
  6111. to_client = client;
  6112. }
  6113. if (player)
  6114. {
  6115. if (player->GetSkills()->HasSkill(skill->skill_id))
  6116. {
  6117. player->RemoveSkillFromDB(skill, true);
  6118. if (client == to_client) {
  6119. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  6120. }
  6121. else {
  6122. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6123. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6124. }
  6125. }
  6126. else {
  6127. if (client == to_client)
  6128. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  6129. else
  6130. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6131. }
  6132. }
  6133. }
  6134. else
  6135. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6136. }
  6137. else if (strcmp(sep->arg[0], "set") == 0) {
  6138. if (!sep->IsNumber(2)) {
  6139. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  6140. return;
  6141. }
  6142. const char* skill_name = sep->arg[1];
  6143. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6144. if (skill) {
  6145. int16 val = atoi(sep->arg[2]);
  6146. Player* player = 0;
  6147. Client* to_client = 0;
  6148. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6149. player = (Player*)client->GetPlayer()->GetTarget();
  6150. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6151. }
  6152. else {
  6153. player = client->GetPlayer();
  6154. to_client = client;
  6155. }
  6156. if (player)
  6157. {
  6158. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6159. player->GetSkills()->SetSkill(skill->skill_id, val);
  6160. if (client != to_client)
  6161. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6162. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6163. }
  6164. else {
  6165. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6166. }
  6167. }
  6168. }
  6169. else {
  6170. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6171. }
  6172. }
  6173. else {
  6174. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6175. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6176. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6177. }
  6178. }
  6179. else {
  6180. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6181. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6182. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6183. }
  6184. }
  6185. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6186. {
  6187. PrintSep(sep, "COMMAND_MODIFY");
  6188. // need at least 2 args for a valid command
  6189. if( sep && sep->arg[1] )
  6190. {
  6191. }
  6192. else
  6193. Command_Modify(client);
  6194. }
  6195. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6196. {
  6197. PrintSep(sep, "COMMAND_MODIFY");
  6198. // need at least 2 args for a valid command
  6199. if( sep && sep->arg[1] )
  6200. {
  6201. }
  6202. else
  6203. Command_Modify(client);
  6204. }
  6205. /*
  6206. Function: Command_MOTD()
  6207. Purpose : Displays server MOTD
  6208. Params :
  6209. Dev : LethalEncounter
  6210. Example : /motd
  6211. */
  6212. void Commands::Command_MOTD(Client* client)
  6213. {
  6214. if (client)
  6215. ClientPacketFunctions::SendMOTD(client);
  6216. }
  6217. /*
  6218. Function: Command_Pet()
  6219. Purpose : Handle Pet {Command} commands
  6220. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6221. Dev :
  6222. Example : /pet preserve_master
  6223. */
  6224. void Commands::Command_Pet(Client* client, Seperator* sep)
  6225. {
  6226. PrintSep(sep, "COMMAND_PET");
  6227. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6228. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6229. if (strcmp(sep->arg[0], "hide") == 0) {
  6230. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6231. Entity* pet = client->GetPlayer()->GetDeityPet();
  6232. if (pet) {
  6233. if (pet->IsPrivateSpawn())
  6234. client->GetPlayer()->HideDeityPet(false);
  6235. else
  6236. client->GetPlayer()->HideDeityPet(true);
  6237. }
  6238. pet = client->GetPlayer()->GetCosmeticPet();
  6239. if (pet) {
  6240. if (pet->IsPrivateSpawn())
  6241. client->GetPlayer()->HideCosmeticPet(false);
  6242. else
  6243. client->GetPlayer()->HideCosmeticPet(true);
  6244. }
  6245. return;
  6246. }
  6247. // below is for all combat pets
  6248. if (!client->GetPlayer()->HasPet()) {
  6249. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6250. return;
  6251. }
  6252. if (strcmp(sep->arg[0], "stay") == 0) {
  6253. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6254. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  6255. client->GetPlayer()->SetCharSheetChanged(true);
  6256. if (client->GetPlayer()->GetPet())
  6257. client->GetPlayer()->GetPet()->following = false;
  6258. if (client->GetPlayer()->GetCharmedPet())
  6259. client->GetPlayer()->GetCharmedPet()->following = false;
  6260. }
  6261. else if (strcmp(sep->arg[0], "follow") == 0) {
  6262. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6263. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  6264. client->GetPlayer()->SetCharSheetChanged(true);
  6265. }
  6266. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6267. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  6268. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6269. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  6270. }
  6271. else {
  6272. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6273. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  6274. }
  6275. client->GetPlayer()->SetCharSheetChanged(true);
  6276. }
  6277. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6278. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  6279. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6280. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  6281. }
  6282. else {
  6283. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6284. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  6285. }
  6286. client->GetPlayer()->SetCharSheetChanged(true);
  6287. }
  6288. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6289. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6290. if (client->GetPlayer()->GetPet())
  6291. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6292. if (client->GetPlayer()->GetCharmedPet())
  6293. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6294. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  6295. client->GetPlayer()->SetCharSheetChanged(true);
  6296. }
  6297. else if (strcmp(sep->arg[0], "attack") == 0) {
  6298. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6299. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6300. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6301. if (client->GetPlayer()->GetPet())
  6302. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6303. if (client->GetPlayer()->GetCharmedPet())
  6304. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6305. }
  6306. else
  6307. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6308. }
  6309. else
  6310. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6311. }
  6312. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6313. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6314. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6315. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6316. }
  6317. else
  6318. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6319. }
  6320. /*
  6321. Function: Command_PetName()
  6322. Purpose : Pet your name (???)
  6323. Params :
  6324. Dev :
  6325. Example :
  6326. */
  6327. void Commands::Command_PetName(Client* client, Seperator* sep)
  6328. {
  6329. PrintSep(sep, "COMMAND_PETNAME");
  6330. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6331. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6332. }
  6333. /*
  6334. Function: Command_NamePet()
  6335. Purpose : Name your pet
  6336. Params :
  6337. Dev :
  6338. Example :
  6339. */
  6340. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6341. {
  6342. PrintSep(sep, "COMMAND_NAME_PET");
  6343. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6344. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6345. }
  6346. /*
  6347. Function: Command_Rename()
  6348. Purpose : Renames existing pet
  6349. Params :
  6350. Dev :
  6351. Example :
  6352. */
  6353. void Commands::Command_Rename(Client* client, Seperator* sep)
  6354. {
  6355. PrintSep(sep, "COMMAND_RENAME");
  6356. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6357. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6358. }
  6359. /*
  6360. Function: Command_ConfirmRename()
  6361. Purpose : Confirms renaming your pet
  6362. Params :
  6363. Dev :
  6364. Example :
  6365. */
  6366. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6367. {
  6368. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6369. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6370. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6371. }
  6372. /*
  6373. Function: Command_PetOptions()
  6374. Purpose : Sets various pet options
  6375. Params :
  6376. Dev :
  6377. Example :
  6378. */
  6379. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6380. {
  6381. PrintSep(sep, "COMMAND_PETOPTIONS");
  6382. Player* player = client->GetPlayer();
  6383. Spawn* target = player->GetTarget();
  6384. if (!target)
  6385. return;
  6386. if (target == player->GetPet())
  6387. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6388. else if (target == player->GetCharmedPet())
  6389. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6390. else if (target == player->GetCosmeticPet())
  6391. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6392. else if (target == player->GetDeityPet())
  6393. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6394. }
  6395. /*
  6396. Function: Command_Random()
  6397. Purpose : Handles /random dice roll in-game
  6398. Params : 1-100
  6399. Dev : Scatman
  6400. Example : /randon 1 100
  6401. */
  6402. void Commands::Command_Random(Client* client, Seperator* sep)
  6403. {
  6404. char message[256] = {0};
  6405. if (sep)
  6406. {
  6407. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6408. 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])));
  6409. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6410. 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])));
  6411. else
  6412. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6413. }
  6414. else
  6415. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6416. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6417. }
  6418. /*
  6419. Function: Command_Randomize()
  6420. Purpose : Sets randomize (appearance) values for NPCs
  6421. Params : Attrib Name
  6422. Dev : Scatman
  6423. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6424. */
  6425. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6426. {
  6427. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6428. if (target)
  6429. {
  6430. if (target->IsNPC())
  6431. {
  6432. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6433. {
  6434. const char* value = sep->arg[0];
  6435. if (strncasecmp(value, "show", strlen(value)) == 0)
  6436. {
  6437. client->DisplayRandomizeFeatures(target->GetRandomize());
  6438. }
  6439. else
  6440. {
  6441. if (sep->arg[1] && sep->IsNumber(1))
  6442. {
  6443. int8 option = atoi(sep->arg[1]);
  6444. if (option == 0 || option == 1)
  6445. {
  6446. int32 feature = 0;
  6447. char feature_text[32] = {0};
  6448. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6449. feature = RANDOMIZE_GENDER;
  6450. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6451. }
  6452. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6453. feature = RANDOMIZE_RACE;
  6454. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6455. }
  6456. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6457. feature = RANDOMIZE_MODEL_TYPE;
  6458. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6459. }
  6460. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6461. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6462. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6463. }
  6464. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6465. feature = RANDOMIZE_HAIR_TYPE;
  6466. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6467. }
  6468. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6469. feature = RANDOMIZE_WING_TYPE;
  6470. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6471. }
  6472. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6473. feature = RANDOMIZE_CHEEK_TYPE;
  6474. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6475. }
  6476. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6477. feature = RANDOMIZE_CHIN_TYPE;
  6478. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6479. }
  6480. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6481. feature = RANDOMIZE_EAR_TYPE;
  6482. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6483. }
  6484. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6485. feature = RANDOMIZE_EYE_BROW_TYPE;
  6486. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6487. }
  6488. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6489. feature = RANDOMIZE_EYE_TYPE;
  6490. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6491. }
  6492. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6493. feature = RANDOMIZE_LIP_TYPE;
  6494. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6495. }
  6496. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6497. feature = RANDOMIZE_NOSE_TYPE;
  6498. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6499. }
  6500. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6501. feature = RANDOMIZE_EYE_COLOR;
  6502. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6503. }
  6504. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6505. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6506. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6507. }
  6508. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6509. feature = RANDOMIZE_HAIR_COLOR1;
  6510. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6511. }
  6512. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6513. feature = RANDOMIZE_HAIR_COLOR2;
  6514. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6515. }
  6516. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6517. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6518. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6519. }
  6520. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6521. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6522. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6523. }
  6524. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6525. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6526. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6527. }
  6528. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6529. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6530. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6531. }
  6532. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6533. feature = RANDOMIZE_SKIN_COLOR;
  6534. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6535. }
  6536. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6537. feature = RANDOMIZE_WING_COLOR1;
  6538. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6539. }
  6540. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6541. feature = RANDOMIZE_WING_COLOR2;
  6542. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6543. }
  6544. else {
  6545. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6546. 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'.");
  6547. }
  6548. if (feature > 0) {
  6549. if (option == 1) {
  6550. if (target->GetRandomize() & feature)
  6551. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6552. else {
  6553. target->AddRandomize(feature);
  6554. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6555. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6556. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6557. }
  6558. }
  6559. else {
  6560. if (target->GetRandomize() & feature) {
  6561. target->AddRandomize(-feature);
  6562. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6563. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6564. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6565. }
  6566. else
  6567. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6568. }
  6569. }
  6570. }
  6571. else
  6572. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6573. }
  6574. else
  6575. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6576. }
  6577. }
  6578. else {
  6579. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6580. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6581. 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'.");
  6582. }
  6583. }
  6584. else
  6585. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6586. }
  6587. else
  6588. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6589. }
  6590. /*
  6591. Function: Command_ShowCloak()
  6592. Purpose : Character Settings combo box for Show Cloak
  6593. Params : true/false
  6594. Dev : John Adams
  6595. Example :
  6596. */
  6597. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6598. {
  6599. Player* player = client->GetPlayer();
  6600. if (sep && sep->arg[0])
  6601. {
  6602. const char* value = sep->arg[0];
  6603. if (strncasecmp(value, "true", strlen(value)) == 0)
  6604. {
  6605. player->set_character_flag(CF_SHOW_CLOAK);
  6606. player->reset_character_flag(CF2_SHOW_RANGED);
  6607. }
  6608. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6609. player->reset_character_flag(CF_SHOW_CLOAK);
  6610. else
  6611. {
  6612. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6613. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6614. }
  6615. }
  6616. }
  6617. /*
  6618. Function: Command_ShowHelm()
  6619. Purpose : Character Settings combo box for Show Helm
  6620. Params : true/false
  6621. Dev : John Adams
  6622. Example :
  6623. */
  6624. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6625. {
  6626. Player* player = client->GetPlayer();
  6627. if (sep && sep->arg[0])
  6628. {
  6629. const char* value = sep->arg[0];
  6630. if (strncasecmp(value, "true", strlen(value)) == 0)
  6631. {
  6632. player->reset_character_flag(CF_HIDE_HELM);
  6633. player->set_character_flag(CF_HIDE_HOOD);
  6634. }
  6635. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6636. player->set_character_flag(CF_HIDE_HELM);
  6637. else
  6638. {
  6639. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6640. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6641. }
  6642. }
  6643. }
  6644. /*
  6645. Function: Command_ShowHood()
  6646. Purpose : Character Settings combo box for Show Hood
  6647. Params : true/false
  6648. Dev : John Adams
  6649. Example :
  6650. */
  6651. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6652. {
  6653. Player* player = client->GetPlayer();
  6654. if (sep && sep->arg[0])
  6655. {
  6656. const char* value = sep->arg[0];
  6657. if (strncasecmp(value, "true", strlen(value)) == 0)
  6658. {
  6659. player->reset_character_flag(CF_HIDE_HOOD);
  6660. player->set_character_flag(CF_HIDE_HELM);
  6661. }
  6662. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6663. player->set_character_flag(CF_HIDE_HOOD);
  6664. else
  6665. {
  6666. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6667. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6668. }
  6669. }
  6670. }
  6671. /*
  6672. Function: Command_ShowHoodHelm()
  6673. Purpose : Character Settings combo box for Show Helm or Hood
  6674. Params : true/false
  6675. Dev : John Adams
  6676. Example :
  6677. */
  6678. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6679. {
  6680. Player* player = client->GetPlayer();
  6681. if (sep && sep->arg[0])
  6682. {
  6683. const char* value = sep->arg[0];
  6684. if (strncasecmp(value, "true", strlen(value)) == 0)
  6685. {
  6686. player->reset_character_flag(CF_HIDE_HOOD);
  6687. player->reset_character_flag(CF_HIDE_HELM);
  6688. }
  6689. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6690. {
  6691. // don't think we ever wind up in here...
  6692. player->set_character_flag(CF_HIDE_HOOD);
  6693. player->set_character_flag(CF_HIDE_HELM);
  6694. }
  6695. else
  6696. {
  6697. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6698. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6699. }
  6700. }
  6701. }
  6702. /*
  6703. Function: Command_ShowRanged()
  6704. Purpose : Character Settings combo box for Show Ranged weapon
  6705. Params : true/false
  6706. Dev : John Adams
  6707. Example :
  6708. */
  6709. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6710. {
  6711. Player* player = client->GetPlayer();
  6712. if (sep && sep->arg[0])
  6713. {
  6714. const char* value = sep->arg[0];
  6715. if (strncasecmp(value, "true", strlen(value)) == 0)
  6716. {
  6717. player->set_character_flag(CF2_SHOW_RANGED);
  6718. player->reset_character_flag(CF_SHOW_CLOAK);
  6719. }
  6720. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6721. player->reset_character_flag(CF2_SHOW_RANGED);
  6722. else
  6723. {
  6724. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6725. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6726. }
  6727. }
  6728. }
  6729. /*
  6730. Function:
  6731. Purpose :
  6732. Params :
  6733. Dev :
  6734. Example :
  6735. */
  6736. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6737. {
  6738. Player* player = 0;
  6739. Client* to_client = 0;
  6740. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6741. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6742. switch(handler)
  6743. {
  6744. case COMMAND_SKILL:
  6745. {
  6746. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6747. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6748. break;
  6749. }
  6750. case COMMAND_SKILL_ADD:
  6751. {
  6752. if (sep && sep->arg[0])
  6753. {
  6754. const char* skill_name = sep->argplus[0];
  6755. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6756. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6757. {
  6758. player = to_client->GetPlayer();
  6759. if (player)
  6760. {
  6761. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6762. {
  6763. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6764. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6765. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6766. }
  6767. else
  6768. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6769. }
  6770. }
  6771. else if (skill) // add skill to yourself
  6772. {
  6773. player = client->GetPlayer();
  6774. if (player)
  6775. {
  6776. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6777. {
  6778. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6779. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6780. }
  6781. else
  6782. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6783. }
  6784. }
  6785. else
  6786. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6787. }
  6788. else
  6789. {
  6790. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6791. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6792. }
  6793. break;
  6794. }
  6795. case COMMAND_SKILL_REMOVE:
  6796. {
  6797. if (sep && sep->arg[0])
  6798. {
  6799. const char* skill_name = sep->argplus[0];
  6800. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6801. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6802. {
  6803. player = to_client->GetPlayer();
  6804. if (player)
  6805. {
  6806. if (player->GetSkills()->HasSkill(skill->skill_id))
  6807. {
  6808. player->RemoveSkillFromDB(skill, true);
  6809. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6810. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6811. }
  6812. else
  6813. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6814. }
  6815. }
  6816. else if(skill) // remove skill from yourself
  6817. {
  6818. Player* player = client->GetPlayer();
  6819. if (player)
  6820. {
  6821. if (player->GetSkills()->HasSkill(skill->skill_id))
  6822. {
  6823. player->RemoveSkillFromDB(skill, true);
  6824. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6825. }
  6826. else
  6827. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6828. }
  6829. }
  6830. else
  6831. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6832. }
  6833. else
  6834. {
  6835. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  6836. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6837. }
  6838. break;
  6839. }
  6840. case COMMAND_SKILL_LIST:
  6841. {
  6842. if (sep && sep->arg[0])
  6843. {
  6844. const char* skill_name = sep->argplus[0];
  6845. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  6846. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  6847. map<int32, Skill*>::iterator itr;
  6848. if (skills && skills->size() > 0)
  6849. {
  6850. for (itr = skills->begin(); itr != skills->end(); itr++)
  6851. {
  6852. Skill* skill = itr->second;
  6853. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  6854. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  6855. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  6856. }
  6857. }
  6858. }
  6859. else
  6860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  6861. break;
  6862. }
  6863. }
  6864. }
  6865. /*
  6866. Function: Command_SpawnTemplate()
  6867. Purpose : Create or Use defined Spawn Templates
  6868. Params : create, save, rempve, list
  6869. Dev : John Adams
  6870. Example : /spawn template create "Test"
  6871. */
  6872. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  6873. {
  6874. if (sep == NULL || sep->arg[0] == NULL)
  6875. {
  6876. 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.");
  6877. return;
  6878. }
  6879. // got params, continue
  6880. const char * template_cmd = sep->arg[0];
  6881. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  6882. {
  6883. if (!sep->IsSet(1))
  6884. {
  6885. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  6886. 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.");
  6887. return;
  6888. }
  6889. map<int32, string>* template_names = 0;
  6890. if (sep->IsNumber(1))
  6891. {
  6892. int32 location_id = 0;
  6893. location_id = atoi(sep->arg[1]);
  6894. template_names = database.GetSpawnTemplateListByID(location_id);
  6895. }
  6896. else
  6897. {
  6898. const char* name = 0;
  6899. name = sep->argplus[1];
  6900. template_names = database.GetSpawnTemplateListByName(name);
  6901. }
  6902. if(!template_names)
  6903. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  6904. else
  6905. {
  6906. map<int32, string>::iterator itr;
  6907. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  6908. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  6909. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  6910. safe_delete(template_names);
  6911. }
  6912. }
  6913. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  6914. {
  6915. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6916. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  6917. {
  6918. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  6919. {
  6920. // first, lookup to see if template name already exists
  6921. const char* name = 0;
  6922. name = sep->argplus[1];
  6923. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  6924. if(!template_names)
  6925. {
  6926. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  6927. if( new_template_id > 0 )
  6928. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  6929. else
  6930. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  6931. }
  6932. else
  6933. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  6934. }
  6935. else
  6936. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  6937. }
  6938. else
  6939. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  6940. }
  6941. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  6942. {
  6943. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  6944. {
  6945. int32 template_id = 0;
  6946. template_id = atoi(sep->arg[1]);
  6947. if (database.RemoveSpawnTemplate(template_id))
  6948. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  6949. else
  6950. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  6951. }
  6952. else
  6953. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  6954. }
  6955. // Renamed create to spawn
  6956. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  6957. {
  6958. if (sep && sep->arg[1][0])
  6959. {
  6960. int32 new_location = 0;
  6961. if (sep->IsNumber(1))
  6962. {
  6963. int32 template_id = 0;
  6964. template_id = atoi(sep->arg[1]);
  6965. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  6966. if( new_location > 0 )
  6967. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  6968. else
  6969. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  6970. }
  6971. else
  6972. {
  6973. const char* name = 0;
  6974. name = sep->argplus[1];
  6975. new_location = database.CreateSpawnFromTemplateByName(client, name);
  6976. if( new_location > 0 )
  6977. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  6978. else
  6979. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  6980. }
  6981. }
  6982. else
  6983. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  6984. }
  6985. else
  6986. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  6987. }
  6988. void Commands::Command_Speed(Client* client, Seperator* sep) {
  6989. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  6990. float new_speed = atof(sep->arg[0]);
  6991. if (new_speed > 0.0f)
  6992. {
  6993. client->GetPlayer()->SetSpeed(new_speed, true);
  6994. client->GetPlayer()->SetCharSheetChanged(true);
  6995. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  6996. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  6997. }
  6998. else
  6999. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  7000. }
  7001. else{
  7002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  7003. }
  7004. }
  7005. /*
  7006. Function: Command_StationMarketPlace()
  7007. Purpose : just trying to eat the console spam for now
  7008. Params :
  7009. Dev : John
  7010. */
  7011. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  7012. {
  7013. PrintSep(sep, "COMMAND_SMP");
  7014. // This will reduce the spam from once every 10 sec to once every 30 sec,
  7015. // can't seem to reduce it any more get rid of it completely...
  7016. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  7017. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  7018. if (packet) {
  7019. packet->setDataByName("account_id", client->GetAccountID());
  7020. packet->setDataByName("character_id", client->GetCharacterID());
  7021. packet->setDataByName("unknown1", 1, 5);
  7022. packet->setDataByName("unknown1", 26, 6);
  7023. packet->setDataByName("unknown2", 0xFFFFFFFF);
  7024. packet->setDataByName("unknown3", 248, 1);
  7025. client->QueuePacket(packet->serialize());
  7026. }
  7027. safe_delete(packet);
  7028. }
  7029. }
  7030. /*
  7031. Function: Command_StopDrinking()
  7032. Purpose : Stops player from auto-consuming drink
  7033. Params :
  7034. Dev : Zcoretri
  7035. Example : /stopdrinking
  7036. */
  7037. void Commands::Command_StopDrinking(Client* client)
  7038. {
  7039. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  7040. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  7041. }
  7042. /*
  7043. Function: Command_StopEating()
  7044. Purpose : Stops player from auto-consuming food
  7045. Params :
  7046. Dev : Zcoretri
  7047. Example : /stopeating
  7048. */
  7049. void Commands::Command_StopEating(Client* client)
  7050. {
  7051. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  7052. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  7053. }
  7054. /*
  7055. Function: Command_Title()
  7056. Purpose : Help for /title command
  7057. Params : n/a
  7058. Dev : Zcoretri
  7059. Example : /title
  7060. */
  7061. void Commands::Command_Title(Client* client)
  7062. {
  7063. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  7064. }
  7065. /*
  7066. Function: Command_TitleList()
  7067. Purpose : List available titles for player
  7068. Params : n/a
  7069. Dev : Zcoretri
  7070. Example : /title list
  7071. */
  7072. void Commands::Command_TitleList(Client* client)
  7073. {
  7074. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  7075. list<Title*>::iterator itr;
  7076. Title* title;
  7077. int16 i = 0;
  7078. client->Message(CHANNEL_COLOR_WHITE, "Listing available titles:");
  7079. for(itr = titles->begin(); itr != titles->end(); itr++)
  7080. {
  7081. title = *itr;
  7082. client->Message(CHANNEL_COLOR_WHITE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  7083. i++;
  7084. }
  7085. }
  7086. /*
  7087. Function: Command_TitleSetPrefix()
  7088. Purpose : Set Prefix title for player
  7089. Params : Title ID
  7090. Dev : Zcoretri
  7091. Example : /title setprefix 1
  7092. */
  7093. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  7094. {
  7095. if (sep && sep->arg[0] && sep->IsNumber(0))
  7096. {
  7097. int32 index = atoul(sep->arg[0]);
  7098. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  7099. client->SendTitleUpdate();
  7100. }
  7101. }
  7102. /*
  7103. Function: Command_TitleSetSuffix()
  7104. Purpose : Set Suffix title for player
  7105. Params : Title ID
  7106. Dev : Zcoretri
  7107. Example : /title setsuffix 1
  7108. */
  7109. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  7110. {
  7111. if (sep && sep->arg[0] && sep->IsNumber(0))
  7112. {
  7113. int32 index = atoul(sep->arg[0]);
  7114. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  7115. client->SendTitleUpdate();
  7116. }
  7117. }
  7118. /*
  7119. Function: Command_TitleFix()
  7120. Purpose : Fix title for player (???)
  7121. Params :
  7122. Dev : Zcoretri
  7123. Example :
  7124. */
  7125. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  7126. {
  7127. PrintSep(sep, "COMMAND_TITLE_FIX");
  7128. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  7129. }
  7130. /*
  7131. Function: Command_Toggle_Anonymous()
  7132. Purpose : Toggles player Anonymous
  7133. Params :
  7134. Dev : paulgh
  7135. Example : /anon
  7136. */
  7137. void Commands::Command_Toggle_Anonymous(Client* client)
  7138. {
  7139. Player* player = client->GetPlayer();
  7140. player->toggle_character_flag(CF_ANONYMOUS);
  7141. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  7142. if (player->get_character_flag(CF_ANONYMOUS))
  7143. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  7144. else
  7145. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  7146. }
  7147. /*
  7148. Function: Command_Toggle_AutoConsume()
  7149. Purpose : Toggles player food/drink auto consume
  7150. Params : unknown
  7151. Dev : paulgh
  7152. Example : /set_auto_consume
  7153. */
  7154. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7155. {
  7156. Player* player = client->GetPlayer();
  7157. if (sep && sep->arg[0])
  7158. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7159. if (sep && sep->arg[0] && sep->IsNumber(0))
  7160. {
  7161. int8 slot = atoi(sep->arg[0]);
  7162. int8 flag = atoi(sep->arg[1]);
  7163. if (slot == EQ2_FOOD_SLOT)
  7164. {
  7165. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7166. player->SetCharSheetChanged(true);
  7167. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7168. if (flag == 1)
  7169. client->Message(CHANNEL_COLOR_WHITE, "You decide to eat immediately whenever you become hungry.");
  7170. else
  7171. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the hunger.");
  7172. }
  7173. else
  7174. {
  7175. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7176. player->SetCharSheetChanged(true);
  7177. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7178. if (flag == 1)
  7179. client->Message(CHANNEL_COLOR_WHITE, "You decide to drink immediately whenever you become thirsty.");
  7180. else
  7181. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the thirst.");
  7182. }
  7183. }
  7184. }
  7185. /*
  7186. Function: Command_Toggle_BonusXP()
  7187. Purpose : Toggles player Bonus XP
  7188. Params :
  7189. Dev : John Adams
  7190. Example : /disable_char_bonus_exp
  7191. */
  7192. void Commands::Command_Toggle_BonusXP(Client* client)
  7193. {
  7194. Player* player = client->GetPlayer();
  7195. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7196. player->SetCharSheetChanged(true);
  7197. }
  7198. /*
  7199. Function: Command_Toggle_CombatXP()
  7200. Purpose : Toggles player Adventure XP
  7201. Params :
  7202. Dev : John Adams
  7203. Example : /disable_combat_exp
  7204. */
  7205. void Commands::Command_Toggle_CombatXP(Client* client)
  7206. {
  7207. Player* player = client->GetPlayer();
  7208. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7209. player->SetCharSheetChanged(true);
  7210. }
  7211. /*
  7212. Function: Command_Toggle_GMHide()
  7213. Purpose : Toggles hiding player GM status
  7214. Params :
  7215. Dev : Scatman
  7216. Example : /gm_hide
  7217. */
  7218. void Commands::Command_Toggle_GMHide(Client* client)
  7219. {
  7220. Player* player = client->GetPlayer();
  7221. player->toggle_character_flag(CF_HIDE_STATUS);
  7222. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7223. }
  7224. /*
  7225. Function: Command_Toggle_GMVanish()
  7226. Purpose : Toggles hiding GM players from /who searches
  7227. Params :
  7228. Dev : Scatman
  7229. Example : /gm_vanish
  7230. */
  7231. void Commands::Command_Toggle_GMVanish(Client* client)
  7232. {
  7233. Player* player = client->GetPlayer();
  7234. player->toggle_character_flag(CF_GM_HIDDEN);
  7235. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7236. }
  7237. /*
  7238. Function: Command_Toggle_Illusions()
  7239. Purpose : Toggles player illusion form
  7240. Params : not sure sep is needed, testing
  7241. Dev : paulgh
  7242. Example : /hide_illusions
  7243. */
  7244. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7245. {
  7246. if (sep && sep->arg[0])
  7247. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7248. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7249. }
  7250. /*
  7251. Function: Command_Toggle_LFG()
  7252. Purpose : Toggles player LFG Flag
  7253. Params :
  7254. Dev : paulgh
  7255. Example : /lfg
  7256. */
  7257. void Commands::Command_Toggle_LFG(Client* client)
  7258. {
  7259. Player* player = client->GetPlayer();
  7260. player->toggle_character_flag(CF_LFG);
  7261. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7262. if (player->get_character_flag(CF_LFG))
  7263. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7264. else
  7265. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7266. }
  7267. /*
  7268. Function: Command_Toggle_LFW()
  7269. Purpose : Toggles player LFW Flag
  7270. Params :
  7271. Dev : paulgh
  7272. Example : /lfw
  7273. */
  7274. void Commands::Command_Toggle_LFW(Client* client)
  7275. {
  7276. Player* player = client->GetPlayer();
  7277. player->toggle_character_flag(CF_LFW);
  7278. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7279. if (player->get_character_flag(CF_LFW))
  7280. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7281. else
  7282. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7283. }
  7284. /*
  7285. Function: Command_Toggle_QuestXP()
  7286. Purpose : Toggles player Quest XP
  7287. Params :
  7288. Dev : John Adams
  7289. Example : /disable_quest_exp
  7290. */
  7291. void Commands::Command_Toggle_QuestXP(Client* client)
  7292. {
  7293. Player* player = client->GetPlayer();
  7294. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7295. player->SetCharSheetChanged(true);
  7296. }
  7297. /*
  7298. Function: Command_Toggle_Roleplaying()
  7299. Purpose : Toggles player Roleplaying flag
  7300. Params :
  7301. Dev : paulgh
  7302. Example : /role
  7303. */
  7304. void Commands::Command_Toggle_Roleplaying(Client* client)
  7305. {
  7306. Player* player = client->GetPlayer();
  7307. player->toggle_character_flag(CF_ROLEPLAYING);
  7308. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  7309. if (player->get_character_flag(CF_ROLEPLAYING))
  7310. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  7311. else
  7312. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  7313. }
  7314. void Commands::Command_Toggle_Duels(Client* client)
  7315. {
  7316. Player* player = client->GetPlayer();
  7317. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7318. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7319. }
  7320. void Commands::Command_Toggle_Trades(Client* client)
  7321. {
  7322. Player* player = client->GetPlayer();
  7323. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7324. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7325. }
  7326. void Commands::Command_Toggle_Guilds(Client* client)
  7327. {
  7328. Player* player = client->GetPlayer();
  7329. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7330. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7331. }
  7332. void Commands::Command_Toggle_Groups(Client* client)
  7333. {
  7334. Player* player = client->GetPlayer();
  7335. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7336. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7337. }
  7338. void Commands::Command_Toggle_Raids(Client* client)
  7339. {
  7340. Player* player = client->GetPlayer();
  7341. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7342. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7343. }
  7344. void Commands::Command_Toggle_LON(Client* client)
  7345. {
  7346. Player* player = client->GetPlayer();
  7347. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7348. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7349. }
  7350. void Commands::Command_Toggle_VoiceChat(Client* client)
  7351. {
  7352. Player* player = client->GetPlayer();
  7353. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7354. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7355. }
  7356. /*
  7357. Function: Command_TradeStart()
  7358. Purpose : Starts item/coin trade between players
  7359. Params :
  7360. Dev :
  7361. Example :
  7362. */
  7363. #include "../Trade.h"
  7364. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7365. {
  7366. PrintSep(sep, "COMMAND_START_TRADE");
  7367. Entity* trader = client->GetPlayer();
  7368. Entity* trader2 = 0;
  7369. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7370. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7371. if (spawn) {
  7372. if (spawn->IsEntity())
  7373. trader2 = (Entity*)spawn;
  7374. }
  7375. }
  7376. else if (client->GetPlayer()->GetTarget()) {
  7377. if (client->GetPlayer()->GetTarget()->IsEntity())
  7378. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7379. }
  7380. // can only trade with player or bots
  7381. if (trader && trader2) {
  7382. if (trader == trader2) {
  7383. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7384. }
  7385. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7386. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7387. if (trader->trade)
  7388. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7389. else if (trader2->trade)
  7390. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7391. else {
  7392. Trade* trade = new Trade(trader, trader2);
  7393. trader->trade = trade;
  7394. trader2->trade = trade;
  7395. }
  7396. }
  7397. else {
  7398. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  7399. }
  7400. }
  7401. else
  7402. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  7403. }
  7404. /*
  7405. Function: Command_Track()
  7406. Purpose : Starts/Stops Tracking for a player
  7407. Params :
  7408. Dev : Scatman
  7409. Example : /track
  7410. */
  7411. void Commands::Command_Track(Client* client)
  7412. {
  7413. if (!client->GetPlayer()->GetIsTracking())
  7414. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7415. else
  7416. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7417. }
  7418. /*
  7419. Function: Command_TradeAccept()
  7420. Purpose : Accepts item/coin trade between players
  7421. Params :
  7422. Dev :
  7423. Example :
  7424. */
  7425. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7426. {
  7427. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7428. Trade* trade = client->GetPlayer()->trade;
  7429. if (trade) {
  7430. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7431. if (trade_complete)
  7432. safe_delete(trade);
  7433. }
  7434. else
  7435. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7436. }
  7437. /*
  7438. Function: Command_TradeReject()
  7439. Purpose : Rejects item/coin trade between players
  7440. Params :
  7441. Dev :
  7442. Example :
  7443. */
  7444. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7445. {
  7446. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7447. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7448. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7449. }
  7450. /*
  7451. Function: Command_TradeCancel()
  7452. Purpose : Cancels item/coin trade between players
  7453. Params :
  7454. Dev :
  7455. Example :
  7456. */
  7457. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7458. {
  7459. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7460. Trade* trade = client->GetPlayer()->trade;
  7461. if (trade) {
  7462. trade->CancelTrade(client->GetPlayer());
  7463. safe_delete(trade);
  7464. }
  7465. else
  7466. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7467. }
  7468. /*
  7469. Function: Command_TradeSetCoin()
  7470. Purpose : Sets coin trade between players
  7471. Params :
  7472. Dev :
  7473. Example :
  7474. */
  7475. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7476. {
  7477. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7478. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7479. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7480. }
  7481. /*
  7482. Function: Command_TradeAddCoin()
  7483. Purpose : Adds coin to trade between players
  7484. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7485. Dev :
  7486. Example :
  7487. */
  7488. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7489. {
  7490. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7491. Trade* trade = client->GetPlayer()->trade;
  7492. if (trade) {
  7493. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7494. int32 amount = atoi(sep->arg[0]);
  7495. int64 val = 0;
  7496. switch (handler) {
  7497. case COMMAND_ADD_TRADE_COPPER:
  7498. {
  7499. val = amount;
  7500. trade->AddCoinToTrade(client->GetPlayer(), val);
  7501. break;
  7502. }
  7503. case COMMAND_ADD_TRADE_SILVER:
  7504. {
  7505. val = amount * 100;
  7506. trade->AddCoinToTrade(client->GetPlayer(), val);
  7507. break;
  7508. }
  7509. case COMMAND_ADD_TRADE_GOLD:
  7510. {
  7511. val = amount * 10000;
  7512. trade->AddCoinToTrade(client->GetPlayer(), val);
  7513. break;
  7514. }
  7515. case COMMAND_ADD_TRADE_PLAT:
  7516. {
  7517. val = amount * 1000000;
  7518. trade->AddCoinToTrade(client->GetPlayer(), val);
  7519. break;
  7520. }
  7521. default:
  7522. {
  7523. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7524. break;
  7525. }
  7526. }
  7527. }
  7528. else
  7529. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7530. }
  7531. else
  7532. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7533. }
  7534. /*
  7535. Function: Command_TradeRemoveCoin()
  7536. Purpose : Removes coin from trade between players
  7537. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7538. Dev :
  7539. Example :
  7540. */
  7541. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7542. {
  7543. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7544. Trade* trade = client->GetPlayer()->trade;
  7545. if (trade) {
  7546. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7547. int32 amount = atoi(sep->arg[0]);
  7548. int64 val = 0;
  7549. switch (handler) {
  7550. case COMMAND_REMOVE_TRADE_COPPER:
  7551. {
  7552. val = amount;
  7553. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7554. break;
  7555. }
  7556. case COMMAND_REMOVE_TRADE_SILVER:
  7557. {
  7558. val = amount * 100;
  7559. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7560. break;
  7561. }
  7562. case COMMAND_REMOVE_TRADE_GOLD:
  7563. {
  7564. val = amount * 10000;
  7565. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7566. break;
  7567. }
  7568. case COMMAND_REMOVE_TRADE_PLAT:
  7569. {
  7570. val = amount * 1000000;
  7571. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7572. break;
  7573. }
  7574. default:
  7575. {
  7576. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7577. break;
  7578. }
  7579. }
  7580. }
  7581. else
  7582. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7583. }
  7584. else
  7585. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7586. }
  7587. /*
  7588. Function: Command_TradeAddItem()
  7589. Purpose : Adds item to trade between players
  7590. Params :
  7591. Dev :
  7592. Example :
  7593. */
  7594. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7595. {
  7596. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7597. /*
  7598. arg[0] = item index
  7599. arg[1] = slot
  7600. arg[2] = quantity
  7601. */
  7602. if (!client->GetPlayer()->trade) {
  7603. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7604. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7605. return;
  7606. }
  7607. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7608. Item* item = 0;
  7609. int32 index = atoi(sep->arg[0]);
  7610. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7611. if (item) {
  7612. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7613. if (result == 1)
  7614. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7615. else if (result == 2)
  7616. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7617. else if (result == 3)
  7618. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7619. else if (result == 255)
  7620. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7621. }
  7622. else {
  7623. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7624. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7625. }
  7626. }
  7627. else
  7628. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7629. }
  7630. /*
  7631. Function: Command_TradeRemoveItem()
  7632. Purpose : Removes item from trade between players
  7633. Params :
  7634. Dev :
  7635. Example :
  7636. */
  7637. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7638. {
  7639. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7640. /*
  7641. arg[0] = trade window slot
  7642. */
  7643. Trade* trade = client->GetPlayer()->trade;
  7644. if (trade) {
  7645. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7646. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7647. }
  7648. else
  7649. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7650. }
  7651. else
  7652. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7653. }
  7654. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7655. {
  7656. Item *item = 0;
  7657. sint32 crc;
  7658. if (sep) {
  7659. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7660. if (client->GetVersion() < 1096) {
  7661. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7662. {
  7663. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7664. crc = atol(sep->arg[2]);
  7665. }
  7666. }
  7667. else {
  7668. // From the broker and links in chat
  7669. if (strcmp(sep->arg[0], "crc") == 0) {
  7670. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7671. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7672. crc = atol(sep->arg[3]);
  7673. }
  7674. }
  7675. // From inventory
  7676. if (strcmp(sep->arg[0], "dbid") == 0) {
  7677. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7678. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7679. crc = atol(sep->arg[4]);
  7680. }
  7681. }
  7682. }
  7683. if (item)
  7684. client->ShowDressingRoom(item, crc);
  7685. }
  7686. }
  7687. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7688. const char *channel_name, *password = NULL;
  7689. if (sep == NULL || !sep->IsSet(0)) {
  7690. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7691. return;
  7692. }
  7693. channel_name = sep->arg[0];
  7694. if (sep->IsSet(1))
  7695. password = sep->arg[1];
  7696. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7697. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7698. return;
  7699. }
  7700. if (chat.IsInChannel(client, channel_name)) {
  7701. client->Message(CHANNEL_COLOR_WHITE, "You are already in '%s'.", channel_name);
  7702. return;
  7703. }
  7704. if (chat.HasPassword(channel_name)) {
  7705. if (password == NULL) {
  7706. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': That channel is password protected.", channel_name);
  7707. return;
  7708. }
  7709. if (!chat.PasswordMatches(channel_name, password)) {
  7710. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': The password is not correc.t", channel_name);
  7711. return;
  7712. }
  7713. }
  7714. if (!chat.JoinChannel(client, channel_name))
  7715. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7716. }
  7717. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7718. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7719. Command_JoinChannel(client, sep);
  7720. }
  7721. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7722. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7723. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7724. PrintSep(sep, "tellchannel");
  7725. return;
  7726. }
  7727. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7728. }
  7729. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7730. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7731. if (sep->IsSet(0)) {
  7732. if (atoi(sep->arg[0]) == 1) {
  7733. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  7734. if (packet2) {
  7735. packet2->setDataByName("spell_type", 2);
  7736. packet2->setDataByName("spell_id", 8308);
  7737. packet2->setDataByName("spell_name", "Sprint");
  7738. packet2->setDataByName("add_silently", 0);
  7739. packet2->setDataByName("tier", 1);
  7740. packet2->setDataByName("blah1", 1);
  7741. packet2->setDataByName("blah2", 1);
  7742. EQ2Packet* outapp = packet2->serialize();
  7743. DumpPacket(outapp);
  7744. client->QueuePacket(outapp);
  7745. safe_delete(packet2);
  7746. }
  7747. }
  7748. else if (atoi(sep->arg[0]) == 2) {
  7749. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  7750. if (packet2) {
  7751. packet2->setDataByName("guild_name", "Test");
  7752. packet2->setDataByName("guild_motd", "Test MOTD");
  7753. packet2->setDataByName("guild_id", 1234);
  7754. packet2->setDataByName("guild_level", 1);
  7755. packet2->setDataByName("unknown", 2);
  7756. packet2->setDataByName("unknown2", 3);
  7757. packet2->setDataByName("exp_current", 1);
  7758. packet2->setDataByName("exp_to_next_level", 4);
  7759. EQ2Packet* outapp = packet2->serialize();
  7760. DumpPacket(outapp);
  7761. client->QueuePacket(outapp);
  7762. safe_delete(packet2);
  7763. }
  7764. }
  7765. else if (atoi(sep->arg[0]) == 3) {
  7766. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  7767. if (packet2) {
  7768. packet2->setDataByName("guild_id", 1234);
  7769. packet2->setDataByName("character_id", 1);
  7770. packet2->setDataByName("account_id", 2);
  7771. packet2->setDataByName("guild_level", 1);
  7772. packet2->setDataByName("name", "Test");
  7773. packet2->setDataByName("unknown2", 0);
  7774. packet2->setDataByName("unknown3", 1);
  7775. packet2->setDataByName("adventure_class", 6);
  7776. packet2->setDataByName("adventure_level", 7);
  7777. packet2->setDataByName("tradeskill_class", 4);
  7778. packet2->setDataByName("tradeskill_level", 5);
  7779. packet2->setDataByName("rank", 0);
  7780. packet2->setDataByName("member_flags", 2);
  7781. packet2->setDataByName("join_date", 1591112273);
  7782. packet2->setDataByName("guild_status", 2);
  7783. packet2->setDataByName("last_login", 1591132273);
  7784. packet2->setDataByName("recruiter_id", 1);
  7785. packet2->setDataByName("points", 2345);
  7786. packet2->setDataByName("note", "note");
  7787. packet2->setMediumStringByName("officer_note", "O note");
  7788. packet2->setMediumStringByName("zone", "Blah");
  7789. EQ2Packet* outapp = packet2->serialize();
  7790. DumpPacket(outapp);
  7791. client->QueuePacket(outapp);
  7792. safe_delete(packet2);
  7793. }
  7794. }
  7795. else if (atoi(sep->arg[0]) == 5) {
  7796. client->GetPlayer()->GetTarget();
  7797. int16 offset = atoi(sep->arg[2]);
  7798. int32 value1 = atol(sep->arg[4]);
  7799. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  7800. client->QueuePacket(outapp);
  7801. }
  7802. else if (atoi(sep->arg[0]) == 6) {
  7803. Spawn* spawn = client->GetPlayer()->GetTarget();
  7804. if (!spawn)
  7805. spawn = client->GetPlayer();
  7806. else if (spawn->IsEntity())
  7807. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  7808. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  7809. }
  7810. else if (atoi(sep->arg[0]) == 7) {
  7811. int32 id = 0;
  7812. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  7813. if (spawn) {
  7814. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7815. spawn->SetY(client->GetPlayer()->GetY(), false);
  7816. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7817. float heading = client->GetPlayer()->GetHeading() + 180;
  7818. if (heading > 360)
  7819. heading -= 360;
  7820. spawn->SetLevel(5);
  7821. spawn->SetAdventureClass(4);
  7822. spawn->SetHeading(heading, false);
  7823. spawn->SetSpawnOrigX(spawn->GetX());
  7824. spawn->SetSpawnOrigY(spawn->GetY());
  7825. spawn->SetSpawnOrigZ(spawn->GetZ());
  7826. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  7827. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  7828. spawn->appearance.targetable = 1;
  7829. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  7830. spawn->SetTotalHP(spawn->GetLevel() * 15);
  7831. spawn->SetHP(spawn->GetTotalHP());
  7832. }
  7833. if (spawn->GetTotalPower() == 0) {
  7834. spawn->SetTotalPower(spawn->GetLevel() * 15);
  7835. spawn->SetPower(spawn->GetTotalPower());
  7836. }
  7837. int16 offset = atoi(sep->arg[1]);
  7838. int32 value1 = atol(sep->arg[2]);
  7839. sprintf(spawn->appearance.name, "Offset %i", offset);
  7840. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  7841. DumpPacket(ret);
  7842. client->QueuePacket(ret);
  7843. }
  7844. }
  7845. else if (atoi(sep->arg[0]) == 8) {
  7846. int32 id = atoi(sep->arg[1]);
  7847. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  7848. if (spawn) {
  7849. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7850. spawn->SetY(client->GetPlayer()->GetY(), false);
  7851. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7852. float heading = client->GetPlayer()->GetHeading() + 180;
  7853. if (heading > 360)
  7854. heading -= 360;
  7855. spawn->SetLevel(5);
  7856. spawn->SetAdventureClass(4);
  7857. spawn->SetHeading(heading, false);
  7858. spawn->SetSpawnOrigX(spawn->GetX());
  7859. spawn->SetSpawnOrigY(spawn->GetY());
  7860. spawn->SetSpawnOrigZ(spawn->GetZ());
  7861. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  7862. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  7863. spawn->appearance.targetable = 1;
  7864. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  7865. spawn->SetTotalHP(spawn->GetLevel() * 15);
  7866. spawn->SetHP(spawn->GetTotalHP());
  7867. }
  7868. if (spawn->GetTotalPower() == 0) {
  7869. spawn->SetTotalPower(spawn->GetLevel() * 15);
  7870. spawn->SetPower(spawn->GetTotalPower());
  7871. }
  7872. int16 offset = atoi(sep->arg[2]);
  7873. int16 offset2 = atoi(sep->arg[3]);
  7874. int32 value1 = atol(sep->arg[4]);
  7875. int16 offset3 = 0;
  7876. int16 offset4 = 0;
  7877. int32 value2 = 0;
  7878. if (sep->IsSet(7)) {
  7879. offset3 = atoi(sep->arg[5]);
  7880. offset4 = atoi(sep->arg[6]);
  7881. value2 = atol(sep->arg[7]);
  7882. }
  7883. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  7884. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  7885. DumpPacket(ret);
  7886. client->QueuePacket(ret);
  7887. }
  7888. }
  7889. else if (atoi(sep->arg[0]) == 9) {
  7890. Item* item = master_item_list.GetItem(70007);
  7891. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  7892. if (sep->IsSet(2)) {
  7893. int8 offset = atoi(sep->arg[1]);
  7894. uchar* ptr2 = app->pBuffer;
  7895. ptr2 += offset;
  7896. if (sep->IsNumber(2)) {
  7897. int32 value1 = atol(sep->arg[2]);
  7898. if (value1 > 0xFFFF)
  7899. memcpy(ptr2, (uchar*)&value1, 4);
  7900. else if (value1 > 0xFF)
  7901. memcpy(ptr2, (uchar*)&value1, 2);
  7902. else
  7903. memcpy(ptr2, (uchar*)&value1, 1);
  7904. }
  7905. else {
  7906. int8 len = strlen(sep->arg[2]);
  7907. memcpy(ptr2, (uchar*)&len, 1);
  7908. ptr2 += 1;
  7909. memcpy(ptr2, sep->arg[2], len);
  7910. }
  7911. }
  7912. if (sep->IsSet(4)) {
  7913. int8 offset = atoi(sep->arg[3]);
  7914. uchar* ptr2 = app->pBuffer;
  7915. ptr2 += offset;
  7916. if (sep->IsNumber(4)) {
  7917. int32 value1 = atol(sep->arg[4]);
  7918. if (value1 > 0xFFFF)
  7919. memcpy(ptr2, (uchar*)&value1, 4);
  7920. else if (value1 > 0xFF)
  7921. memcpy(ptr2, (uchar*)&value1, 2);
  7922. else
  7923. memcpy(ptr2, (uchar*)&value1, 1);
  7924. }
  7925. else {
  7926. int8 len = strlen(sep->arg[4]);
  7927. memcpy(ptr2, (uchar*)&len, 1);
  7928. ptr2 += 1;
  7929. memcpy(ptr2, sep->arg[4], len);
  7930. }
  7931. }
  7932. DumpPacket(app);
  7933. client->QueuePacket(app);
  7934. }
  7935. else if (atoi(sep->arg[0]) == 10) {
  7936. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  7937. if (packet2) {
  7938. packet2->setArrayLengthByName("num_quests", 1);
  7939. packet2->setArrayDataByName("active", 1);
  7940. packet2->setArrayDataByName("name", "Archetype Selection");
  7941. packet2->setArrayDataByName("quest_type", "Hallmark");
  7942. packet2->setArrayDataByName("quest_zone", "Hallmark");
  7943. packet2->setArrayDataByName("journal_updated", 1);
  7944. packet2->setArrayDataByName("quest_id", 5);
  7945. packet2->setArrayDataByName("day", 19);
  7946. packet2->setArrayDataByName("month", 6);
  7947. packet2->setArrayDataByName("year", 20);
  7948. packet2->setArrayDataByName("level", 2);
  7949. packet2->setArrayDataByName("encounter_level", 4);
  7950. packet2->setArrayDataByName("difficulty", 3);
  7951. packet2->setArrayDataByName("visible", 1);
  7952. packet2->setDataByName("visible_quest_id", 5);
  7953. packet2->setDataByName("player_crc", 2900677088);
  7954. packet2->setDataByName("player_name", "LethalEncounter");
  7955. EQ2Packet* app = packet2->serialize();
  7956. if (sep->IsSet(2)) {
  7957. int8 offset = atoi(sep->arg[1]);
  7958. uchar* ptr2 = app->pBuffer;
  7959. ptr2 += offset;
  7960. if (sep->IsNumber(2)) {
  7961. int32 value1 = atol(sep->arg[2]);
  7962. if (value1 > 0xFFFF)
  7963. memcpy(ptr2, (uchar*)&value1, 4);
  7964. else if (value1 > 0xFF)
  7965. memcpy(ptr2, (uchar*)&value1, 2);
  7966. else
  7967. memcpy(ptr2, (uchar*)&value1, 1);
  7968. }
  7969. else {
  7970. int8 len = strlen(sep->arg[2]);
  7971. memcpy(ptr2, (uchar*)&len, 1);
  7972. ptr2 += 1;
  7973. memcpy(ptr2, sep->arg[2], len);
  7974. }
  7975. }
  7976. DumpPacket(app);
  7977. client->QueuePacket(app);
  7978. safe_delete(packet2);
  7979. }
  7980. }
  7981. else if (atoi(sep->arg[0]) == 11) {
  7982. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  7983. if (packet2) {
  7984. packet2->setDataByName("quest_id", 5);
  7985. packet2->setDataByName("player_crc", 2900677088);
  7986. packet2->setDataByName("name", "Archetype Selection");
  7987. packet2->setDataByName("description", "I have reported my profession to Garven Tralk");
  7988. packet2->setDataByName("type", "Hallmark");
  7989. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  7990. packet2->setDataByName("day", 19);
  7991. packet2->setDataByName("month", 6);
  7992. packet2->setDataByName("year", 20);
  7993. packet2->setDataByName("level", 2);
  7994. packet2->setDataByName("encounter_level", 4);
  7995. packet2->setDataByName("difficulty", 3);
  7996. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  7997. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  7998. packet2->setDataByName("timer_duration", 300);
  7999. packet2->setDataByName("timer_running", 1);
  8000. packet2->setArrayLengthByName("task_groups_completed", 0);
  8001. packet2->setArrayLengthByName("num_task_groups", 1);
  8002. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8003. packet2->setSubArrayLengthByName("num_tasks", 1);
  8004. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8005. packet2->setSubArrayLengthByName("num_updates", 1);
  8006. packet2->setSubArrayDataByName("update_currentval", 0);
  8007. packet2->setSubArrayDataByName("update_maxval", 1);
  8008. packet2->setSubArrayDataByName("icon", 11);
  8009. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8010. packet2->setDataByName("journal_updated", 1);
  8011. EQ2Packet* app = packet2->serialize();
  8012. if (sep->IsSet(2)) {
  8013. int16 offset = atoi(sep->arg[1]);
  8014. uchar* ptr2 = app->pBuffer;
  8015. ptr2 += offset;
  8016. if (sep->IsNumber(2)) {
  8017. int32 value1 = atol(sep->arg[2]);
  8018. if (value1 > 0xFFFF)
  8019. memcpy(ptr2, (uchar*)&value1, 4);
  8020. else if (value1 > 0xFF)
  8021. memcpy(ptr2, (uchar*)&value1, 2);
  8022. else
  8023. memcpy(ptr2, (uchar*)&value1, 1);
  8024. }
  8025. else {
  8026. int16 len = strlen(sep->arg[2]);
  8027. memcpy(ptr2, (uchar*)&len, 2);
  8028. ptr2 += 2;
  8029. memcpy(ptr2, sep->arg[2], len);
  8030. }
  8031. }
  8032. DumpPacket(app);
  8033. client->QueuePacket(app);
  8034. safe_delete(packet2);
  8035. }
  8036. }
  8037. else if (atoi(sep->arg[0]) == 12) {
  8038. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8039. if (packet2) {
  8040. packet2->setDataByName("quest_id", 5);
  8041. packet2->setDataByName("player_crc", 2900677088);
  8042. packet2->setDataByName("name", "Archetype Selection");
  8043. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  8044. packet2->setDataByName("type", "Hallmark");
  8045. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8046. packet2->setDataByName("day", 19);
  8047. packet2->setDataByName("month", 6);
  8048. packet2->setDataByName("year", 20);
  8049. packet2->setDataByName("level", 2);
  8050. packet2->setDataByName("encounter_level", 4);
  8051. packet2->setDataByName("difficulty", 3);
  8052. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8053. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8054. packet2->setDataByName("timer_duration", 300);
  8055. packet2->setDataByName("timer_running", 1);
  8056. packet2->setArrayLengthByName("task_groups_completed", 0);
  8057. packet2->setArrayLengthByName("num_task_groups", 1);
  8058. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8059. packet2->setSubArrayLengthByName("num_tasks", 1);
  8060. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8061. packet2->setSubArrayLengthByName("num_updates", 1);
  8062. packet2->setSubArrayDataByName("update_currentval", 0);
  8063. packet2->setSubArrayDataByName("update_maxval", 1);
  8064. packet2->setSubArrayDataByName("icon", 11);
  8065. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8066. packet2->setDataByName("journal_updated", 1);
  8067. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8068. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8069. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  8070. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8071. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8072. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8073. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  8074. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  8075. Item* item = master_item_list.GetItem(152755);
  8076. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8077. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8078. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  8079. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  8080. packet2->setSubstructDataByName("item", "icon", 0xe7);
  8081. packet2->setSubstructDataByName("item", "tier", 4);
  8082. packet2->setSubstructDataByName("item", "flags", 0x60);
  8083. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  8084. packet2->setSubstructDataByName("item", "stat_type", 1);
  8085. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  8086. packet2->setSubstructDataByName("item", "value", 3);
  8087. packet2->setSubstructDataByName("item", "condition", 100);
  8088. packet2->setSubstructDataByName("item", "weight", 1);
  8089. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  8090. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  8091. packet2->setSubstructDataByName("item", "skill_min", 1);
  8092. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  8093. packet2->setSubstructDataByName("item", "adventure_class", 1);
  8094. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  8095. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  8096. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  8097. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  8098. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  8099. packet2->setSubstructDataByName("item", "level", 0x1e);
  8100. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  8101. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  8102. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  8103. //packet2->PrintPacket();
  8104. EQ2Packet* app = packet2->serialize();
  8105. if (sep->IsSet(2)) {
  8106. int16 offset = atoi(sep->arg[1]);
  8107. uchar* ptr2 = app->pBuffer;
  8108. ptr2 += offset;
  8109. if (sep->IsNumber(2)) {
  8110. int32 value1 = atol(sep->arg[2]);
  8111. if (value1 > 0xFFFF)
  8112. memcpy(ptr2, (uchar*)&value1, 4);
  8113. else if (value1 > 0xFF)
  8114. memcpy(ptr2, (uchar*)&value1, 2);
  8115. else
  8116. memcpy(ptr2, (uchar*)&value1, 1);
  8117. }
  8118. else {
  8119. int16 len = strlen(sep->arg[2]);
  8120. memcpy(ptr2, (uchar*)&len, 2);
  8121. ptr2 += 2;
  8122. memcpy(ptr2, sep->arg[2], len);
  8123. }
  8124. }
  8125. DumpPacket(app);
  8126. client->QueuePacket(app);
  8127. safe_delete(packet2);
  8128. }
  8129. }
  8130. else if (atoi(sep->arg[0]) == 13) {
  8131. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  8132. if (packet2 && sep->IsSet(7)) {
  8133. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  8134. char blah[128];
  8135. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  8136. packet2->setDataByName("text", blah);
  8137. packet2->setDataByName("message_type", sep->arg[3]);
  8138. packet2->setDataByName("size", atof(sep->arg[4]));
  8139. packet2->setDataByName("red", atoi(sep->arg[5]));
  8140. packet2->setDataByName("green", atoi(sep->arg[6]));
  8141. packet2->setDataByName("blue", atoi(sep->arg[7]));
  8142. EQ2Packet* app = packet2->serialize();
  8143. DumpPacket(app);
  8144. client->QueuePacket(app);
  8145. safe_delete(packet2);
  8146. }
  8147. }
  8148. else if (atoi(sep->arg[0]) == 14) {
  8149. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  8150. if (packet2 && sep->IsSet(3)) {
  8151. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  8152. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  8153. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  8154. 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.");
  8155. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  8156. packet2->setArrayLengthByName("num_goals", 1);
  8157. //packet2->setArrayDataByName("goal_text", )
  8158. packet2->setSubArrayLengthByName("num_tasks", 1);
  8159. packet2->setSubArrayDataByName("task_text", "continue");
  8160. packet2->setDataByName("complete_sound", "click");
  8161. packet2->setDataByName("signal", "introduction");
  8162. packet2->setDataByName("voice_key1", 0xcda65173);
  8163. packet2->setDataByName("voice_key2", 0x984bfc6d);
  8164. EQ2Packet* app = packet2->serialize();
  8165. DumpPacket(app);
  8166. client->QueuePacket(app);
  8167. safe_delete(packet2);
  8168. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  8169. packet2->setDataByName("window", "MainHUD.StartMenu");
  8170. packet2->setDataByName("show", 1);
  8171. app = packet2->serialize();
  8172. DumpPacket(app);
  8173. client->QueuePacket(app);
  8174. safe_delete(packet2);
  8175. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  8176. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  8177. packet2->setDataByName("flash_seconds", 10);
  8178. app = packet2->serialize();
  8179. DumpPacket(app);
  8180. client->QueuePacket(app);
  8181. safe_delete(packet2);
  8182. }
  8183. }
  8184. else if (atoi(sep->arg[0]) == 15) {
  8185. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8186. if (packet2) {
  8187. packet2->setArrayLengthByName("loot_count", 1);
  8188. packet2->setArrayDataByName("name", "Test");
  8189. packet2->setArrayDataByName("item_id", 1234);
  8190. packet2->setArrayDataByName("count", 1);
  8191. packet2->setArrayDataByName("icon", 258);
  8192. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  8193. Spawn* spawn = client->GetPlayer()->GetTarget();
  8194. if (spawn)
  8195. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8196. packet2->setDataByName("unknown3", 1);
  8197. packet2->setDataByName("unknown4", 1);
  8198. packet2->setDataByName("unknown5", 60);
  8199. EQ2Packet* app = packet2->serialize();
  8200. DumpPacket(app);
  8201. client->QueuePacket(app);
  8202. safe_delete(packet2);
  8203. }
  8204. }
  8205. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  8206. char blah[32];
  8207. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  8208. client->SimpleMessage(atoi(sep->arg[1]), blah);
  8209. }
  8210. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  8211. if (sep->IsSet(2)) {
  8212. int16 offset = atoi(sep->arg[1]);
  8213. if (sep->IsNumber(2)) {
  8214. int32 value1 = atol(sep->arg[2]);
  8215. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  8216. cout << "Sent" << endl;
  8217. }
  8218. }
  8219. }
  8220. else if (atoi(sep->arg[0]) == 18) {
  8221. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  8222. if (packet2) {
  8223. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8224. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8225. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8226. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8227. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8228. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  8229. Item* item = new Item(master_item_list.GetItem(36212));
  8230. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8231. item->stack_count = 20;
  8232. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8233. safe_delete(item);
  8234. item = new Item(master_item_list.GetItem(36685));
  8235. item->stack_count = 20;
  8236. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8237. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  8238. safe_delete(item);
  8239. item = master_item_list.GetItem(1414);
  8240. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8241. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  8242. item = master_item_list.GetItem(75057);
  8243. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8244. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  8245. EQ2Packet* app = packet2->serialize();
  8246. if (sep->IsSet(2)) {
  8247. int16 offset = atoi(sep->arg[1]);
  8248. uchar* ptr2 = app->pBuffer;
  8249. ptr2 += offset;
  8250. if (sep->IsNumber(2)) {
  8251. int32 value1 = atol(sep->arg[2]);
  8252. if (value1 > 0xFFFF)
  8253. memcpy(ptr2, (uchar*)&value1, 4);
  8254. else if (value1 > 0xFF)
  8255. memcpy(ptr2, (uchar*)&value1, 2);
  8256. else
  8257. memcpy(ptr2, (uchar*)&value1, 1);
  8258. }
  8259. else {
  8260. int16 len = strlen(sep->arg[2]);
  8261. memcpy(ptr2, (uchar*)&len, 2);
  8262. ptr2 += 2;
  8263. memcpy(ptr2, sep->arg[2], len);
  8264. }
  8265. }
  8266. DumpPacket(app);
  8267. client->QueuePacket(app);
  8268. safe_delete(packet2);
  8269. }
  8270. }
  8271. else if (atoi(sep->arg[0]) == 19) {
  8272. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8273. Spawn* spawn = client->GetPlayer()->GetTarget();
  8274. if (packet2 && spawn) {
  8275. Item* item = master_item_list.GetItem(130053);
  8276. packet2->setArrayLengthByName("loot_count", 1);
  8277. packet2->setArrayDataByName("loot_id", item->details.item_id);
  8278. packet2->setArrayDataByName("unknown2", 1);
  8279. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  8280. packet2->setDataByName("display", 1);
  8281. packet2->setDataByName("unknown2b", 1);
  8282. packet2->setDataByName("unknown3", 0x3c);
  8283. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8284. packet2->PrintPacket();
  8285. EQ2Packet* app = packet2->serialize();
  8286. if (sep->IsSet(2)) {
  8287. int16 offset = atoi(sep->arg[1]);
  8288. int16 offset2 = 0;
  8289. int32 value1 = 0;
  8290. if (sep->IsSet(3)) {
  8291. offset2 = atoi(sep->arg[2]);
  8292. value1 = atol(sep->arg[3]);
  8293. }
  8294. else
  8295. value1 = atol(sep->arg[2]);
  8296. int16 offset3 = 0;
  8297. int16 offset4 = 0;
  8298. int32 value2 = 0;
  8299. if (sep->IsSet(6)) {
  8300. offset3 = atoi(sep->arg[4]);
  8301. offset4 = atoi(sep->arg[5]);
  8302. value2 = atol(sep->arg[6]);
  8303. }
  8304. offset--;
  8305. if (offset2 > 0 && offset2 >= offset) {
  8306. offset2--;
  8307. uchar* ptr2 = app->pBuffer;
  8308. ptr2 += offset;
  8309. for (int i = offset; i <= offset2; i++) {
  8310. if (value1 > 0xFFFF) {
  8311. memcpy(ptr2, (uchar*)&value1, 4);
  8312. i += 3;
  8313. ptr2 += 3;
  8314. }
  8315. else if (value1 > 0xFF) {
  8316. memcpy(ptr2, (uchar*)&value1, 2);
  8317. i++;
  8318. ptr2++;
  8319. }
  8320. else
  8321. memcpy(ptr2, (uchar*)&value1, 1);
  8322. ptr2++;
  8323. }
  8324. }
  8325. if (offset4 > 0 && offset4 >= offset3) {
  8326. offset3--;
  8327. offset4--;
  8328. uchar* ptr2 = app->pBuffer;
  8329. ptr2 += offset3;
  8330. for (int i = offset3; i <= offset4; i++) {
  8331. if (value2 > 0xFFFF) {
  8332. memcpy(ptr2, (uchar*)&value2, 4);
  8333. i += 3;
  8334. ptr2 += 3;
  8335. }
  8336. else if (value2 > 0xFF) {
  8337. memcpy(ptr2, (uchar*)&value2, 2);
  8338. i++;
  8339. ptr2++;
  8340. }
  8341. else
  8342. memcpy(ptr2, (uchar*)&value2, 1);
  8343. ptr2++;
  8344. }
  8345. }
  8346. }
  8347. DumpPacket(app);
  8348. client->QueuePacket(app);
  8349. safe_delete(packet2);
  8350. }
  8351. }
  8352. else if (atoi(sep->arg[0]) == 21) {
  8353. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8354. if (packet2) {
  8355. packet2->setDataByName("unknown0", 255);
  8356. packet2->setDataByName("reward", "New Quest");
  8357. packet2->setDataByName("title", "Title");
  8358. packet2->setDataByName("description", "description");
  8359. packet2->setDataByName("quest_difficulty", 3);
  8360. packet2->setDataByName("unknown1", 5);
  8361. packet2->setDataByName("level", 3);
  8362. packet2->setDataByName("coin", 150);
  8363. packet2->setDataByName("status_points", 5);
  8364. packet2->setDataByName("exp_bonus", 10);
  8365. packet2->setArrayLengthByName("num_rewards", 1);
  8366. Item* item = new Item(master_item_list.GetItem(36212));
  8367. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8368. item->stack_count = 20;
  8369. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8370. safe_delete(item);
  8371. char accept[35] = { 0 };
  8372. char decline[35] = { 0 };
  8373. sprintf(accept, "q_accept_pending_quest %u", 0);
  8374. sprintf(decline, "q_deny_pending_quest %u", 0);
  8375. packet2->setDataByName("accept_command", accept);
  8376. packet2->setDataByName("decline_command", decline);
  8377. EQ2Packet* app = packet2->serialize();
  8378. if (sep->IsSet(2)) {
  8379. int16 offset = atoi(sep->arg[1]);
  8380. uchar* ptr2 = app->pBuffer;
  8381. ptr2 += offset;
  8382. if (sep->IsNumber(2)) {
  8383. int32 value1 = atol(sep->arg[2]);
  8384. if (value1 > 0xFFFF)
  8385. memcpy(ptr2, (uchar*)&value1, 4);
  8386. else if (value1 > 0xFF)
  8387. memcpy(ptr2, (uchar*)&value1, 2);
  8388. else
  8389. memcpy(ptr2, (uchar*)&value1, 1);
  8390. }
  8391. DumpPacket(app);
  8392. client->QueuePacket(app);
  8393. safe_delete(packet2);
  8394. }
  8395. }
  8396. }
  8397. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  8398. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8399. if (packet2) {
  8400. packet2->setDataByName("unknown0", 255);
  8401. packet2->setDataByName("reward", "New Quest");
  8402. packet2->setDataByName("title", "Title");
  8403. packet2->setDataByName("description", "description");
  8404. packet2->setDataByName("quest_difficulty", 3);
  8405. packet2->setDataByName("unknown1", 5);
  8406. packet2->setDataByName("level", 3);
  8407. packet2->setDataByName("coin", 150);
  8408. packet2->setDataByName("status_points", 5);
  8409. packet2->setDataByName("exp_bonus", 10);
  8410. packet2->setArrayLengthByName("num_rewards", 1);
  8411. Item* item = new Item(master_item_list.GetItem(36212));
  8412. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8413. item->stack_count = 20;
  8414. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8415. safe_delete(item);
  8416. char accept[35] = { 0 };
  8417. char decline[35] = { 0 };
  8418. sprintf(accept, "q_accept_pending_quest %u", 0);
  8419. sprintf(decline, "q_deny_pending_quest %u", 0);
  8420. packet2->setDataByName("accept_command", accept);
  8421. packet2->setDataByName("decline_command", decline);
  8422. EQ2Packet* app = packet2->serialize();
  8423. if (sep->IsSet(2)) {
  8424. int16 offset = atoi(sep->arg[1]);
  8425. uchar* ptr2 = app->pBuffer;
  8426. ptr2 += offset;
  8427. if (sep->IsNumber(2)) {
  8428. int32 value1 = atol(sep->arg[2]);
  8429. if (value1 > 0xFFFF)
  8430. memcpy(ptr2, (uchar*)&value1, 4);
  8431. else if (value1 > 0xFF)
  8432. memcpy(ptr2, (uchar*)&value1, 2);
  8433. else
  8434. memcpy(ptr2, (uchar*)&value1, 1);
  8435. }
  8436. else {
  8437. int8 len = strlen(sep->arg[2]);
  8438. memcpy(ptr2, (uchar*)&len, 1);
  8439. ptr2 += 1;
  8440. memcpy(ptr2, sep->arg[2], len);
  8441. }
  8442. }
  8443. DumpPacket(app);
  8444. client->QueuePacket(app);
  8445. safe_delete(packet2);
  8446. }
  8447. }
  8448. else if (atoi(sep->arg[0]) == 23) {
  8449. if (client->GetPlayer()->GetTarget()) {
  8450. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  8451. if (packet2) {
  8452. Spawn* target = client->GetPlayer()->GetTarget();
  8453. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8454. Item* item = new Item(master_item_list.GetItem(12565));
  8455. int8 i = 0;
  8456. packet2->setArrayLengthByName("num_items", 1);
  8457. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  8458. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  8459. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  8460. packet2->setArrayDataByName("icon", item->details.icon, i);
  8461. int8 tmp_level = 0;
  8462. if (item->generic_info.adventure_default_level > 0)
  8463. tmp_level = item->generic_info.adventure_default_level;
  8464. else
  8465. tmp_level = item->generic_info.tradeskill_default_level;
  8466. packet2->setArrayDataByName("level", tmp_level, i);
  8467. packet2->setArrayDataByName("tier", item->details.tier, i);
  8468. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  8469. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  8470. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  8471. item_difficulty = ARROW_COLOR_WHITE;
  8472. item_difficulty -= 6;
  8473. if (item_difficulty < 0)
  8474. item_difficulty *= -1;
  8475. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  8476. packet2->setArrayDataByName("quantity", 2, i);
  8477. packet2->setArrayDataByName("unknown5", 255, i);
  8478. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  8479. packet2->setArrayDataByName("description", item->description.c_str(), i);
  8480. packet2->setDataByName("type", 2);
  8481. EQ2Packet* app = packet2->serialize();
  8482. if (sep->IsSet(2)) {
  8483. int16 offset = atoi(sep->arg[1]);
  8484. uchar* ptr2 = app->pBuffer;
  8485. ptr2 += offset;
  8486. if (sep->IsNumber(2)) {
  8487. int32 value1 = atol(sep->arg[2]);
  8488. if (value1 > 0xFFFF)
  8489. memcpy(ptr2, (uchar*)&value1, 4);
  8490. else if (value1 > 0xFF)
  8491. memcpy(ptr2, (uchar*)&value1, 2);
  8492. else
  8493. memcpy(ptr2, (uchar*)&value1, 1);
  8494. }
  8495. else {
  8496. int8 len = strlen(sep->arg[2]);
  8497. memcpy(ptr2, (uchar*)&len, 1);
  8498. ptr2 += 1;
  8499. memcpy(ptr2, sep->arg[2], len);
  8500. }
  8501. }
  8502. DumpPacket(app);
  8503. client->QueuePacket(app);
  8504. safe_delete(packet2);
  8505. }
  8506. }
  8507. }
  8508. else if (atoi(sep->arg[0]) == 24) {
  8509. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  8510. if (packet2) {
  8511. if (sep->IsSet(2)) {
  8512. packet2->setDataByName("event_name", sep->arg[1]);
  8513. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  8514. EQ2Packet* app = packet2->serialize();
  8515. DumpPacket(app);
  8516. client->QueuePacket(app);
  8517. safe_delete(packet2);
  8518. }
  8519. }
  8520. }
  8521. else if (atoi(sep->arg[0]) == 25) {
  8522. if (sep->IsSet(1)) {
  8523. Widget* new_spawn = new Widget();
  8524. int32 id = atoul(sep->arg[1]);
  8525. new_spawn->SetWidgetID(id);
  8526. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  8527. client->QueuePacket(ret);
  8528. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  8529. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  8530. if (packet2) {
  8531. packet2->setDataByName("spawn_index", index);
  8532. packet2->setDataByName("delete", 1);
  8533. EQ2Packet* app = packet2->serialize();
  8534. client->QueuePacket(app);
  8535. safe_delete(packet2);
  8536. }
  8537. }
  8538. }
  8539. else if (atoi(sep->arg[0]) == 26) {
  8540. if (sep->IsSet(4)) {
  8541. Widget* new_spawn = new Widget();
  8542. int32 id = atoul(sep->arg[1]);
  8543. new_spawn->SetWidgetID(id);
  8544. float x = atof(sep->arg[2]);
  8545. float y = atof(sep->arg[3]);
  8546. float z = atof(sep->arg[4]);
  8547. new_spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8548. new_spawn->SetWidgetX(x);
  8549. new_spawn->SetWidgetY(y);
  8550. new_spawn->SetWidgetZ(z);
  8551. new_spawn->SetX(x);
  8552. new_spawn->SetY(y);
  8553. new_spawn->SetZ(z);
  8554. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  8555. client->QueuePacket(ret);
  8556. }
  8557. }
  8558. else if (atoi(sep->arg[0]) == 27) {
  8559. Spawn* target = client->GetPlayer()->GetTarget();
  8560. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  8561. if (packet2 && target && sep->IsSet(2)) {
  8562. packet2->setSubstructDataByName("header", "defender", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8563. packet2->setSubstructDataByName("header", "defender_proxy", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8564. packet2->setSubstructDataByName("header", "attacker", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  8565. packet2->setArrayLengthByName("num_dmg", 1);
  8566. packet2->setArrayDataByName("damage_type", atoi(sep->arg[1]));
  8567. packet2->setArrayDataByName("damage", atoi(sep->arg[2]));
  8568. packet2->setDataByName("spell", 1);
  8569. packet2->setDataByName("spell_name", "Testing");
  8570. EQ2Packet* app = packet2->serialize();
  8571. if (sep->IsSet(4)) {
  8572. int16 offset = atoi(sep->arg[3]);
  8573. uchar* ptr2 = app->pBuffer;
  8574. ptr2 += offset;
  8575. if (sep->IsNumber(4)) {
  8576. int32 value1 = atol(sep->arg[4]);
  8577. if (value1 > 0xFFFF)
  8578. memcpy(ptr2, (uchar*)&value1, 4);
  8579. else if (value1 > 0xFF)
  8580. memcpy(ptr2, (uchar*)&value1, 2);
  8581. else
  8582. memcpy(ptr2, (uchar*)&value1, 1);
  8583. }
  8584. else {
  8585. int8 len = strlen(sep->arg[4]);
  8586. memcpy(ptr2, (uchar*)&len, 1);
  8587. ptr2 += 1;
  8588. memcpy(ptr2, sep->arg[4], len);
  8589. }
  8590. }
  8591. if (sep->IsSet(6)) {
  8592. int16 offset = atoi(sep->arg[5]);
  8593. uchar* ptr2 = app->pBuffer;
  8594. ptr2 += offset;
  8595. if (sep->IsNumber(6)) {
  8596. int32 value1 = atol(sep->arg[6]);
  8597. if (value1 > 0xFFFF)
  8598. memcpy(ptr2, (uchar*)&value1, 4);
  8599. else if (value1 > 0xFF)
  8600. memcpy(ptr2, (uchar*)&value1, 2);
  8601. else
  8602. memcpy(ptr2, (uchar*)&value1, 1);
  8603. }
  8604. else {
  8605. int8 len = strlen(sep->arg[6]);
  8606. memcpy(ptr2, (uchar*)&len, 1);
  8607. ptr2 += 1;
  8608. memcpy(ptr2, sep->arg[6], len);
  8609. }
  8610. }
  8611. DumpPacket(app);
  8612. client->QueuePacket(app);
  8613. safe_delete(packet2);
  8614. }
  8615. }
  8616. }
  8617. else {
  8618. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  8619. if (packet2) {
  8620. packet2->setSubstructDataByName("info_header", "show_name", 1);
  8621. packet2->setSubstructDataByName("info_header", "unknown", 7);
  8622. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  8623. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  8624. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  8625. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  8626. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  8627. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  8628. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  8629. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  8630. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  8631. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  8632. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  8633. packet2->setSubstructDataByName("info_header", "packettype", 3);
  8634. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  8635. packet2->setSubstructDataByName("spell_info", "level", 19);
  8636. packet2->setSubstructDataByName("spell_info", "tier", 1);
  8637. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  8638. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  8639. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  8640. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  8641. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  8642. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  8643. packet2->setSubstructDataByName("spell_info", "recast", 280);
  8644. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  8645. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  8646. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  8647. packet2->setSubstructDataByName("spell_info", "quality", 3);
  8648. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  8649. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  8650. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  8651. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  8652. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  8653. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  8654. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  8655. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  8656. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  8657. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  8658. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  8659. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  8660. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  8661. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  8662. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  8663. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  8664. packet2->setArrayDataByName("reagent", "Alcohol");
  8665. packet2->setArrayDataByName("consumed", "123");
  8666. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  8667. packet2->setSubstructDataByName("spell_info", "id", 8308);
  8668. packet2->setSubstructDataByName("spell_info", "icon", 303);
  8669. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  8670. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  8671. packet2->setSubstructDataByName("spell_info", "type", 2);
  8672. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  8673. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  8674. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  8675. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  8676. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  8677. EQ2Packet* outapp = packet2->serialize();
  8678. DumpPacket(outapp);
  8679. client->QueuePacket(outapp);
  8680. safe_delete(packet2);
  8681. }
  8682. }
  8683. return;
  8684. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  8685. if (!p) return;
  8686. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8687. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  8688. //}
  8689. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8690. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  8691. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  8692. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  8693. if (packet) {
  8694. client->QueuePacket(packet->serialize());
  8695. safe_delete(packet);
  8696. }
  8697. }*/
  8698. /*if (client->GetCurrentZone()->Grid != nullptr) {
  8699. int32 numFaces = 0;
  8700. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  8701. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  8702. map<int32, vector<Face*> >::iterator itr;
  8703. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  8704. numFaces += (*itr).second.size();
  8705. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  8706. }*/
  8707. //uchar blah[] = {
  8708. // 1208 - OP_EQUpdateStoreCmd
  8709. // /*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
  8710. // /*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
  8711. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  8712. // /*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
  8713. /*};
  8714. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8715. int8 val = 0;
  8716. int16 pos = 0;
  8717. int idx = 0;
  8718. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  8719. pos = atoi(sep2->arg[idx]);
  8720. val = atoi(sep2->arg[idx+1]);
  8721. memset(blah+pos, val, 1);
  8722. idx+=2;
  8723. }
  8724. DumpPacket(blah, sizeof(blah));
  8725. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  8726. if (client->GetPlayer()->GetTarget()) {
  8727. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  8728. if (packet) {
  8729. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8730. packet->setDataByName("size", 0);
  8731. packet->setDataByName("unknown2", 0);
  8732. EQ2Packet* app = packet->serialize();
  8733. client->QueuePacket(app);
  8734. safe_delete(packet);
  8735. }
  8736. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  8737. if (set_pov) {
  8738. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8739. EQ2Packet* app_pov = set_pov->serialize();
  8740. client->QueuePacket(app_pov);
  8741. safe_delete(set_pov);
  8742. }
  8743. }
  8744. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8745. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  8746. if (packet) {
  8747. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  8748. packet->setDataByName("Type", atoi(sep2->arg[0]));
  8749. else
  8750. packet->setDataByName("Type", 2);
  8751. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  8752. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  8753. else
  8754. packet->setDataByName("race_id", 0);
  8755. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  8756. packet->setDataByName("gender", atoi(sep2->arg[2]));
  8757. else
  8758. packet->setDataByName("gender", 2);
  8759. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  8760. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  8761. else
  8762. packet->setDataByName("unknown", 0, 0);
  8763. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  8764. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  8765. else
  8766. packet->setDataByName("unknown", 0, 1);
  8767. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  8768. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  8769. else
  8770. packet->setDataByName("unknown", 0, 2);
  8771. client->QueuePacket(packet->serialize());
  8772. }
  8773. safe_delete(packet);
  8774. safe_delete(sep2);
  8775. }
  8776. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  8777. const char *channel_name;
  8778. if (sep == NULL || !sep->IsSet(0)) {
  8779. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  8780. PrintSep(sep);
  8781. return;
  8782. }
  8783. channel_name = sep->arg[0];
  8784. if (!chat.IsInChannel(client, channel_name))
  8785. client->Message(CHANNEL_COLOR_WHITE, "Unable to leave '%s': You are not in the channel.", channel_name);
  8786. else if (!chat.LeaveChannel(client, channel_name))
  8787. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  8788. }
  8789. /*
  8790. Function:
  8791. Purpose :
  8792. Params :
  8793. Dev :
  8794. Example :
  8795. */
  8796. void Commands::Command_WeaponStats(Client* client)
  8797. {
  8798. Player* player = client->GetPlayer();
  8799. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  8800. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  8801. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  8802. client->SimpleMessage(0, "Primary:");
  8803. if (primary) {
  8804. client->Message(0, "Name: %s", primary->name.c_str());
  8805. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  8806. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8807. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  8808. client->Message(0, "Proc Percent: %d%%", 0);
  8809. client->Message(0, "Procs Per Minute: %d", 0);
  8810. }
  8811. else {
  8812. client->SimpleMessage(0, "Name: fist");
  8813. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8814. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8815. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  8816. client->Message(0, "Proc Percent: %d%%", 0);
  8817. client->Message(0, "Procs Per Minute: %d", 0);
  8818. }
  8819. client->SimpleMessage(0, " ");
  8820. client->SimpleMessage(0, " ");
  8821. if (secondary) {
  8822. client->SimpleMessage(0, "Secondary:");
  8823. client->Message(0, "Name: %s", secondary->name.c_str());
  8824. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  8825. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  8826. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  8827. client->Message(0, "Proc Percent: %d%%", 0);
  8828. client->Message(0, "Procs Per Minute: %d", 0);
  8829. client->SimpleMessage(0, " ");
  8830. client->SimpleMessage(0, " ");
  8831. }
  8832. client->SimpleMessage(0, "Ranged:");
  8833. if (ranged) {
  8834. client->Message(0, "Name: %s", ranged->name.c_str());
  8835. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  8836. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  8837. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  8838. client->Message(0, "Proc Percent: %d%%", 0);
  8839. client->Message(0, "Procs Per Minute: %d", 0);
  8840. }
  8841. else
  8842. client->SimpleMessage(0, "None");
  8843. }
  8844. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  8845. const char *channel_name;
  8846. if (sep == NULL || !sep->IsSet(0)) {
  8847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  8848. return;
  8849. }
  8850. channel_name = sep->arg[0];
  8851. if (!chat.ChannelExists(channel_name))
  8852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  8853. else
  8854. chat.SendChannelUserList(client, channel_name);
  8855. }
  8856. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  8857. {
  8858. ZoneServer* zone = 0;
  8859. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  8860. if (zone_id > 0)
  8861. {
  8862. zone = zone_list.Get(zone_id, false);
  8863. if (zone)
  8864. {
  8865. zone->SetSafeX(client->GetPlayer()->GetX());
  8866. zone->SetSafeY(client->GetPlayer()->GetY());
  8867. zone->SetSafeZ(client->GetPlayer()->GetZ());
  8868. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  8869. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  8870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  8871. else
  8872. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  8873. }
  8874. }
  8875. }
  8876. /*
  8877. Function:
  8878. Purpose :
  8879. Params :
  8880. Dev :
  8881. Example :
  8882. */
  8883. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  8884. {
  8885. ZoneInfo* zone_info = new ZoneInfo;
  8886. if (sep && sep->arg[0])
  8887. {
  8888. if (sep->IsNumber(0))
  8889. zone_info->id = atoi(sep->arg[0]);
  8890. else
  8891. zone_info->id = database.GetZoneID(sep->arg[0]);
  8892. if (zone_info->id > 0)
  8893. {
  8894. database.LoadZoneInfo(zone_info);
  8895. 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);
  8896. 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);
  8897. 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);
  8898. 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);
  8899. 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);
  8900. 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);
  8901. 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);
  8902. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  8903. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  8904. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  8905. }
  8906. else
  8907. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  8908. }
  8909. else
  8910. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  8911. safe_delete(zone_info);
  8912. }
  8913. /*
  8914. Function:
  8915. Purpose :
  8916. Params :
  8917. Dev :
  8918. Example :
  8919. */
  8920. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  8921. {
  8922. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  8923. {
  8924. ZoneServer* zone = 0;
  8925. int32 zone_id = 0;
  8926. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  8927. {
  8928. zone_id = atoi(sep->arg[0]);
  8929. zone = zone_list.Get(atoi(sep->arg[0]), false);
  8930. }
  8931. else
  8932. {
  8933. zone_id = database.GetZoneID(sep->arg[0]);
  8934. if (zone_id > 0)
  8935. zone = zone_list.Get(sep->arg[0], false);
  8936. }
  8937. if (zone_id > 0)
  8938. {
  8939. if (zone_set_values.count(string(sep->arg[1])) > 0)
  8940. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  8941. else
  8942. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  8943. }
  8944. else
  8945. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  8946. }
  8947. else
  8948. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  8949. }
  8950. void Commands::Command_Rain(Client* client, Seperator* sep) {
  8951. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8952. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  8953. return;
  8954. }
  8955. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  8956. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  8957. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  8958. }
  8959. void Commands::Command_Wind(Client* client, Seperator* sep) {
  8960. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8961. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  8962. return;
  8963. }
  8964. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  8965. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  8966. }
  8967. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  8968. Spawn* spawn = client->GetPlayer()->GetTarget();
  8969. if(spawn) {
  8970. client->SetMerchantTransaction(spawn);
  8971. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  8972. client->SendHailCommand(spawn);
  8973. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  8974. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  8975. client->SendBuyMerchantList(sell);
  8976. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  8977. client->SendSellMerchantList(sell);
  8978. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  8979. client->SendBuyBackList(sell);
  8980. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  8981. if (packet) {
  8982. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  8983. packet->setDataByName("type", 16);
  8984. EQ2Packet* outapp = packet->serialize();
  8985. if (outapp)
  8986. client->QueuePacket(outapp);
  8987. safe_delete(packet);
  8988. }
  8989. }
  8990. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  8991. client->SendRepairList();
  8992. }
  8993. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  8994. }
  8995. void Commands::Command_Weather(Client* client, Seperator* sep)
  8996. {
  8997. //PrintSep(sep, "Weather");
  8998. if( sep && sep->arg[0] )
  8999. {
  9000. ZoneServer* zsZone = client->GetCurrentZone();
  9001. const char* value = sep->arg[0];
  9002. // process single-param commands first
  9003. if( strncasecmp(value, "details", strlen(value)) == 0 )
  9004. {
  9005. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  9006. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  9007. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  9008. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  9009. }
  9010. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  9011. {
  9012. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9013. zsZone->ProcessWeather();
  9014. }
  9015. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  9016. {
  9017. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  9018. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  9019. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  9020. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  9021. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  9022. zsZone->SetWeatherPattern(1);
  9023. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  9024. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  9025. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  9026. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9027. zsZone->ProcessWeather();
  9028. }
  9029. // process commands with params
  9030. if( sep->arg[1] )
  9031. {
  9032. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  9033. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  9034. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  9035. zsZone->SetWeatherType(atoi(sep->arg[1]));
  9036. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  9037. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  9038. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  9039. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  9040. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  9041. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  9042. }
  9043. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  9044. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  9045. zsZone->SetRain(zsZone->GetCurrentWeather());
  9046. }
  9047. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  9048. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  9049. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  9050. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  9051. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9052. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  9053. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9054. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  9055. }
  9056. }
  9057. else
  9058. {
  9059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  9060. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  9061. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  9062. return;
  9063. }
  9064. }
  9065. void Commands::Command_Select(Client* client, Seperator* sep) {
  9066. if (sep && sep->arg[1]) {
  9067. Spawn* spawn = client->GetPlayer()->GetTarget();
  9068. if (spawn && strlen(sep->arg[1]) > 0)
  9069. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  9070. }
  9071. }
  9072. /*
  9073. Function: Command_ConsumeFood()
  9074. Purpose : Consume Food/Drink and apply mods
  9075. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  9076. Dev : Zcoretri
  9077. Example : /consume_food 22
  9078. */
  9079. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  9080. if (sep && sep->arg[0] && sep->IsNumber(0))
  9081. {
  9082. Player* player = client->GetPlayer();
  9083. int8 slot = atoi(sep->arg[0]);
  9084. Item* item = player->GetEquipmentList()->GetItem(slot);
  9085. if(item) {
  9086. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  9087. if(item->GetItemScript() && lua_interface){
  9088. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  9089. if (slot == 22)
  9090. client->Message(CHANNEL_COLOR_WHITE, "You eat a %s.", item->name.c_str());
  9091. else
  9092. client->Message(CHANNEL_COLOR_WHITE, "You drink a %s.", item->name.c_str());
  9093. }
  9094. }
  9095. if (item->details.count > 1) {
  9096. item->details.count -= 1;
  9097. item->save_needed = true;
  9098. }
  9099. else {
  9100. player->GetEquipmentList()->RemoveItem(slot, true);
  9101. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  9102. }
  9103. client->GetPlayer()->SetCharSheetChanged(true);
  9104. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  9105. }
  9106. }
  9107. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  9108. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9109. if (atoi(sep->arg[0]) == 1) {
  9110. client->GetPlayer()->GetInfoStruct()->vision = 4;
  9111. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  9112. client->GetPlayer()->SetCharSheetChanged(true);
  9113. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  9114. }
  9115. else {
  9116. client->GetPlayer()->GetInfoStruct()->vision = 0;
  9117. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  9118. client->GetPlayer()->SetCharSheetChanged(true);
  9119. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  9120. }
  9121. }
  9122. else
  9123. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  9124. }
  9125. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  9126. {
  9127. if(sep)
  9128. {
  9129. string data;
  9130. if(sep->arg[0]){
  9131. data = string(sep->arg[0]);
  9132. }
  9133. for(int i=1;i<sep->GetMaxArgNum();i++){
  9134. if(sep->arg[i])
  9135. data.append(" ").append(sep->arg[i]);
  9136. }
  9137. const char* target_name = 0;
  9138. int32 spawn_id = 0;
  9139. if(client->GetPlayer()->GetTarget())
  9140. {
  9141. target_name = client->GetPlayer()->GetTarget()->GetName();
  9142. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9143. }
  9144. else
  9145. target_name = "N/A";
  9146. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  9147. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  9148. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  9149. else
  9150. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  9151. }
  9152. }
  9153. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  9154. PrintSep(sep, "Command_Attune_Inv");
  9155. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9156. // Get the item index from the first parameter
  9157. int16 index = atoi(sep->arg[0]);
  9158. // Check to see if this is a valid item index for the player, if not exit out of the function
  9159. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  9160. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  9161. return;
  9162. }
  9163. // Get the item
  9164. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  9165. if(item) {
  9166. // Valid item lets check to make sure this item is attunable, if not return out
  9167. if (!item->CheckFlag(ATTUNEABLE)) {
  9168. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  9169. return;
  9170. }
  9171. // Remove the attunable flag
  9172. item->generic_info.item_flags -= ATTUNEABLE;
  9173. // Set the attuned flag
  9174. item->generic_info.item_flags += ATTUNED;
  9175. // Flag this item for saving
  9176. item->save_needed = true;
  9177. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  9178. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  9179. EQ2Packet* outapp = 0;
  9180. for (int32 i=0;i<packets.size();i++) {
  9181. outapp = packets[i];
  9182. if(outapp)
  9183. client->QueuePacket(outapp);
  9184. }
  9185. }
  9186. }
  9187. }
  9188. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  9189. PrintSep(sep, "Command_Reset_Zone_Timer");
  9190. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9191. int32 db_id = atoul(sep->arg[0]);
  9192. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  9193. if (data) {
  9194. // TODO: add a check to timers to ensure it can be reset
  9195. // Delete the character from the instance
  9196. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  9197. data->instance_id = 0;
  9198. // Update the success time and set to 0 so the player can enter it again
  9199. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  9200. data->last_success_timestamp = 0;
  9201. }
  9202. }*/
  9203. }
  9204. void Commands::Command_Player(Client* client, Seperator* sep) {
  9205. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  9206. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  9207. }
  9208. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  9209. // /player coins add 10
  9210. // /player coins add plat 10
  9211. Player* player = client->GetPlayer();
  9212. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  9213. player = (Player*)player->GetTarget();
  9214. if (sep && sep->arg[0] && sep->arg[1]) {
  9215. const char* action = sep->arg[0];
  9216. int64 value = 0;
  9217. if (strncasecmp(action, "add", strlen(action)) == 0) {
  9218. if (sep->IsNumber(1)) {
  9219. value = atoi64(sep->arg[1]);
  9220. player->AddCoins(value);
  9221. if (client->GetPlayer() == player)
  9222. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9223. else {
  9224. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9225. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9226. }
  9227. return;
  9228. }
  9229. else if (sep->arg[2] && sep->IsNumber(2)) {
  9230. const char* type = sep->arg[1];
  9231. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  9232. value = atoi64(sep->arg[2]);
  9233. }
  9234. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  9235. value = atoi64(sep->arg[2]) * 100;
  9236. }
  9237. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  9238. value = atoi64(sep->arg[2]) * 10000;
  9239. }
  9240. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  9241. value = atoi64(sep->arg[2]) * 1000000;
  9242. }
  9243. player->AddCoins(value);
  9244. if (client->GetPlayer() == player)
  9245. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9246. else {
  9247. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9248. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9249. }
  9250. return;
  9251. }
  9252. }
  9253. }
  9254. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  9255. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  9256. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  9257. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  9258. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  9259. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  9260. }
  9261. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  9262. PrintSep(sep, "ACHIEVEMENT_ADD");
  9263. if (sep && sep->IsSet(0)) {
  9264. int32 spell_id = atoul(sep->arg[1]);
  9265. int8 spell_tier = 0;
  9266. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9267. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9268. // addspellbookentry here
  9269. if (spell_tier >= data->maxRank) {
  9270. return;
  9271. }
  9272. if (!spell_tier) {
  9273. spell_tier = 1;
  9274. }
  9275. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9276. {
  9277. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9278. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9279. client->GetPlayer()->UnlockSpell(spell);
  9280. client->SendSpellUpdate(spell);
  9281. }
  9282. else
  9283. {
  9284. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  9285. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9286. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9287. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9288. client->GetPlayer()->UnlockSpell(spell);
  9289. client->SendSpellUpdate(spell);
  9290. }
  9291. // cast spell here
  9292. if (!spell_tier)
  9293. spell_tier = 1;
  9294. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9295. if (spell) {
  9296. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9297. }
  9298. }
  9299. else {
  9300. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9301. }
  9302. master_aa_list.DisplayAA(client, 0, 0);
  9303. }
  9304. void Commands::Command_Editor(Client* client, Seperator* sep) {
  9305. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  9306. if (packet) {
  9307. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  9308. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  9309. char command[255];
  9310. url = "browser " + url;
  9311. int32 spawn_id = 0;
  9312. int32 zone_id = 0;
  9313. string type;
  9314. if (client->GetCurrentZone())
  9315. zone_id = client->GetCurrentZone()->GetZoneID();
  9316. if (client->GetPlayer()->GetTarget()) {
  9317. Spawn* target = client->GetPlayer()->GetTarget();
  9318. if (target->IsWidget())
  9319. type = "widgets";
  9320. else if (target->IsSign())
  9321. type = "signs";
  9322. else if (target->IsObject())
  9323. type = "objects";
  9324. else if (target->IsNPC())
  9325. type = "npcs";
  9326. else if (target->IsGroundSpawn())
  9327. type = "ground";
  9328. else
  9329. type = "spawn";
  9330. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9331. }
  9332. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  9333. packet->setDataByName("accept_command", command);
  9334. }
  9335. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  9336. char command[255];
  9337. url = "browser " + url;
  9338. if (client->GetPlayer()->GetTarget())
  9339. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  9340. packet->setDataByName("accept_command", command);
  9341. }
  9342. else {
  9343. string command = "browser " + url;
  9344. packet->setDataByName("accept_command", command.c_str());
  9345. }
  9346. packet->setDataByName("text", "Open the web editor?");
  9347. packet->setDataByName("accept_text", "Open");
  9348. packet->setDataByName("cancel_text", "Cancel");
  9349. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  9350. packet->setDataByName("unknown2", 50);
  9351. packet->setDataByName("unknown4", 1);
  9352. client->QueuePacket(packet->serialize());
  9353. safe_delete(packet);
  9354. }
  9355. }
  9356. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  9357. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9358. return;
  9359. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9360. if(client->GetCurrentRez()->active)
  9361. client->AcceptResurrection();
  9362. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9363. }
  9364. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  9365. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9366. return;
  9367. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9368. if(client->GetCurrentRez()->active)
  9369. client->GetCurrentRez()->should_delete = true;
  9370. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9371. }
  9372. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  9373. PrintSep(sep, "Switch_AA_Profile");
  9374. if (sep && sep->IsSet(0)) {
  9375. string type = sep->arg[0];
  9376. int8 newtemplate = atoul(sep->arg[1]);
  9377. master_aa_list.DisplayAA(client, newtemplate, 1);
  9378. }
  9379. }
  9380. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  9381. PrintSep(sep, "Get_AA_Xml");
  9382. if (sep && sep->IsSet(0)) {
  9383. string tabnum = sep->arg[0];
  9384. string spellid = sep->arg[1];
  9385. }
  9386. }
  9387. void Commands::Add_AA(Client* client, Seperator* sep) {
  9388. PrintSep(sep, "Add_AA");
  9389. if (sep && sep->IsSet(0)) {
  9390. int32 spell_id = atoul(sep->arg[1]);
  9391. int8 spell_tier = 0;
  9392. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9393. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9394. // addspellbookentry here
  9395. if (spell_tier >= data->maxRank) {
  9396. return;
  9397. }
  9398. if (!spell_tier) {
  9399. spell_tier = 1;
  9400. }
  9401. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9402. {
  9403. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9404. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9405. client->GetPlayer()->UnlockSpell(spell);
  9406. client->SendSpellUpdate(spell);
  9407. }
  9408. else
  9409. {
  9410. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  9411. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9412. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9413. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9414. client->GetPlayer()->UnlockSpell(spell);
  9415. client->SendSpellUpdate(spell);
  9416. }
  9417. // cast spell here
  9418. if (!spell_tier)
  9419. spell_tier = 1;
  9420. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9421. if (spell) {
  9422. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9423. }
  9424. }
  9425. else {
  9426. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9427. }
  9428. master_aa_list.DisplayAA(client, 0, 0);
  9429. }
  9430. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  9431. PrintSep(sep, "Commit_AA_Profile");
  9432. if (sep && sep->IsSet(0)) {
  9433. }
  9434. }
  9435. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  9436. PrintSep(sep, "Begin_AA_Profile");
  9437. if (sep && sep->IsSet(0)) {
  9438. master_aa_list.DisplayAA(client, 100, 2);
  9439. }
  9440. }
  9441. void Commands::Back_AA(Client* client, Seperator* sep) {
  9442. if (sep && sep->IsSet(0)) {
  9443. PrintSep(sep, "Back_AA");
  9444. }
  9445. }
  9446. void Commands::Remove_AA(Client* client, Seperator* sep) {
  9447. if (sep && sep->IsSet(0)) {
  9448. PrintSep(sep, "Remove_AA");
  9449. }
  9450. }
  9451. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  9452. MasterAAList master_aa_list;
  9453. PrintSep(sep, "Cancel_AA_Profile");
  9454. master_aa_list.DisplayAA(client, 0, 0);
  9455. }
  9456. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  9457. if (sep && sep->IsSet(0)) {
  9458. PrintSep(sep, "Save_AA_Profile");
  9459. }
  9460. }
  9461. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  9462. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  9463. if (!sep->IsNumber(0)) return;
  9464. int32 request_id = atoul(sep->arg[0]);
  9465. if (!sep->IsNumber(1)) return;
  9466. sint32 item_id = atoi(sep->arg[1]);
  9467. if (client->IsCurrentTransmuteID(request_id)) {
  9468. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  9469. }
  9470. else if (client->IsCurrentTransmuteID(item_id)) {
  9471. if (!sep->IsSet(2)) return;
  9472. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  9473. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  9474. }
  9475. }
  9476. }
  9477. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  9478. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  9479. }