Commands.cpp 321 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include "Commands.h"
  18. #include "../ClientPacketFunctions.h"
  19. #include "../../common/version.h"
  20. #include "../../common/seperator.h"
  21. #include "../../common/servertalk.h"
  22. #include "../WorldDatabase.h"
  23. #include "../World.h"
  24. #include "../../common/ConfigReader.h"
  25. #include "../VisualStates.h"
  26. #include "../../common/debug.h"
  27. #include "../LuaInterface.h"
  28. #include "../Quests.h"
  29. #include "../client.h"
  30. #include "../NPC.h"
  31. #include "../Guilds/Guild.h"
  32. #include "../SpellProcess.h"
  33. #include "../Tradeskills/Tradeskills.h"
  34. #include "../../common/Log.h"
  35. #include "../../common/MiscFunctions.h"
  36. #include "../Languages.h"
  37. #include "../IRC/IRC.h"
  38. #include "../Traits/Traits.h"
  39. #include "../Chat/Chat.h"
  40. #include "../Rules/Rules.h"
  41. #include "../AltAdvancement/AltAdvancement.h"
  42. #include "../RaceTypes/RaceTypes.h"
  43. #include "../classes.h"
  44. #include "../Transmute.h"
  45. #include "../Zone/SPGrid.h"
  46. extern WorldDatabase database;
  47. extern MasterSpellList master_spell_list;
  48. extern MasterTraitList master_trait_list;
  49. extern MasterRecipeList master_recipe_list;
  50. extern MasterRecipeBookList master_recipebook_list;
  51. extern World world;
  52. extern ClientList client_list;
  53. extern ConfigReader configReader;
  54. extern VisualStates visual_states;
  55. extern ZoneList zone_list;
  56. extern LuaInterface* lua_interface;
  57. extern MasterQuestList master_quest_list;
  58. extern MasterCollectionList master_collection_list;
  59. extern MasterSkillList master_skill_list;
  60. extern MasterFactionList master_faction_list;
  61. extern GuildList guild_list;
  62. extern MasterLanguagesList master_languages_list;
  63. extern IRC irc;
  64. extern Chat chat;
  65. extern RuleManager rule_manager;
  66. extern MasterAAList master_aa_list;
  67. extern MasterRaceTypeList race_types_list;
  68. extern Classes classes;
  69. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  70. #if defined(__GNUC__)
  71. #define stricmp strcasecmp
  72. #define strnicmp strncasecmp
  73. #endif
  74. EQ2Packet* RemoteCommands::serialize(){
  75. buffer.clear();
  76. vector<EQ2_RemoteCommandString>::iterator command_list;
  77. buffer.append((char*)&num_commands, sizeof(int16));
  78. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  79. AddDataCommand(&(*command_list));
  80. }
  81. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  82. return app;
  83. }
  84. Commands::Commands(){
  85. remote_commands = new RemoteCommands();
  86. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  87. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  88. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  89. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  90. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  91. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  92. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  93. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  94. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  95. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  96. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  97. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  98. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  99. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  100. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  101. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  102. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  103. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  104. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  105. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  106. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  107. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  108. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  109. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  110. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  111. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  112. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  113. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  114. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  115. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  116. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  117. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  118. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  119. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  120. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  121. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  122. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  123. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  124. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  125. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  126. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  127. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  128. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  129. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  130. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  131. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  132. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  133. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  134. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  135. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  136. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  137. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  138. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  139. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  140. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  141. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  142. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  143. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  144. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  145. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  146. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  147. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  148. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  149. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  150. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  151. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  152. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  153. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  154. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  155. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  156. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  157. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  158. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  159. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  160. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  161. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  162. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  163. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  164. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  165. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  166. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  167. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  168. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  169. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  170. }
  171. Commands::~Commands() {
  172. safe_delete(remote_commands);
  173. }
  174. int32 Commands::GetSpawnSetType(string val){
  175. if(spawn_set_values.count(val) > 0)
  176. return spawn_set_values[val];
  177. return 0xFFFFFFFF;
  178. }
  179. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  180. if(!target)
  181. return false;
  182. int32 val = 0;
  183. try{
  184. if(type != SPAWN_SET_VALUE_NAME && !(type >= SPAWN_SET_VALUE_SPAWN_SCRIPT && type <= SPAWN_SET_VALUE_SUB_TITLE) && !(type >= SPAWN_SET_VALUE_PREFIX && type <= SPAWN_SET_VALUE_EXPANSION_FLAG))
  185. val = atoul(value);
  186. }
  187. catch(...){
  188. if(client)
  189. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  190. return false;
  191. }
  192. if(temporary && temp_value){
  193. char tmp[128] = {0};
  194. switch(type){
  195. case SPAWN_SET_VALUE_NAME:{
  196. sprintf(tmp, "%s", target->GetName());
  197. target->SetName(value);
  198. client->GetCurrentZone()->SendUpdateTitles(target);
  199. break;
  200. }
  201. case SPAWN_SET_VALUE_X_OFFSET:
  202. {
  203. sprintf(tmp, "%f", target->GetXOffset());
  204. target->SetXOffset(float(val));
  205. break;
  206. }
  207. case SPAWN_SET_VALUE_Y_OFFSET:
  208. {
  209. sprintf(tmp, "%f", target->GetYOffset());
  210. target->SetYOffset(float(val));
  211. break;
  212. }
  213. case SPAWN_SET_VALUE_Z_OFFSET:
  214. {
  215. sprintf(tmp, "%f", target->GetZOffset());
  216. target->SetZOffset(float(val));
  217. break;
  218. }
  219. case SPAWN_SET_VALUE_EXPIRE: {
  220. sprintf(tmp, "%u", target->GetExpireTime());
  221. target->SetExpireTime(val);
  222. break;
  223. }
  224. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  225. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  226. target->SetExpireOffsetTime(val);
  227. break;
  228. }
  229. case SPAWN_SET_VALUE_SUB_TITLE: {
  230. sprintf(tmp, "%s", target->GetSubTitle());
  231. target->SetSubTitle(value);
  232. client->GetCurrentZone()->SendUpdateTitles(target);
  233. break;
  234. }
  235. case SPAWN_SET_VALUE_LEVEL:{
  236. sprintf(tmp, "%i", target->GetLevel());
  237. target->SetLevel(val, send_update);
  238. break;
  239. }
  240. case SPAWN_SET_VALUE_DIFFICULTY:{
  241. sprintf(tmp, "%i", target->GetEncounterLevel());
  242. target->SetEncounterLevel(val, send_update);
  243. break;
  244. }
  245. case SPAWN_SET_VALUE_MODEL_TYPE:{
  246. sprintf(tmp, "%i", target->GetModelType());
  247. target->SetModelType(val, send_update);
  248. break;
  249. }
  250. case SPAWN_SET_VALUE_CLASS:{
  251. sprintf(tmp, "%i", target->GetAdventureClass());
  252. target->SetAdventureClass(val, send_update);
  253. break;
  254. }
  255. case SPAWN_SET_VALUE_GENDER:{
  256. sprintf(tmp, "%i", target->GetGender());
  257. target->SetGender(val, send_update);
  258. break;
  259. }
  260. case SPAWN_SET_VALUE_SHOW_NAME:{
  261. sprintf(tmp, "%i", target->GetShowName());
  262. target->SetShowName(val, send_update);
  263. break;
  264. }
  265. case SPAWN_SET_VALUE_ATTACKABLE:{
  266. sprintf(tmp, "%i", target->GetAttackable());
  267. target->SetAttackable(val, send_update);
  268. break;
  269. }
  270. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  271. sprintf(tmp, "%i", target->GetShowLevel());
  272. target->SetShowLevel(val, send_update);
  273. break;
  274. }
  275. case SPAWN_SET_VALUE_TARGETABLE:{
  276. sprintf(tmp, "%i", target->GetTargetable());
  277. target->SetTargetable(val, send_update);
  278. break;
  279. }
  280. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  281. sprintf(tmp, "%i", target->GetShowCommandIcon());
  282. target->SetShowCommandIcon(val, send_update);
  283. break;
  284. }
  285. case SPAWN_SET_VALUE_HAND_ICON:{
  286. sprintf(tmp, "%i", target->GetShowHandIcon());
  287. target->SetShowHandIcon(val, send_update);
  288. break;
  289. }
  290. case SPAWN_SET_VALUE_HAIR_TYPE:{
  291. if(target->IsEntity()){
  292. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  293. ((Entity*)target)->SetHairType(val, send_update);
  294. }
  295. break;
  296. }
  297. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  298. if(target->IsEntity()){
  299. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  300. ((Entity*)target)->SetHairType(val, send_update);
  301. }
  302. break;
  303. }
  304. case SPAWN_SET_VALUE_WING_TYPE:{
  305. if(target->IsEntity()){
  306. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  307. ((Entity*)target)->SetWingType(val, send_update);
  308. }
  309. break;
  310. }
  311. case SPAWN_SET_VALUE_CHEST_TYPE:{
  312. if(target->IsEntity()){
  313. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  314. ((Entity*)target)->SetChestType(val, send_update);
  315. }
  316. break;
  317. }
  318. case SPAWN_SET_VALUE_LEGS_TYPE:{
  319. if(target->IsEntity()){
  320. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  321. ((Entity*)target)->SetLegsType(val, send_update);
  322. }
  323. break;
  324. }
  325. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  326. if(target->IsEntity()){
  327. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  328. ((Entity*)target)->SetSogaHairType(val, send_update);
  329. }
  330. break;
  331. }
  332. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  333. if(target->IsEntity()){
  334. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  335. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  336. }
  337. break;
  338. }
  339. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  340. sprintf(tmp, "%i", target->GetSogaModelType());
  341. target->SetSogaModelType(val, send_update);
  342. break;
  343. }
  344. case SPAWN_SET_VALUE_SIZE:{
  345. sprintf(tmp, "%i", target->GetSize());
  346. target->SetSize(val, send_update);
  347. break;
  348. }
  349. case SPAWN_SET_VALUE_HP:{
  350. sprintf(tmp, "%i", target->GetHP());
  351. target->SetHP(val, send_update);
  352. break;
  353. }
  354. case SPAWN_SET_VALUE_POWER:{
  355. sprintf(tmp, "%i", target->GetPower());
  356. target->SetPower(val, send_update);
  357. break;
  358. }
  359. case SPAWN_SET_VALUE_HEROIC:{
  360. sprintf(tmp, "%i", target->GetHeroic());
  361. target->SetHeroic(val, send_update);
  362. break;
  363. }
  364. case SPAWN_SET_VALUE_RESPAWN:{
  365. sprintf(tmp, "%u", target->GetRespawnTime());
  366. target->SetRespawnTime(val);
  367. break;
  368. }
  369. case SPAWN_SET_VALUE_X:{
  370. sprintf(tmp, "%f", target->GetX());
  371. target->SetX(atof(value), send_update);
  372. break;
  373. }
  374. case SPAWN_SET_VALUE_Y:{
  375. sprintf(tmp, "%f", target->GetY());
  376. target->SetY(atof(value), send_update);
  377. break;
  378. }
  379. case SPAWN_SET_VALUE_Z:{
  380. sprintf(tmp, "%f", target->GetZ());
  381. target->SetZ(atof(value), send_update);
  382. break;
  383. }
  384. case SPAWN_SET_VALUE_HEADING:{
  385. sprintf(tmp, "%f", target->GetHeading());
  386. target->SetHeading(atof(value) + 360, send_update);
  387. break;
  388. }
  389. case SPAWN_SET_VALUE_VISUAL_STATE:{
  390. sprintf(tmp, "%i", target->GetVisualState());
  391. target->SetVisualState(val, send_update);
  392. break;
  393. }
  394. case SPAWN_SET_VALUE_ACTION_STATE:{
  395. sprintf(tmp, "%i", target->GetActionState());
  396. target->SetActionState(val, send_update);
  397. break;
  398. }
  399. case SPAWN_SET_VALUE_MOOD_STATE:{
  400. sprintf(tmp, "%i", target->GetMoodState());
  401. target->SetMoodState(val, send_update);
  402. break;
  403. }
  404. case SPAWN_SET_VALUE_INITIAL_STATE:{
  405. sprintf(tmp, "%i", target->GetInitialState());
  406. target->SetInitialState(val, send_update);
  407. break;
  408. }
  409. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  410. sprintf(tmp, "%i", target->GetActivityStatus());
  411. target->SetActivityStatus(val, send_update);
  412. break;
  413. }
  414. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  415. sprintf(tmp, "%i", target->GetCollisionRadius());
  416. target->SetCollisionRadius(val, send_update);
  417. break;
  418. }
  419. case SPAWN_SET_VALUE_DEVICE_ID: {
  420. if (target->IsObject()) {
  421. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  422. ((Object*)target)->SetDeviceID(val);
  423. }
  424. break;
  425. }
  426. case SPAWN_SET_VALUE_PITCH: {
  427. sprintf(tmp, "%f", target->GetPitch());
  428. target->SetPitch(atof(value), send_update);
  429. break;
  430. }
  431. case SPAWN_SET_VALUE_ROLL: {
  432. sprintf(tmp, "%f", target->GetRoll());
  433. target->SetRoll(atof(value), send_update);
  434. break;
  435. }
  436. case SPAWN_SET_VALUE_HIDE_HOOD: {
  437. sprintf(tmp, "%i", target->appearance.hide_hood);
  438. target->SetHideHood(val);
  439. break;
  440. }
  441. case SPAWN_SET_VALUE_EMOTE_STATE: {
  442. sprintf(tmp, "%i", target->appearance.emote_state);
  443. target->SetEmoteState(val);
  444. break;
  445. }
  446. case SPAWN_SET_VALUE_ICON: {
  447. sprintf(tmp, "%i", target->GetIconValue());
  448. target->SetIcon(val);
  449. break;
  450. }
  451. case SPAWN_SET_VALUE_PREFIX: {
  452. sprintf(tmp, "%s", target->GetPrefixTitle());
  453. target->SetPrefixTitle(value);
  454. client->GetCurrentZone()->SendUpdateTitles(target);
  455. break;
  456. }
  457. case SPAWN_SET_VALUE_SUFFIX: {
  458. sprintf(tmp, "%s", target->GetSuffixTitle());
  459. target->SetSuffixTitle(value);
  460. client->GetCurrentZone()->SendUpdateTitles(target);
  461. break;
  462. }
  463. case SPAWN_SET_VALUE_LASTNAME: {
  464. sprintf(tmp, "%s", target->GetLastName());
  465. target->SetLastName(value);
  466. client->GetCurrentZone()->SendUpdateTitles(target);
  467. break;
  468. }
  469. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  470. // nothing to do must reload spawns
  471. break;
  472. }
  473. *temp_value = string(tmp);
  474. }
  475. }
  476. else{
  477. switch(type){
  478. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  479. if (target->GetDatabaseID() > 0)
  480. {
  481. char query[256];
  482. snprintf(query, 256, "update spawn set expansion_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  483. if (database.RunQuery(query, strnlen(query, 256)))
  484. {
  485. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  486. }
  487. }
  488. break;
  489. }
  490. case SPAWN_SET_VALUE_NAME:{
  491. target->SetName(value);
  492. client->GetCurrentZone()->SendUpdateTitles(target);
  493. break;
  494. }
  495. case SPAWN_SET_VALUE_SUB_TITLE: {
  496. target->SetSubTitle(value);
  497. client->GetCurrentZone()->SendUpdateTitles(target);
  498. break;
  499. }
  500. case SPAWN_SET_VALUE_X_OFFSET:
  501. {
  502. target->SetXOffset(atof(value));
  503. break;
  504. }
  505. case SPAWN_SET_VALUE_Y_OFFSET:
  506. {
  507. target->SetYOffset(atof(value));
  508. break;
  509. }
  510. case SPAWN_SET_VALUE_Z_OFFSET:
  511. {
  512. target->SetZOffset(atof(value));
  513. break;
  514. }
  515. case SPAWN_SET_VALUE_EXPIRE: {
  516. target->SetExpireTime(val);
  517. break;
  518. }
  519. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  520. target->SetExpireOffsetTime(val);
  521. break;
  522. }
  523. case SPAWN_SET_VALUE_LEVEL:{
  524. target->SetLevel(val, send_update);
  525. break;
  526. }
  527. case SPAWN_SET_VALUE_DIFFICULTY:{
  528. target->SetEncounterLevel(val, send_update);
  529. break;
  530. }
  531. case SPAWN_SET_VALUE_MODEL_TYPE:{
  532. target->SetModelType(val, send_update);
  533. break;
  534. }
  535. case SPAWN_SET_VALUE_CLASS:{
  536. target->SetAdventureClass(val, send_update);
  537. break;
  538. }
  539. case SPAWN_SET_VALUE_GENDER:{
  540. target->SetGender(val, send_update);
  541. break;
  542. }
  543. case SPAWN_SET_VALUE_SHOW_NAME:{
  544. target->SetShowName(val, send_update);
  545. break;
  546. }
  547. case SPAWN_SET_VALUE_ATTACKABLE:{
  548. target->SetAttackable(val, send_update);
  549. break;
  550. }
  551. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  552. target->SetShowLevel(val, send_update);
  553. break;
  554. }
  555. case SPAWN_SET_VALUE_TARGETABLE:{
  556. target->SetTargetable(val, send_update);
  557. break;
  558. }
  559. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  560. target->SetShowCommandIcon(val, send_update);
  561. break;
  562. }
  563. case SPAWN_SET_VALUE_HAND_ICON:{
  564. target->SetShowHandIcon(val, send_update);
  565. break;
  566. }
  567. case SPAWN_SET_VALUE_HAIR_TYPE:{
  568. if(target->IsEntity())
  569. ((Entity*)target)->SetHairType(val, send_update);
  570. break;
  571. }
  572. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  573. if(target->IsEntity())
  574. ((Entity*)target)->SetHairType(val, send_update);
  575. break;
  576. }
  577. case SPAWN_SET_VALUE_WING_TYPE:{
  578. if(target->IsEntity())
  579. ((Entity*)target)->SetWingType(val, send_update);
  580. break;
  581. }
  582. case SPAWN_SET_VALUE_CHEST_TYPE:{
  583. if(target->IsEntity())
  584. ((Entity*)target)->SetChestType(val, send_update);
  585. break;
  586. }
  587. case SPAWN_SET_VALUE_LEGS_TYPE:{
  588. if(target->IsEntity())
  589. ((Entity*)target)->SetLegsType(val, send_update);
  590. break;
  591. }
  592. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  593. if(target->IsEntity())
  594. ((Entity*)target)->SetSogaHairType(val, send_update);
  595. break;
  596. }
  597. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  598. if(target->IsEntity())
  599. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  600. break;
  601. }
  602. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  603. target->SetSogaModelType(val, send_update);
  604. break;
  605. }
  606. case SPAWN_SET_VALUE_SIZE:{
  607. target->SetSize(val, send_update);
  608. break;
  609. }
  610. case SPAWN_SET_VALUE_HP:{
  611. target->SetHP(val, send_update);
  612. break;
  613. }
  614. case SPAWN_SET_VALUE_POWER:{
  615. target->SetPower(val, send_update);
  616. break;
  617. }
  618. case SPAWN_SET_VALUE_HEROIC:{
  619. target->SetHeroic(val, send_update);
  620. break;
  621. }
  622. case SPAWN_SET_VALUE_RESPAWN:{
  623. target->SetRespawnTime(val);
  624. break;
  625. }
  626. case SPAWN_SET_VALUE_X:{
  627. target->SetX(atof(value), send_update);
  628. target->SetSpawnOrigX(target->GetX());
  629. break;
  630. }
  631. case SPAWN_SET_VALUE_Y:{
  632. target->SetY(atof(value), send_update);
  633. target->SetSpawnOrigY(target->GetY());
  634. break;
  635. }
  636. case SPAWN_SET_VALUE_Z:{
  637. target->SetZ(atof(value), send_update);
  638. target->SetSpawnOrigZ(target->GetZ());
  639. break;
  640. }
  641. case SPAWN_SET_VALUE_HEADING:{
  642. target->SetHeading(atof(value), send_update);
  643. target->SetSpawnOrigHeading(target->GetHeading());
  644. break;
  645. }
  646. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  647. ZoneServer* zone = target->GetZone();
  648. if (!zone)
  649. zone = client->GetCurrentZone();
  650. if(zone->GetEntityCommandList(val))
  651. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  652. target->primary_command_list_id = val;
  653. break;
  654. }
  655. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  656. ZoneServer* zone = target->GetZone();
  657. if (!zone)
  658. zone = client->GetCurrentZone();
  659. if (zone->GetEntityCommandList(val))
  660. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  661. target->secondary_command_list_id = val;
  662. break;
  663. }
  664. case SPAWN_SET_VALUE_VISUAL_STATE:{
  665. target->SetVisualState(val, send_update);
  666. break;
  667. }
  668. case SPAWN_SET_VALUE_ACTION_STATE:{
  669. target->SetActionState(val, send_update);
  670. break;
  671. }
  672. case SPAWN_SET_VALUE_MOOD_STATE:{
  673. target->SetMoodState(val, send_update);
  674. break;
  675. }
  676. case SPAWN_SET_VALUE_INITIAL_STATE:{
  677. target->SetInitialState(val, send_update);
  678. break;
  679. }
  680. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  681. target->SetActivityStatus(val, send_update);
  682. break;
  683. }
  684. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  685. target->SetCollisionRadius(val, send_update);
  686. break;
  687. }
  688. case SPAWN_SET_VALUE_FACTION:{
  689. ZoneServer* zone = target->GetZone();
  690. if (!zone)
  691. zone = client->GetCurrentZone();
  692. target->faction_id = val;
  693. zone->RemoveDeadEnemyList(target);
  694. if(target->IsNPC())
  695. zone->AddEnemyList((NPC*)target);
  696. break;
  697. }
  698. case SPAWN_SET_VALUE_DEVICE_ID:{
  699. if (target->IsObject())
  700. ((Object*)target)->SetDeviceID(val);
  701. break;
  702. }
  703. case SPAWN_SET_VALUE_PITCH: {
  704. target->SetPitch(atof(value), send_update);
  705. target->SetSpawnOrigPitch(atof(value));
  706. break;
  707. }
  708. case SPAWN_SET_VALUE_ROLL: {
  709. target->SetRoll(atof(value), send_update);
  710. target->SetSpawnOrigRoll(atof(value));
  711. break;
  712. }
  713. case SPAWN_SET_VALUE_HIDE_HOOD: {
  714. target->SetHideHood(val);
  715. break;
  716. }
  717. case SPAWN_SET_VALUE_EMOTE_STATE: {
  718. target->SetEmoteState(val);
  719. break;
  720. }
  721. case SPAWN_SET_VALUE_ICON: {
  722. target->SetIcon(val);
  723. break;
  724. }
  725. case SPAWN_SET_VALUE_PREFIX: {
  726. target->SetPrefixTitle(value);
  727. client->GetCurrentZone()->SendUpdateTitles(target);
  728. break;
  729. }
  730. case SPAWN_SET_VALUE_SUFFIX: {
  731. target->SetSuffixTitle(value);
  732. client->GetCurrentZone()->SendUpdateTitles(target);
  733. break;
  734. }
  735. case SPAWN_SET_VALUE_LASTNAME: {
  736. target->SetLastName(value);
  737. client->GetCurrentZone()->SendUpdateTitles(target);
  738. break;
  739. }
  740. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  741. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  742. if(client){
  743. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  744. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  745. }
  746. return false;
  747. }
  748. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  749. return false;
  750. else{
  751. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  752. target->SetSpawnScript(value);
  753. }
  754. break;
  755. }
  756. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  757. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  758. if(client){
  759. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  760. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  761. }
  762. return false;
  763. }
  764. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  765. return false;
  766. else{
  767. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  768. target->SetSpawnScript(value);
  769. }
  770. break;
  771. }
  772. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  773. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  774. if(client){
  775. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  776. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  777. }
  778. return false;
  779. }
  780. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  781. return false;
  782. else
  783. target->SetSpawnScript(value);
  784. break;
  785. }
  786. }
  787. }
  788. return true;
  789. }
  790. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  791. the database fields always and also update the zone in memory if it's running. */
  792. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  793. if (client && zone_id > 0 && type > 0 && value) {
  794. sint32 int_value = 0;
  795. float float_value = 0;
  796. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  797. try {
  798. float_value = atof(value);
  799. }
  800. catch (...) {
  801. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  802. return false;
  803. }
  804. }
  805. else if (type != ZONE_SET_VALUE_NAME && type != ZONE_SET_VALUE_FILE && type != ZONE_SET_VALUE_DESCRIPTION && type != ZONE_SET_VALUE_ZONE_TYPE && type != ZONE_SET_VALUE_LUA_SCRIPT && type != ZONE_SET_VALUE_ZONE_MOTD) {
  806. try {
  807. int_value = atoi(value);
  808. }
  809. catch (...) {
  810. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  811. return false;
  812. }
  813. }
  814. switch (type) {
  815. case ZONE_SET_VALUE_EXPANSION_ID: {
  816. break;
  817. }
  818. case ZONE_SET_VALUE_NAME: {
  819. if (zone)
  820. zone->SetZoneName(const_cast<char*>(value));
  821. database.SaveZoneInfo(zone_id, "name", value);
  822. break;
  823. }
  824. case ZONE_SET_VALUE_FILE: {
  825. if (zone)
  826. zone->SetZoneFile(const_cast<char*>(value));
  827. database.SaveZoneInfo(zone_id, "file", value);
  828. break;
  829. }
  830. case ZONE_SET_VALUE_DESCRIPTION: {
  831. if (zone)
  832. zone->SetZoneDescription(const_cast<char*>(value));
  833. database.SaveZoneInfo(zone_id, "description", value);
  834. break;
  835. }
  836. case ZONE_SET_VALUE_SAFE_X: {
  837. if (zone)
  838. zone->SetSafeX(float_value);
  839. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  840. break;
  841. }
  842. case ZONE_SET_VALUE_SAFE_Y: {
  843. if (zone)
  844. zone->SetSafeY(float_value);
  845. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  846. break;
  847. }
  848. case ZONE_SET_VALUE_SAFE_Z: {
  849. if (zone)
  850. zone->SetSafeZ(float_value);
  851. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  852. break;
  853. }
  854. case ZONE_SET_VALUE_UNDERWORLD: {
  855. if (zone)
  856. zone->SetUnderWorld(float_value);
  857. database.SaveZoneInfo(zone_id, "underworld", float_value);
  858. break;
  859. }
  860. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  861. break;
  862. }
  863. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  864. break;
  865. }
  866. case ZONE_SET_VALUE_ZONE_TYPE: {
  867. break;
  868. }
  869. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  870. if (zone)
  871. zone->SetAlwaysLoaded(int_value == 1);
  872. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  873. break;
  874. }
  875. case ZONE_SET_VALUE_CITY_ZONE: {
  876. if (zone)
  877. zone->SetCityZone(int_value == 1);
  878. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  879. break;
  880. }
  881. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  882. if (zone)
  883. zone->SetWeatherAllowed(int_value == 1);
  884. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  885. break;
  886. }
  887. case ZONE_SET_VALUE_MIN_STATUS: {
  888. if (zone)
  889. zone->SetMinimumStatus(int_value);
  890. database.SaveZoneInfo(zone_id, "min_status", int_value);
  891. break;
  892. }
  893. case ZONE_SET_VALUE_MIN_LEVEL: {
  894. if (zone)
  895. zone->SetMinimumLevel(int_value);
  896. database.SaveZoneInfo(zone_id, "min_level", int_value);
  897. break;
  898. }
  899. case ZONE_SET_VALUE_MAX_LEVEL: {
  900. if (zone)
  901. zone->SetMaximumLevel(int_value);
  902. database.SaveZoneInfo(zone_id, "max_level", int_value);
  903. break;
  904. }
  905. case ZONE_SET_VALUE_START_ZONE: {
  906. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  907. break;
  908. }
  909. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  910. if (zone)
  911. zone->SetInstanceType(int_value);
  912. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  913. break;
  914. }
  915. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  916. if (zone)
  917. zone->SetDefaultReenterTime(int_value);
  918. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  919. break;
  920. }
  921. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  922. if (zone)
  923. zone->SetDefaultResetTime(int_value);
  924. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  925. break;
  926. }
  927. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  928. if (zone)
  929. zone->SetDefaultLockoutTime(int_value);
  930. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  931. break;
  932. }
  933. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  934. if (zone)
  935. zone->SetForceGroupZoneOption(int_value);
  936. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  937. break;
  938. }
  939. case ZONE_SET_VALUE_LUA_SCRIPT: {
  940. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  941. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  942. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  943. return false;
  944. }
  945. else {
  946. world.AddZoneScript(zone_id, const_cast<char*>(value));
  947. database.SaveZoneInfo(zone_id, "lua_script", value);
  948. }
  949. break;
  950. }
  951. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  952. if (zone)
  953. zone->SetShutdownTimer(int_value);
  954. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  955. break;
  956. }
  957. case ZONE_SET_VALUE_ZONE_MOTD: {
  958. if (zone)
  959. zone->SetZoneMOTD(string(value));
  960. database.SaveZoneInfo(zone_id, "zone_motd", value);
  961. break;
  962. }
  963. default: {
  964. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  965. return false;
  966. }
  967. }
  968. }
  969. else {
  970. if (client)
  971. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  972. return false;
  973. }
  974. return true;
  975. }
  976. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  977. if (index >= remote_commands->commands.size()) {
  978. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  979. return;
  980. }
  981. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  982. EQ2_RemoteCommandString* parent_command = 0;
  983. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  984. Seperator* sep = 0;
  985. if (command_parms->size > 0) {
  986. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  987. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  988. parent_command = command;
  989. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  990. safe_delete(sep);
  991. if (command_parms->data.length() > (command->command.data.length() + 1))
  992. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  993. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  994. }
  995. else
  996. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  997. }
  998. int ndx = 0;
  999. if (command->required_status > client->GetAdminStatus())
  1000. {
  1001. LogWrite(COMMAND__ERROR, 0, "Command", "Player '%s' (%u) needs status %i to use command: %s", client->GetPlayer()->GetName(), client->GetAccountID(), command->required_status, command->command.data.c_str());
  1002. safe_delete(sep);
  1003. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1004. return;
  1005. }
  1006. Player* player = client->GetPlayer();
  1007. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1008. switch (command->handler) {
  1009. case COMMAND_RELOAD: {
  1010. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1012. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1013. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1014. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1015. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1016. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1017. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1018. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1019. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1020. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1021. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1022. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1023. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1024. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1025. break;
  1026. }
  1027. case COMMAND_RELOADSTRUCTS: {
  1028. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1029. configReader.ReloadStructs();
  1030. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1031. break;
  1032. }
  1033. case COMMAND_RELOAD_QUESTS: {
  1034. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1035. master_quest_list.Reload();
  1036. client_list.ReloadQuests();
  1037. zone_list.ReloadClientQuests();
  1038. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1039. break;
  1040. }
  1041. case COMMAND_RELOAD_SPAWNS: {
  1042. client->GetCurrentZone()->ReloadSpawns();
  1043. break;
  1044. }
  1045. case COMMAND_RELOAD_SPELLS: {
  1046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1047. zone_list.DeleteSpellProcess();
  1048. master_spell_list.Reload();
  1049. if (lua_interface)
  1050. lua_interface->ReloadSpells();
  1051. zone_list.LoadSpellProcess();
  1052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1053. break;
  1054. }
  1055. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1057. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1058. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1060. break;
  1061. }
  1062. case COMMAND_RELOAD_ZONESCRIPTS: {
  1063. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1064. world.ResetZoneScripts();
  1065. database.LoadZoneScriptData();
  1066. if (lua_interface)
  1067. lua_interface->DestroyZoneScripts();
  1068. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1069. break;
  1070. }
  1071. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1072. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1073. client->GetCurrentZone()->ClearEntityCommands();
  1074. database.LoadEntityCommands(client->GetCurrentZone());
  1075. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1076. break;
  1077. }
  1078. case COMMAND_RELOAD_FACTIONS: {
  1079. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1080. master_faction_list.Clear();
  1081. database.LoadFactionList();
  1082. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1083. break;
  1084. }
  1085. case COMMAND_RELOAD_MAIL: {
  1086. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1087. zone_list.ReloadMail();
  1088. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1089. break;
  1090. }
  1091. case COMMAND_RELOAD_GUILDS: {
  1092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1093. world.ReloadGuilds();
  1094. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1095. break;
  1096. }
  1097. case COMMAND_RELOAD_LOCATIONS: {
  1098. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1099. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1100. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1101. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1102. break;
  1103. }
  1104. case COMMAND_READ: {
  1105. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1106. if (strcmp(sep->arg[0], "read") == 0) {
  1107. int32 item_index = atol(sep->arg[1]);
  1108. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1109. if (item) {
  1110. Spawn* spawn = cmdTarget;
  1111. int8 numpages = item->book_pages.size();
  1112. string page1 = string(item->book_pages[0]->page_text.data);
  1113. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  1114. string title = item->name;
  1115. if (packet) {
  1116. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  1117. packet->setDataByName("book_title", title.c_str());
  1118. packet->setDataByName("book_type", "simple");
  1119. packet->setDataByName("unknown2", 1);
  1120. packet->setDataByName("unknown5", 1, 4);
  1121. packet->setArrayLengthByName("num_pages", numpages);
  1122. for (int8 pages = 1; pages <= numpages; pages++) {
  1123. int8 pagenum = int8(item->book_pages[pages - 1]->page);
  1124. string page = string(item->book_pages[pages-1]->page_text.data);
  1125. int8 valign = int8(item->book_pages[pages - 1]->valign);
  1126. int8 halign = int8(item->book_pages[pages - 1]->halign);
  1127. packet->setArrayDataByName("page_text", page.c_str(), pagenum -1);
  1128. packet->setArrayDataByName("page_text_valign", valign , pagenum - 1);
  1129. packet->setArrayDataByName("page_text_halign", halign, pagenum - 1);
  1130. // Need to add support for images
  1131. }
  1132. client->QueuePacket(packet->serialize());
  1133. safe_delete(packet);
  1134. }
  1135. break;
  1136. }
  1137. }
  1138. }
  1139. }
  1140. case COMMAND_USEABILITY:{
  1141. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1142. if (client->GetPlayer()->GetHP() == 0) {
  1143. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1144. }
  1145. else {
  1146. int32 spell_id = atoul(sep->arg[0]);
  1147. int8 spell_tier = 0;
  1148. if (sep->arg[1][0] && sep->IsNumber(1))
  1149. spell_tier = atoi(sep->arg[1]);
  1150. else
  1151. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1152. if (!spell_tier)
  1153. spell_tier = 1;
  1154. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1155. if (spell) {
  1156. if (strncmp(spell->GetName(), "Gathering", 9) == 0 || strncmp(spell->GetName(), "Mining", 6) == 0 || strncmp(spell->GetName(), "Trapping", 8) == 0 || strncmp(spell->GetName(), "Foresting", 9) == 0 || strncmp(spell->GetName(), "Fishing", 7) == 0 || strncmp(spell->GetName(), "Collecting", 10) == 0)
  1157. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1158. else
  1159. {
  1160. if (cmdTarget)
  1161. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1162. else
  1163. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1164. }
  1165. }
  1166. }
  1167. }
  1168. else if (cmdTarget && cmdTarget->IsWidget())
  1169. {
  1170. Widget* widget = (Widget*)cmdTarget;
  1171. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1172. }
  1173. else
  1174. {
  1175. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1176. }
  1177. break;
  1178. }
  1179. case COMMAND_INFO:{
  1180. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1181. if(strcmp(sep->arg[0], "inventory") == 0){
  1182. int32 item_index = atol(sep->arg[1]);
  1183. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1184. if(item){
  1185. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1186. break;
  1187. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1188. //DumpPacket(app);
  1189. client->QueuePacket(app);
  1190. if(item->GetItemScript() && lua_interface)
  1191. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1192. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1193. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id);
  1194. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1195. client->AddPendingQuest(quest);
  1196. }
  1197. }
  1198. else
  1199. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1200. }
  1201. else if(strcmp(sep->arg[0], "equipment") == 0){
  1202. int32 item_index = atol(sep->arg[1]);
  1203. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1204. if(item){
  1205. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1206. client->QueuePacket(app);
  1207. if(item->GetItemScript() && lua_interface)
  1208. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1209. }
  1210. else
  1211. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1212. }
  1213. else if(strcmp(sep->arg[0], "item") == 0 || strcmp(sep->arg[0], "merchant") == 0 || strcmp(sep->arg[0], "store") == 0 || strcmp(sep->arg[0], "buyback") == 0 || strcmp(sep->arg[0], "consignment") == 0){
  1214. int32 item_id = atoul(sep->arg[1]);
  1215. Item* item = master_item_list.GetItem(item_id);
  1216. if(item){
  1217. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1218. client->QueuePacket(app);
  1219. }
  1220. else
  1221. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1222. }
  1223. else if (strcmp(sep->arg[0], "spell") == 0) {
  1224. sint32 spell_id = atol(sep->arg[1]);
  1225. int8 tier = atoi(sep->arg[3]);
  1226. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1227. if (outapp)
  1228. client->QueuePacket(outapp);
  1229. else
  1230. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1231. }
  1232. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1233. sint32 spell_id = atol(sep->arg[2]);
  1234. int8 group = atoi(sep->arg[1]);
  1235. AltAdvanceData* data = 0;
  1236. SpellBookEntry* spellentry = 0;
  1237. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1238. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1239. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1240. if (outapp)
  1241. client->QueuePacket(outapp);
  1242. else
  1243. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1244. }
  1245. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1246. sint32 spell_id = atol(sep->arg[1]);
  1247. int8 tier = atoi(sep->arg[2]);
  1248. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1249. if (outapp)
  1250. client->QueuePacket(outapp);
  1251. else
  1252. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1253. }
  1254. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1255. sint32 recipe_id = atol(sep->arg[1]);
  1256. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1257. if(outapp)
  1258. client->QueuePacket(outapp);
  1259. else
  1260. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1261. }
  1262. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1263. int32 slot = atol(sep->arg[1]);
  1264. int32 spell_id = atol(sep->arg[2]);
  1265. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1266. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1267. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1268. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1269. if(outapp)
  1270. client->QueuePacket(outapp);
  1271. else
  1272. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1273. }
  1274. else if (strcmp(sep->arg[0], "effect") == 0) {
  1275. int32 spell_id = atol(sep->arg[1]);
  1276. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1277. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1278. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, 0x00);
  1279. if (outapp){
  1280. client->QueuePacket(outapp);
  1281. }
  1282. else
  1283. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1284. }
  1285. }
  1286. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1287. Item* item = player->item_list.GetOverflowItem();
  1288. if(item) {
  1289. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1290. client->QueuePacket(app);
  1291. }
  1292. else
  1293. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1294. }
  1295. else
  1296. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1297. break;
  1298. }
  1299. case COMMAND_USE_EQUIPPED_ITEM:{
  1300. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1301. int32 slot_id = atoul(sep->arg[0]);
  1302. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1303. if (item && item->generic_info.usable && item->GetItemScript())
  1304. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1305. }
  1306. break;
  1307. }
  1308. case COMMAND_USE_ITEM: {
  1309. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1310. int32 item_index = atoul(sep->arg[0]);
  1311. Item* item = player->item_list.GetItemFromIndex(item_index);
  1312. if (item && item->GetItemScript()) {
  1313. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1314. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1315. else {
  1316. if (item->generic_info.display_charges > 0) {
  1317. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1318. item->generic_info.display_charges -= 1;
  1319. item->save_needed = true;
  1320. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1321. }
  1322. }
  1323. }
  1324. }
  1325. break;
  1326. }
  1327. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1328. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1329. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1330. if (item) {
  1331. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1332. if(item->generic_info.item_type == 6) {
  1333. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1334. int8 old_slot = 0;
  1335. if (spell) {
  1336. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1337. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1338. player->RemoveSpellBookEntry(spell->GetSpellID());
  1339. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1340. player->UnlockSpell(spell);
  1341. client->SendSpellUpdate(spell);
  1342. database.DeleteItem(client->GetCharacterID(), item, 0);
  1343. player->item_list.RemoveItem(item, true);
  1344. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1345. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1346. }
  1347. }
  1348. else
  1349. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1350. }
  1351. else if(item->generic_info.item_type == 7){
  1352. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1353. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1354. // if valid recipe book and the player doesn't have it
  1355. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1356. client->Message(CHANNEL_COLOR_WHITE, "Your tradeskill level is not high enough to scribe this book.");
  1357. safe_delete(recipe_book);
  1358. }
  1359. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1360. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1361. // Add recipe book to the players list
  1362. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1363. // Get a list of all recipes this book contains
  1364. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1365. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1366. // Create the packet to send to update the players recipe list
  1367. PacketStruct* packet = 0;
  1368. if (client->GetRecipeListSent()) {
  1369. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1370. if (packet)
  1371. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1372. }
  1373. // loop through the list
  1374. vector<Recipe*>::iterator itr;
  1375. int16 i = 0;
  1376. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1377. // check to see if the player already has this recipe some how
  1378. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1379. // Player doesn't already have this recipe so lets add it
  1380. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1381. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1382. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1383. client->Message(CHANNEL_COLOR_WHITE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1384. if (packet && client->GetRecipeListSent()) {
  1385. packet->setArrayDataByName("id", recipe->GetID(), i);
  1386. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1387. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1388. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1389. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1390. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1391. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1392. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1393. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1394. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1395. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1396. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1397. i++;
  1398. }
  1399. }
  1400. }
  1401. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1402. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1403. database.DeleteItem(client->GetCharacterID(), item, 0);
  1404. client->GetPlayer()->item_list.RemoveItem(item, true);
  1405. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1406. if (packet && client->GetRecipeListSent())
  1407. client->QueuePacket(packet->serialize());
  1408. safe_delete(packet);
  1409. }
  1410. else {
  1411. if (recipe_book)
  1412. client->Message(CHANNEL_COLOR_WHITE, "You have already learned all you can from this item.");
  1413. safe_delete(recipe_book);
  1414. }
  1415. }
  1416. }
  1417. else
  1418. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1419. }
  1420. break;
  1421. }
  1422. case COMMAND_SUMMONITEM: {
  1423. if (sep && sep->IsNumber(0)) {
  1424. int32 item_id = atol(sep->arg[0]);
  1425. int32 quantity = 1;
  1426. if (sep->arg[1] && sep->IsNumber(1))
  1427. quantity = atoi(sep->arg[1]);
  1428. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1429. client->AddItemToBank(item_id,quantity);
  1430. }
  1431. else {
  1432. client->AddItem(item_id, quantity);
  1433. }
  1434. }
  1435. else {
  1436. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1437. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1438. }
  1439. break;
  1440. }
  1441. case COMMAND_COLLECTION_ADDITEM: {
  1442. // takes 2 params: collection_id, slot
  1443. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1444. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1445. if (item)
  1446. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1447. else
  1448. LogWrite(COLLECTION__ERROR, 0, "Collect", "Error in 'COMMAND_COLLECTION_ADDITEM'. Unable to get item from player '%s' at index %u", client->GetPlayer()->GetName(), atoul(sep->arg[0]));
  1449. }
  1450. else
  1451. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1452. break;
  1453. }
  1454. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1455. // takes 1 param: slot
  1456. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1457. int i = 0;
  1458. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1459. printf("\t%u: %s\n", i, sep->arg[i]);
  1460. i++;
  1461. }
  1462. break;
  1463. }
  1464. case COMMAND_WHO:{
  1465. const char* who = 0;
  1466. if(sep && sep->arg[0]){
  1467. //cout << "Who query: \n";
  1468. who = sep->argplus[0];
  1469. //cout << who << endl;
  1470. }
  1471. zone_list.ProcessWhoQuery(who, client);
  1472. break;
  1473. }
  1474. case COMMAND_SELECT_JUNCTION:{
  1475. LogWrite(MISC__TODO, 1, "TODO", "For access/travel selections (i.e. Mariner Bells, Player Death Window, etc.)\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1476. int32 choice = 0;
  1477. if(sep && sep->arg[0] && sep->IsNumber(0))
  1478. choice = atoul(sep->arg[0]);
  1479. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1480. client->HandlePlayerRevive(choice);
  1481. }
  1482. break;
  1483. }
  1484. case COMMAND_SPAWN_MOVE: {
  1485. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  1486. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1487. if (packet) {
  1488. float unknown2_3 = 0;
  1489. int8 placement_mode = 0;
  1490. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1491. if (sep && sep->arg[0][0]) {
  1492. if (strcmp(sep->arg[0], "wall") == 0) {
  1493. placement_mode = 2;
  1494. unknown2_3 = 150;
  1495. }
  1496. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1497. placement_mode = 1;
  1498. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1499. {
  1500. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1501. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1502. }
  1503. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1504. {
  1505. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1506. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1507. }
  1508. else if (strcmp(sep->arg[0], "myloc") == 0)
  1509. {
  1510. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1511. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1512. safe_delete(packet);
  1513. break;
  1514. }
  1515. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1516. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1517. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1518. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1519. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1520. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1521. safe_delete(packet);
  1522. break;
  1523. }
  1524. }
  1525. packet->setDataByName("placement_mode", placement_mode);
  1526. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1527. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1528. packet->setDataByName("unknown", 1); //size
  1529. packet->setDataByName("unknown2", 1); //size 2
  1530. packet->setDataByName("unknown2", .5, 1); //size 3
  1531. packet->setDataByName("unknown2", 3, 2);
  1532. packet->setDataByName("unknown2", unknown2_3, 3);
  1533. packet->setDataByName("max_distance", 500);
  1534. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1535. client->QueuePacket(packet->serialize());
  1536. safe_delete(packet);
  1537. }
  1538. }
  1539. else {
  1540. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1541. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1542. }
  1543. break;
  1544. }
  1545. case COMMAND_HAIL:{
  1546. Spawn* spawn = cmdTarget;
  1547. if(spawn && spawn->GetTargetable())
  1548. {
  1549. char tmp[75] = {0};
  1550. sprintf(tmp, "Hail, %s", spawn->GetName());
  1551. bool show_bubble = true;
  1552. if (spawn->IsNPC())
  1553. show_bubble = false;
  1554. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1555. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < 30){
  1556. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1557. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1558. else
  1559. spawn->ProcessMovement();
  1560. LogWrite(MISC__TODO, 0, "Check", "ProcessMovement has been called");
  1561. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer());
  1562. }
  1563. }
  1564. else {
  1565. string tmp = "Hail";
  1566. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1567. }
  1568. break;
  1569. }
  1570. case COMMAND_SAY:{
  1571. if (sep && sep->arg[0][0]) {
  1572. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1573. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1574. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1575. }
  1576. else
  1577. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1578. break;
  1579. }
  1580. case COMMAND_TELL:{
  1581. if(sep && sep->arg[0] && sep->argplus[1]){
  1582. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_TELL, sep->argplus[1]))
  1583. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1584. }else
  1585. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1586. break;
  1587. }
  1588. case COMMAND_SHOUT:{
  1589. if(sep && sep->arg[0][0])
  1590. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1591. else
  1592. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1593. break;
  1594. }
  1595. case COMMAND_AUCTION:{
  1596. if(sep && sep->arg[0][0])
  1597. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1598. else
  1599. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1600. break;
  1601. }
  1602. case COMMAND_OOC:{
  1603. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  1604. if(sep && sep->arg[0][0])
  1605. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OOC, sep->argplus[0]);
  1606. else
  1607. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  1608. break;
  1609. }
  1610. case COMMAND_EMOTE:{
  1611. if(sep && sep->arg[0][0])
  1612. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  1613. else
  1614. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  1615. break;
  1616. }
  1617. case COMMAND_RACE:{
  1618. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  1619. if(sep->arg[1][0] && sep->IsNumber(1)){
  1620. client->GetPlayer()->GetInfoStruct()->race = atoi(sep->arg[1]);
  1621. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  1622. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  1623. client->GetPlayer()->SetCharSheetChanged(true);
  1624. }
  1625. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  1626. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  1627. //client->QueuePacket(outapp);
  1628. }
  1629. else{
  1630. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  1631. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  1632. }
  1633. break;
  1634. }
  1635. case COMMAND_BANK_DEPOSIT:{
  1636. if(client->GetBanker() && sep && sep->arg[0]){
  1637. int64 amount = 0;
  1638. string deposit = string(sep->arg[0]);
  1639. amount = atoi64(deposit.c_str());
  1640. client->BankDeposit(amount);
  1641. }
  1642. break;
  1643. }
  1644. case COMMAND_BANK_WITHDRAWAL:{
  1645. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  1646. int64 amount = 0;
  1647. string deposit = string(sep->arg[0]);
  1648. amount = atoi64(deposit.c_str());
  1649. client->BankWithdrawal(amount);
  1650. }
  1651. break;
  1652. }
  1653. case COMMAND_BANK_CANCEL:{
  1654. Spawn* banker = cmdTarget;
  1655. client->Bank(banker, true);
  1656. break;
  1657. }
  1658. case COMMAND_BANK:{
  1659. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  1660. Spawn* banker = cmdTarget;
  1661. client->Bank(banker);
  1662. break;
  1663. }
  1664. case COMMAND_GUILD_BANK:{
  1665. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  1666. //Spawn* banker = client->GetPlayer()->GetTarget();
  1667. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  1668. break;
  1669. }
  1670. case COMMAND_START_MAIL: {
  1671. client->SetMailTransaction(cmdTarget);
  1672. client->SendMailList();
  1673. break;
  1674. }
  1675. case COMMAND_CANCEL_MAIL: {
  1676. client->SetMailTransaction(0);
  1677. break;
  1678. }
  1679. case COMMAND_GET_MAIL_MESSAGE: {
  1680. if (sep && sep->arg[0] && sep->IsNumber(0))
  1681. client->DisplayMailMessage(atoul(sep->arg[0]));
  1682. break;
  1683. }
  1684. case COMMAND_ADD_MAIL_PLAT: {
  1685. if (sep && sep->arg[0] && sep->IsNumber(0))
  1686. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1687. break;
  1688. }
  1689. case COMMAND_ADD_MAIL_GOLD: {
  1690. if (sep && sep->arg[0] && sep->IsNumber(0))
  1691. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  1692. break;
  1693. }
  1694. case COMMAND_ADD_MAIL_SILVER: {
  1695. if (sep && sep->arg[0] && sep->IsNumber(0))
  1696. client->AddMailCoin(0, atoul(sep->arg[0]));
  1697. break;
  1698. }
  1699. case COMMAND_ADD_MAIL_COPPER: {
  1700. if (sep && sep->arg[0] && sep->IsNumber(0))
  1701. client->AddMailCoin(atoul(sep->arg[0]));
  1702. break;
  1703. }
  1704. case COMMAND_SET_MAIL_ITEM: {
  1705. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1706. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1707. break;
  1708. }
  1709. case COMMAND_REMOVE_MAIL_PLAT: {
  1710. if (sep && sep->arg[0] && sep->IsNumber(0))
  1711. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1712. break;
  1713. }
  1714. case COMMAND_REMOVE_MAIL_GOLD: {
  1715. if (sep && sep->arg[0] && sep->IsNumber(0))
  1716. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  1717. break;
  1718. }
  1719. case COMMAND_REMOVE_MAIL_SILVER: {
  1720. if (sep && sep->arg[0] && sep->IsNumber(0))
  1721. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  1722. break;
  1723. }
  1724. case COMMAND_REMOVE_MAIL_COPPER: {
  1725. if (sep && sep->arg[0] && sep->IsNumber(0))
  1726. client->RemoveMailCoin(atoul(sep->arg[0]));
  1727. break;
  1728. }
  1729. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  1730. if (sep && sep->arg[0] && sep->IsNumber(0))
  1731. client->TakeMailAttachments(atoul(sep->arg[0]));
  1732. break;
  1733. }
  1734. case COMMAND_CANCEL_SEND_MAIL: {
  1735. client->CancelSendMail();
  1736. break;
  1737. }
  1738. case COMMAND_DELETE_MAIL_MESSAGE: {
  1739. if (sep && sep->arg[0] && sep->IsNumber(0))
  1740. client->DeleteMail(atoul(sep->arg[0]), true);
  1741. break;
  1742. }
  1743. case COMMAND_REPORT_SPAM: {
  1744. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1745. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1746. break;
  1747. }
  1748. case COMMAND_KILL:{
  1749. Spawn* dead = 0;
  1750. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  1751. dead=client->GetPlayer();
  1752. client->GetPlayer()->SetHP(0);
  1753. client->GetPlayer()->KillSpawn(dead);
  1754. }else{
  1755. dead= cmdTarget;
  1756. if(dead && dead->IsPlayer() == false){
  1757. dead->SetHP(0);
  1758. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  1759. client->GetCurrentZone()->RemoveSpawn(false, dead, true);
  1760. else
  1761. client->GetPlayer()->KillSpawn(dead);
  1762. }else{
  1763. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  1764. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  1765. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  1766. }
  1767. }
  1768. break;
  1769. }
  1770. case COMMAND_LEVEL:{
  1771. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  1772. int16 new_level = atoi(sep->arg[ndx]);
  1773. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  1774. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  1775. else {
  1776. if (new_level < 1)
  1777. new_level = 1;
  1778. if (new_level > 255)
  1779. new_level = 255;
  1780. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  1781. client->GetPlayer()->SetXP(1);
  1782. client->GetPlayer()->SetNeededXP();
  1783. }
  1784. }else
  1785. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  1786. break;
  1787. }
  1788. case COMMAND_SIT: {
  1789. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1790. if(client->GetPlayer()->GetHP() > 0){
  1791. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  1792. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  1793. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  1794. }
  1795. break;
  1796. }
  1797. case COMMAND_STAND: {
  1798. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1799. if(client->GetPlayer()->GetHP() > 0){
  1800. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  1801. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  1802. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  1803. }
  1804. break;
  1805. }
  1806. case COMMAND_CLASS:{
  1807. if(sep && sep->arg[ndx][0]){
  1808. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  1809. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  1810. }else
  1811. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  1812. break;
  1813. }
  1814. case COMMAND_GENDER:{
  1815. if(sep && sep->arg[ndx][0]){
  1816. client->GetPlayer()->GetInfoStruct()->gender = atoi(sep->arg[ndx]);
  1817. client->GetPlayer()->SetCharSheetChanged(true);
  1818. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  1819. }else{
  1820. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  1821. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  1822. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  1823. }
  1824. break;
  1825. }
  1826. case COMMAND_FLYMODE:{
  1827. if(sep && sep->arg[0] && sep->IsNumber(0)){
  1828. PrintSep(sep, "COMMAND_FLYMODE");
  1829. int8 val = atoi(sep->arg[0]);
  1830. ClientPacketFunctions::SendFlyMode(client, val);
  1831. }
  1832. else{
  1833. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  1834. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  1835. }
  1836. break;
  1837. }
  1838. case COMMAND_LOOT_LIST:{
  1839. Spawn* spawn = cmdTarget;
  1840. if(spawn && spawn->IsEntity()){
  1841. if (sep && sep->arg[0]) {
  1842. if (!spawn->GetDatabaseID())
  1843. {
  1844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  1845. break;
  1846. }
  1847. else if (!spawn->IsNPC())
  1848. {
  1849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  1850. break;
  1851. }
  1852. bool reloadLoot = false;
  1853. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  1854. {
  1855. int32 loottable_id = atoul(sep->arg[1]);
  1856. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  1857. {
  1858. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  1859. reloadLoot = true;
  1860. }
  1861. else
  1862. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  1863. }
  1864. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  1865. {
  1866. int32 loottable_id = atoul(sep->arg[1]);
  1867. if (loottable_id > 0)
  1868. {
  1869. database.AddLootTableToSpawn(spawn, loottable_id);
  1870. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  1871. reloadLoot = true;
  1872. }
  1873. else
  1874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  1875. }
  1876. else if (!stricmp(sep->arg[0], "clearall"))
  1877. {
  1878. if (database.RemoveSpawnLootTable(spawn, 0))
  1879. {
  1880. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  1881. reloadLoot = true;
  1882. }
  1883. else
  1884. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  1885. }
  1886. else
  1887. {
  1888. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  1889. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  1890. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  1891. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  1892. break;
  1893. }
  1894. if (reloadLoot)
  1895. {
  1896. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  1897. if (spawn->IsNPC())
  1898. {
  1899. Entity* ent = (Entity*)spawn;
  1900. ent->SetLootCoins(0);
  1901. ent->ClearLootList();
  1902. spawn->GetZone()->AddLoot((NPC*)spawn);
  1903. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  1904. }
  1905. }
  1906. break; // nothing further this is the end of these sub commands
  1907. }
  1908. else
  1909. {
  1910. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  1911. if (loot_list.size() > 0) {
  1912. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  1913. vector<int32>::iterator list_itr;
  1914. LootTable* table = 0;
  1915. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  1916. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  1917. if (table)
  1918. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  1919. }
  1920. }
  1921. Entity* target = (Entity*)spawn;
  1922. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", target->GetLootCoins());
  1923. vector<Item*>* items = target->GetLootItems();
  1924. if (items) {
  1925. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  1926. vector<Item*>::iterator itr;
  1927. Item* item = 0;
  1928. for (itr = items->begin(); itr != items->end(); itr++) {
  1929. item = *itr;
  1930. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  1931. }
  1932. }
  1933. else
  1934. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  1935. }
  1936. }
  1937. break;
  1938. }
  1939. case COMMAND_LOOT_SETCOIN:{
  1940. Spawn* spawn = cmdTarget;
  1941. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1942. Entity* target = (Entity*)spawn;
  1943. target->SetLootCoins(atoul(sep->arg[0]));
  1944. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  1945. }
  1946. else
  1947. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  1948. break;
  1949. }
  1950. case COMMAND_LOOT_ADDITEM:{
  1951. Spawn* spawn = cmdTarget;
  1952. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1953. Entity* target = (Entity*)spawn;
  1954. int16 charges = 1;
  1955. if(sep->arg[1] && sep->IsNumber(1))
  1956. charges = atoi(sep->arg[1]);
  1957. target->AddLootItem(atoul(sep->arg[0]), charges);
  1958. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  1959. }
  1960. else
  1961. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  1962. break;
  1963. }
  1964. case COMMAND_LOOT_REMOVEITEM:{
  1965. Spawn* spawn = cmdTarget;
  1966. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1967. Entity* target = (Entity*)spawn;
  1968. target->LootItem(atoul(sep->arg[0]));
  1969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  1970. }
  1971. else
  1972. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  1973. break;
  1974. }
  1975. case COMMAND_LOOT_CORPSE:
  1976. case COMMAND_DISARM:
  1977. case COMMAND_LOOT:{
  1978. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  1979. {
  1980. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  1981. break;
  1982. }
  1983. if(cmdTarget && cmdTarget->IsEntity()){
  1984. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  1985. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  1986. client->OpenChest((Entity*)cmdTarget, true);
  1987. else
  1988. client->Loot((Entity*)cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  1989. if (!((Entity*)cmdTarget)->HasLoot()){
  1990. if (((Entity*)cmdTarget)->IsNPC())
  1991. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  1992. }
  1993. }
  1994. else
  1995. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  1996. }
  1997. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  1998. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  1999. break;
  2000. }
  2001. case COMMAND_RELOADSPAWNSCRIPTS:{
  2002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2003. if (lua_interface)
  2004. lua_interface->SetSpawnScriptsReloading(true);
  2005. world.ResetSpawnScripts();
  2006. database.LoadSpawnScriptData();
  2007. if(lua_interface) {
  2008. lua_interface->DestroySpawnScripts();
  2009. lua_interface->SetSpawnScriptsReloading(false);
  2010. }
  2011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2012. break;
  2013. }
  2014. case COMMAND_RELOADLUASYSTEM:{
  2015. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2016. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2017. safe_delete(lua_interface);
  2018. lua_interface = new LuaInterface();
  2019. if(lua_interface)
  2020. lua_interface->SetSpawnScriptsReloading(true);
  2021. if(lua_interface && debug_clients.size() > 0){
  2022. map<Client*, int32>::iterator itr;
  2023. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2024. if(lua_interface)
  2025. lua_interface->UpdateDebugClients(itr->first);
  2026. }
  2027. }
  2028. world.ResetSpawnScripts();
  2029. database.LoadSpawnScriptData();
  2030. world.ResetZoneScripts();
  2031. database.LoadZoneScriptData();
  2032. int32 quest_count = database.LoadQuests();
  2033. zone_list.DeleteSpellProcess();
  2034. master_spell_list.Reload();
  2035. int32 spell_count = 0;
  2036. if(lua_interface) {
  2037. lua_interface->DestroySpawnScripts();
  2038. lua_interface->DestroySpells();
  2039. spell_count = database.LoadSpellScriptData();
  2040. lua_interface->SetSpawnScriptsReloading(false);
  2041. }
  2042. zone_list.LoadSpellProcess();
  2043. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2044. break;
  2045. }
  2046. case COMMAND_DECLINE_QUEST:{
  2047. int32 quest_id = 0;
  2048. if(sep && sep->arg[0] && sep->IsNumber(0))
  2049. quest_id = atoul(sep->arg[0]);
  2050. if(quest_id > 0){
  2051. Quest* quest = client->GetPendingQuest(quest_id);
  2052. if(quest){
  2053. client->RemovePendingQuest(quest);
  2054. if(lua_interface)
  2055. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2056. safe_delete(quest);
  2057. client->GetCurrentZone()->SendQuestUpdates(client);
  2058. }
  2059. }
  2060. break;
  2061. }
  2062. case COMMAND_DELETE_QUEST:{
  2063. int32 quest_id = 0;
  2064. if(sep && sep->arg[0] && sep->IsNumber(0))
  2065. quest_id = atoul(sep->arg[0]);
  2066. if(quest_id > 0){
  2067. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2068. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2069. if (quest)
  2070. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2071. }
  2072. client->RemovePlayerQuest(quest_id);
  2073. client->GetCurrentZone()->SendQuestUpdates(client);
  2074. }
  2075. break;
  2076. }
  2077. case COMMAND_ACCEPT_QUEST:{
  2078. int32 quest_id = 0;
  2079. if(sep && sep->arg[0] && sep->IsNumber(0))
  2080. quest_id = atoul(sep->arg[0]);
  2081. if(quest_id > 0){
  2082. Quest* quest = client->GetPendingQuest(quest_id);
  2083. if(quest){
  2084. client->RemovePendingQuest(quest);
  2085. client->AddPlayerQuest(quest);
  2086. client->GetCurrentZone()->SendQuestUpdates(client);
  2087. // If character has already completed this quest once update the given date in the database
  2088. if (client->GetPlayer()->GetCompletedPlayerQuests()->count(quest_id) > 0) {
  2089. Quest* quest2 = client->GetPlayer()->GetCompletedQuest(quest_id);
  2090. if (quest2)
  2091. quest->SetCompleteCount(quest2->GetCompleteCount());
  2092. database.SaveCharRepeatableQuest(client, quest_id, quest->GetCompleteCount());
  2093. }
  2094. }
  2095. }
  2096. break;
  2097. }
  2098. case COMMAND_NAME:{
  2099. if(sep && sep->arg[ndx][0]){
  2100. memset(client->GetPlayer()->GetInfoStruct()->name, 0, 40);
  2101. strncpy(client->GetPlayer()->GetInfoStruct()->name, sep->arg[ndx], 39);
  2102. client->GetPlayer()->SetCharSheetChanged(true);
  2103. }else
  2104. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2105. break;
  2106. }
  2107. case COMMAND_GROUPSAY:{
  2108. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2109. if(sep && sep->arg[0] && gmi)
  2110. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2111. break;
  2112. }
  2113. case COMMAND_GROUPINVITE: {
  2114. Entity* target = 0;
  2115. Client* target_client = 0;
  2116. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2117. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2118. return;
  2119. }
  2120. // name provided with command so it has to be a player, npc not supported here
  2121. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2122. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2123. if (target_client) {
  2124. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2125. target = 0;
  2126. else
  2127. target = target_client->GetPlayer();
  2128. }
  2129. }
  2130. // if name was not provided use the players target, npc or player supported here
  2131. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2132. target = (Entity*)client->GetPlayer()->GetTarget();
  2133. if (target->IsPlayer()) {
  2134. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2135. }
  2136. }
  2137. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2138. if (result == 0) {
  2139. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2140. if (target_client) {
  2141. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2142. if (packet) {
  2143. packet->setDataByName("type", 1);
  2144. packet->setDataByName("name", client->GetPlayer()->GetName());
  2145. packet->setDataByName("unknown2", 1);
  2146. target_client->QueuePacket(packet->serialize());
  2147. safe_delete(packet);
  2148. }
  2149. }
  2150. }
  2151. else if (result == 1)
  2152. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2153. else if (result == 2)
  2154. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2155. else if (result == 3)
  2156. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2157. else if (result == 4)
  2158. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2159. else if (result == 5)
  2160. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2161. else if (result == 6)
  2162. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2163. else
  2164. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2165. break;
  2166. }
  2167. case COMMAND_GROUPDISBAND: {
  2168. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2169. if (gmi) { // TODO: Leader check
  2170. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2171. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2172. }
  2173. break;
  2174. }
  2175. case COMMAND_GROUP_LEAVE: {
  2176. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2177. if (gmi) {
  2178. int32 group_id = gmi->group_id;
  2179. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2180. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2181. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2182. }
  2183. else {
  2184. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2185. }
  2186. client->SimpleMessage(CHANNEL_COLOR_GROUP, "You have left the group");
  2187. }
  2188. break;
  2189. }
  2190. case COMMAND_FRIEND_ADD:{
  2191. string name = "";
  2192. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2193. name = database.GetPlayerName(sep->arg[0]);
  2194. else if(cmdTarget && cmdTarget->IsPlayer())
  2195. name = string(cmdTarget->GetName());
  2196. if(name.length() > 0){
  2197. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2198. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2199. client->GetPlayer()->RemoveIgnore(name.c_str());
  2200. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2201. client->SendChatRelationship(3, name.c_str());
  2202. }
  2203. client->GetPlayer()->AddFriend(name.c_str(), true);
  2204. client->SendChatRelationship(0, name.c_str());
  2205. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2206. if(zone_list.GetClientByCharName(name))
  2207. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2208. }
  2209. else
  2210. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2211. }
  2212. else
  2213. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2214. break;
  2215. }
  2216. case COMMAND_FRIEND_REMOVE:{
  2217. string name = "";
  2218. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2219. name = database.GetPlayerName(sep->arg[0]);
  2220. else if(cmdTarget && cmdTarget->IsPlayer())
  2221. name = string(cmdTarget->GetName());
  2222. if(name.length() > 0){
  2223. client->GetPlayer()->RemoveFriend(name.c_str());
  2224. client->SendChatRelationship(1, name.c_str());
  2225. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2226. }
  2227. else
  2228. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2229. break;
  2230. }
  2231. case COMMAND_FRIENDS:{
  2232. break;
  2233. }
  2234. case COMMAND_IGNORE_ADD:{
  2235. string name = "";
  2236. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2237. name = database.GetPlayerName(sep->arg[0]);
  2238. else if(cmdTarget && cmdTarget->IsPlayer())
  2239. name = string(cmdTarget->GetName());
  2240. if(name.length() > 0){
  2241. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2242. if(client->GetPlayer()->IsFriend(name.c_str())){
  2243. client->GetPlayer()->RemoveFriend(name.c_str());
  2244. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2245. client->SendChatRelationship(1, name.c_str());
  2246. }
  2247. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2248. client->SendChatRelationship(2, name.c_str());
  2249. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2250. }
  2251. else
  2252. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2253. }
  2254. else
  2255. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2256. break;
  2257. }
  2258. case COMMAND_IGNORE_REMOVE:{
  2259. string name = "";
  2260. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2261. name = database.GetPlayerName(sep->arg[0]);
  2262. else if(cmdTarget && cmdTarget->IsPlayer())
  2263. name = string(cmdTarget->GetName());
  2264. if(name.length() > 0){
  2265. client->GetPlayer()->RemoveIgnore(name.c_str());
  2266. client->SendChatRelationship(3, name.c_str());
  2267. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2268. }
  2269. break;
  2270. }
  2271. case COMMAND_IGNORES:{
  2272. break;
  2273. }
  2274. case COMMAND_GROUP_KICK:{
  2275. Entity* kicked = 0;
  2276. Client* kicked_client = 0;
  2277. int32 group_id = 0;
  2278. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2279. return;
  2280. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2281. if (sep && sep->arg[0]) {
  2282. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2283. if (kicked_client)
  2284. kicked = kicked_client->GetPlayer();
  2285. }
  2286. else if (cmdTarget && cmdTarget->IsEntity()) {
  2287. kicked = (Entity*)cmdTarget;
  2288. }
  2289. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2290. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2291. if (kicked)
  2292. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2293. if(send_kicked_message)
  2294. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2295. else
  2296. client->Message(CHANNEL_COLOR_GROUP, "You kicked %s from the group", kicked->GetName());
  2297. if (kicked_client)
  2298. kicked_client->SimpleMessage(CHANNEL_COLOR_GROUP, "You were kicked from the group");
  2299. break;
  2300. }
  2301. case COMMAND_GROUP_MAKE_LEADER:{
  2302. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2303. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2304. return;
  2305. }
  2306. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2307. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2308. if (new_leader) {
  2309. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2310. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2311. }
  2312. }
  2313. else
  2314. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2315. }
  2316. else if (cmdTarget && cmdTarget->IsPlayer())
  2317. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2318. else
  2319. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2320. break;
  2321. }
  2322. case COMMAND_GROUP_ACCEPT_INVITE: {
  2323. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2324. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2325. if (result == 0)
  2326. client->SimpleMessage(CHANNEL_GROUP, "You have joined the group.");
  2327. else if (result == 1)
  2328. client->SimpleMessage(CHANNEL_GROUP, "You do not have a pending invite.");
  2329. else if (result == 2)
  2330. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - could not find leader.");
  2331. else
  2332. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - unknown error.");
  2333. }
  2334. break;
  2335. }
  2336. case COMMAND_GROUP_DECLINE_INVITE: {
  2337. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2338. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2339. }
  2340. break;
  2341. }
  2342. case COMMAND_SUMMON:{
  2343. char* search_name = 0;
  2344. if(sep && sep->arg[0][0])
  2345. search_name = sep->arg[0];
  2346. if(!search_name && !cmdTarget){
  2347. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2348. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Summons a targeted spawn or a spawn by name to you. If more than one spawn matches name, it will summon closest.");
  2349. }
  2350. else{
  2351. if(!client->Summon(search_name))
  2352. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2353. }
  2354. break;
  2355. }
  2356. case COMMAND_GOTO:{
  2357. const char* search_name = 0;
  2358. if(sep && sep->arg[0][0])
  2359. search_name = sep->argplus[0];
  2360. if(!search_name && !cmdTarget){
  2361. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2362. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves to targeted spawn or to a spawn by name. If more than one spawn matches name, you will move to closest.");
  2363. }
  2364. else{
  2365. if(!client->GotoSpawn(search_name))
  2366. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2367. }
  2368. break;
  2369. }
  2370. case COMMAND_MOVE:{
  2371. bool success = false;
  2372. try{
  2373. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2374. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2375. if(app){
  2376. client->QueuePacket(app);
  2377. success = true;
  2378. }
  2379. }
  2380. }
  2381. catch(...){}
  2382. if(!success){
  2383. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2384. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2385. }
  2386. break;
  2387. }
  2388. case COMMAND_SETTIME:{
  2389. if(sep && sep->arg[0]){
  2390. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2391. if(sep->arg[1] && sep->IsNumber(1))
  2392. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2393. if(sep->arg[2] && sep->IsNumber(2))
  2394. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2395. if(sep->arg[3] && sep->IsNumber(3))
  2396. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2397. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2398. }
  2399. else{
  2400. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2401. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2402. }
  2403. break;
  2404. }
  2405. case COMMAND_VERSION:{
  2406. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2407. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2408. break;
  2409. }
  2410. case COMMAND_ZONE:{
  2411. string* zonename = 0;
  2412. int32 instanceID = 0;
  2413. const char* zone = 0;
  2414. int32 zone_id = 0;
  2415. bool listSearch = false;
  2416. bool isInstance = false;
  2417. ZoneServer* zsZone = 0;
  2418. if(sep && sep->arg[0][0])
  2419. {
  2420. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2421. listSearch = true;
  2422. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2423. {
  2424. zone_list.SendZoneList(client);
  2425. break;
  2426. }
  2427. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2428. {
  2429. if(sep->IsNumber(1))
  2430. instanceID = atol(sep->arg[1]);
  2431. }
  2432. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2433. {
  2434. PrintSep(sep, "ZONE LOCK");
  2435. if(sep->IsNumber(1))
  2436. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2437. else
  2438. zsZone = zone_list.Get(sep->arg[1], false);
  2439. if( zsZone )
  2440. {
  2441. zsZone->SetZoneLockState(true);
  2442. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2443. }
  2444. else
  2445. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2446. break;
  2447. }
  2448. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2449. {
  2450. PrintSep(sep, "ZONE UNLOCK");
  2451. if(sep->IsNumber(1))
  2452. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2453. else
  2454. zsZone = zone_list.Get(sep->arg[1], false);
  2455. if( zsZone )
  2456. {
  2457. zsZone->SetZoneLockState(false);
  2458. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2459. }
  2460. else
  2461. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2462. break;
  2463. }
  2464. else
  2465. {
  2466. if(sep->IsNumber(0))
  2467. {
  2468. zone_id = atoul(sep->arg[0]);
  2469. zonename = database.GetZoneName(zone_id);
  2470. if(zonename)
  2471. zone = zonename->c_str();
  2472. }
  2473. else
  2474. zone = sep->arg[0];
  2475. }
  2476. if(instanceID > 0)
  2477. {
  2478. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2479. if(zsInstance != NULL)
  2480. {
  2481. instanceID = zsInstance->GetInstanceID();
  2482. zone = zsInstance->GetZoneName();
  2483. zone_id = zsInstance->GetZoneID();
  2484. isInstance = true;
  2485. }
  2486. }
  2487. }
  2488. if(!listSearch)
  2489. {
  2490. if(!zone)
  2491. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2492. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2493. zone_id != client->GetCurrentZone()->GetZoneID())
  2494. {
  2495. if(database.VerifyZone(zone))
  2496. {
  2497. if(client->CheckZoneAccess(zone))
  2498. {
  2499. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zone);
  2500. if(isInstance)
  2501. client->Zone(instanceID,true,true);
  2502. else
  2503. client->Zone(zone);
  2504. }
  2505. }
  2506. else
  2507. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zone);
  2508. }
  2509. else
  2510. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2511. }
  2512. else
  2513. {
  2514. const char* name = 0;
  2515. if(sep && sep->arg[1][0])
  2516. {
  2517. map<int32, string>* zone_names;
  2518. name = sep->argplus[1];
  2519. sint16 status = client->GetAdminStatus();
  2520. if( status > 0 )
  2521. {
  2522. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2523. zone_names = database.GetZoneList(name, true);
  2524. }
  2525. else
  2526. zone_names = database.GetZoneList(name);
  2527. if(!zone_names)
  2528. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2529. else
  2530. {
  2531. map<int32, string>::iterator itr;
  2532. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2533. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2534. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2535. safe_delete(zone_names);
  2536. }
  2537. }
  2538. else
  2539. {
  2540. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2541. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2542. }
  2543. }
  2544. safe_delete(zonename);
  2545. break;
  2546. }
  2547. case COMMAND_USE: {
  2548. Spawn* target = cmdTarget;
  2549. if (target->IsWidget())
  2550. ((Widget*)target)->HandleUse(client, "use");
  2551. break;
  2552. }
  2553. case COMMAND_OPEN: {
  2554. Spawn* target = cmdTarget;
  2555. if (target->IsWidget())
  2556. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2557. break;
  2558. }
  2559. case COMMAND_CASTSPELL: {
  2560. if (sep && sep->arg[0] && sep->IsNumber(0))
  2561. {
  2562. int8 tier = 1;
  2563. if (sep->arg[1] && sep->IsNumber(1))
  2564. tier = atoul(sep->arg[1]);
  2565. int32 spellid = atoul(sep->arg[0]);
  2566. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2567. if (spell)
  2568. {
  2569. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2570. SpellProcess* spellProcess = 0;
  2571. // Get the current zones spell process
  2572. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2573. spellProcess->CastInstant(spell, (Entity*)client->GetPlayer(), (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2574. }
  2575. else
  2576. {
  2577. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2578. }
  2579. }
  2580. else if (sep && sep->arg[0])
  2581. {
  2582. database.FindSpell(client, (char*)sep->argplus[0]);
  2583. }
  2584. else
  2585. {
  2586. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2587. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2588. }
  2589. break;
  2590. }
  2591. case COMMAND_KNOWLEDGEWINDOWSORT: {
  2592. if (sep && sep->GetArgNumber() == 4)
  2593. {
  2594. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  2595. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  2596. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  2597. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  2598. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  2599. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  2600. ClientPacketFunctions::SendSkillSlotMappings(client);
  2601. }
  2602. else
  2603. {
  2604. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  2605. }
  2606. break;
  2607. }
  2608. case COMMAND_PLACE_HOUSE_ITEM: {
  2609. if (sep && sep->IsNumber(0))
  2610. {
  2611. int32 uniqueid = atoi(sep->arg[0]);
  2612. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  2613. //Item* item = player->GetEquipmentList()->GetItem(slot);
  2614. if (item && item->IsHouseItem())
  2615. {
  2616. if (!client->HasOwnerOrEditAccess())
  2617. {
  2618. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  2619. break;
  2620. }
  2621. else if (!item->generic_info.appearance_id)
  2622. {
  2623. 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);
  2624. break;
  2625. }
  2626. if (client->GetTempPlacementSpawn())
  2627. {
  2628. Spawn* tmp = client->GetTempPlacementSpawn();
  2629. client->GetCurrentZone()->RemoveSpawn(false, tmp);
  2630. delete tmp;
  2631. client->SetTempPlacementSpawn(nullptr);
  2632. }
  2633. Spawn* spawn = new Object();
  2634. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2635. spawn->SetID(Spawn::NextID());
  2636. spawn->SetX(client->GetPlayer()->GetX());
  2637. spawn->SetY(client->GetPlayer()->GetY());
  2638. spawn->SetZ(client->GetPlayer()->GetZ());
  2639. spawn->SetHeading(client->GetPlayer()->GetHeading());
  2640. spawn->SetSpawnOrigX(spawn->GetX());
  2641. spawn->SetSpawnOrigY(spawn->GetY());
  2642. spawn->SetSpawnOrigZ(spawn->GetZ());
  2643. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  2644. spawn->appearance.targetable = 1;
  2645. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  2646. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  2647. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  2648. spawn->SetZone(client->GetCurrentZone());
  2649. client->GetCurrentZone()->SendSpawn(spawn, client);
  2650. client->SetTempPlacementSpawn(spawn);
  2651. client->SetPlacementUniqueItemID(uniqueid);
  2652. client->SendMoveObjectMode(spawn, 0);
  2653. }
  2654. }
  2655. break;
  2656. }
  2657. case COMMAND_GM:
  2658. {
  2659. if (sep->arg[0] && sep->arg[1])
  2660. {
  2661. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  2662. if (strcmp(sep->arg[0], "vision") == 0)
  2663. {
  2664. client->GetPlayer()->SetGMVision(onOff);
  2665. #if defined(__GNUC__)
  2666. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  2667. #else
  2668. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  2669. #endif
  2670. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  2671. if (onOff)
  2672. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  2673. else
  2674. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  2675. }
  2676. }
  2677. break;
  2678. }
  2679. case COMMAND_ATTACK:
  2680. case COMMAND_AUTO_ATTACK:{
  2681. int8 type = 1;
  2682. Player* player = client->GetPlayer();
  2683. if(!player)
  2684. break;
  2685. bool incombat = player->EngagedInCombat();
  2686. if(sep && sep->arg[0] && sep->IsNumber(0))
  2687. type = atoi(sep->arg[0]);
  2688. if(client->GetPlayer()->GetHP() == 0){
  2689. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  2690. break;
  2691. }
  2692. if(type == 0){
  2693. if(incombat)
  2694. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2695. player->InCombat(false);
  2696. player->InCombat(false, true);
  2697. player->SetRangeAttack(false);
  2698. }
  2699. else {
  2700. if(type == 2){
  2701. player->InCombat(false);
  2702. if(incombat && player->GetRangeAttack()){
  2703. player->SetRangeAttack(false);
  2704. player->InCombat(false, true);
  2705. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2706. }
  2707. else{
  2708. player->SetRangeAttack(true);
  2709. player->InCombat(true, true);
  2710. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2711. }
  2712. }
  2713. else {
  2714. player->InCombat(false, true);
  2715. player->SetRangeAttack(false);
  2716. player->InCombat(true);
  2717. if(!incombat)
  2718. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2719. }
  2720. /*else
  2721. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  2722. }
  2723. player->SetCharSheetChanged(true);
  2724. break;
  2725. }
  2726. case COMMAND_DEPOP:{
  2727. bool allow_respawns = false;
  2728. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2729. if(atoi(sep->arg[0]) == 1)
  2730. allow_respawns = true;
  2731. }
  2732. client->GetCurrentZone()->Depop(allow_respawns);
  2733. break;
  2734. }
  2735. case COMMAND_REPOP:{
  2736. client->GetCurrentZone()->Depop(false, true);
  2737. break;
  2738. }
  2739. case COMMAND_BUYBACK:{
  2740. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2741. // 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
  2742. int64 id = atoi64(sep->arg[0]);
  2743. // get the first int32, the item id
  2744. //int32 item_id = (int32)id;
  2745. // get the second int32, the unique id
  2746. int32 unique_id = (int32)(id>>32);
  2747. int8 quantity = atoi(sep->arg[1]);
  2748. if(quantity == 255)
  2749. quantity = 1;
  2750. client->BuyBack(unique_id, quantity);
  2751. }
  2752. break;
  2753. }
  2754. case COMMAND_MERCHANT_BUY:{
  2755. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2756. int32 item_id = atoul(sep->arg[0]);
  2757. int8 quantity = atoi(sep->arg[1]);
  2758. client->BuyItem(item_id, quantity);
  2759. }
  2760. break;
  2761. }
  2762. case COMMAND_MERCHANT_SELL:{
  2763. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2764. // 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
  2765. int64 id = atoi64(sep->arg[0]);
  2766. // get the first int32, the item id
  2767. int32 item_id = (int32)id;
  2768. // get the second int32, the unique id
  2769. int32 unique_id = (int32)(id>>32);
  2770. int8 quantity = atoi(sep->arg[1]);
  2771. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  2772. client->SellItem(item_id, quantity, unique_id);
  2773. }
  2774. break;
  2775. }
  2776. case COMMAND_MENDER_REPAIR: {
  2777. if (sep && sep->arg[0] && sep->IsNumber(0))
  2778. client->RepairItem(atoul(sep->arg[0]));
  2779. break;
  2780. }
  2781. case COMMAND_MENDER_REPAIR_ALL: {
  2782. client->RepairAllItems();
  2783. break;
  2784. }
  2785. case COMMAND_CANCEL_MERCHANT:{
  2786. client->SetMerchantTransaction(0);
  2787. break;
  2788. }
  2789. case COMMAND_START_MERCHANT:{
  2790. break;
  2791. }
  2792. case COMMAND_INVULNERABLE:{
  2793. sint8 val = -1;
  2794. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2795. val = atoi(sep->arg[0]);
  2796. //devn00b: Fix for linux builds
  2797. #if defined(__GNUC__)
  2798. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  2799. #else
  2800. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2801. #endif
  2802. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2803. client->GetPlayer()->SetInvulnerable(val==1);
  2804. if(client->GetPlayer()->GetInvulnerable())
  2805. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  2806. else
  2807. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  2808. }
  2809. if(val == -1)
  2810. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  2811. break;
  2812. }
  2813. case COMMAND_REPAIR: {
  2814. Spawn* spawn = cmdTarget;
  2815. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  2816. client->SendHailCommand(spawn);
  2817. client->SetMerchantTransaction(spawn);
  2818. client->SendRepairList();
  2819. }
  2820. break;
  2821. }
  2822. case COMMAND_LOTTO: {
  2823. Spawn* spawn = cmdTarget;
  2824. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  2825. client->SetMerchantTransaction(spawn);
  2826. client->ShowLottoWindow();
  2827. }
  2828. break;
  2829. }
  2830. case COMMAND_ACCEPT_REWARD:{
  2831. int32 unknown = 0;
  2832. int32 selectable_item_id = 0;
  2833. //Quest *quest = 0;
  2834. Collection *collection = 0;
  2835. /* no idea what the first argument is for (faction maybe?)
  2836. if the reward has a selectable item reward, it's sent as the second argument
  2837. if neither of these are included in the reward, there is no sep
  2838. 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
  2839. only 1 quest or collection reward may be displayed at a time */
  2840. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2841. unknown = atoul(sep->arg[0]);
  2842. selectable_item_id = atoul(sep->arg[1]);
  2843. }
  2844. //if ((quest = player->GetPendingQuestReward()))
  2845. // client->AcceptQuestRewards(quest, selectable_item_id);
  2846. /* the below needs to go away eventually and be redone */
  2847. int32 item_id = 0;
  2848. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  2849. item_id = atoul(sep->arg[0]);
  2850. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  2851. if(quest){
  2852. client->AcceptQuestReward(quest, item_id);
  2853. break;
  2854. }
  2855. if (collection = player->GetPendingCollectionReward())
  2856. client->AcceptCollectionRewards(collection, selectable_item_id);
  2857. else
  2858. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  2859. break;
  2860. }
  2861. case COMMAND_BUY_FROM_BROKER:{
  2862. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2863. int32 item_id = atoul(sep->arg[0]);
  2864. int16 quantity = atoul(sep->arg[1]);
  2865. client->AddItem(item_id, quantity);
  2866. }
  2867. break;
  2868. }
  2869. case COMMAND_SEARCH_STORES_PAGE:{
  2870. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2871. int32 page = atoul(sep->arg[0]);
  2872. client->SearchStore(page);
  2873. }
  2874. break;
  2875. }
  2876. case COMMAND_SEARCH_STORES:{
  2877. if(sep && sep->arg[0][0]){
  2878. const char* values = sep->argplus[0];
  2879. if(values){
  2880. map<string, string> str_values = TranslateBrokerRequest(values);
  2881. vector<Item*>* items = master_item_list.GetItems(str_values);
  2882. if(items){
  2883. client->SetItemSearch(items);
  2884. client->SearchStore(0);
  2885. }
  2886. }
  2887. }
  2888. break;
  2889. }
  2890. case COMMAND_LUADEBUG:{
  2891. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  2892. client->SetLuaDebugClient(true);
  2893. if(lua_interface)
  2894. lua_interface->UpdateDebugClients(client);
  2895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  2896. }
  2897. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  2898. client->SetLuaDebugClient(false);
  2899. if(lua_interface)
  2900. lua_interface->RemoveDebugClients(client);
  2901. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  2902. }
  2903. else{
  2904. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  2905. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  2906. }
  2907. break;
  2908. }
  2909. case COMMAND_SPAWN_GROUP:
  2910. {
  2911. Spawn* target = cmdTarget;
  2912. if(target && target->IsPlayer() == false)
  2913. {
  2914. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  2915. {
  2916. if(target->GetSpawnLocationPlacementID() > 0)
  2917. {
  2918. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  2919. {
  2920. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  2921. if(id > 0)
  2922. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  2923. else
  2924. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  2925. target->SetSpawnGroupID(id);
  2926. target->AddSpawnToGroup(target);
  2927. }
  2928. else
  2929. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  2930. }
  2931. else
  2932. 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.");
  2933. }
  2934. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  2935. {
  2936. if(sep->arg[1] && sep->IsNumber(1))
  2937. {
  2938. int32 group_id = atoul(sep->arg[1]);
  2939. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  2940. if(leader)
  2941. {
  2942. leader->AddSpawnToGroup(target);
  2943. target->SetSpawnGroupID(group_id);
  2944. if(database.SpawnGroupAddSpawn(target, group_id))
  2945. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  2946. else
  2947. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  2948. }
  2949. else
  2950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  2951. }
  2952. else
  2953. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  2954. }
  2955. else if(target->GetSpawnGroupID() == 0)
  2956. {
  2957. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  2958. }
  2959. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  2960. {
  2961. int32 group_id = target->GetSpawnGroupID();
  2962. target->RemoveSpawnFromGroup();
  2963. if(database.SpawnGroupRemoveSpawn(target, group_id))
  2964. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  2965. else
  2966. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  2967. }
  2968. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  2969. {
  2970. int32 group_id = target->GetSpawnGroupID();
  2971. if(sep->arg[1] && sep->IsNumber(1))
  2972. {
  2973. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  2974. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  2975. else
  2976. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  2977. }
  2978. else
  2979. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  2980. }
  2981. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  2982. {
  2983. int32 group_id = target->GetSpawnGroupID();
  2984. if(sep->arg[1] && sep->IsNumber(1))
  2985. {
  2986. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  2987. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  2988. else
  2989. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  2990. }
  2991. else
  2992. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  2993. }
  2994. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  2995. {
  2996. if(sep->arg[1] && sep->IsNumber(1))
  2997. {
  2998. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  2999. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  3000. else
  3001. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  3002. }
  3003. else
  3004. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  3005. }
  3006. else
  3007. {
  3008. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  3009. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  3010. }
  3011. }
  3012. else
  3013. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  3014. break;
  3015. }
  3016. case COMMAND_SPAWN_COMBINE:{
  3017. Spawn* spawn = cmdTarget;
  3018. float radius = 0;
  3019. bool failed = true;
  3020. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  3021. failed = false;
  3022. if(spawn->GetSpawnGroupID() > 0){
  3023. 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.");
  3024. }
  3025. else if(sep->IsNumber(0)){
  3026. radius = atof(sep->arg[0]);
  3027. client->CombineSpawns(radius, spawn);
  3028. }
  3029. else{
  3030. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  3031. client->AddCombineSpawn(spawn);
  3032. }
  3033. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  3034. client->RemoveCombineSpawn(spawn);
  3035. }
  3036. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  3037. const char* name = 0;
  3038. if(sep->arg[1] && sep->arg[1][0])
  3039. name = sep->argplus[1];
  3040. client->SaveCombineSpawns(name);
  3041. }
  3042. else
  3043. failed = true;
  3044. }
  3045. }
  3046. if(failed){
  3047. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  3048. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  3049. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  3050. }
  3051. break;
  3052. }
  3053. case COMMAND_SPAWN_CREATE:{
  3054. Spawn* spawn = 0;
  3055. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3056. spawn = new Object();
  3057. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3058. }
  3059. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3060. spawn = new GroundSpawn();
  3061. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3062. }
  3063. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3064. spawn = new Sign();
  3065. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3066. }
  3067. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3068. spawn = new NPC();
  3069. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3070. spawn->appearance.pos.collision_radius = 32;
  3071. spawn->secondary_command_list_id = 0;
  3072. spawn->primary_command_list_id = 0;
  3073. spawn->appearance.display_name = 1;
  3074. spawn->appearance.show_level = 1;
  3075. spawn->appearance.attackable = 1;
  3076. }
  3077. else{
  3078. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  3079. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  3080. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  3081. break;
  3082. }
  3083. spawn->SetID(Spawn::NextID());
  3084. spawn->SetX(client->GetPlayer()->GetX());
  3085. spawn->SetY(client->GetPlayer()->GetY());
  3086. spawn->SetZ(client->GetPlayer()->GetZ());
  3087. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3088. spawn->SetSpawnOrigX(spawn->GetX());
  3089. spawn->SetSpawnOrigY(spawn->GetY());
  3090. spawn->SetSpawnOrigZ(spawn->GetZ());
  3091. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3092. spawn->appearance.targetable = 1;
  3093. spawn->appearance.race = 255;
  3094. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3095. spawn->SetModelType(atoi(sep->arg[1]));
  3096. spawn->SetAdventureClass(atoi(sep->arg[2]));
  3097. spawn->SetLevel(atoi(sep->arg[3]));
  3098. spawn->SetName(sep->arg[4]);
  3099. if(sep->arg[5][0] && sep->IsNumber(5))
  3100. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  3101. if(sep->arg[6][0] && sep->IsNumber(6))
  3102. spawn->size = atoi(sep->arg[6]);
  3103. if(spawn->GetTotalHP() == 0){
  3104. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  3105. spawn->SetHP(25*spawn->GetLevel() + 1);
  3106. }
  3107. if(spawn->GetTotalPower() == 0){
  3108. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3109. spawn->SetPower(25*spawn->GetLevel() + 1);
  3110. }
  3111. client->GetCurrentZone()->AddSpawn(spawn);
  3112. break;
  3113. }
  3114. case COMMAND_SPAWN_EQUIPMENT:{
  3115. Spawn* spawn = cmdTarget;
  3116. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3117. int8 slot = atoi(sep->arg[0]);
  3118. int16 type = atoi(sep->arg[1]);
  3119. int8 red = 0;
  3120. int8 green = 0;
  3121. int8 blue = 0;
  3122. int8 h_red = 0;
  3123. int8 h_green = 0;
  3124. int8 h_blue = 0;
  3125. if(sep->arg[2])
  3126. red = atoi(sep->arg[2]);
  3127. if(sep->arg[3])
  3128. green = atoi(sep->arg[3]);
  3129. if(sep->arg[4])
  3130. blue = atoi(sep->arg[4]);
  3131. if(sep->arg[5])
  3132. h_red = atoi(sep->arg[5]);
  3133. if(sep->arg[6])
  3134. h_green = atoi(sep->arg[6]);
  3135. if(sep->arg[7])
  3136. h_blue = atoi(sep->arg[7]);
  3137. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3138. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3139. }
  3140. else{
  3141. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3142. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3143. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3144. }
  3145. break;
  3146. }
  3147. case COMMAND_SPAWN_DETAILS:{
  3148. Spawn* spawn = cmdTarget;
  3149. if (sep && sep->arg[0][0]) {
  3150. if (cmdTarget)
  3151. {
  3152. if (ToLower(string(sep->arg[0])) == "los")
  3153. {
  3154. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3155. if (hasLOS)
  3156. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3157. else
  3158. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3159. break;
  3160. }
  3161. else if (ToLower(string(sep->arg[0])) == "bestz")
  3162. {
  3163. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3164. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3165. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3166. break;
  3167. }
  3168. else if (ToLower(string(sep->arg[0])) == "pathto")
  3169. {
  3170. break;
  3171. }
  3172. else if (ToLower(string(sep->arg[0])) == "pathfrom")
  3173. {
  3174. break;
  3175. }
  3176. }
  3177. if (sep->IsNumber(0))
  3178. {
  3179. float radius = atof(sep->arg[0]);
  3180. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3181. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3182. break;
  3183. }
  3184. }
  3185. if(spawn){
  3186. const char* type = "NPC";
  3187. if(spawn->IsObject())
  3188. type = "Object";
  3189. else if(spawn->IsSign())
  3190. type = "Sign";
  3191. else if(spawn->IsWidget())
  3192. type = "Widget";
  3193. else if(spawn->IsGroundSpawn())
  3194. type = "GroundSpawn";
  3195. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3196. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3197. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3198. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3199. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3200. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3201. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3202. 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());
  3203. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3204. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3205. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3206. if(spawn->IsEntity()){
  3207. 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());
  3208. 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());
  3209. }
  3210. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3211. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3212. 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());
  3213. 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);
  3214. if (spawn->IsNPC())
  3215. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3216. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  3217. if (packet) {
  3218. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3219. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3220. packet->setDataByName("book_title", title.c_str());
  3221. packet->setDataByName("book_type", "simple");
  3222. packet->setDataByName("unknown2", 1);
  3223. packet->setDataByName("unknown5", 1, 4);
  3224. packet->setArrayLengthByName("num_pages", 4);
  3225. string details;
  3226. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3227. details += "Type: " + string(type) + "\n";
  3228. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3229. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3230. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3231. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3232. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3233. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3234. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3235. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3236. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3237. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3238. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3239. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3240. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3241. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3242. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3243. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3244. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3245. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3246. char x[16];
  3247. sprintf(x, "%.2f", spawn->GetX());
  3248. char y[16];
  3249. sprintf(y, "%.2f", spawn->GetY());
  3250. char z[16];
  3251. sprintf(z, "%.2f", spawn->GetZ());
  3252. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3253. string details2;
  3254. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3255. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3256. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3257. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3258. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3259. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3260. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3261. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3262. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3263. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3264. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3265. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3266. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3267. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3268. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3269. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3270. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3271. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3272. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3273. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3274. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3275. string details3;
  3276. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3277. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3278. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3279. string details4;
  3280. if (spawn->IsEntity()) {
  3281. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3282. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3283. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3284. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3285. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3286. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3287. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3288. if (spawn->IsNPC()) {
  3289. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3290. }
  3291. }
  3292. //details2 += "" + to_string() + "\n";
  3293. packet->setArrayDataByName("page_text", details.c_str());
  3294. packet->setArrayDataByName("page_text", details2.c_str(), 1);
  3295. packet->setArrayDataByName("page_text", details3.c_str(), 2);
  3296. packet->setArrayDataByName("page_text", details4.c_str(), 3);
  3297. client->QueuePacket(packet->serialize());
  3298. safe_delete(packet);
  3299. }
  3300. }
  3301. else {
  3302. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3303. 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.");
  3304. }
  3305. break;
  3306. }
  3307. case COMMAND_SPAWN_TARGET:{
  3308. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3309. int32 spawn_id = atoul(sep->arg[0]);
  3310. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3311. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3312. }
  3313. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3314. float distance = atof(sep->arg[1]);
  3315. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3316. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3317. }
  3318. else{
  3319. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3320. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3321. }
  3322. break;
  3323. }
  3324. case COMMAND_SPAWN_SET:
  3325. {
  3326. Spawn* spawn = cmdTarget;
  3327. sint16 set_type = -1;
  3328. string type_str;
  3329. if (spawn)
  3330. {
  3331. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3332. 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)
  3333. {
  3334. // set the type, which will be 0 if location or list or invalid
  3335. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3336. }
  3337. if(set_type > 0)
  3338. {
  3339. // check if spawn set is NOT a char update, or not location, or isn't a number
  3340. if(!(set_type >= SPAWN_SET_VALUE_PREFIX) && !(set_type <= SPAWN_SET_VALUE_EXPANSION_FLAG) && set_type != SPAWN_SET_VALUE_NAME && ((set_type < SPAWN_SET_VALUE_SPAWN_SCRIPT) || (set_type > SPAWN_SET_VALUE_SUB_TITLE)) && set_type != SPAWN_SET_VALUE_LOCATION && sep->IsNumber(1) == false)
  3341. {
  3342. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3343. }
  3344. else
  3345. {
  3346. string name = string(spawn->GetName());
  3347. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1]))
  3348. {
  3349. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG)
  3350. {
  3351. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack flag.");
  3352. }
  3353. else if(set_type == SPAWN_SET_VALUE_NAME)
  3354. {
  3355. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3356. }
  3357. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3358. {
  3359. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3360. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3361. }
  3362. else
  3363. {
  3364. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3365. }
  3366. if(set_type != SPAWN_SET_VALUE_FACTION && set_type != SPAWN_SET_VALUE_EXPANSION_FLAG)
  3367. {
  3368. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->arg[1]);
  3369. }
  3370. 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))
  3371. {
  3372. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3373. {
  3374. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3375. }
  3376. else if(spawn->GetSpawnLocationID() > 0)
  3377. {
  3378. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3379. }
  3380. }
  3381. else
  3382. {
  3383. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3384. {
  3385. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3386. }
  3387. else if(spawn->GetDatabaseID() > 0)
  3388. {
  3389. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3390. }
  3391. }
  3392. }
  3393. }
  3394. }
  3395. else if(set_type == 0)
  3396. {
  3397. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3398. map<string, int8>::iterator itr;
  3399. int i=0;
  3400. string list;
  3401. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3402. {
  3403. if(i==10)
  3404. {
  3405. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3406. i = 0;
  3407. }
  3408. if(i>0)
  3409. {
  3410. list.append(", ").append(itr->first);
  3411. }
  3412. else
  3413. {
  3414. list = itr->first;
  3415. }
  3416. }
  3417. if(list.length() > 0)
  3418. {
  3419. // if 1 or more, display in client.
  3420. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3421. }
  3422. }
  3423. else
  3424. {
  3425. // syntax fail
  3426. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3427. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3428. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3429. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3430. }
  3431. }
  3432. break;
  3433. }
  3434. case COMMAND_SPAWN_REMOVE:{
  3435. Spawn* spawn = cmdTarget;
  3436. if(spawn && !spawn->IsPlayer()){
  3437. if(spawn->GetSpawnLocationID() > 0){
  3438. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3439. bool delete_spawn = false;
  3440. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3441. if(atoi(sep->arg[0]) == 1)
  3442. delete_spawn = true;
  3443. }
  3444. if(delete_spawn)
  3445. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, false);
  3446. else
  3447. spawn->SetSpawnLocationID(0);
  3448. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3449. }
  3450. else
  3451. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3452. }
  3453. else
  3454. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3455. }
  3456. else{
  3457. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3458. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3459. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Optionally, you can supply a 1 after the command to despawn it as well. IE /spawn remove 1");
  3460. }
  3461. break;
  3462. }
  3463. case COMMAND_SPAWN_LIST:{
  3464. if(sep && sep->arg[0][0]){
  3465. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3466. vector<string>::iterator itr;
  3467. if(results){
  3468. for(itr=results->begin();itr!=results->end();itr++){
  3469. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3470. }
  3471. safe_delete(results);
  3472. }
  3473. else
  3474. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3475. }
  3476. else{
  3477. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3478. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3479. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3480. }
  3481. break;
  3482. }
  3483. case COMMAND_SPAWN_ADD:{
  3484. Spawn* spawn = cmdTarget;
  3485. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3486. if(spawn->GetSpawnLocationID() > 0){
  3487. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3488. break;
  3489. }
  3490. if(spawn->GetDatabaseID() == 0){
  3491. if(database.SaveSpawnInfo(spawn)) {
  3492. char spawn_type[32];
  3493. memset(spawn_type, 0, sizeof(spawn_type));
  3494. if (spawn->IsNPC())
  3495. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3496. else if (spawn->IsObject())
  3497. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3498. else if (spawn->IsSign())
  3499. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3500. else if (spawn->IsGroundSpawn())
  3501. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3502. else
  3503. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3504. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3505. }
  3506. else
  3507. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3508. }
  3509. int32 spawn_group_id = 0;
  3510. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3511. spawn_group_id = database.GetNextSpawnLocation();
  3512. else
  3513. spawn_group_id = atol(sep->arg[0]);
  3514. int8 percent = 100;
  3515. if(sep->arg[2] && sep->IsNumber(2))
  3516. percent = atoi(sep->arg[2]);
  3517. spawn->SetSpawnLocationID(spawn_group_id);
  3518. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3519. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3520. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3521. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3522. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3523. else
  3524. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3525. }
  3526. else{
  3527. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3528. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3529. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3530. }
  3531. break;
  3532. }
  3533. case COMMAND_SPAWN:{
  3534. int32 id = 0;
  3535. Spawn* spawn = 0;
  3536. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3537. id = atol(sep->arg[0]);
  3538. spawn = client->GetCurrentZone()->GetSpawn(id);
  3539. }
  3540. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3541. id = 0;
  3542. if(!id || !spawn){
  3543. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3544. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3545. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3546. safe_delete(sep);
  3547. return;
  3548. }
  3549. if(sep && sep->arg[1][0]){
  3550. float x = atof(sep->arg[1]);
  3551. spawn->appearance.pos.X = x;
  3552. }
  3553. else
  3554. spawn->SetX(client->GetPlayer()->GetX(), false);
  3555. if(sep && sep->arg[2][0]){
  3556. float y = atof(sep->arg[2]);
  3557. spawn->appearance.pos.Y = y;
  3558. }
  3559. else
  3560. spawn->SetY(client->GetPlayer()->GetY(), false);
  3561. if(sep && sep->arg[3][0]){
  3562. float z = atof(sep->arg[3]);
  3563. spawn->appearance.pos.Z = z;
  3564. }
  3565. else
  3566. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3567. if(sep && sep->arg[4][0]){
  3568. float heading = atof(sep->arg[4]);
  3569. spawn->SetHeading(heading);
  3570. }
  3571. else
  3572. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3573. spawn->SetSpawnOrigX(spawn->GetX());
  3574. spawn->SetSpawnOrigY(spawn->GetY());
  3575. spawn->SetSpawnOrigZ(spawn->GetZ());
  3576. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3577. if(sep && sep->arg[5][0])
  3578. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3579. else
  3580. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3581. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3582. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3583. spawn->SetHP(spawn->GetTotalHP());
  3584. }
  3585. if(spawn->GetTotalPower() == 0){
  3586. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3587. spawn->SetPower(spawn->GetTotalPower());
  3588. }
  3589. const char* script = world.GetSpawnScript(id);
  3590. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3591. spawn->SetSpawnScript(string(script));
  3592. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  3593. client->GetCurrentZone()->AddSpawn(spawn);
  3594. if(spawn->IsNPC())
  3595. spawn->GetZone()->AddLoot((NPC*)spawn);
  3596. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3597. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3598. break;
  3599. }
  3600. case COMMAND_ADMINFLAG:
  3601. {
  3602. if(sep && sep->arg[0]){
  3603. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3604. sint16 new_status = atoi(sep->arg[1]);
  3605. if(tmp_status == -10)
  3606. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3607. else if(tmp_status >= client->GetAdminStatus())
  3608. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3609. else if (new_status > client->GetAdminStatus())
  3610. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3611. else{
  3612. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3613. if (!client2)
  3614. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3615. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3616. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3617. if (client2) {
  3618. client2->SetAdminStatus(new_status);
  3619. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3620. }
  3621. }
  3622. else
  3623. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3624. }
  3625. }else{
  3626. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3627. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3628. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3629. }
  3630. break;
  3631. }
  3632. case COMMAND_CANNEDEMOTE:{
  3633. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3634. break;
  3635. }
  3636. case COMMAND_BROADCAST: {
  3637. if (sep && sep->arg[0])
  3638. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3639. else
  3640. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3641. break;
  3642. }
  3643. case COMMAND_ANNOUNCE: {
  3644. if (sep && sep->arg[0])
  3645. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3646. else
  3647. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3648. break;
  3649. }
  3650. case COMMAND_RELOAD_ITEMS:{
  3651. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3652. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3653. database.ReloadItemList();
  3654. database.LoadMerchantInformation();
  3655. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3656. break;
  3657. }
  3658. case COMMAND_ENABLE_ABILITY_QUE:{
  3659. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3660. if(app)
  3661. client->QueuePacket(app);
  3662. break;
  3663. }
  3664. case COMMAND_ITEMSEARCH:{
  3665. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3666. if (packet) {
  3667. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3668. //packet->setDataByName("unknown", 1);
  3669. packet->setDataByName("unknown2", 5, 0);
  3670. packet->setDataByName("unknown2", 20, 1);
  3671. packet->setDataByName("unknown2", 58, 3);
  3672. packet->setDataByName("unknown2", 40, 4);
  3673. client->QueuePacket(packet->serialize());
  3674. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3675. if (packet2) {
  3676. packet2->setDataByName("char_id", client->GetCharacterID());
  3677. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3678. safe_delete(packet2);
  3679. }
  3680. safe_delete(packet);
  3681. }
  3682. break;
  3683. }
  3684. case COMMAND_ANIMTEST:{
  3685. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3686. if(command_packet){
  3687. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  3688. if (cmdTarget)
  3689. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  3690. command_packet->setDataByName ( "spawn_id" , id);
  3691. int animID = 1;
  3692. if(sep && sep->arg[0] && sep->IsNumber(0))
  3693. animID = atoi(sep->arg[0]);
  3694. VisualState* vs = NULL;
  3695. if(animID == 0)
  3696. {
  3697. vs = visual_states.FindVisualState(sep->arg[0]);
  3698. }
  3699. char msg[128];
  3700. sprintf(msg,"Animation Test ID: %i",animID);
  3701. command_packet->setMediumStringByName ( "emote_msg" , msg );
  3702. if(vs != NULL)
  3703. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  3704. else
  3705. command_packet->setDataByName ( "anim_type", animID );
  3706. command_packet->setDataByName ( "unknown0", 0 );
  3707. EQ2Packet* outapp = command_packet->serialize();
  3708. client->QueuePacket(outapp);
  3709. safe_delete(command_packet);
  3710. }
  3711. break;
  3712. }
  3713. case COMMAND_KICK:
  3714. {
  3715. if( sep == 0 || sep->arg[0] == 0)
  3716. {
  3717. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  3718. }
  3719. else
  3720. {
  3721. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  3722. if ( kickClient == client )
  3723. {
  3724. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  3725. break;
  3726. }
  3727. else if(kickClient != NULL)
  3728. {
  3729. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3730. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  3731. {
  3732. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3733. break;
  3734. }
  3735. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  3736. kickClient->Disconnect();
  3737. }
  3738. else
  3739. {
  3740. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3741. }
  3742. }
  3743. break;
  3744. }
  3745. case COMMAND_LOCK:
  3746. {
  3747. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  3748. int worldLocked = atoi(sep->arg[0]);
  3749. net.world_locked = worldLocked;
  3750. if ( worldLocked )
  3751. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  3752. else
  3753. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  3754. }
  3755. else
  3756. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  3757. break;
  3758. }
  3759. case COMMAND_BAN:{
  3760. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  3761. {
  3762. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  3763. }
  3764. else
  3765. {
  3766. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  3767. if ( kickClient == client )
  3768. {
  3769. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  3770. break;
  3771. }
  3772. else if(kickClient != NULL)
  3773. {
  3774. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3775. if ( maxStatus > client->GetAdminStatus( ) ||
  3776. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  3777. {
  3778. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3779. break;
  3780. }
  3781. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  3782. int perm = atol(sep->arg[1]);
  3783. if ( perm == 1 )
  3784. database.UpdateAdminStatus(sep->arg[0],-2);
  3785. else
  3786. database.UpdateAdminStatus(sep->arg[0],-1);
  3787. kickClient->Disconnect();
  3788. }
  3789. else
  3790. {
  3791. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3792. }
  3793. }
  3794. break;
  3795. }
  3796. case COMMAND_SET_COMBAT_VOICE:{
  3797. int32 value = 0;
  3798. if(sep && sep->arg[0] && sep->IsNumber(0))
  3799. value = atoi(sep->arg[0]);
  3800. client->GetPlayer()->SetCombatVoice(value);
  3801. break;
  3802. }
  3803. case COMMAND_SET_EMOTE_VOICE:{
  3804. int32 value = 0;
  3805. if(sep && sep->arg[0] && sep->IsNumber(0))
  3806. value = atoi(sep->arg[0]);
  3807. client->GetPlayer()->SetEmoteVoice(value);
  3808. break;
  3809. }
  3810. case COMMAND_GIVEITEM:{
  3811. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  3812. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  3813. if ( itemToClient == NULL )
  3814. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  3815. else
  3816. {
  3817. int32 item_id = atol(sep->arg[1]);
  3818. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  3819. itemToClient->AddItem(item_id);
  3820. }
  3821. }
  3822. else
  3823. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  3824. break;
  3825. }
  3826. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  3827. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  3828. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  3829. case COMMAND_SKILL :
  3830. case COMMAND_SKILL_ADD :
  3831. case COMMAND_SKILL_REMOVE :
  3832. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  3833. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  3834. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  3835. case COMMAND_ENTITYCOMMAND :
  3836. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  3837. case COMMAND_MERCHANT :
  3838. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  3839. case COMMAND_APPEARANCE :
  3840. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  3841. case COMMAND_TRACK : { Command_Track(client); break; }
  3842. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  3843. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  3844. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  3845. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  3846. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  3847. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  3848. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  3849. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  3850. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  3851. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  3852. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  3853. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  3854. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  3855. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  3856. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  3857. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  3858. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  3859. case COMMAND_LOCATION : { Command_Location(client); break; }
  3860. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  3861. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  3862. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  3863. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  3864. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  3865. case COMMAND_GRID : { Command_Grid(client); break; }
  3866. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  3867. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  3868. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  3869. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  3870. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  3871. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  3872. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  3873. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  3874. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  3875. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  3876. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  3877. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  3878. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  3879. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  3880. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  3881. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  3882. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  3883. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  3884. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  3885. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  3886. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  3887. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  3888. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  3889. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  3890. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  3891. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  3892. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  3893. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  3894. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  3895. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  3896. case COMMAND_MOTD : { Command_MOTD(client); break; }
  3897. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  3898. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  3899. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  3900. case COMMAND_TITLE : { Command_Title(client); break; }
  3901. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  3902. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  3903. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  3904. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  3905. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  3906. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  3907. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  3908. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  3909. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  3910. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  3911. case COMMAND_PET : { Command_Pet(client, sep); break; }
  3912. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  3913. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  3914. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  3915. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  3916. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  3917. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  3918. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  3919. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  3920. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  3921. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  3922. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  3923. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  3924. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  3925. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  3926. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  3927. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  3928. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  3929. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  3930. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  3931. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  3932. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  3933. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  3934. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  3935. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  3936. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  3937. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  3938. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  3939. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  3940. case COMMAND_MODIFY : { Command_Modify(client); break; }
  3941. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  3942. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  3943. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  3944. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  3945. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  3946. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  3947. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  3948. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  3949. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  3950. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  3951. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  3952. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  3953. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  3954. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  3955. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  3956. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  3957. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  3958. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  3959. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  3960. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  3961. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  3962. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  3963. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  3964. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  3965. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  3966. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  3967. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  3968. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  3969. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  3970. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  3971. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  3972. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  3973. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  3974. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  3975. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  3976. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  3977. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  3978. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  3979. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  3980. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  3981. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  3982. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  3983. case ADD_AA : { Add_AA(client, sep); break; }
  3984. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  3985. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  3986. case BACK_AA : { Back_AA(client, sep); break; }
  3987. case REMOVE_AA : { Remove_AA(client, sep); break; }
  3988. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  3989. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  3990. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  3991. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  3992. default:
  3993. {
  3994. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  3995. break;
  3996. }
  3997. }
  3998. safe_delete(sep);
  3999. }
  4000. /******************** New COMMAND Handler Functions ********************/
  4001. /*
  4002. Started breaking apart the huge switch() for commands into sepErate
  4003. functions so it is easier to locate the blocks of code by command
  4004. -- JA 2012.03.03
  4005. */
  4006. // sample function header
  4007. /*
  4008. Function:
  4009. Purpose :
  4010. Params :
  4011. Dev :
  4012. Example :
  4013. */
  4014. //void Commands::Command()
  4015. //{
  4016. //}
  4017. /*
  4018. Function: Command_AcceptAdvancement()
  4019. Purpose : Player accepts a new advancement option
  4020. Params : Spell ID
  4021. Dev : Jabantiz
  4022. */
  4023. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4024. {
  4025. Player *player = client->GetPlayer();
  4026. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4027. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4028. if (!player->HasSpell(trait->spellID, 0, true))
  4029. {
  4030. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4031. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4032. }
  4033. else
  4034. {
  4035. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4036. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4037. player->RemoveSpellBookEntry(spell->GetSpellID());
  4038. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4039. player->UnlockSpell(spell);
  4040. client->SendSpellUpdate(spell);
  4041. }
  4042. // Spell book update
  4043. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4044. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4045. }
  4046. /*
  4047. Function:
  4048. Purpose :
  4049. Params :
  4050. Dev :
  4051. Example :
  4052. */
  4053. void Commands::Command_AFK(Client* client, Seperator* sep)
  4054. {
  4055. Player* player = client->GetPlayer();
  4056. player->toggle_character_flag(CF_AFK);
  4057. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4058. if (player->get_character_flag(CF_AFK))
  4059. {
  4060. //LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4061. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK);
  4062. if (sep && sep->argplus[0])
  4063. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4064. else
  4065. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4066. string message = string(player->GetName()) + " is going afk.";
  4067. Spawn* target = player->GetTarget();
  4068. if (target && target != player)
  4069. {
  4070. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4071. player->GetGender() == 1 ? message += "he" : message += "she";
  4072. message += " is going afk.";
  4073. }
  4074. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4075. }
  4076. else
  4077. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK);
  4078. }
  4079. /*
  4080. Function: Command_Appearance()
  4081. Purpose : Handles /appearance commands
  4082. Params : list
  4083. Dev : Scatman
  4084. Example : /appearance list
  4085. */
  4086. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4087. {
  4088. if( handler == COMMAND_APPEARANCE )
  4089. {
  4090. // /appearance command by itself shows help (to be extended)
  4091. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4092. return;
  4093. }
  4094. else if( handler == COMMAND_APPEARANCE_LIST )
  4095. {
  4096. // /appearance list command expects "name" param
  4097. if (sep && sep->arg[0])
  4098. {
  4099. const char* appearance_name = sep->argplus[0];
  4100. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4101. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4102. if (appearances)
  4103. {
  4104. vector<int16>::iterator itr;
  4105. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4106. {
  4107. int16 id = *itr;
  4108. string name = database.GetAppearanceName(id);
  4109. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4110. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4111. }
  4112. safe_delete(appearances);
  4113. }
  4114. }
  4115. else // no param
  4116. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4117. }
  4118. }
  4119. /*
  4120. Function: Command_Claim()
  4121. Purpose :
  4122. Params :
  4123. Dev :
  4124. Example :
  4125. */
  4126. void Commands::Command_Claim(Client* client, Seperator* sep)
  4127. {
  4128. if (sep && sep->arg[0] && sep->IsNumber(0))
  4129. {
  4130. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4132. }
  4133. else
  4134. client->ShowClaimWindow();
  4135. }
  4136. /*
  4137. Function: Command_ClearAllQueued()
  4138. Purpose :
  4139. Params :
  4140. Dev :
  4141. Example :
  4142. */
  4143. void Commands::Command_ClearAllQueued(Client* client)
  4144. {
  4145. ZoneServer* zone = client->GetPlayer()->GetZone();
  4146. if (zone && zone->GetSpellProcess())
  4147. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4148. }
  4149. /*
  4150. Function: Command_CancelMaintained()
  4151. Purpose : Cancels maintained spells
  4152. Params : Maintained Spell Index
  4153. Dev : Zcoretri
  4154. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4155. */
  4156. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4157. {
  4158. if (sep && sep->arg[0] && sep->IsNumber(0))
  4159. {
  4160. int32 spell_index = atoul(sep->arg[0]);
  4161. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4162. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4163. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4164. // just not spelleffects/dets - Foof
  4165. //{
  4166. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell))
  4167. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4168. // }
  4169. //else
  4170. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4171. }
  4172. }
  4173. /*
  4174. Function: Command_Create()
  4175. Purpose : Handler for starting Tradeskilling table
  4176. Params :
  4177. Dev : Zcoretri
  4178. Example :
  4179. */
  4180. void Commands::Command_Create(Client* client, Seperator* sep)
  4181. {
  4182. PrintSep(sep, "COMMAND_CREATE");
  4183. client->SendRecipeList();
  4184. client->ShowRecipeBook();
  4185. }
  4186. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4187. {
  4188. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4189. if (sep && sep->arg[0] && sep->IsNumber(0))
  4190. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4191. }
  4192. /*
  4193. Function: Command_Distance()
  4194. Purpose : Displays distance from targeted spawn
  4195. Params :
  4196. Dev : Scatman
  4197. Example : /distance
  4198. */
  4199. void Commands::Command_Distance(Client* client)
  4200. {
  4201. Spawn* target = client->GetPlayer()->GetTarget();
  4202. if (target)
  4203. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4204. else
  4205. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4206. }
  4207. /*
  4208. Function: Command_Duel()
  4209. Purpose : Handle the /duel commands - not yet implemented
  4210. Params : unknown
  4211. Dev :
  4212. Example :
  4213. */
  4214. void Commands::Command_Duel(Client* client, Seperator* sep)
  4215. {
  4216. PrintSep(sep, "COMMAND_DUEL");
  4217. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4218. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4219. }
  4220. /*
  4221. Function: Command_DuelBet()
  4222. Purpose : Handle the /duel commands - not yet implemented
  4223. Params : unknown
  4224. Dev :
  4225. Example :
  4226. */
  4227. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4228. {
  4229. PrintSep(sep, "COMMAND_DUELBET");
  4230. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4231. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4232. }
  4233. /*
  4234. Function: Command_DuelAccept()
  4235. Purpose : Handle the /duel commands - not yet implemented
  4236. Params : unknown
  4237. Dev :
  4238. Example :
  4239. */
  4240. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4241. {
  4242. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4243. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4244. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4245. }
  4246. /*
  4247. Function: Command_DuelDecline()
  4248. Purpose : Handle the /duel commands - not yet implemented
  4249. Params : unknown
  4250. Dev :
  4251. Example :
  4252. */
  4253. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4254. {
  4255. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4256. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4257. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4258. }
  4259. /*
  4260. Function: Command_DuelSurrender()
  4261. Purpose : Handle the /duel commands - not yet implemented
  4262. Params : unknown
  4263. Dev :
  4264. Example :
  4265. */
  4266. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4267. {
  4268. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4269. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4270. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4271. // JA, just messin around ;)
  4272. char surrender[64];
  4273. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4274. zone_list.HandleGlobalAnnouncement(surrender);
  4275. }
  4276. /*
  4277. Function: Command_DuelToggle()
  4278. Purpose : Handle the /duel commands - not yet implemented
  4279. Params : unknown
  4280. Dev :
  4281. Example :
  4282. */
  4283. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4284. {
  4285. PrintSep(sep, "COMMAND_DUEL");
  4286. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4287. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4288. }
  4289. /*
  4290. Function:
  4291. Purpose :
  4292. Params :
  4293. Dev :
  4294. Example :
  4295. */
  4296. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4297. {
  4298. if( handler == COMMAND_ENTITYCOMMAND )
  4299. {
  4300. // /entitycommand command by itself shows help (to be extended)
  4301. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4302. return;
  4303. }
  4304. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4305. {
  4306. // /entitycommand list command expects "name" param
  4307. if (sep && sep->arg[0])
  4308. {
  4309. const char* entity_command_name = sep->argplus[0];
  4310. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4311. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4312. map<int32, vector<EntityCommand*>*>::iterator itr;
  4313. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4314. {
  4315. vector<EntityCommand*>* entity_command_list = itr->second;
  4316. vector<EntityCommand*>::iterator itr2;
  4317. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4318. {
  4319. EntityCommand* entity_command = *itr2;
  4320. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4321. 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);
  4322. }
  4323. }
  4324. }
  4325. else // no command name
  4326. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4327. }
  4328. }
  4329. /*
  4330. Function: Command_Follow()
  4331. Purpose : Handle the /follow command - not yet implemented
  4332. Params :
  4333. Dev :
  4334. Example :
  4335. */
  4336. void Commands::Command_Follow(Client* client, Seperator* sep)
  4337. {
  4338. PrintSep(sep, "COMMAND_FOLLOW");
  4339. // flag to toggle if the players target is in the players group
  4340. bool targetInGroup = false;
  4341. // get a pointer to the players group
  4342. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4343. // If the player has a group and has a target
  4344. if (gmi && client->GetPlayer()->GetTarget()) {
  4345. deque<GroupMemberInfo*>::iterator itr;
  4346. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4347. deque<GroupMemberInfo*>* members = world.GetGroupManager()->GetGroupMembers(gmi->group_id);
  4348. // Loop through the group members
  4349. for (itr = members->begin(); itr != members->end(); itr++) {
  4350. // If a group member matches a target
  4351. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4352. // toggle the flag and break the loop
  4353. targetInGroup = true;
  4354. break;
  4355. }
  4356. }
  4357. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4358. }
  4359. if (targetInGroup) {
  4360. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4361. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4362. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4363. client->GetPlayer()->info_changed = true;
  4364. client->GetPlayer()->changed = true;
  4365. }
  4366. else
  4367. client->Message(CHANNEL_COLOR_WHITE, "You must first select a group member to follow.");
  4368. }
  4369. /*
  4370. Function: Command_StopFollow()
  4371. Purpose : Handle the /stop_follow command - not yet implemented
  4372. Params :
  4373. Dev :
  4374. Example :
  4375. */
  4376. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4377. {
  4378. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4379. if (client->GetPlayer()->GetFollowTarget()) {
  4380. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4381. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4382. client->GetPlayer()->SetFollowTarget(0);
  4383. client->GetPlayer()->info_changed = true;
  4384. client->GetPlayer()->changed = true;
  4385. }
  4386. }
  4387. #include "../Zone/SPGrid.h"
  4388. /*
  4389. Function: Command_Grid()
  4390. Purpose : Show player's current Grid ID
  4391. Params :
  4392. Dev : Scatman
  4393. Example : /grid
  4394. */
  4395. void Commands::Command_Grid(Client* client)
  4396. {
  4397. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4398. if (client->GetCurrentZone()->Grid != nullptr) {
  4399. int32 grid = client->GetCurrentZone()->Grid->GetGridID(client->GetPlayer());
  4400. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4401. }
  4402. }
  4403. /*
  4404. Function: Command_Guild()
  4405. Purpose : Handler for all UI-related guild commands
  4406. Dev : Scatman
  4407. */
  4408. void Commands::Command_Guild(Client* client, Seperator* sep)
  4409. {
  4410. Guild* guild = client->GetPlayer()->GetGuild();
  4411. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  4412. {
  4413. const char* command = sep->arg[0];
  4414. int32 length = strlen(command);
  4415. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4416. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4417. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4418. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4419. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4420. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4421. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4422. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4423. guild->KickGuildMember(client, sep->arg[1]);
  4424. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4425. guild->DemoteGuildMember(client, sep->arg[1]);
  4426. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4427. guild->PromoteGuildMember(client, sep->arg[1]);
  4428. else if (strncmp(command, "points", length) == 0 && guild)
  4429. {
  4430. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4431. {
  4432. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4433. {
  4434. float points = atof(sep->arg[2]);
  4435. const char* option = sep->arg[3];
  4436. const char* comment = sep->argplus[4];
  4437. if (strncmp(option, "all", strlen(option)) == 0)
  4438. guild->AddPointsToAll(client, points, comment);
  4439. else if (strncmp(option, "online", strlen(option)) == 0)
  4440. guild->AddPointsToAllOnline(client, points, comment);
  4441. else if (strncmp(option, "group", strlen(option)) == 0)
  4442. guild->AddPointsToGroup(client, points, comment);
  4443. else if (strncmp(option, "raid", strlen(option)) == 0)
  4444. guild->AddPointsToRaid(client, points, comment);
  4445. else
  4446. guild->AddPointsToGuildMember(client, points, option, comment);
  4447. }
  4448. }
  4449. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4450. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4451. else
  4452. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4453. }
  4454. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4455. guild->SetMOTD(sep->argplus[1]);
  4456. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4457. {
  4458. if (sep->arg[1])
  4459. {
  4460. const char* option = sep->arg[1];
  4461. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4462. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4463. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4464. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4465. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4466. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4467. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4468. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4469. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4470. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4471. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4472. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4473. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4474. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4475. else
  4476. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4477. }
  4478. else
  4479. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4480. }
  4481. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4482. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4483. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4484. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4485. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4486. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4487. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4488. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4489. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4490. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4491. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4492. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4493. else if (strncmp(command, "invite", length) == 0 && guild)
  4494. {
  4495. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4496. guild->InvitePlayer(client, sep->arg[1]);
  4497. else
  4498. {
  4499. Spawn* target = client->GetPlayer()->GetTarget();
  4500. if (target)
  4501. {
  4502. if (target->IsPlayer())
  4503. guild->InvitePlayer(client, target->GetName());
  4504. else
  4505. client->Message(CHANNEL_COLOR_WHITE, "%s is not a player.", target->GetName());
  4506. }
  4507. }
  4508. }
  4509. else if (strncmp(command, "accept", length) == 0)
  4510. {
  4511. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4512. if (pgi && pgi->guild && pgi->invited_by)
  4513. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4514. client->SetPendingGuildInvite(0);
  4515. }
  4516. else if (strncmp(command, "decline", length) == 0)
  4517. {
  4518. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4519. if (pgi && pgi->guild && pgi->invited_by)
  4520. {
  4521. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4522. if (client_inviter)
  4523. client_inviter->Message(CHANNEL_COLOR_WHITE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4524. }
  4525. client->SetPendingGuildInvite(0);
  4526. }
  4527. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4528. {
  4529. const char* guild_name = sep->argplus[1];
  4530. if (!guild_list.GetGuild(guild_name))
  4531. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  4532. else
  4533. client->SimpleMessage(CHANNEL_COLOR_WHITE, "A guild with that name already exists.");
  4534. }
  4535. else if (strncmp(command, "search", length) == 0)
  4536. client->ShowGuildSearchWindow();
  4537. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4538. {
  4539. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4540. if (to_guild)
  4541. to_guild->SendGuildRecruitingDetails(client);
  4542. }
  4543. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4544. {
  4545. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4546. if (to_guild)
  4547. to_guild->SendGuildRecruitingImages(client);
  4548. }
  4549. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4550. {
  4551. if (sep->arg[1])
  4552. {
  4553. const char* option = sep->arg[1];
  4554. if (strncmp(option, "toggle", strlen(option)) == 0)
  4555. guild->ToggleGuildRecruiterAdventureClass(client);
  4556. }
  4557. else
  4558. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4559. }
  4560. else if (strncmp(command, "display_heraldry", length) == 0)
  4561. {
  4562. // JA: not sure this is right...
  4563. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4564. client->GetPlayer()->SetCharSheetChanged(true);
  4565. }
  4566. else
  4567. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4568. }
  4569. }
  4570. /*
  4571. Function: Command_GuildCreate()
  4572. Purpose : Display's in-game Guild Creation window
  4573. Dev : Scatman
  4574. */
  4575. void Commands::Command_CreateGuild(Client* client)
  4576. {
  4577. client->SendGuildCreateWindow();
  4578. }
  4579. /*
  4580. Function: Command_SetGuildOfficerNote()
  4581. Purpose :
  4582. Dev : Scatman
  4583. */
  4584. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4585. {
  4586. if (sep && sep->arg[0] && sep->arg[1])
  4587. {
  4588. Guild* guild = client->GetPlayer()->GetGuild();
  4589. if (guild)
  4590. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4591. }
  4592. }
  4593. /*
  4594. Function: Command_SetGuildMemberNote()
  4595. Purpose :
  4596. Dev : Scatman
  4597. */
  4598. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4599. {
  4600. if (sep && sep->arg[0] && sep->arg[1])
  4601. {
  4602. Guild* guild = client->GetPlayer()->GetGuild();
  4603. if (guild)
  4604. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4605. }
  4606. }
  4607. /*
  4608. Function: Command_GuildSay()
  4609. Purpose :
  4610. Dev : Scatman
  4611. */
  4612. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4613. {
  4614. Guild* guild = client->GetPlayer()->GetGuild();
  4615. if (guild)
  4616. {
  4617. if (sep && sep->arg[0])
  4618. guild->HandleGuildSay(client, sep->argplus[0]);
  4619. }
  4620. else
  4621. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4622. }
  4623. /*
  4624. Function: Command_OfficerSay()
  4625. Purpose :
  4626. Dev : Scatman
  4627. */
  4628. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4629. {
  4630. Guild* guild = client->GetPlayer()->GetGuild();
  4631. if (guild)
  4632. {
  4633. if (sep && sep->arg[0])
  4634. guild->HandleOfficerSay(client, sep->argplus[0]);
  4635. }
  4636. else
  4637. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4638. }
  4639. /*
  4640. Function: Command_Guilds()
  4641. Purpose : Shows help for /guild command
  4642. Params :
  4643. Dev : Scatman
  4644. Example :
  4645. */
  4646. void Commands::Command_Guilds(Client* client)
  4647. {
  4648. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4649. }
  4650. /*
  4651. Function: Command_GuildsAdd()
  4652. Purpose : Add's players to a guild
  4653. Params : guild_name|guild_id, player name
  4654. Dev : Scatman
  4655. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4656. */
  4657. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4658. {
  4659. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4660. {
  4661. Guild* guild = 0;
  4662. bool found = true;
  4663. if (sep->IsNumber(0))
  4664. {
  4665. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4666. if (!guild)
  4667. {
  4668. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4669. found = false;
  4670. }
  4671. }
  4672. else
  4673. {
  4674. guild = guild_list.GetGuild(sep->arg[0]);
  4675. if (!guild)
  4676. {
  4677. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4678. found = false;
  4679. }
  4680. }
  4681. if (found)
  4682. {
  4683. Client* to_client = 0;
  4684. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4685. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4686. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4687. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4688. if (to_client)
  4689. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  4690. else
  4691. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4692. }
  4693. }
  4694. else
  4695. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  4696. }
  4697. /*
  4698. Function: Command_GuildsCreate()
  4699. Purpose : Creates a guild
  4700. Params : guild_name, player_name (optional)
  4701. Dev : Scatman
  4702. Example : /guilds create [guild name] (player name)
  4703. */
  4704. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  4705. {
  4706. if (sep && sep->arg[0])
  4707. {
  4708. const char* guild_name = sep->arg[0];
  4709. if (!guild_list.GetGuild(guild_name))
  4710. {
  4711. bool ret = false;
  4712. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4713. {
  4714. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4715. if (to_client)
  4716. {
  4717. world.CreateGuild(guild_name, to_client);
  4718. ret = true;
  4719. }
  4720. else
  4721. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  4722. }
  4723. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4724. {
  4725. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4726. if (to_client)
  4727. {
  4728. world.CreateGuild(guild_name, to_client);
  4729. ret = true;
  4730. }
  4731. }
  4732. else
  4733. {
  4734. world.CreateGuild(guild_name);
  4735. ret = true;
  4736. }
  4737. if (ret)
  4738. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  4739. else
  4740. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  4741. }
  4742. else
  4743. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  4744. }
  4745. else
  4746. 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.");
  4747. }
  4748. /*
  4749. Function: Command_GuildsDelete()
  4750. Purpose : Delete's a guild
  4751. Params : guild name
  4752. Dev : Scatman
  4753. Example : /guilds delete Test
  4754. */
  4755. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  4756. {
  4757. if (sep && sep->arg[0])
  4758. {
  4759. Guild* guild = 0;
  4760. bool found = true;
  4761. if (sep->IsNumber(0))
  4762. {
  4763. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4764. if (!guild)
  4765. {
  4766. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4767. found = false;
  4768. }
  4769. }
  4770. else
  4771. {
  4772. guild = guild_list.GetGuild(sep->arg[0]);
  4773. if (!guild)
  4774. {
  4775. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4776. found = false;
  4777. }
  4778. }
  4779. if (found)
  4780. {
  4781. guild->RemoveAllGuildMembers();
  4782. database.DeleteGuild(guild);
  4783. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  4784. guild_list.RemoveGuild(guild, true);
  4785. }
  4786. }
  4787. else
  4788. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  4789. }
  4790. /*
  4791. Function: Command_GuildsList()
  4792. Purpose : Lists current guilds on server
  4793. Params :
  4794. Dev : Scatman
  4795. Example : /guilds list
  4796. */
  4797. void Commands::Command_GuildsList(Client* client)
  4798. {
  4799. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  4800. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  4801. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  4802. if (guilds->size() == 0)
  4803. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  4804. else {
  4805. while (itr.Next()) {
  4806. Guild* guild = itr.second;
  4807. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  4808. }
  4809. }
  4810. }
  4811. /*
  4812. Function: Command_GuildsRemove()
  4813. Purpose : Removes a player from a guild
  4814. Params : guild name|guild id, player name
  4815. Dev : Scatman
  4816. Example : /guilds remove 1 Admin = removes Admin from guild 1
  4817. */
  4818. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  4819. {
  4820. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4821. {
  4822. Guild* guild = 0;
  4823. bool found = true;
  4824. if (sep->IsNumber(0))
  4825. {
  4826. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4827. if (!guild)
  4828. {
  4829. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4830. found = false;
  4831. }
  4832. }
  4833. else
  4834. {
  4835. guild = guild_list.GetGuild(sep->arg[0]);
  4836. if (!guild)
  4837. {
  4838. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4839. found = false;
  4840. }
  4841. }
  4842. if (found)
  4843. {
  4844. Client* to_client = 0;
  4845. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4846. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4847. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4848. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4849. if (to_client)
  4850. {
  4851. Player* to_player = to_client->GetPlayer();
  4852. if (to_player->GetGuild())
  4853. {
  4854. if (to_player->GetGuild() == guild)
  4855. {
  4856. guild->KickGuildMember(client, to_player->GetName());
  4857. }
  4858. else
  4859. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  4860. }
  4861. else
  4862. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  4863. }
  4864. else
  4865. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4866. }
  4867. }
  4868. else
  4869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  4870. }
  4871. /*
  4872. Function: Command_InspectPlayer()
  4873. Purpose : Handle the Inspect functions
  4874. Params : Client to inspect
  4875. Dev : Scatman
  4876. Example : /inspect Scatman
  4877. */
  4878. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  4879. {
  4880. if (sep && sep->arg[0])
  4881. {
  4882. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  4883. if (inspect_client)
  4884. client->InspectPlayer(inspect_client->GetPlayer());
  4885. }
  4886. else
  4887. {
  4888. Spawn* target = client->GetPlayer()->GetTarget();
  4889. if (target && target->IsPlayer())
  4890. client->InspectPlayer((Player*)target);
  4891. }
  4892. }
  4893. /*
  4894. Function: Command_Inventory()
  4895. Purpose : Handle changes in player inventory
  4896. Params : <TBD>
  4897. Dev : All
  4898. Example : /inventory delete item_id
  4899. */
  4900. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  4901. {
  4902. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  4903. Player* player = client->GetPlayer();
  4904. if(sep && sep->arg[0][0])
  4905. {
  4906. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  4907. if(client->GetPlayer()->GetHP() == 0)
  4908. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  4909. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  4910. {
  4911. int16 index = atoi(sep->arg[1]);
  4912. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  4913. if(item)
  4914. {
  4915. if(item->GetItemScript() && lua_interface)
  4916. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  4917. int32 bag_id = item->details.inv_slot_id;
  4918. database.DeleteItem(client->GetCharacterID(), item, 0);
  4919. client->GetPlayer()->item_list.DestroyItem(index);
  4920. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4921. client->QueuePacket(outapp);
  4922. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  4923. if (outapp)
  4924. client->QueuePacket(outapp);
  4925. }
  4926. }
  4927. 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))
  4928. {
  4929. int16 from_index = atoi(sep->arg[1]);
  4930. sint16 to_slot = atoi(sep->arg[2]);
  4931. sint32 bag_id = atol(sep->arg[3]);
  4932. int8 charges = atoi(sep->arg[4]);
  4933. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  4934. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  4935. {
  4936. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  4937. return;
  4938. }
  4939. sint32 old_inventory_id = 0;
  4940. if(item)
  4941. old_inventory_id = item->details.inv_slot_id;
  4942. //autobank
  4943. if (bag_id == -3 && to_slot == -1)
  4944. {
  4945. if (player->HasFreeBankSlot())
  4946. to_slot = player->FindFreeBankSlot();
  4947. else
  4948. {
  4949. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  4950. return;
  4951. }
  4952. }
  4953. //auto inventory
  4954. if (bag_id == 0 && to_slot == -1)
  4955. {
  4956. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  4957. {
  4958. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  4959. return;
  4960. }
  4961. }
  4962. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  4963. client->QueuePacket(outapp);
  4964. //removed from bag send update
  4965. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  4966. {
  4967. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  4968. if(outapp)
  4969. client->QueuePacket(outapp);
  4970. }
  4971. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  4972. {
  4973. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  4974. if(outapp)
  4975. client->QueuePacket(outapp);
  4976. }
  4977. }
  4978. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  4979. {
  4980. if(client->GetPlayer()->EngagedInCombat())
  4981. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  4982. else
  4983. {
  4984. int16 index = atoi(sep->arg[1]);
  4985. int8 slot_id = 255;
  4986. if(sep->arg[2][0] && sep->IsNumber(2))
  4987. slot_id = atoi(sep->arg[2]);
  4988. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  4989. EQ2Packet* outapp = 0;
  4990. for(int32 i=0;i<packets.size();i++)
  4991. {
  4992. outapp = packets[i];
  4993. if(outapp)
  4994. client->QueuePacket(outapp);
  4995. }
  4996. client->GetPlayer()->ChangePrimaryWeapon();
  4997. client->GetPlayer()->ChangeSecondaryWeapon();
  4998. client->GetPlayer()->ChangeRangedWeapon();
  4999. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5000. client->QueuePacket(characterSheetPackets);
  5001. }
  5002. }
  5003. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5004. {
  5005. if (client->GetPlayer()->EngagedInCombat())
  5006. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5007. else {
  5008. int16 index = atoi(sep->arg[1]);
  5009. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5010. if (item) {
  5011. // client->GetPlayer()->item_list.DestroyItem(index);
  5012. if (item->item_sets.size() > 0) {
  5013. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5014. ItemSet* set = item->item_sets[i];
  5015. if (set->item_stack_size == 0)
  5016. set->item_stack_size += 1;
  5017. client->AddItem(set->item_id, set->item_stack_size);
  5018. }
  5019. }
  5020. }
  5021. client->RemoveItem(item, 1);
  5022. }
  5023. }
  5024. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5025. {
  5026. if(client->GetPlayer()->EngagedInCombat())
  5027. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5028. else
  5029. {
  5030. int16 index = atoi(sep->arg[1]);
  5031. sint32 bag_id = -999;
  5032. int8 to_slot = 255;
  5033. if(sep->arg[3][0])
  5034. {
  5035. if(sep->IsNumber(2))
  5036. bag_id = atol(sep->arg[2]);
  5037. if(sep->IsNumber(3))
  5038. to_slot = atoi(sep->arg[3]);
  5039. }
  5040. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  5041. EQ2Packet* outapp = 0;
  5042. for(int32 i=0;i<packets.size();i++)
  5043. {
  5044. outapp = packets[i];
  5045. if(outapp)
  5046. client->QueuePacket(outapp);
  5047. }
  5048. client->GetPlayer()->ChangePrimaryWeapon();
  5049. client->GetPlayer()->ChangeSecondaryWeapon();
  5050. client->GetPlayer()->ChangeRangedWeapon();
  5051. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5052. client->QueuePacket(characterSheetPackets);
  5053. }
  5054. }
  5055. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5056. {
  5057. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5058. int16 index1 = atoi(sep->arg[1]);
  5059. int16 index2 = atoi(sep->arg[2]);
  5060. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  5061. if(outapp)
  5062. client->QueuePacket(outapp);
  5063. else
  5064. {
  5065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5066. return;
  5067. }
  5068. }
  5069. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5070. {
  5071. sint16 to_slot = atoi(sep->arg[1]);
  5072. sint32 bag_id = atoi(sep->arg[2]);
  5073. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5074. if (item) {
  5075. //auto inventory
  5076. if (bag_id == 0 && to_slot == -1)
  5077. {
  5078. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5079. {
  5080. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5081. return;
  5082. }
  5083. // Set the slot for the item
  5084. item->details.inv_slot_id = bag_id;
  5085. item->details.slot_id = to_slot;
  5086. // Flag the item so it gets saved in its new location
  5087. item->save_needed = true;
  5088. // Add the item to its new location
  5089. player->item_list.AddItem(item);
  5090. // Remove the item from the overflow list
  5091. player->item_list.RemoveOverflowItem(item);
  5092. // Send the inventory update packet
  5093. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5094. return;
  5095. }
  5096. else if (bag_id == -3 && to_slot == -1) {
  5097. // Auto Bank
  5098. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5099. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5100. return;
  5101. }
  5102. item->details.inv_slot_id = bag_id;
  5103. item->details.slot_id = to_slot;
  5104. item->save_needed = true;
  5105. player->item_list.AddItem(item);
  5106. player->item_list.RemoveOverflowItem(item);
  5107. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5108. }
  5109. else if (bag_id == -4) {
  5110. // Shared Bank
  5111. if (!player->item_list.SharedBankAddAllowed(item)) {
  5112. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5113. return;
  5114. }
  5115. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5116. if (tmp_item) {
  5117. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5118. return;
  5119. }
  5120. else {
  5121. item->details.inv_slot_id = bag_id;
  5122. item->details.slot_id = to_slot;
  5123. item->save_needed = true;
  5124. player->item_list.AddItem(item);
  5125. player->item_list.RemoveOverflowItem(item);
  5126. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5127. return;
  5128. }
  5129. }
  5130. else {
  5131. // Try to get an item from the given bag id and slot id
  5132. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5133. // Check to see if we got an item, if we do send an error,
  5134. // if we don't put the overflow item into this slot
  5135. if (tmp_item) {
  5136. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5137. }
  5138. else {
  5139. item->details.inv_slot_id = bag_id;
  5140. item->details.slot_id = to_slot;
  5141. item->save_needed = true;
  5142. player->item_list.AddItem(item);
  5143. player->item_list.RemoveOverflowItem(item);
  5144. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5145. return;
  5146. }
  5147. }
  5148. }
  5149. }
  5150. }
  5151. else
  5152. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5153. }
  5154. /*
  5155. Function: Command_IRC()
  5156. Purpose : Handle the IRC functions
  5157. Params : IRC Commands
  5158. Dev : Scatman
  5159. Example : /irc say #Channel Hello World!
  5160. */
  5161. void Commands::Command_IRC(Client* client, Seperator* sep)
  5162. {
  5163. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5164. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5165. return;
  5166. }
  5167. if (sep && sep->arg[0][0]) {
  5168. if (strcasecmp(sep->arg[0], "say") == 0) {
  5169. if (sep->arg[1][0] && sep->arg[2][0]) {
  5170. if (sep->IsNumber(sep->arg[1]))
  5171. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5172. else
  5173. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5174. }
  5175. else
  5176. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5177. }
  5178. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5179. if (sep->arg[1][0])
  5180. irc.JoinChannel(client, sep->arg[1]);
  5181. else
  5182. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5183. }
  5184. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5185. if (sep->arg[1][0])
  5186. irc.LeaveChannel(client, sep->arg[1]);
  5187. else
  5188. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5189. }
  5190. else if (strcasecmp(sep->arg[0], "list") == 0)
  5191. irc.ListChannels(client);
  5192. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5193. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5194. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5195. else
  5196. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5197. }
  5198. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5199. irc.DisconnectFromServer(client);
  5200. else
  5201. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5202. }
  5203. else
  5204. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5205. }
  5206. /*
  5207. Function: Command_Languages()
  5208. Purpose : Show's languages the player knows
  5209. Params :
  5210. Dev : Zcoretri
  5211. Example :
  5212. */
  5213. void Commands::Command_Languages(Client* client, Seperator* sep)
  5214. {
  5215. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5216. list<Language*>::iterator itr;
  5217. Language* language;
  5218. client->Message(CHANNEL_COLOR_WHITE, "You know the following languages:");
  5219. for(itr = languages->begin(); itr != languages->end(); itr++)
  5220. {
  5221. language = *itr;
  5222. client->Message(CHANNEL_COLOR_WHITE, "%s", language->GetName());
  5223. }
  5224. }
  5225. /*
  5226. Function: Command_SetLanguage()
  5227. Purpose : Handles language commands
  5228. Params : Language ID
  5229. Dev : Zcoretri
  5230. Example :
  5231. */
  5232. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5233. {
  5234. Player* player = client->GetPlayer();
  5235. if (sep && sep->arg[0])
  5236. {
  5237. if(!sep->IsNumber(0))
  5238. {
  5239. //String passed in
  5240. const char* value = sep->arg[0];
  5241. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5242. {
  5243. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5244. client->SendLanguagesUpdate(0);
  5245. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", value);
  5246. }
  5247. else
  5248. {
  5249. if(player->HasLanguage(value))
  5250. {
  5251. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5252. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5253. client->SendLanguagesUpdate(language->GetID());
  5254. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5255. }
  5256. else
  5257. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", value);
  5258. }
  5259. }
  5260. else
  5261. {
  5262. //Number passed in
  5263. int32 id = atoul(sep->arg[0]);
  5264. if(player->HasLanguage(id))
  5265. {
  5266. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5267. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5268. client->SendLanguagesUpdate(id);
  5269. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5270. }
  5271. else
  5272. {
  5273. Language* language = master_languages_list.GetLanguage(id);
  5274. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", language->GetName());
  5275. }
  5276. }
  5277. }
  5278. else
  5279. {
  5280. //No value was passed in
  5281. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5282. if(id > 0)
  5283. {
  5284. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5285. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking %s ", language->GetName());
  5286. }
  5287. else
  5288. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking Common");
  5289. }
  5290. }
  5291. /*
  5292. Function: Command_LastName()
  5293. Purpose : Sets player surname
  5294. Params : Name text
  5295. Dev : theFoof
  5296. Example :
  5297. */
  5298. void Commands::Command_LastName(Client* client, Seperator* sep)
  5299. {
  5300. if (!client)
  5301. return;
  5302. if (sep && sep->arg[0])
  5303. {
  5304. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5305. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5306. return;
  5307. }
  5308. client->RemovePendingLastName();
  5309. uchar* checkname = (uchar*)sep->arg[0];
  5310. bool valid_name = true;
  5311. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5312. if (!alpha_check(checkname[i])) {
  5313. valid_name = false;
  5314. break;
  5315. }
  5316. }
  5317. if (!valid_name) {
  5318. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5319. return;
  5320. }
  5321. string last_name = (string)sep->arg[0];
  5322. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5323. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5324. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5325. client->SetPendingLastName(last_name);
  5326. client->SendLastNameConfirmation();
  5327. }
  5328. else
  5329. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5330. }
  5331. }
  5332. /*
  5333. Function: Command_ConfirmLastName()
  5334. Purpose : Confirms setting of player surname
  5335. Params : Name text
  5336. Dev : theFoof
  5337. Example :
  5338. */
  5339. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5340. {
  5341. if (!client)
  5342. return;
  5343. string* name = client->GetPendingLastName();
  5344. if (name){
  5345. Player* player = client->GetPlayer();
  5346. player->SetLastName(name->c_str(), false);
  5347. client->SendTitleUpdate();
  5348. player->SetCharSheetChanged(true);
  5349. client->RemovePendingLastName();
  5350. }
  5351. }
  5352. /*
  5353. Function: Command_Location()
  5354. Purpose : Display's Help for /location commands
  5355. Params :
  5356. Dev : Scatman
  5357. Example : /location = show's help for command
  5358. */
  5359. void Commands::Command_Location(Client* client)
  5360. {
  5361. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5362. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5363. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5364. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5365. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5366. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5367. }
  5368. /*
  5369. Function: Command_LocationAdd()
  5370. Purpose : Add's a location to an existing location config
  5371. Params : location_id
  5372. Dev : Scatman
  5373. Example : /location add {location_id}
  5374. */
  5375. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5376. {
  5377. if (sep && sep->arg[0] && sep->IsNumber(0))
  5378. {
  5379. int32 location_id = atoul(sep->arg[0]);
  5380. float x = client->GetPlayer()->GetX();
  5381. float y = client->GetPlayer()->GetY();
  5382. float z = client->GetPlayer()->GetZ();
  5383. if (database.AddLocationPoint(location_id, x, y, z))
  5384. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5385. else
  5386. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5387. }
  5388. else
  5389. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5390. }
  5391. /*
  5392. Function: Command_LocationCreate()
  5393. Purpose : Creates a new location config
  5394. Params : location name, 0/1 for include_y (optional)
  5395. Dev : Scatman
  5396. Example : /location create Test 1 = creates a new location named Test with include_y True
  5397. */
  5398. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5399. {
  5400. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5401. {
  5402. const char* name = sep->arg[0];
  5403. bool include_y = false;
  5404. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5405. include_y = true;
  5406. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5407. if (location_id > 0)
  5408. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5409. else
  5410. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5411. }
  5412. else
  5413. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5414. }
  5415. /*
  5416. Function: Command_LocationDelete()
  5417. Purpose : Delete's a location config and all it's location points
  5418. Params : location_id
  5419. Dev : Scatman
  5420. Example : /location delete {location_id}
  5421. */
  5422. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5423. {
  5424. if (sep && sep->arg[0] && sep->IsNumber(0))
  5425. {
  5426. int32 location_id = atoul(sep->arg[0]);
  5427. if (database.DeleteLocation(location_id))
  5428. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5429. else
  5430. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5431. }
  5432. else
  5433. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5434. }
  5435. /*
  5436. Function: Command_LocationList()
  5437. Purpose : Display's a list of location points
  5438. Params : location_id
  5439. Dev : Scatman
  5440. Example : /location list {location_id}
  5441. */
  5442. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5443. {
  5444. if (sep && sep->arg[0])
  5445. {
  5446. const char* option = sep->arg[0];
  5447. if (strncmp(option, "locations", strlen(option)) == 0)
  5448. database.ListLocations(client);
  5449. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5450. {
  5451. int32 location_id = atoul(sep->arg[1]);
  5452. database.ListLocationPoints(client, location_id);
  5453. }
  5454. else
  5455. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5456. }
  5457. else
  5458. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5459. }
  5460. /*
  5461. Function: Command_LocationRemove()
  5462. Purpose : Removes a single location point from a location config
  5463. Params : location_point_id (gotten from /location list {id})
  5464. Dev : Scatman
  5465. Example : /location remove 1 = will remove location_point_id 1
  5466. */
  5467. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5468. {
  5469. if (sep && sep->arg[0] && sep->IsNumber(0))
  5470. {
  5471. int32 location_point_id = atoul(sep->arg[0]);
  5472. if (database.DeleteLocationPoint(location_point_id))
  5473. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5474. else
  5475. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5476. }
  5477. else
  5478. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5479. }
  5480. /*
  5481. Function: Command_Merchant()
  5482. Purpose : Handles Merchant commands
  5483. Params : list
  5484. Dev : Scatman
  5485. Example : /merchant list
  5486. */
  5487. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5488. {
  5489. if( handler == COMMAND_MERCHANT )
  5490. {
  5491. // /merchant command by itself shows help (to be extended)
  5492. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5493. return;
  5494. }
  5495. else if( handler == COMMAND_MERCHANT_LIST )
  5496. {
  5497. // /merchant list command expects "description" param
  5498. if (sep && sep->arg[0])
  5499. {
  5500. const char* merchant_description = sep->argplus[0];
  5501. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5502. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5503. map<int32, MerchantInfo*>::iterator itr;
  5504. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5505. {
  5506. string description = database.GetMerchantDescription(itr->first);
  5507. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5508. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5509. }
  5510. }
  5511. else // no description
  5512. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5513. }
  5514. }
  5515. /*
  5516. Function: Command_Modify()
  5517. Purpose : to replace our other "set" commands
  5518. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5519. Dev : John Adams
  5520. Example : /modify spell set name "Aegolism III"
  5521. */
  5522. void Commands::Command_Modify(Client* client)
  5523. {
  5524. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5525. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5526. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5527. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5528. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5529. }
  5530. /*
  5531. Function: Command_ModifySpawn()
  5532. Purpose : replace "spawn set" commands
  5533. Params : Action : the action to perform (or special handler)
  5534. : Field : the DB field to change
  5535. : Value : what to set the value to
  5536. : Target : what object to change (my target, or spawn_id)
  5537. Dev : John Adams
  5538. Example : /modify spawn set name "Lady Vox"
  5539. :
  5540. Note : Special Handlers, like "zoneto" for Signs
  5541. : /modify spawn zoneto
  5542. : Will set a sign's zone x/y/z to my current coords
  5543. */
  5544. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5545. {
  5546. PrintSep(sep, "COMMAND_MODIFY");
  5547. // need at least 2 args for a valid command
  5548. if( sep && sep->arg[1] )
  5549. {
  5550. // JA: just a quick implementation because I need it :)
  5551. if (strcmp(sep->arg[0], "zoneto") == 0)
  5552. {
  5553. if( sep->IsNumber(1) )
  5554. {
  5555. int32 spawn_id = atoul(sep->arg[1]);
  5556. float x_coord = client->GetPlayer()->GetX();
  5557. float y_coord = client->GetPlayer()->GetY();
  5558. float z_coord = client->GetPlayer()->GetZ();
  5559. float h_coord = client->GetPlayer()->GetHeading();
  5560. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5561. }
  5562. else
  5563. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5564. }
  5565. }
  5566. else
  5567. Command_Modify(client);
  5568. }
  5569. /*
  5570. Function: Command_ModifyCharacter()
  5571. Purpose : to replace our other "set" commands
  5572. Params : Action : Add, Remove
  5573. : Field : copper, silver, gold, plat
  5574. : Value : min 1, max unlimited
  5575. : Target : Self, Player
  5576. Dev : Cynnar
  5577. Example : /modify character add gold 50
  5578. : /modify character remove silver 25
  5579. */
  5580. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5581. {
  5582. PrintSep(sep, "COMMAND_MODIFY");
  5583. int64 value = 0;
  5584. Player* player = client->GetPlayer();
  5585. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5586. player = (Player*)player->GetTarget();
  5587. // need at least 2 args for a valid command
  5588. if( sep && sep->arg[1] )
  5589. {
  5590. if (strcmp(sep->arg[0], "add") == 0)
  5591. {
  5592. if (strcmp(sep->arg[1], "copper") == 0)
  5593. {
  5594. value = atoi64(sep->arg[2]);
  5595. player->AddCoins(value);
  5596. if (client->GetPlayer() == player)
  5597. {
  5598. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5599. }
  5600. else {
  5601. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5602. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5603. }
  5604. }
  5605. else if (strcmp(sep->arg[1], "silver") == 0)
  5606. {
  5607. value = atoi64(sep->arg[2]) * 100;
  5608. player->AddCoins(value);
  5609. if (client->GetPlayer() == player)
  5610. {
  5611. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5612. }
  5613. else {
  5614. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5615. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5616. }
  5617. }
  5618. else if (strcmp(sep->arg[1], "gold") == 0)
  5619. {
  5620. value = atoi64(sep->arg[2]) * 10000;
  5621. player->AddCoins(value);
  5622. if (client->GetPlayer() == player)
  5623. {
  5624. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5625. }
  5626. else {
  5627. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5628. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5629. }
  5630. }
  5631. else if (strcmp(sep->arg[1], "plat") == 0)
  5632. {
  5633. value = atoi64(sep->arg[2]) * 1000000;
  5634. player->AddCoins(value);
  5635. if (client->GetPlayer() == player)
  5636. {
  5637. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5638. }
  5639. else {
  5640. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5641. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5642. }
  5643. }
  5644. else
  5645. {
  5646. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5647. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5648. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5649. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5650. }
  5651. }
  5652. else if (strcmp(sep->arg[0], "remove") == 0)
  5653. {
  5654. if (strcmp(sep->arg[1], "copper") == 0)
  5655. {
  5656. value = atoi64(sep->arg[2]);
  5657. player->RemoveCoins(value);
  5658. if (client->GetPlayer() == player)
  5659. {
  5660. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5661. }
  5662. else {
  5663. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5664. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5665. }
  5666. }
  5667. else if (strcmp(sep->arg[1], "silver") == 0)
  5668. {
  5669. value = atoi64(sep->arg[2]) * 100;
  5670. player->RemoveCoins(value);
  5671. if (client->GetPlayer() == player)
  5672. {
  5673. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5674. }
  5675. else {
  5676. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5677. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5678. }
  5679. }
  5680. else if (strcmp(sep->arg[1], "gold") == 0)
  5681. {
  5682. value = atoi64(sep->arg[2]) * 10000;
  5683. player->RemoveCoins(value);
  5684. if (client->GetPlayer() == player)
  5685. {
  5686. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  5687. }
  5688. else {
  5689. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  5690. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5691. }
  5692. }
  5693. else if (strcmp(sep->arg[1], "plat") == 0)
  5694. {
  5695. value = atoi64(sep->arg[2]) * 1000000;
  5696. player->RemoveCoins(value);
  5697. if (client->GetPlayer() == player)
  5698. {
  5699. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  5700. }
  5701. else {
  5702. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  5703. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5704. }
  5705. }
  5706. else
  5707. {
  5708. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5709. }
  5710. }
  5711. else if (strcmp(sep->arg[0], "set") == 0) {
  5712. if (strcmp(sep->arg[1], "tslevel") == 0) {
  5713. int8 level = atoi(sep->arg[2]);
  5714. if (level > 0 && level < 256) {
  5715. if (player) {
  5716. if (client->GetPlayer() == player)
  5717. client->ChangeTSLevel(player->GetTSLevel(), level);
  5718. else
  5719. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  5720. }
  5721. }
  5722. else
  5723. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  5724. }
  5725. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  5726. int8 tsclass = atoi(sep->arg[2]);
  5727. player->SetTradeskillClass(tsclass);
  5728. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  5729. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  5730. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  5731. player->SetCharSheetChanged(true);
  5732. }
  5733. }
  5734. }
  5735. else
  5736. {
  5737. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5738. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5739. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5740. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5741. }
  5742. }
  5743. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  5744. {
  5745. PrintSep(sep, "COMMAND_MODIFY");
  5746. // need at least 2 args for a valid command
  5747. if( sep && sep->arg[1] )
  5748. {
  5749. }
  5750. else
  5751. Command_Modify(client);
  5752. }
  5753. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  5754. {
  5755. PrintSep(sep, "COMMAND_MODIFY");
  5756. // need at least 2 args for a valid command
  5757. if( sep && sep->arg[1] )
  5758. {
  5759. }
  5760. else
  5761. Command_Modify(client);
  5762. }
  5763. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  5764. {
  5765. PrintSep(sep, "COMMAND_MODIFY");
  5766. // need at least 2 args for a valid command
  5767. if( sep && sep->arg[1] )
  5768. {
  5769. }
  5770. else
  5771. Command_Modify(client);
  5772. }
  5773. /*
  5774. Function: Command_ModifyQuest()
  5775. Purpose : to list players quest and completed quests
  5776. Params : Action : list, completed
  5777. : Target : Self, Player
  5778. Dev : Cynnar
  5779. Example : /modify quest list
  5780. : /modify quest completed
  5781. */
  5782. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  5783. {
  5784. PrintSep(sep, "COMMAND_MODIFY");
  5785. int64 value = 0;
  5786. Player* player = client->GetPlayer();
  5787. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5788. player = (Player*)player->GetTarget();
  5789. // need at least 2 args for a valid command
  5790. if (sep && sep->arg[1])
  5791. {
  5792. if (strcmp(sep->arg[0], "list") == 0)
  5793. {
  5794. map<int32, Quest*>* quests = player->GetPlayerQuests();
  5795. map<int32, Quest*>::iterator itr;
  5796. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  5797. if (quests->size() == 0)
  5798. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  5799. else
  5800. {
  5801. for (itr = quests->begin(); itr != quests->end(); itr++)
  5802. {
  5803. Quest* quest = itr->second;
  5804. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5805. }
  5806. }
  5807. }
  5808. else if (strcmp(sep->arg[0], "completed") == 0)
  5809. {
  5810. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  5811. map<int32, Quest*>::iterator itr;
  5812. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  5813. if (quests->size() == 0)
  5814. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  5815. else
  5816. {
  5817. for (itr = quests->begin(); itr != quests->end(); itr++)
  5818. {
  5819. Quest* quest = itr->second;
  5820. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5821. }
  5822. }
  5823. }
  5824. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  5825. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  5826. else if (strcmp(sep->arg[0], "remove") == 0)
  5827. {
  5828. int32 quest_id = 0;
  5829. if (sep && sep->arg[1] && sep->IsNumber(1))
  5830. quest_id = atoul(sep->arg[1]);
  5831. if (quest_id > 0)
  5832. {
  5833. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  5834. {
  5835. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5836. if (quest)
  5837. if (client->GetPlayer() == player)
  5838. {
  5839. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  5840. }
  5841. else
  5842. {
  5843. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  5844. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  5845. }
  5846. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  5847. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  5848. }
  5849. client->RemovePlayerQuest(quest_id);
  5850. client->GetCurrentZone()->SendQuestUpdates(client);
  5851. }
  5852. }
  5853. else if (strcmp(sep->arg[0], "advance") == 0)
  5854. {
  5855. int32 quest_id = 0;
  5856. int32 step = 0;
  5857. if (sep && sep->arg[1] && sep->IsNumber(1))
  5858. {
  5859. quest_id = atoul(sep->arg[1]);
  5860. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5861. if (sep && sep->arg[2] && sep->IsNumber(1))
  5862. {
  5863. step = atoul(sep->arg[2]);
  5864. if (quest_id > 0 && step > 0)
  5865. {
  5866. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  5867. {
  5868. if (client)
  5869. {
  5870. client->AddPendingQuestUpdate(quest_id, step);
  5871. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  5872. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  5873. }
  5874. }
  5875. }
  5876. else
  5877. {
  5878. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  5879. }
  5880. }
  5881. else
  5882. {
  5883. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  5884. }
  5885. }
  5886. else
  5887. {
  5888. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  5889. }
  5890. }
  5891. else
  5892. {
  5893. Command_Modify(client);
  5894. }
  5895. }
  5896. else
  5897. {
  5898. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  5899. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  5900. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  5901. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  5902. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  5903. }
  5904. }
  5905. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  5906. {
  5907. PrintSep(sep, "COMMAND_MODIFY");
  5908. // need at least 2 args for a valid command
  5909. if( sep && sep->arg[1] )
  5910. {
  5911. if (strcmp(sep->arg[0], "add") == 0) {
  5912. const char* skill_name = sep->argplus[1];
  5913. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5914. if (skill) {
  5915. Player* player = 0;
  5916. Client* to_client = 0;
  5917. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5918. player = (Player*)client->GetPlayer()->GetTarget();
  5919. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5920. }
  5921. else {
  5922. player = client->GetPlayer();
  5923. to_client = client;
  5924. }
  5925. if (player)
  5926. {
  5927. if (!player->GetSkills()->HasSkill(skill->skill_id))
  5928. {
  5929. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  5930. if (to_client == client) {
  5931. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  5932. }
  5933. else {
  5934. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  5935. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  5936. }
  5937. }
  5938. else
  5939. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  5940. }
  5941. }
  5942. else
  5943. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5944. }
  5945. else if (strcmp(sep->arg[0], "remove") == 0) {
  5946. const char* skill_name = sep->argplus[1];
  5947. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5948. if (skill) {
  5949. Player* player = 0;
  5950. Client* to_client = 0;
  5951. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5952. player = (Player*)client->GetPlayer()->GetTarget();
  5953. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5954. }
  5955. else {
  5956. player = client->GetPlayer();
  5957. to_client = client;
  5958. }
  5959. if (player)
  5960. {
  5961. if (player->GetSkills()->HasSkill(skill->skill_id))
  5962. {
  5963. player->RemoveSkillFromDB(skill, true);
  5964. if (client == to_client) {
  5965. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  5966. }
  5967. else {
  5968. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  5969. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  5970. }
  5971. }
  5972. else {
  5973. if (client == to_client)
  5974. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  5975. else
  5976. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  5977. }
  5978. }
  5979. }
  5980. else
  5981. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5982. }
  5983. else if (strcmp(sep->arg[0], "set") == 0) {
  5984. if (!sep->IsNumber(2)) {
  5985. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  5986. return;
  5987. }
  5988. const char* skill_name = sep->arg[1];
  5989. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5990. if (skill) {
  5991. int16 val = atoi(sep->arg[2]);
  5992. Player* player = 0;
  5993. Client* to_client = 0;
  5994. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5995. player = (Player*)client->GetPlayer()->GetTarget();
  5996. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5997. }
  5998. else {
  5999. player = client->GetPlayer();
  6000. to_client = client;
  6001. }
  6002. if (player)
  6003. {
  6004. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6005. player->GetSkills()->SetSkill(skill->skill_id, val);
  6006. if (client != to_client)
  6007. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6008. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6009. }
  6010. else {
  6011. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6012. }
  6013. }
  6014. }
  6015. else {
  6016. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6017. }
  6018. }
  6019. else {
  6020. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6021. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6022. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6023. }
  6024. }
  6025. else {
  6026. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6027. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6028. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6029. }
  6030. }
  6031. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6032. {
  6033. PrintSep(sep, "COMMAND_MODIFY");
  6034. // need at least 2 args for a valid command
  6035. if( sep && sep->arg[1] )
  6036. {
  6037. }
  6038. else
  6039. Command_Modify(client);
  6040. }
  6041. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6042. {
  6043. PrintSep(sep, "COMMAND_MODIFY");
  6044. // need at least 2 args for a valid command
  6045. if( sep && sep->arg[1] )
  6046. {
  6047. }
  6048. else
  6049. Command_Modify(client);
  6050. }
  6051. /*
  6052. Function: Command_MOTD()
  6053. Purpose : Displays server MOTD
  6054. Params :
  6055. Dev : LethalEncounter
  6056. Example : /motd
  6057. */
  6058. void Commands::Command_MOTD(Client* client)
  6059. {
  6060. if (client)
  6061. ClientPacketFunctions::SendMOTD(client);
  6062. }
  6063. /*
  6064. Function: Command_Pet()
  6065. Purpose : Handle Pet {Command} commands
  6066. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6067. Dev :
  6068. Example : /pet preserve_master
  6069. */
  6070. void Commands::Command_Pet(Client* client, Seperator* sep)
  6071. {
  6072. PrintSep(sep, "COMMAND_PET");
  6073. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6074. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6075. if (strcmp(sep->arg[0], "hide") == 0) {
  6076. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6077. Entity* pet = client->GetPlayer()->GetDeityPet();
  6078. if (pet) {
  6079. if (pet->IsPrivateSpawn())
  6080. client->GetPlayer()->HideDeityPet(false);
  6081. else
  6082. client->GetPlayer()->HideDeityPet(true);
  6083. }
  6084. pet = client->GetPlayer()->GetCosmeticPet();
  6085. if (pet) {
  6086. if (pet->IsPrivateSpawn())
  6087. client->GetPlayer()->HideCosmeticPet(false);
  6088. else
  6089. client->GetPlayer()->HideCosmeticPet(true);
  6090. }
  6091. return;
  6092. }
  6093. // below is for all combat pets
  6094. if (!client->GetPlayer()->HasPet()) {
  6095. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6096. return;
  6097. }
  6098. if (strcmp(sep->arg[0], "stay") == 0) {
  6099. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6100. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  6101. client->GetPlayer()->SetCharSheetChanged(true);
  6102. if (client->GetPlayer()->GetPet())
  6103. client->GetPlayer()->GetPet()->following = false;
  6104. if (client->GetPlayer()->GetCharmedPet())
  6105. client->GetPlayer()->GetCharmedPet()->following = false;
  6106. }
  6107. else if (strcmp(sep->arg[0], "follow") == 0) {
  6108. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6109. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  6110. client->GetPlayer()->SetCharSheetChanged(true);
  6111. }
  6112. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6113. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  6114. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6115. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  6116. }
  6117. else {
  6118. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6119. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  6120. }
  6121. client->GetPlayer()->SetCharSheetChanged(true);
  6122. }
  6123. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6124. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  6125. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6126. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  6127. }
  6128. else {
  6129. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6130. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  6131. }
  6132. client->GetPlayer()->SetCharSheetChanged(true);
  6133. }
  6134. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6135. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6136. if (client->GetPlayer()->GetPet())
  6137. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6138. if (client->GetPlayer()->GetCharmedPet())
  6139. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6140. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  6141. client->GetPlayer()->SetCharSheetChanged(true);
  6142. }
  6143. else if (strcmp(sep->arg[0], "attack") == 0) {
  6144. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6145. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6146. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6147. if (client->GetPlayer()->GetPet())
  6148. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6149. if (client->GetPlayer()->GetCharmedPet())
  6150. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6151. }
  6152. else
  6153. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6154. }
  6155. else
  6156. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6157. }
  6158. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6159. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6160. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6161. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6162. }
  6163. else
  6164. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6165. }
  6166. /*
  6167. Function: Command_PetName()
  6168. Purpose : Pet your name (???)
  6169. Params :
  6170. Dev :
  6171. Example :
  6172. */
  6173. void Commands::Command_PetName(Client* client, Seperator* sep)
  6174. {
  6175. PrintSep(sep, "COMMAND_PETNAME");
  6176. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6177. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6178. }
  6179. /*
  6180. Function: Command_NamePet()
  6181. Purpose : Name your pet
  6182. Params :
  6183. Dev :
  6184. Example :
  6185. */
  6186. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6187. {
  6188. PrintSep(sep, "COMMAND_NAME_PET");
  6189. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6190. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6191. }
  6192. /*
  6193. Function: Command_Rename()
  6194. Purpose : Renames existing pet
  6195. Params :
  6196. Dev :
  6197. Example :
  6198. */
  6199. void Commands::Command_Rename(Client* client, Seperator* sep)
  6200. {
  6201. PrintSep(sep, "COMMAND_RENAME");
  6202. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6203. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6204. }
  6205. /*
  6206. Function: Command_ConfirmRename()
  6207. Purpose : Confirms renaming your pet
  6208. Params :
  6209. Dev :
  6210. Example :
  6211. */
  6212. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6213. {
  6214. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6215. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6216. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6217. }
  6218. /*
  6219. Function: Command_PetOptions()
  6220. Purpose : Sets various pet options
  6221. Params :
  6222. Dev :
  6223. Example :
  6224. */
  6225. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6226. {
  6227. PrintSep(sep, "COMMAND_PETOPTIONS");
  6228. Player* player = client->GetPlayer();
  6229. Spawn* target = player->GetTarget();
  6230. if (!target)
  6231. return;
  6232. if (target == player->GetPet())
  6233. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6234. else if (target == player->GetCharmedPet())
  6235. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6236. else if (target == player->GetCosmeticPet())
  6237. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6238. else if (target == player->GetDeityPet())
  6239. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6240. }
  6241. /*
  6242. Function: Command_Random()
  6243. Purpose : Handles /random dice roll in-game
  6244. Params : 1-100
  6245. Dev : Scatman
  6246. Example : /randon 1 100
  6247. */
  6248. void Commands::Command_Random(Client* client, Seperator* sep)
  6249. {
  6250. char message[256] = {0};
  6251. if (sep)
  6252. {
  6253. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6254. 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])));
  6255. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6256. 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])));
  6257. else
  6258. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6259. }
  6260. else
  6261. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6262. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6263. }
  6264. /*
  6265. Function: Command_Randomize()
  6266. Purpose : Sets randomize (appearance) values for NPCs
  6267. Params : Attrib Name
  6268. Dev : Scatman
  6269. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6270. */
  6271. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6272. {
  6273. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6274. if (target)
  6275. {
  6276. if (target->IsNPC())
  6277. {
  6278. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6279. {
  6280. const char* value = sep->arg[0];
  6281. if (strncasecmp(value, "show", strlen(value)) == 0)
  6282. {
  6283. client->DisplayRandomizeFeatures(target->GetRandomize());
  6284. }
  6285. else
  6286. {
  6287. if (sep->arg[1] && sep->IsNumber(1))
  6288. {
  6289. int8 option = atoi(sep->arg[1]);
  6290. if (option == 0 || option == 1)
  6291. {
  6292. int32 feature = 0;
  6293. char feature_text[32] = {0};
  6294. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6295. feature = RANDOMIZE_GENDER;
  6296. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6297. }
  6298. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6299. feature = RANDOMIZE_RACE;
  6300. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6301. }
  6302. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6303. feature = RANDOMIZE_MODEL_TYPE;
  6304. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6305. }
  6306. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6307. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6308. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6309. }
  6310. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6311. feature = RANDOMIZE_HAIR_TYPE;
  6312. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6313. }
  6314. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6315. feature = RANDOMIZE_WING_TYPE;
  6316. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6317. }
  6318. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6319. feature = RANDOMIZE_CHEEK_TYPE;
  6320. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6321. }
  6322. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6323. feature = RANDOMIZE_CHIN_TYPE;
  6324. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6325. }
  6326. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6327. feature = RANDOMIZE_EAR_TYPE;
  6328. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6329. }
  6330. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6331. feature = RANDOMIZE_EYE_BROW_TYPE;
  6332. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6333. }
  6334. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6335. feature = RANDOMIZE_EYE_TYPE;
  6336. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6337. }
  6338. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6339. feature = RANDOMIZE_LIP_TYPE;
  6340. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6341. }
  6342. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6343. feature = RANDOMIZE_NOSE_TYPE;
  6344. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6345. }
  6346. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6347. feature = RANDOMIZE_EYE_COLOR;
  6348. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6349. }
  6350. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6351. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6352. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6353. }
  6354. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6355. feature = RANDOMIZE_HAIR_COLOR1;
  6356. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6357. }
  6358. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6359. feature = RANDOMIZE_HAIR_COLOR2;
  6360. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6361. }
  6362. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6363. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6364. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6365. }
  6366. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6367. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6368. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6369. }
  6370. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6371. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6372. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6373. }
  6374. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6375. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6376. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6377. }
  6378. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6379. feature = RANDOMIZE_SKIN_COLOR;
  6380. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6381. }
  6382. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6383. feature = RANDOMIZE_WING_COLOR1;
  6384. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6385. }
  6386. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6387. feature = RANDOMIZE_WING_COLOR2;
  6388. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6389. }
  6390. else {
  6391. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6392. 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'.");
  6393. }
  6394. if (feature > 0) {
  6395. if (option == 1) {
  6396. if (target->GetRandomize() & feature)
  6397. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6398. else {
  6399. target->AddRandomize(feature);
  6400. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6401. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6402. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6403. }
  6404. }
  6405. else {
  6406. if (target->GetRandomize() & feature) {
  6407. target->AddRandomize(-feature);
  6408. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6409. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6410. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6411. }
  6412. else
  6413. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6414. }
  6415. }
  6416. }
  6417. else
  6418. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6419. }
  6420. else
  6421. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6422. }
  6423. }
  6424. else {
  6425. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6426. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6427. 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'.");
  6428. }
  6429. }
  6430. else
  6431. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6432. }
  6433. else
  6434. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6435. }
  6436. /*
  6437. Function: Command_ShowCloak()
  6438. Purpose : Character Settings combo box for Show Cloak
  6439. Params : true/false
  6440. Dev : John Adams
  6441. Example :
  6442. */
  6443. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6444. {
  6445. Player* player = client->GetPlayer();
  6446. if (sep && sep->arg[0])
  6447. {
  6448. const char* value = sep->arg[0];
  6449. if (strncasecmp(value, "true", strlen(value)) == 0)
  6450. {
  6451. player->set_character_flag(CF_SHOW_CLOAK);
  6452. player->reset_character_flag(CF2_SHOW_RANGED);
  6453. }
  6454. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6455. player->reset_character_flag(CF_SHOW_CLOAK);
  6456. else
  6457. {
  6458. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6459. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6460. }
  6461. }
  6462. }
  6463. /*
  6464. Function: Command_ShowHelm()
  6465. Purpose : Character Settings combo box for Show Helm
  6466. Params : true/false
  6467. Dev : John Adams
  6468. Example :
  6469. */
  6470. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6471. {
  6472. Player* player = client->GetPlayer();
  6473. if (sep && sep->arg[0])
  6474. {
  6475. const char* value = sep->arg[0];
  6476. if (strncasecmp(value, "true", strlen(value)) == 0)
  6477. {
  6478. player->reset_character_flag(CF_HIDE_HELM);
  6479. player->set_character_flag(CF_HIDE_HOOD);
  6480. }
  6481. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6482. player->set_character_flag(CF_HIDE_HELM);
  6483. else
  6484. {
  6485. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6486. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6487. }
  6488. }
  6489. }
  6490. /*
  6491. Function: Command_ShowHood()
  6492. Purpose : Character Settings combo box for Show Hood
  6493. Params : true/false
  6494. Dev : John Adams
  6495. Example :
  6496. */
  6497. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6498. {
  6499. Player* player = client->GetPlayer();
  6500. if (sep && sep->arg[0])
  6501. {
  6502. const char* value = sep->arg[0];
  6503. if (strncasecmp(value, "true", strlen(value)) == 0)
  6504. {
  6505. player->reset_character_flag(CF_HIDE_HOOD);
  6506. player->set_character_flag(CF_HIDE_HELM);
  6507. }
  6508. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6509. player->set_character_flag(CF_HIDE_HOOD);
  6510. else
  6511. {
  6512. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6513. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6514. }
  6515. }
  6516. }
  6517. /*
  6518. Function: Command_ShowHoodHelm()
  6519. Purpose : Character Settings combo box for Show Helm or Hood
  6520. Params : true/false
  6521. Dev : John Adams
  6522. Example :
  6523. */
  6524. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6525. {
  6526. Player* player = client->GetPlayer();
  6527. if (sep && sep->arg[0])
  6528. {
  6529. const char* value = sep->arg[0];
  6530. if (strncasecmp(value, "true", strlen(value)) == 0)
  6531. {
  6532. player->reset_character_flag(CF_HIDE_HOOD);
  6533. player->reset_character_flag(CF_HIDE_HELM);
  6534. }
  6535. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6536. {
  6537. // don't think we ever wind up in here...
  6538. player->set_character_flag(CF_HIDE_HOOD);
  6539. player->set_character_flag(CF_HIDE_HELM);
  6540. }
  6541. else
  6542. {
  6543. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6544. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6545. }
  6546. }
  6547. }
  6548. /*
  6549. Function: Command_ShowRanged()
  6550. Purpose : Character Settings combo box for Show Ranged weapon
  6551. Params : true/false
  6552. Dev : John Adams
  6553. Example :
  6554. */
  6555. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6556. {
  6557. Player* player = client->GetPlayer();
  6558. if (sep && sep->arg[0])
  6559. {
  6560. const char* value = sep->arg[0];
  6561. if (strncasecmp(value, "true", strlen(value)) == 0)
  6562. {
  6563. player->set_character_flag(CF2_SHOW_RANGED);
  6564. player->reset_character_flag(CF_SHOW_CLOAK);
  6565. }
  6566. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6567. player->reset_character_flag(CF2_SHOW_RANGED);
  6568. else
  6569. {
  6570. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6571. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6572. }
  6573. }
  6574. }
  6575. /*
  6576. Function:
  6577. Purpose :
  6578. Params :
  6579. Dev :
  6580. Example :
  6581. */
  6582. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6583. {
  6584. Player* player = 0;
  6585. Client* to_client = 0;
  6586. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6587. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6588. switch(handler)
  6589. {
  6590. case COMMAND_SKILL:
  6591. {
  6592. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6593. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6594. break;
  6595. }
  6596. case COMMAND_SKILL_ADD:
  6597. {
  6598. if (sep && sep->arg[0])
  6599. {
  6600. const char* skill_name = sep->argplus[0];
  6601. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6602. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6603. {
  6604. player = to_client->GetPlayer();
  6605. if (player)
  6606. {
  6607. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6608. {
  6609. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6610. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6611. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6612. }
  6613. else
  6614. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6615. }
  6616. }
  6617. else if (skill) // add skill to yourself
  6618. {
  6619. player = client->GetPlayer();
  6620. if (player)
  6621. {
  6622. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6623. {
  6624. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6625. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6626. }
  6627. else
  6628. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6629. }
  6630. }
  6631. else
  6632. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6633. }
  6634. else
  6635. {
  6636. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6637. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6638. }
  6639. break;
  6640. }
  6641. case COMMAND_SKILL_REMOVE:
  6642. {
  6643. if (sep && sep->arg[0])
  6644. {
  6645. const char* skill_name = sep->argplus[0];
  6646. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6647. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6648. {
  6649. player = to_client->GetPlayer();
  6650. if (player)
  6651. {
  6652. if (player->GetSkills()->HasSkill(skill->skill_id))
  6653. {
  6654. player->RemoveSkillFromDB(skill, true);
  6655. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6656. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6657. }
  6658. else
  6659. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6660. }
  6661. }
  6662. else if(skill) // remove skill from yourself
  6663. {
  6664. Player* player = client->GetPlayer();
  6665. if (player)
  6666. {
  6667. if (player->GetSkills()->HasSkill(skill->skill_id))
  6668. {
  6669. player->RemoveSkillFromDB(skill, true);
  6670. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6671. }
  6672. else
  6673. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6674. }
  6675. }
  6676. else
  6677. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6678. }
  6679. else
  6680. {
  6681. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  6682. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6683. }
  6684. break;
  6685. }
  6686. case COMMAND_SKILL_LIST:
  6687. {
  6688. if (sep && sep->arg[0])
  6689. {
  6690. const char* skill_name = sep->argplus[0];
  6691. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  6692. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  6693. map<int32, Skill*>::iterator itr;
  6694. if (skills && skills->size() > 0)
  6695. {
  6696. for (itr = skills->begin(); itr != skills->end(); itr++)
  6697. {
  6698. Skill* skill = itr->second;
  6699. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  6700. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  6701. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  6702. }
  6703. }
  6704. }
  6705. else
  6706. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  6707. break;
  6708. }
  6709. }
  6710. }
  6711. /*
  6712. Function: Command_SpawnTemplate()
  6713. Purpose : Create or Use defined Spawn Templates
  6714. Params : create, save, rempve, list
  6715. Dev : John Adams
  6716. Example : /spawn template create "Test"
  6717. */
  6718. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  6719. {
  6720. if (sep == NULL || sep->arg[0] == NULL)
  6721. {
  6722. 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.");
  6723. return;
  6724. }
  6725. // got params, continue
  6726. const char * template_cmd = sep->arg[0];
  6727. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  6728. {
  6729. if (!sep->IsSet(1))
  6730. {
  6731. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  6732. 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.");
  6733. return;
  6734. }
  6735. map<int32, string>* template_names = 0;
  6736. if (sep->IsNumber(1))
  6737. {
  6738. int32 location_id = 0;
  6739. location_id = atoi(sep->arg[1]);
  6740. template_names = database.GetSpawnTemplateListByID(location_id);
  6741. }
  6742. else
  6743. {
  6744. const char* name = 0;
  6745. name = sep->argplus[1];
  6746. template_names = database.GetSpawnTemplateListByName(name);
  6747. }
  6748. if(!template_names)
  6749. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  6750. else
  6751. {
  6752. map<int32, string>::iterator itr;
  6753. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  6754. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  6755. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  6756. safe_delete(template_names);
  6757. }
  6758. }
  6759. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  6760. {
  6761. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6762. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  6763. {
  6764. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  6765. {
  6766. // first, lookup to see if template name already exists
  6767. const char* name = 0;
  6768. name = sep->argplus[1];
  6769. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  6770. if(!template_names)
  6771. {
  6772. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  6773. if( new_template_id > 0 )
  6774. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  6775. else
  6776. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  6777. }
  6778. else
  6779. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  6780. }
  6781. else
  6782. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  6783. }
  6784. else
  6785. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  6786. }
  6787. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  6788. {
  6789. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  6790. {
  6791. int32 template_id = 0;
  6792. template_id = atoi(sep->arg[1]);
  6793. if (database.RemoveSpawnTemplate(template_id))
  6794. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  6795. else
  6796. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  6797. }
  6798. else
  6799. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  6800. }
  6801. // Renamed create to spawn
  6802. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  6803. {
  6804. if (sep && sep->arg[1][0])
  6805. {
  6806. int32 new_location = 0;
  6807. if (sep->IsNumber(1))
  6808. {
  6809. int32 template_id = 0;
  6810. template_id = atoi(sep->arg[1]);
  6811. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  6812. if( new_location > 0 )
  6813. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  6814. else
  6815. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  6816. }
  6817. else
  6818. {
  6819. const char* name = 0;
  6820. name = sep->argplus[1];
  6821. new_location = database.CreateSpawnFromTemplateByName(client, name);
  6822. if( new_location > 0 )
  6823. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  6824. else
  6825. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  6826. }
  6827. }
  6828. else
  6829. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  6830. }
  6831. else
  6832. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  6833. }
  6834. void Commands::Command_Speed(Client* client, Seperator* sep) {
  6835. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  6836. float new_speed = atof(sep->arg[0]);
  6837. if (new_speed > 0.0f)
  6838. {
  6839. client->GetPlayer()->SetSpeed(new_speed, true);
  6840. client->GetPlayer()->SetCharSheetChanged(true);
  6841. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  6842. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  6843. }
  6844. else
  6845. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  6846. }
  6847. else{
  6848. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  6849. }
  6850. }
  6851. /*
  6852. Function: Command_StationMarketPlace()
  6853. Purpose : just trying to eat the console spam for now
  6854. Params :
  6855. Dev : John
  6856. */
  6857. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  6858. {
  6859. PrintSep(sep, "COMMAND_SMP");
  6860. // This will reduce the spam from once every 10 sec to once every 30 sec,
  6861. // can't seem to reduce it any more get rid of it completely...
  6862. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  6863. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  6864. if (packet) {
  6865. packet->setDataByName("account_id", client->GetAccountID());
  6866. packet->setDataByName("character_id", client->GetCharacterID());
  6867. packet->setDataByName("unknown1", 1, 5);
  6868. packet->setDataByName("unknown1", 26, 6);
  6869. packet->setDataByName("unknown2", 0xFFFFFFFF);
  6870. packet->setDataByName("unknown3", 248, 1);
  6871. client->QueuePacket(packet->serialize());
  6872. }
  6873. safe_delete(packet);
  6874. }
  6875. }
  6876. /*
  6877. Function: Command_StopDrinking()
  6878. Purpose : Stops player from auto-consuming drink
  6879. Params :
  6880. Dev : Zcoretri
  6881. Example : /stopdrinking
  6882. */
  6883. void Commands::Command_StopDrinking(Client* client)
  6884. {
  6885. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  6886. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  6887. }
  6888. /*
  6889. Function: Command_StopEating()
  6890. Purpose : Stops player from auto-consuming food
  6891. Params :
  6892. Dev : Zcoretri
  6893. Example : /stopeating
  6894. */
  6895. void Commands::Command_StopEating(Client* client)
  6896. {
  6897. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  6898. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  6899. }
  6900. /*
  6901. Function: Command_Title()
  6902. Purpose : Help for /title command
  6903. Params : n/a
  6904. Dev : Zcoretri
  6905. Example : /title
  6906. */
  6907. void Commands::Command_Title(Client* client)
  6908. {
  6909. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  6910. }
  6911. /*
  6912. Function: Command_TitleList()
  6913. Purpose : List available titles for player
  6914. Params : n/a
  6915. Dev : Zcoretri
  6916. Example : /title list
  6917. */
  6918. void Commands::Command_TitleList(Client* client)
  6919. {
  6920. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  6921. list<Title*>::iterator itr;
  6922. Title* title;
  6923. int16 i = 0;
  6924. client->Message(CHANNEL_COLOR_WHITE, "Listing available titles:");
  6925. for(itr = titles->begin(); itr != titles->end(); itr++)
  6926. {
  6927. title = *itr;
  6928. client->Message(CHANNEL_COLOR_WHITE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  6929. i++;
  6930. }
  6931. }
  6932. /*
  6933. Function: Command_TitleSetPrefix()
  6934. Purpose : Set Prefix title for player
  6935. Params : Title ID
  6936. Dev : Zcoretri
  6937. Example : /title setprefix 1
  6938. */
  6939. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  6940. {
  6941. if (sep && sep->arg[0] && sep->IsNumber(0))
  6942. {
  6943. int32 index = atoul(sep->arg[0]);
  6944. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  6945. client->SendTitleUpdate();
  6946. }
  6947. }
  6948. /*
  6949. Function: Command_TitleSetSuffix()
  6950. Purpose : Set Suffix title for player
  6951. Params : Title ID
  6952. Dev : Zcoretri
  6953. Example : /title setsuffix 1
  6954. */
  6955. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  6956. {
  6957. if (sep && sep->arg[0] && sep->IsNumber(0))
  6958. {
  6959. int32 index = atoul(sep->arg[0]);
  6960. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  6961. client->SendTitleUpdate();
  6962. }
  6963. }
  6964. /*
  6965. Function: Command_TitleFix()
  6966. Purpose : Fix title for player (???)
  6967. Params :
  6968. Dev : Zcoretri
  6969. Example :
  6970. */
  6971. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  6972. {
  6973. PrintSep(sep, "COMMAND_TITLE_FIX");
  6974. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  6975. }
  6976. /*
  6977. Function: Command_Toggle_Anonymous()
  6978. Purpose : Toggles player Anonymous
  6979. Params :
  6980. Dev : paulgh
  6981. Example : /anon
  6982. */
  6983. void Commands::Command_Toggle_Anonymous(Client* client)
  6984. {
  6985. Player* player = client->GetPlayer();
  6986. player->toggle_character_flag(CF_ANONYMOUS);
  6987. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  6988. if (player->get_character_flag(CF_ANONYMOUS))
  6989. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  6990. else
  6991. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  6992. }
  6993. /*
  6994. Function: Command_Toggle_AutoConsume()
  6995. Purpose : Toggles player food/drink auto consume
  6996. Params : unknown
  6997. Dev : paulgh
  6998. Example : /set_auto_consume
  6999. */
  7000. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7001. {
  7002. Player* player = client->GetPlayer();
  7003. if (sep && sep->arg[0])
  7004. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7005. if (sep && sep->arg[0] && sep->IsNumber(0))
  7006. {
  7007. int8 slot = atoi(sep->arg[0]);
  7008. int8 flag = atoi(sep->arg[1]);
  7009. if (slot == EQ2_FOOD_SLOT)
  7010. {
  7011. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7012. player->SetCharSheetChanged(true);
  7013. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7014. if (flag == 1)
  7015. client->Message(CHANNEL_COLOR_WHITE, "You decide to eat immediately whenever you become hungry.");
  7016. else
  7017. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the hunger.");
  7018. }
  7019. else
  7020. {
  7021. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7022. player->SetCharSheetChanged(true);
  7023. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7024. if (flag == 1)
  7025. client->Message(CHANNEL_COLOR_WHITE, "You decide to drink immediately whenever you become thirsty.");
  7026. else
  7027. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the thirst.");
  7028. }
  7029. }
  7030. }
  7031. /*
  7032. Function: Command_Toggle_BonusXP()
  7033. Purpose : Toggles player Bonus XP
  7034. Params :
  7035. Dev : John Adams
  7036. Example : /disable_char_bonus_exp
  7037. */
  7038. void Commands::Command_Toggle_BonusXP(Client* client)
  7039. {
  7040. Player* player = client->GetPlayer();
  7041. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7042. player->SetCharSheetChanged(true);
  7043. }
  7044. /*
  7045. Function: Command_Toggle_CombatXP()
  7046. Purpose : Toggles player Adventure XP
  7047. Params :
  7048. Dev : John Adams
  7049. Example : /disable_combat_exp
  7050. */
  7051. void Commands::Command_Toggle_CombatXP(Client* client)
  7052. {
  7053. Player* player = client->GetPlayer();
  7054. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7055. player->SetCharSheetChanged(true);
  7056. }
  7057. /*
  7058. Function: Command_Toggle_GMHide()
  7059. Purpose : Toggles hiding player GM status
  7060. Params :
  7061. Dev : Scatman
  7062. Example : /gm_hide
  7063. */
  7064. void Commands::Command_Toggle_GMHide(Client* client)
  7065. {
  7066. Player* player = client->GetPlayer();
  7067. player->toggle_character_flag(CF_HIDE_STATUS);
  7068. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7069. }
  7070. /*
  7071. Function: Command_Toggle_GMVanish()
  7072. Purpose : Toggles hiding GM players from /who searches
  7073. Params :
  7074. Dev : Scatman
  7075. Example : /gm_vanish
  7076. */
  7077. void Commands::Command_Toggle_GMVanish(Client* client)
  7078. {
  7079. Player* player = client->GetPlayer();
  7080. player->toggle_character_flag(CF_GM_HIDDEN);
  7081. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7082. }
  7083. /*
  7084. Function: Command_Toggle_Illusions()
  7085. Purpose : Toggles player illusion form
  7086. Params : not sure sep is needed, testing
  7087. Dev : paulgh
  7088. Example : /hide_illusions
  7089. */
  7090. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7091. {
  7092. if (sep && sep->arg[0])
  7093. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7094. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7095. }
  7096. /*
  7097. Function: Command_Toggle_LFG()
  7098. Purpose : Toggles player LFG Flag
  7099. Params :
  7100. Dev : paulgh
  7101. Example : /lfg
  7102. */
  7103. void Commands::Command_Toggle_LFG(Client* client)
  7104. {
  7105. Player* player = client->GetPlayer();
  7106. player->toggle_character_flag(CF_LFG);
  7107. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7108. if (player->get_character_flag(CF_LFG))
  7109. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7110. else
  7111. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7112. }
  7113. /*
  7114. Function: Command_Toggle_LFW()
  7115. Purpose : Toggles player LFW Flag
  7116. Params :
  7117. Dev : paulgh
  7118. Example : /lfw
  7119. */
  7120. void Commands::Command_Toggle_LFW(Client* client)
  7121. {
  7122. Player* player = client->GetPlayer();
  7123. player->toggle_character_flag(CF_LFW);
  7124. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7125. if (player->get_character_flag(CF_LFW))
  7126. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7127. else
  7128. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7129. }
  7130. /*
  7131. Function: Command_Toggle_QuestXP()
  7132. Purpose : Toggles player Quest XP
  7133. Params :
  7134. Dev : John Adams
  7135. Example : /disable_quest_exp
  7136. */
  7137. void Commands::Command_Toggle_QuestXP(Client* client)
  7138. {
  7139. Player* player = client->GetPlayer();
  7140. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7141. player->SetCharSheetChanged(true);
  7142. }
  7143. /*
  7144. Function: Command_Toggle_Roleplaying()
  7145. Purpose : Toggles player Roleplaying flag
  7146. Params :
  7147. Dev : paulgh
  7148. Example : /role
  7149. */
  7150. void Commands::Command_Toggle_Roleplaying(Client* client)
  7151. {
  7152. Player* player = client->GetPlayer();
  7153. player->toggle_character_flag(CF_ROLEPLAYING);
  7154. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  7155. if (player->get_character_flag(CF_ROLEPLAYING))
  7156. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  7157. else
  7158. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  7159. }
  7160. void Commands::Command_Toggle_Duels(Client* client)
  7161. {
  7162. Player* player = client->GetPlayer();
  7163. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7164. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7165. }
  7166. void Commands::Command_Toggle_Trades(Client* client)
  7167. {
  7168. Player* player = client->GetPlayer();
  7169. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7170. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7171. }
  7172. void Commands::Command_Toggle_Guilds(Client* client)
  7173. {
  7174. Player* player = client->GetPlayer();
  7175. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7176. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7177. }
  7178. void Commands::Command_Toggle_Groups(Client* client)
  7179. {
  7180. Player* player = client->GetPlayer();
  7181. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7182. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7183. }
  7184. void Commands::Command_Toggle_Raids(Client* client)
  7185. {
  7186. Player* player = client->GetPlayer();
  7187. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7188. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7189. }
  7190. void Commands::Command_Toggle_LON(Client* client)
  7191. {
  7192. Player* player = client->GetPlayer();
  7193. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7194. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7195. }
  7196. void Commands::Command_Toggle_VoiceChat(Client* client)
  7197. {
  7198. Player* player = client->GetPlayer();
  7199. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7200. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7201. }
  7202. /*
  7203. Function: Command_TradeStart()
  7204. Purpose : Starts item/coin trade between players
  7205. Params :
  7206. Dev :
  7207. Example :
  7208. */
  7209. #include "../Trade.h"
  7210. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7211. {
  7212. PrintSep(sep, "COMMAND_START_TRADE");
  7213. Entity* trader = client->GetPlayer();
  7214. Entity* trader2 = 0;
  7215. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7216. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7217. if (spawn) {
  7218. if (spawn->IsEntity())
  7219. trader2 = (Entity*)spawn;
  7220. }
  7221. }
  7222. else if (client->GetPlayer()->GetTarget()) {
  7223. if (client->GetPlayer()->GetTarget()->IsEntity())
  7224. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7225. }
  7226. // can only trade with player or bots
  7227. if (trader && trader2) {
  7228. if (trader == trader2) {
  7229. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7230. }
  7231. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7232. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7233. if (trader->trade)
  7234. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7235. else if (trader2->trade)
  7236. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7237. else {
  7238. Trade* trade = new Trade(trader, trader2);
  7239. trader->trade = trade;
  7240. trader2->trade = trade;
  7241. }
  7242. }
  7243. else {
  7244. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  7245. }
  7246. }
  7247. else
  7248. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  7249. }
  7250. /*
  7251. Function: Command_Track()
  7252. Purpose : Starts/Stops Tracking for a player
  7253. Params :
  7254. Dev : Scatman
  7255. Example : /track
  7256. */
  7257. void Commands::Command_Track(Client* client)
  7258. {
  7259. if (!client->GetPlayer()->GetIsTracking())
  7260. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7261. else
  7262. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7263. }
  7264. /*
  7265. Function: Command_TradeAccept()
  7266. Purpose : Accepts item/coin trade between players
  7267. Params :
  7268. Dev :
  7269. Example :
  7270. */
  7271. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7272. {
  7273. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7274. Trade* trade = client->GetPlayer()->trade;
  7275. if (trade) {
  7276. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7277. if (trade_complete)
  7278. safe_delete(trade);
  7279. }
  7280. else
  7281. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7282. }
  7283. /*
  7284. Function: Command_TradeReject()
  7285. Purpose : Rejects item/coin trade between players
  7286. Params :
  7287. Dev :
  7288. Example :
  7289. */
  7290. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7291. {
  7292. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7293. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7294. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7295. }
  7296. /*
  7297. Function: Command_TradeCancel()
  7298. Purpose : Cancels item/coin trade between players
  7299. Params :
  7300. Dev :
  7301. Example :
  7302. */
  7303. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7304. {
  7305. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7306. Trade* trade = client->GetPlayer()->trade;
  7307. if (trade) {
  7308. trade->CancelTrade(client->GetPlayer());
  7309. safe_delete(trade);
  7310. }
  7311. else
  7312. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7313. }
  7314. /*
  7315. Function: Command_TradeSetCoin()
  7316. Purpose : Sets coin trade between players
  7317. Params :
  7318. Dev :
  7319. Example :
  7320. */
  7321. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7322. {
  7323. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7324. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7325. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7326. }
  7327. /*
  7328. Function: Command_TradeAddCoin()
  7329. Purpose : Adds coin to trade between players
  7330. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7331. Dev :
  7332. Example :
  7333. */
  7334. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7335. {
  7336. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7337. Trade* trade = client->GetPlayer()->trade;
  7338. if (trade) {
  7339. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7340. int32 amount = atoi(sep->arg[0]);
  7341. int64 val = 0;
  7342. switch (handler) {
  7343. case COMMAND_ADD_TRADE_COPPER:
  7344. {
  7345. val = amount;
  7346. trade->AddCoinToTrade(client->GetPlayer(), val);
  7347. break;
  7348. }
  7349. case COMMAND_ADD_TRADE_SILVER:
  7350. {
  7351. val = amount * 100;
  7352. trade->AddCoinToTrade(client->GetPlayer(), val);
  7353. break;
  7354. }
  7355. case COMMAND_ADD_TRADE_GOLD:
  7356. {
  7357. val = amount * 10000;
  7358. trade->AddCoinToTrade(client->GetPlayer(), val);
  7359. break;
  7360. }
  7361. case COMMAND_ADD_TRADE_PLAT:
  7362. {
  7363. val = amount * 1000000;
  7364. trade->AddCoinToTrade(client->GetPlayer(), val);
  7365. break;
  7366. }
  7367. default:
  7368. {
  7369. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7370. break;
  7371. }
  7372. }
  7373. }
  7374. else
  7375. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7376. }
  7377. else
  7378. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7379. }
  7380. /*
  7381. Function: Command_TradeRemoveCoin()
  7382. Purpose : Removes coin from trade between players
  7383. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7384. Dev :
  7385. Example :
  7386. */
  7387. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7388. {
  7389. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7390. Trade* trade = client->GetPlayer()->trade;
  7391. if (trade) {
  7392. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7393. int32 amount = atoi(sep->arg[0]);
  7394. int64 val = 0;
  7395. switch (handler) {
  7396. case COMMAND_REMOVE_TRADE_COPPER:
  7397. {
  7398. val = amount;
  7399. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7400. break;
  7401. }
  7402. case COMMAND_REMOVE_TRADE_SILVER:
  7403. {
  7404. val = amount * 100;
  7405. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7406. break;
  7407. }
  7408. case COMMAND_REMOVE_TRADE_GOLD:
  7409. {
  7410. val = amount * 10000;
  7411. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7412. break;
  7413. }
  7414. case COMMAND_REMOVE_TRADE_PLAT:
  7415. {
  7416. val = amount * 1000000;
  7417. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7418. break;
  7419. }
  7420. default:
  7421. {
  7422. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7423. break;
  7424. }
  7425. }
  7426. }
  7427. else
  7428. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7429. }
  7430. else
  7431. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7432. }
  7433. /*
  7434. Function: Command_TradeAddItem()
  7435. Purpose : Adds item to trade between players
  7436. Params :
  7437. Dev :
  7438. Example :
  7439. */
  7440. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7441. {
  7442. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7443. /*
  7444. arg[0] = item index
  7445. arg[1] = slot
  7446. arg[2] = quantity
  7447. */
  7448. if (!client->GetPlayer()->trade) {
  7449. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7450. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7451. return;
  7452. }
  7453. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7454. Item* item = 0;
  7455. int32 index = atoi(sep->arg[0]);
  7456. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7457. if (item) {
  7458. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7459. if (result == 1)
  7460. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7461. else if (result == 2)
  7462. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7463. else if (result == 3)
  7464. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7465. else if (result == 255)
  7466. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7467. }
  7468. else {
  7469. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7470. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7471. }
  7472. }
  7473. else
  7474. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7475. }
  7476. /*
  7477. Function: Command_TradeRemoveItem()
  7478. Purpose : Removes item from trade between players
  7479. Params :
  7480. Dev :
  7481. Example :
  7482. */
  7483. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7484. {
  7485. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7486. /*
  7487. arg[0] = trade window slot
  7488. */
  7489. Trade* trade = client->GetPlayer()->trade;
  7490. if (trade) {
  7491. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7492. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7493. }
  7494. else
  7495. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7496. }
  7497. else
  7498. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7499. }
  7500. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7501. {
  7502. Item *item = 0;
  7503. sint32 crc;
  7504. if (sep) {
  7505. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7506. if (client->GetVersion() < 1096) {
  7507. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7508. {
  7509. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7510. crc = atol(sep->arg[2]);
  7511. }
  7512. }
  7513. else {
  7514. // From the broker and links in chat
  7515. if (strcmp(sep->arg[0], "crc") == 0) {
  7516. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7517. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7518. crc = atol(sep->arg[3]);
  7519. }
  7520. }
  7521. // From inventory
  7522. if (strcmp(sep->arg[0], "dbid") == 0) {
  7523. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7524. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7525. crc = atol(sep->arg[4]);
  7526. }
  7527. }
  7528. }
  7529. if (item)
  7530. client->ShowDressingRoom(item, crc);
  7531. }
  7532. }
  7533. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7534. const char *channel_name, *password = NULL;
  7535. if (sep == NULL || !sep->IsSet(0)) {
  7536. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7537. return;
  7538. }
  7539. channel_name = sep->arg[0];
  7540. if (sep->IsSet(1))
  7541. password = sep->arg[1];
  7542. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7543. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7544. return;
  7545. }
  7546. if (chat.IsInChannel(client, channel_name)) {
  7547. client->Message(CHANNEL_COLOR_WHITE, "You are already in '%s'.", channel_name);
  7548. return;
  7549. }
  7550. if (chat.HasPassword(channel_name)) {
  7551. if (password == NULL) {
  7552. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': That channel is password protected.", channel_name);
  7553. return;
  7554. }
  7555. if (!chat.PasswordMatches(channel_name, password)) {
  7556. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': The password is not correc.t", channel_name);
  7557. return;
  7558. }
  7559. }
  7560. if (!chat.JoinChannel(client, channel_name))
  7561. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7562. }
  7563. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7564. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7565. Command_JoinChannel(client, sep);
  7566. }
  7567. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7568. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7569. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7570. PrintSep(sep, "tellchannel");
  7571. return;
  7572. }
  7573. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7574. }
  7575. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7576. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  7577. if (!p) return;
  7578. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7579. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  7580. //}
  7581. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7582. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  7583. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  7584. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  7585. if (packet) {
  7586. client->QueuePacket(packet->serialize());
  7587. safe_delete(packet);
  7588. }
  7589. }*/
  7590. /*if (client->GetCurrentZone()->Grid != nullptr) {
  7591. int32 numFaces = 0;
  7592. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  7593. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  7594. map<int32, vector<Face*> >::iterator itr;
  7595. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  7596. numFaces += (*itr).second.size();
  7597. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  7598. }*/
  7599. //uchar blah[] = {
  7600. // 1208 - OP_EQUpdateStoreCmd
  7601. // /*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
  7602. // /*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
  7603. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  7604. // /*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
  7605. /*};
  7606. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7607. int8 val = 0;
  7608. int16 pos = 0;
  7609. int idx = 0;
  7610. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  7611. pos = atoi(sep2->arg[idx]);
  7612. val = atoi(sep2->arg[idx+1]);
  7613. memset(blah+pos, val, 1);
  7614. idx+=2;
  7615. }
  7616. DumpPacket(blah, sizeof(blah));
  7617. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  7618. if (client->GetPlayer()->GetTarget()) {
  7619. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  7620. if (packet) {
  7621. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7622. packet->setDataByName("size", 0);
  7623. packet->setDataByName("unknown2", 0);
  7624. EQ2Packet* app = packet->serialize();
  7625. client->QueuePacket(app);
  7626. safe_delete(packet);
  7627. }
  7628. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  7629. if (set_pov) {
  7630. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7631. EQ2Packet* app_pov = set_pov->serialize();
  7632. client->QueuePacket(app_pov);
  7633. safe_delete(set_pov);
  7634. }
  7635. }
  7636. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7637. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  7638. if (packet) {
  7639. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  7640. packet->setDataByName("Type", atoi(sep2->arg[0]));
  7641. else
  7642. packet->setDataByName("Type", 2);
  7643. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  7644. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  7645. else
  7646. packet->setDataByName("race_id", 0);
  7647. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  7648. packet->setDataByName("gender", atoi(sep2->arg[2]));
  7649. else
  7650. packet->setDataByName("gender", 2);
  7651. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  7652. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  7653. else
  7654. packet->setDataByName("unknown", 0, 0);
  7655. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  7656. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  7657. else
  7658. packet->setDataByName("unknown", 0, 1);
  7659. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  7660. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  7661. else
  7662. packet->setDataByName("unknown", 0, 2);
  7663. client->QueuePacket(packet->serialize());
  7664. }
  7665. safe_delete(packet);
  7666. safe_delete(sep2);
  7667. }
  7668. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  7669. const char *channel_name;
  7670. if (sep == NULL || !sep->IsSet(0)) {
  7671. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  7672. PrintSep(sep);
  7673. return;
  7674. }
  7675. channel_name = sep->arg[0];
  7676. if (!chat.IsInChannel(client, channel_name))
  7677. client->Message(CHANNEL_COLOR_WHITE, "Unable to leave '%s': You are not in the channel.", channel_name);
  7678. else if (!chat.LeaveChannel(client, channel_name))
  7679. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  7680. }
  7681. /*
  7682. Function:
  7683. Purpose :
  7684. Params :
  7685. Dev :
  7686. Example :
  7687. */
  7688. void Commands::Command_WeaponStats(Client* client)
  7689. {
  7690. Player* player = client->GetPlayer();
  7691. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  7692. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  7693. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  7694. client->SimpleMessage(0, "Primary:");
  7695. if (primary) {
  7696. client->Message(0, "Name: %s", primary->name.c_str());
  7697. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  7698. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7699. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  7700. client->Message(0, "Proc Percent: %d%%", 0);
  7701. client->Message(0, "Procs Per Minute: %d", 0);
  7702. }
  7703. else {
  7704. client->SimpleMessage(0, "Name: fist");
  7705. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7706. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7707. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  7708. client->Message(0, "Proc Percent: %d%%", 0);
  7709. client->Message(0, "Procs Per Minute: %d", 0);
  7710. }
  7711. client->SimpleMessage(0, " ");
  7712. client->SimpleMessage(0, " ");
  7713. if (secondary) {
  7714. client->SimpleMessage(0, "Secondary:");
  7715. client->Message(0, "Name: %s", secondary->name.c_str());
  7716. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  7717. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  7718. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  7719. client->Message(0, "Proc Percent: %d%%", 0);
  7720. client->Message(0, "Procs Per Minute: %d", 0);
  7721. client->SimpleMessage(0, " ");
  7722. client->SimpleMessage(0, " ");
  7723. }
  7724. client->SimpleMessage(0, "Ranged:");
  7725. if (ranged) {
  7726. client->Message(0, "Name: %s", ranged->name.c_str());
  7727. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  7728. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  7729. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  7730. client->Message(0, "Proc Percent: %d%%", 0);
  7731. client->Message(0, "Procs Per Minute: %d", 0);
  7732. }
  7733. else
  7734. client->SimpleMessage(0, "None");
  7735. }
  7736. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  7737. const char *channel_name;
  7738. if (sep == NULL || !sep->IsSet(0)) {
  7739. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  7740. return;
  7741. }
  7742. channel_name = sep->arg[0];
  7743. if (!chat.ChannelExists(channel_name))
  7744. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  7745. else
  7746. chat.SendChannelUserList(client, channel_name);
  7747. }
  7748. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  7749. {
  7750. ZoneServer* zone = 0;
  7751. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  7752. if (zone_id > 0)
  7753. {
  7754. zone = zone_list.Get(zone_id, false);
  7755. if (zone)
  7756. {
  7757. zone->SetSafeX(client->GetPlayer()->GetX());
  7758. zone->SetSafeY(client->GetPlayer()->GetY());
  7759. zone->SetSafeZ(client->GetPlayer()->GetZ());
  7760. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  7761. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  7762. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  7763. else
  7764. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  7765. }
  7766. }
  7767. }
  7768. /*
  7769. Function:
  7770. Purpose :
  7771. Params :
  7772. Dev :
  7773. Example :
  7774. */
  7775. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  7776. {
  7777. ZoneInfo* zone_info = new ZoneInfo;
  7778. if (sep && sep->arg[0])
  7779. {
  7780. if (sep->IsNumber(0))
  7781. zone_info->id = atoi(sep->arg[0]);
  7782. else
  7783. zone_info->id = database.GetZoneID(sep->arg[0]);
  7784. if (zone_info->id > 0)
  7785. {
  7786. database.LoadZoneInfo(zone_info);
  7787. 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);
  7788. 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);
  7789. 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);
  7790. 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);
  7791. 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);
  7792. 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);
  7793. 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);
  7794. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  7795. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  7796. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  7797. }
  7798. else
  7799. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  7800. }
  7801. else
  7802. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  7803. safe_delete(zone_info);
  7804. }
  7805. /*
  7806. Function:
  7807. Purpose :
  7808. Params :
  7809. Dev :
  7810. Example :
  7811. */
  7812. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  7813. {
  7814. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  7815. {
  7816. ZoneServer* zone = 0;
  7817. int32 zone_id = 0;
  7818. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  7819. {
  7820. zone_id = atoi(sep->arg[0]);
  7821. zone = zone_list.Get(atoi(sep->arg[0]), false);
  7822. }
  7823. else
  7824. {
  7825. zone_id = database.GetZoneID(sep->arg[0]);
  7826. if (zone_id > 0)
  7827. zone = zone_list.Get(sep->arg[0], false);
  7828. }
  7829. if (zone_id > 0)
  7830. {
  7831. if (zone_set_values.count(string(sep->arg[1])) > 0)
  7832. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  7833. else
  7834. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  7835. }
  7836. else
  7837. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  7838. }
  7839. else
  7840. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  7841. }
  7842. void Commands::Command_Rain(Client* client, Seperator* sep) {
  7843. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  7844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  7845. return;
  7846. }
  7847. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  7848. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  7849. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  7850. }
  7851. void Commands::Command_Wind(Client* client, Seperator* sep) {
  7852. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  7853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  7854. return;
  7855. }
  7856. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  7857. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  7858. }
  7859. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  7860. Spawn* spawn = client->GetPlayer()->GetTarget();
  7861. if(spawn) {
  7862. client->SetMerchantTransaction(spawn);
  7863. if (spawn->GetMerchantID() > 0){
  7864. client->SendHailCommand(spawn);
  7865. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  7866. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  7867. client->SendBuyMerchantList(sell);
  7868. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  7869. client->SendSellMerchantList(sell);
  7870. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  7871. client->SendBuyBackList(sell);
  7872. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  7873. if (packet) {
  7874. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  7875. packet->setDataByName("type", 16);
  7876. EQ2Packet* outapp = packet->serialize();
  7877. if (outapp)
  7878. client->QueuePacket(outapp);
  7879. safe_delete(packet);
  7880. }
  7881. }
  7882. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  7883. client->SendRepairList();
  7884. }
  7885. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  7886. }
  7887. void Commands::Command_Weather(Client* client, Seperator* sep)
  7888. {
  7889. //PrintSep(sep, "Weather");
  7890. if( sep && sep->arg[0] )
  7891. {
  7892. ZoneServer* zsZone = client->GetCurrentZone();
  7893. const char* value = sep->arg[0];
  7894. // process single-param commands first
  7895. if( strncasecmp(value, "details", strlen(value)) == 0 )
  7896. {
  7897. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  7898. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  7899. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  7900. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  7901. }
  7902. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  7903. {
  7904. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  7905. zsZone->ProcessWeather();
  7906. }
  7907. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  7908. {
  7909. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  7910. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  7911. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  7912. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  7913. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  7914. zsZone->SetWeatherPattern(1);
  7915. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  7916. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  7917. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  7918. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  7919. zsZone->ProcessWeather();
  7920. }
  7921. // process commands with params
  7922. if( sep->arg[1] )
  7923. {
  7924. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  7925. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  7926. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  7927. zsZone->SetWeatherType(atoi(sep->arg[1]));
  7928. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  7929. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  7930. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  7931. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  7932. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  7933. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  7934. }
  7935. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  7936. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  7937. zsZone->SetRain(zsZone->GetCurrentWeather());
  7938. }
  7939. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  7940. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  7941. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  7942. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  7943. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  7944. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  7945. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  7946. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  7947. }
  7948. }
  7949. else
  7950. {
  7951. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  7952. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  7953. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  7954. return;
  7955. }
  7956. }
  7957. void Commands::Command_Select(Client* client, Seperator* sep) {
  7958. if (sep && sep->arg[1]) {
  7959. Spawn* spawn = client->GetPlayer()->GetTarget();
  7960. if (spawn && strlen(sep->arg[1]) > 0)
  7961. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  7962. }
  7963. }
  7964. /*
  7965. Function: Command_ConsumeFood()
  7966. Purpose : Consume Food/Drink and apply mods
  7967. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  7968. Dev : Zcoretri
  7969. Example : /consume_food 22
  7970. */
  7971. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  7972. if (sep && sep->arg[0] && sep->IsNumber(0))
  7973. {
  7974. Player* player = client->GetPlayer();
  7975. int8 slot = atoi(sep->arg[0]);
  7976. Item* item = player->GetEquipmentList()->GetItem(slot);
  7977. if(item) {
  7978. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  7979. if(item->GetItemScript() && lua_interface){
  7980. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  7981. if (slot == 22)
  7982. client->Message(CHANNEL_COLOR_WHITE, "You eat a %s.", item->name.c_str());
  7983. else
  7984. client->Message(CHANNEL_COLOR_WHITE, "You drink a %s.", item->name.c_str());
  7985. }
  7986. }
  7987. if (item->details.count > 1) {
  7988. item->details.count -= 1;
  7989. item->save_needed = true;
  7990. }
  7991. else {
  7992. player->GetEquipmentList()->RemoveItem(slot, true);
  7993. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  7994. }
  7995. client->GetPlayer()->SetCharSheetChanged(true);
  7996. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7997. }
  7998. }
  7999. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  8000. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  8001. if (atoi(sep->arg[0]) == 1) {
  8002. client->GetPlayer()->GetInfoStruct()->vision = 4;
  8003. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  8004. client->GetPlayer()->SetCharSheetChanged(true);
  8005. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  8006. }
  8007. else {
  8008. client->GetPlayer()->GetInfoStruct()->vision = 0;
  8009. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  8010. client->GetPlayer()->SetCharSheetChanged(true);
  8011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  8012. }
  8013. }
  8014. else
  8015. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  8016. }
  8017. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  8018. {
  8019. if(sep)
  8020. {
  8021. string data;
  8022. if(sep->arg[0]){
  8023. data = string(sep->arg[0]);
  8024. }
  8025. for(int i=1;i<sep->GetMaxArgNum();i++){
  8026. if(sep->arg[i])
  8027. data.append(" ").append(sep->arg[i]);
  8028. }
  8029. const char* target_name = 0;
  8030. int32 spawn_id = 0;
  8031. if(client->GetPlayer()->GetTarget())
  8032. {
  8033. target_name = client->GetPlayer()->GetTarget()->GetName();
  8034. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  8035. }
  8036. else
  8037. target_name = "N/A";
  8038. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  8039. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  8040. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  8041. else
  8042. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  8043. }
  8044. }
  8045. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  8046. PrintSep(sep, "Command_Attune_Inv");
  8047. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  8048. // Get the item index from the first parameter
  8049. int16 index = atoi(sep->arg[0]);
  8050. // Check to see if this is a valid item index for the player, if not exit out of the function
  8051. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  8052. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  8053. return;
  8054. }
  8055. // Get the item
  8056. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  8057. if(item) {
  8058. // Valid item lets check to make sure this item is attunable, if not return out
  8059. if (!item->CheckFlag(ATTUNEABLE)) {
  8060. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  8061. return;
  8062. }
  8063. // Remove the attunable flag
  8064. item->generic_info.item_flags -= ATTUNEABLE;
  8065. // Set the attuned flag
  8066. item->generic_info.item_flags += ATTUNED;
  8067. // Flag this item for saving
  8068. item->save_needed = true;
  8069. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  8070. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  8071. EQ2Packet* outapp = 0;
  8072. for (int32 i=0;i<packets.size();i++) {
  8073. outapp = packets[i];
  8074. if(outapp)
  8075. client->QueuePacket(outapp);
  8076. }
  8077. }
  8078. }
  8079. }
  8080. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  8081. PrintSep(sep, "Command_Reset_Zone_Timer");
  8082. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  8083. int32 db_id = atoul(sep->arg[0]);
  8084. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  8085. if (data) {
  8086. // TODO: add a check to timers to ensure it can be reset
  8087. // Delete the character from the instance
  8088. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  8089. data->instance_id = 0;
  8090. // Update the success time and set to 0 so the player can enter it again
  8091. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  8092. data->last_success_timestamp = 0;
  8093. }
  8094. }*/
  8095. }
  8096. void Commands::Command_Player(Client* client, Seperator* sep) {
  8097. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  8098. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  8099. }
  8100. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  8101. // /player coins add 10
  8102. // /player coins add plat 10
  8103. Player* player = client->GetPlayer();
  8104. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  8105. player = (Player*)player->GetTarget();
  8106. if (sep && sep->arg[0] && sep->arg[1]) {
  8107. const char* action = sep->arg[0];
  8108. int64 value = 0;
  8109. if (strncasecmp(action, "add", strlen(action)) == 0) {
  8110. if (sep->IsNumber(1)) {
  8111. value = atoi64(sep->arg[1]);
  8112. player->AddCoins(value);
  8113. if (client->GetPlayer() == player)
  8114. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  8115. else {
  8116. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  8117. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  8118. }
  8119. return;
  8120. }
  8121. else if (sep->arg[2] && sep->IsNumber(2)) {
  8122. const char* type = sep->arg[1];
  8123. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  8124. value = atoi64(sep->arg[2]);
  8125. }
  8126. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  8127. value = atoi64(sep->arg[2]) * 100;
  8128. }
  8129. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  8130. value = atoi64(sep->arg[2]) * 10000;
  8131. }
  8132. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  8133. value = atoi64(sep->arg[2]) * 1000000;
  8134. }
  8135. player->AddCoins(value);
  8136. if (client->GetPlayer() == player)
  8137. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  8138. else {
  8139. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  8140. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  8141. }
  8142. return;
  8143. }
  8144. }
  8145. }
  8146. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  8147. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  8148. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  8149. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  8150. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  8151. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  8152. }
  8153. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  8154. PrintSep(sep, "ACHIEVEMENT_ADD");
  8155. if (sep && sep->IsSet(0)) {
  8156. int32 spell_id = atoul(sep->arg[1]);
  8157. int8 spell_tier = 0;
  8158. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  8159. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  8160. // addspellbookentry here
  8161. if (spell_tier >= data->maxRank) {
  8162. return;
  8163. }
  8164. if (!spell_tier) {
  8165. spell_tier = 1;
  8166. }
  8167. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  8168. {
  8169. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8170. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8171. client->GetPlayer()->UnlockSpell(spell);
  8172. client->SendSpellUpdate(spell);
  8173. }
  8174. else
  8175. {
  8176. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  8177. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  8178. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  8179. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8180. client->GetPlayer()->UnlockSpell(spell);
  8181. client->SendSpellUpdate(spell);
  8182. }
  8183. // cast spell here
  8184. if (!spell_tier)
  8185. spell_tier = 1;
  8186. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8187. if (spell) {
  8188. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  8189. }
  8190. }
  8191. else {
  8192. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  8193. }
  8194. master_aa_list.DisplayAA(client, 0, 0);
  8195. }
  8196. void Commands::Command_Editor(Client* client, Seperator* sep) {
  8197. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  8198. if (packet) {
  8199. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  8200. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  8201. char command[255];
  8202. url = "browser " + url;
  8203. int32 spawn_id = 0;
  8204. int32 zone_id = 0;
  8205. string type;
  8206. if (client->GetCurrentZone())
  8207. zone_id = client->GetCurrentZone()->GetZoneID();
  8208. if (client->GetPlayer()->GetTarget()) {
  8209. Spawn* target = client->GetPlayer()->GetTarget();
  8210. if (target->IsWidget())
  8211. type = "widgets";
  8212. else if (target->IsSign())
  8213. type = "signs";
  8214. else if (target->IsObject())
  8215. type = "objects";
  8216. else if (target->IsNPC())
  8217. type = "npcs";
  8218. else if (target->IsGroundSpawn())
  8219. type = "ground";
  8220. else
  8221. type = "spawn";
  8222. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  8223. }
  8224. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  8225. packet->setDataByName("accept_command", command);
  8226. }
  8227. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  8228. char command[255];
  8229. url = "browser " + url;
  8230. if (client->GetPlayer()->GetTarget())
  8231. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  8232. packet->setDataByName("accept_command", command);
  8233. }
  8234. else {
  8235. string command = "browser " + url;
  8236. packet->setDataByName("accept_command", command.c_str());
  8237. }
  8238. packet->setDataByName("text", "Open the web editor?");
  8239. packet->setDataByName("accept_text", "Open");
  8240. packet->setDataByName("cancel_text", "Cancel");
  8241. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  8242. packet->setDataByName("unknown2", 50);
  8243. packet->setDataByName("unknown4", 1);
  8244. client->QueuePacket(packet->serialize());
  8245. safe_delete(packet);
  8246. }
  8247. }
  8248. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  8249. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  8250. return;
  8251. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  8252. if(client->GetCurrentRez()->active)
  8253. client->AcceptResurrection();
  8254. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  8255. }
  8256. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  8257. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  8258. return;
  8259. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  8260. if(client->GetCurrentRez()->active)
  8261. client->GetCurrentRez()->should_delete = true;
  8262. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  8263. }
  8264. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  8265. PrintSep(sep, "Switch_AA_Profile");
  8266. if (sep && sep->IsSet(0)) {
  8267. string type = sep->arg[0];
  8268. int8 newtemplate = atoul(sep->arg[1]);
  8269. master_aa_list.DisplayAA(client, newtemplate, 1);
  8270. }
  8271. }
  8272. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  8273. PrintSep(sep, "Get_AA_Xml");
  8274. if (sep && sep->IsSet(0)) {
  8275. string tabnum = sep->arg[0];
  8276. string spellid = sep->arg[1];
  8277. }
  8278. }
  8279. void Commands::Add_AA(Client* client, Seperator* sep) {
  8280. PrintSep(sep, "Add_AA");
  8281. if (sep && sep->IsSet(0)) {
  8282. int32 spell_id = atoul(sep->arg[1]);
  8283. int8 spell_tier = 0;
  8284. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  8285. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  8286. // addspellbookentry here
  8287. if (spell_tier >= data->maxRank) {
  8288. return;
  8289. }
  8290. if (!spell_tier) {
  8291. spell_tier = 1;
  8292. }
  8293. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  8294. {
  8295. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8296. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8297. client->GetPlayer()->UnlockSpell(spell);
  8298. client->SendSpellUpdate(spell);
  8299. }
  8300. else
  8301. {
  8302. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  8303. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  8304. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  8305. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8306. client->GetPlayer()->UnlockSpell(spell);
  8307. client->SendSpellUpdate(spell);
  8308. }
  8309. // cast spell here
  8310. if (!spell_tier)
  8311. spell_tier = 1;
  8312. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8313. if (spell) {
  8314. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  8315. }
  8316. }
  8317. else {
  8318. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  8319. }
  8320. master_aa_list.DisplayAA(client, 0, 0);
  8321. }
  8322. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  8323. PrintSep(sep, "Commit_AA_Profile");
  8324. if (sep && sep->IsSet(0)) {
  8325. }
  8326. }
  8327. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  8328. PrintSep(sep, "Begin_AA_Profile");
  8329. if (sep && sep->IsSet(0)) {
  8330. master_aa_list.DisplayAA(client, 100, 2);
  8331. }
  8332. }
  8333. void Commands::Back_AA(Client* client, Seperator* sep) {
  8334. if (sep && sep->IsSet(0)) {
  8335. PrintSep(sep, "Back_AA");
  8336. }
  8337. }
  8338. void Commands::Remove_AA(Client* client, Seperator* sep) {
  8339. if (sep && sep->IsSet(0)) {
  8340. PrintSep(sep, "Remove_AA");
  8341. }
  8342. }
  8343. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  8344. MasterAAList master_aa_list;
  8345. PrintSep(sep, "Cancel_AA_Profile");
  8346. master_aa_list.DisplayAA(client, 0, 0);
  8347. }
  8348. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  8349. if (sep && sep->IsSet(0)) {
  8350. PrintSep(sep, "Save_AA_Profile");
  8351. }
  8352. }
  8353. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  8354. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  8355. if (!sep->IsNumber(0)) return;
  8356. int32 request_id = atoul(sep->arg[0]);
  8357. if (!sep->IsNumber(1)) return;
  8358. sint32 item_id = atoi(sep->arg[1]);
  8359. if (client->IsCurrentTransmuteID(request_id)) {
  8360. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  8361. }
  8362. else if (client->IsCurrentTransmuteID(item_id)) {
  8363. if (!sep->IsSet(2)) return;
  8364. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  8365. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  8366. }
  8367. }
  8368. }