Commands.cpp 437 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018
  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 <boost/algorithm/string/predicate.hpp>
  18. #include <boost/algorithm/string.hpp>
  19. #include "Commands.h"
  20. #include "../ClientPacketFunctions.h"
  21. #include "../../common/version.h"
  22. #include "../../common/seperator.h"
  23. #include "../../common/servertalk.h"
  24. #include "../WorldDatabase.h"
  25. #include "../World.h"
  26. #include "../../common/ConfigReader.h"
  27. #include "../VisualStates.h"
  28. #include "../../common/debug.h"
  29. #include "../LuaInterface.h"
  30. #include "../Quests.h"
  31. #include "../client.h"
  32. #include "../NPC.h"
  33. #include "../Guilds/Guild.h"
  34. #include "../SpellProcess.h"
  35. #include "../Tradeskills/Tradeskills.h"
  36. #include "../../common/Log.h"
  37. #include "../../common/MiscFunctions.h"
  38. #include "../Languages.h"
  39. #include "../Traits/Traits.h"
  40. #include "../Chat/Chat.h"
  41. #include "../Rules/Rules.h"
  42. #include "../AltAdvancement/AltAdvancement.h"
  43. #include "../RaceTypes/RaceTypes.h"
  44. #include "../classes.h"
  45. #include "../Transmute.h"
  46. #include "../Bots/Bot.h"
  47. extern WorldDatabase database;
  48. extern MasterSpellList master_spell_list;
  49. extern MasterTraitList master_trait_list;
  50. extern MasterRecipeList master_recipe_list;
  51. extern MasterRecipeBookList master_recipebook_list;
  52. extern World world;
  53. extern ClientList client_list;
  54. extern ConfigReader configReader;
  55. extern VisualStates visual_states;
  56. extern ZoneList zone_list;
  57. extern LuaInterface* lua_interface;
  58. extern MasterQuestList master_quest_list;
  59. extern MasterCollectionList master_collection_list;
  60. extern MasterSkillList master_skill_list;
  61. extern MasterFactionList master_faction_list;
  62. extern GuildList guild_list;
  63. extern MasterLanguagesList master_languages_list;
  64. extern Chat chat;
  65. extern RuleManager rule_manager;
  66. extern MasterAAList master_aa_list;
  67. extern MasterRaceTypeList race_types_list;
  68. extern Classes classes;
  69. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  70. #if defined(__GNUC__)
  71. #define stricmp strcasecmp
  72. #define strnicmp strncasecmp
  73. #endif
  74. EQ2Packet* RemoteCommands::serialize(){
  75. buffer.clear();
  76. vector<EQ2_RemoteCommandString>::iterator command_list;
  77. buffer.append((char*)&num_commands, sizeof(int16));
  78. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  79. AddDataCommand(&(*command_list));
  80. }
  81. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  82. return app;
  83. }
  84. Commands::Commands(){
  85. remote_commands = new RemoteCommands();
  86. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  87. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  88. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  89. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  90. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  91. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  92. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  93. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  94. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  95. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  96. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  97. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  98. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  99. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  100. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  101. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  102. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  103. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  104. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  105. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  106. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  107. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  108. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  109. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  110. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  111. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  112. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  113. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  114. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  115. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  116. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  117. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  118. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  119. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  120. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  121. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  122. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  123. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  124. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  125. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  126. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  127. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  128. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  129. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  130. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  131. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  132. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  133. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  134. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  135. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  136. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  137. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  138. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  139. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  140. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  141. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  142. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  143. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  144. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  145. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  146. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  147. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  148. spawn_set_values["skin_color"] = SPAWN_SET_SKIN_COLOR;
  149. spawn_set_values["aaxp_rewards"] = SPAWN_SET_AAXP_REWARDS;
  150. spawn_set_values["hair_color1"] = SPAWN_SET_HAIR_COLOR1;
  151. spawn_set_values["hair_color2"] = SPAWN_SET_HAIR_COLOR2;
  152. spawn_set_values["hair_type_color"] = SPAWN_SET_HAIR_TYPE_COLOR;
  153. spawn_set_values["hair_face_color"] = SPAWN_SET_HAIR_FACE_COLOR;
  154. spawn_set_values["hair_type_highlight_color"] = SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR;
  155. spawn_set_values["face_hairlight_color"] = SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR;
  156. spawn_set_values["hair_highlight"] = SPAWN_SET_HAIR_HIGHLIGHT;
  157. spawn_set_values["model_color"] = SPAWN_SET_MODEL_COLOR;
  158. spawn_set_values["eye_color"] = SPAWN_SET_EYE_COLOR;
  159. spawn_set_values["soga_skin_color"] = SPAWN_SET_SOGA_SKIN_COLOR;
  160. spawn_set_values["soga_hair_color1"] = SPAWN_SET_SOGA_HAIR_COLOR1;
  161. spawn_set_values["soga_hair_color2"] = SPAWN_SET_SOGA_HAIR_COLOR2;
  162. spawn_set_values["soga_hair_type_color"] = SPAWN_SET_SOGA_HAIR_TYPE_COLOR;
  163. spawn_set_values["soga_hair_face_color"] = SPAWN_SET_SOGA_HAIR_FACE_COLOR;
  164. spawn_set_values["soga_hair_type_highlight_color"] = SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR;
  165. spawn_set_values["soga_face_hairlight_color"] = SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR;
  166. spawn_set_values["soga_hair_highlight"] = SPAWN_SET_SOGA_HAIR_HIGHLIGHT;
  167. spawn_set_values["soga_model_color"] = SPAWN_SET_SOGA_MODEL_COLOR;
  168. spawn_set_values["soga_eye_color"] = SPAWN_SET_SOGA_EYE_COLOR;
  169. spawn_set_values["cheek_type"] = SPAWN_SET_CHEEK_TYPE;
  170. spawn_set_values["chin_type"] = SPAWN_SET_CHIN_TYPE;
  171. spawn_set_values["ear_type"] = SPAWN_SET_EAR_TYPE;
  172. spawn_set_values["eye_brow_type"] = SPAWN_SET_EYE_BROW_TYPE;
  173. spawn_set_values["eye_type"] = SPAWN_SET_EYE_TYPE;
  174. spawn_set_values["lip_type"] = SPAWN_SET_LIP_TYPE;
  175. spawn_set_values["nose_type"] = SPAWN_SET_NOSE_TYPE;
  176. spawn_set_values["body_size"] = SPAWN_SET_BODY_SIZE;
  177. spawn_set_values["body_age"] = SPAWN_SET_BODY_AGE;
  178. spawn_set_values["soga_cheek_type"] = SPAWN_SET_SOGA_CHEEK_TYPE;
  179. spawn_set_values["soga_chin_type"] = SPAWN_SET_SOGA_CHIN_TYPE;
  180. spawn_set_values["soga_ear_type"] = SPAWN_SET_SOGA_EAR_TYPE;
  181. spawn_set_values["soga_eye_brow_type"] = SPAWN_SET_SOGA_EYE_BROW_TYPE;
  182. spawn_set_values["soga_eye_type"] = SPAWN_SET_SOGA_EYE_TYPE;
  183. spawn_set_values["soga_lip_type"] = SPAWN_SET_SOGA_LIP_TYPE;
  184. spawn_set_values["soga_nose_type"] = SPAWN_SET_SOGA_NOSE_TYPE;
  185. spawn_set_values["soga_body_size"] = SPAWN_SET_SOGA_BODY_SIZE;
  186. spawn_set_values["soga_body_age"] = SPAWN_SET_SOGA_BODY_AGE;
  187. spawn_set_values["attack_type"] = SPAWN_SET_ATTACK_TYPE;
  188. spawn_set_values["race_type"] = SPAWN_SET_RACE_TYPE;
  189. spawn_set_values["loot_tier"] = SPAWN_SET_LOOT_TIER;
  190. spawn_set_values["loot_drop_type"] = SPAWN_SET_LOOT_DROP_TYPE;
  191. spawn_set_values["scared_strong_players"] = SPAWN_SET_SCARED_STRONG_PLAYERS;
  192. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  193. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  194. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  195. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  196. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  197. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  198. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  199. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  200. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  201. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  202. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  203. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  204. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  205. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  206. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  207. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  208. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  209. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  210. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  211. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  212. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  213. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  214. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  215. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  216. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  217. }
  218. Commands::~Commands() {
  219. safe_delete(remote_commands);
  220. }
  221. int32 Commands::GetSpawnSetType(string val){
  222. if(spawn_set_values.count(val) > 0)
  223. return spawn_set_values[val];
  224. return 0xFFFFFFFF;
  225. }
  226. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value, int8 index){
  227. if(!target)
  228. return false;
  229. int32 val = 0;
  230. try{
  231. if(type != SPAWN_SET_VALUE_NAME &&
  232. !(type >= SPAWN_SET_VALUE_SPAWN_SCRIPT && type <= SPAWN_SET_VALUE_SUB_TITLE) && !(type >= SPAWN_SET_VALUE_PREFIX && type <= SPAWN_SET_VALUE_EXPANSION_FLAG || type == SPAWN_SET_VALUE_HOLIDAY_FLAG))
  233. {
  234. switch(type)
  235. {
  236. case SPAWN_SET_SKIN_COLOR:
  237. case SPAWN_SET_HAIR_COLOR1:
  238. case SPAWN_SET_HAIR_COLOR2:
  239. case SPAWN_SET_HAIR_TYPE_COLOR:
  240. case SPAWN_SET_HAIR_FACE_COLOR:
  241. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  242. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  243. case SPAWN_SET_HAIR_HIGHLIGHT:
  244. case SPAWN_SET_EYE_COLOR:
  245. case SPAWN_SET_SOGA_SKIN_COLOR:
  246. case SPAWN_SET_SOGA_HAIR_COLOR1:
  247. case SPAWN_SET_SOGA_HAIR_COLOR2:
  248. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  249. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  250. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  251. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  252. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  253. case SPAWN_SET_SOGA_EYE_COLOR:
  254. case SPAWN_SET_RACE_TYPE:
  255. // ignore these are colors can't pass as a integer value
  256. break;
  257. default:
  258. val = atoul(value);
  259. }
  260. }
  261. }
  262. catch(...){
  263. if(client)
  264. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  265. return false;
  266. }
  267. if(temporary){
  268. char tmp[128] = {0};
  269. switch(type){
  270. case SPAWN_SET_VALUE_NAME:{
  271. sprintf(tmp, "%s", target->GetName());
  272. target->SetName(value);
  273. if(target->GetZone())
  274. target->GetZone()->SendUpdateTitles(target);
  275. break;
  276. }
  277. case SPAWN_SET_VALUE_X_OFFSET:
  278. {
  279. sprintf(tmp, "%f", target->GetXOffset());
  280. target->SetXOffset(float(val));
  281. break;
  282. }
  283. case SPAWN_SET_VALUE_Y_OFFSET:
  284. {
  285. sprintf(tmp, "%f", target->GetYOffset());
  286. target->SetYOffset(float(val));
  287. break;
  288. }
  289. case SPAWN_SET_VALUE_Z_OFFSET:
  290. {
  291. sprintf(tmp, "%f", target->GetZOffset());
  292. target->SetZOffset(float(val));
  293. break;
  294. }
  295. case SPAWN_SET_VALUE_EXPIRE: {
  296. sprintf(tmp, "%u", target->GetExpireTime());
  297. target->SetExpireTime(val);
  298. break;
  299. }
  300. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  301. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  302. target->SetExpireOffsetTime(val);
  303. break;
  304. }
  305. case SPAWN_SET_VALUE_SUB_TITLE: {
  306. sprintf(tmp, "%s", target->GetSubTitle());
  307. target->SetSubTitle(value);
  308. if(target->GetZone())
  309. target->GetZone()->SendUpdateTitles(target);
  310. break;
  311. }
  312. case SPAWN_SET_VALUE_LEVEL:{
  313. sprintf(tmp, "%i", target->GetLevel());
  314. target->SetLevel(val, send_update);
  315. break;
  316. }
  317. case SPAWN_SET_VALUE_DIFFICULTY:{
  318. sprintf(tmp, "%i", target->GetDifficulty());
  319. target->SetDifficulty(val, send_update);
  320. break;
  321. }
  322. case SPAWN_SET_VALUE_MODEL_TYPE:{
  323. sprintf(tmp, "%i", target->GetModelType());
  324. target->SetModelType(val, send_update);
  325. break;
  326. }
  327. case SPAWN_SET_VALUE_CLASS:{
  328. sprintf(tmp, "%i", target->GetAdventureClass());
  329. target->SetAdventureClass(val, send_update);
  330. break;
  331. }
  332. case SPAWN_SET_VALUE_GENDER:{
  333. sprintf(tmp, "%i", target->GetGender());
  334. target->SetGender(val, send_update);
  335. break;
  336. }
  337. case SPAWN_SET_VALUE_SHOW_NAME:{
  338. sprintf(tmp, "%i", target->GetShowName());
  339. target->SetShowName(val, send_update);
  340. break;
  341. }
  342. case SPAWN_SET_VALUE_ATTACKABLE:{
  343. sprintf(tmp, "%i", target->GetAttackable());
  344. target->SetAttackable(val, send_update);
  345. break;
  346. }
  347. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  348. sprintf(tmp, "%i", target->GetShowLevel());
  349. target->SetShowLevel(val, send_update);
  350. break;
  351. }
  352. case SPAWN_SET_VALUE_TARGETABLE:{
  353. sprintf(tmp, "%i", target->GetTargetable());
  354. target->SetTargetable(val, send_update);
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  358. sprintf(tmp, "%i", target->GetShowCommandIcon());
  359. target->SetShowCommandIcon(val, send_update);
  360. break;
  361. }
  362. case SPAWN_SET_VALUE_HAND_ICON:{
  363. sprintf(tmp, "%i", target->GetShowHandIcon());
  364. target->SetShowHandIcon(val, send_update);
  365. break;
  366. }
  367. case SPAWN_SET_VALUE_HAIR_TYPE:{
  368. if(target->IsEntity()){
  369. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  370. ((Entity*)target)->SetHairType(val, send_update);
  371. }
  372. break;
  373. }
  374. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  375. if(target->IsEntity()){
  376. sprintf(tmp, "%i", ((Entity*)target)->GetFacialHairType());
  377. ((Entity*)target)->SetFacialHairType(val, send_update);
  378. }
  379. break;
  380. }
  381. case SPAWN_SET_VALUE_WING_TYPE:{
  382. if(target->IsEntity()){
  383. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  384. ((Entity*)target)->SetWingType(val, send_update);
  385. }
  386. break;
  387. }
  388. case SPAWN_SET_VALUE_CHEST_TYPE:{
  389. if(target->IsEntity()){
  390. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  391. ((Entity*)target)->SetChestType(val, send_update);
  392. }
  393. break;
  394. }
  395. case SPAWN_SET_VALUE_LEGS_TYPE:{
  396. if(target->IsEntity()){
  397. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  398. ((Entity*)target)->SetLegsType(val, send_update);
  399. }
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  403. if(target->IsEntity()){
  404. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  405. ((Entity*)target)->SetSogaHairType(val, send_update);
  406. }
  407. break;
  408. }
  409. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  410. if(target->IsEntity()){
  411. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  412. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  413. }
  414. break;
  415. }
  416. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  417. sprintf(tmp, "%i", target->GetSogaModelType());
  418. target->SetSogaModelType(val, send_update);
  419. break;
  420. }
  421. case SPAWN_SET_VALUE_SIZE:{
  422. sprintf(tmp, "%i", target->GetSize());
  423. target->SetSize(val, send_update);
  424. break;
  425. }
  426. case SPAWN_SET_VALUE_HP:{
  427. sprintf(tmp, "%i", target->GetHP());
  428. target->SetHP(val, send_update);
  429. break;
  430. }
  431. case SPAWN_SET_VALUE_POWER:{
  432. sprintf(tmp, "%i", target->GetPower());
  433. target->SetPower(val, send_update);
  434. break;
  435. }
  436. case SPAWN_SET_VALUE_HEROIC:{
  437. sprintf(tmp, "%i", target->GetHeroic());
  438. target->SetHeroic(val, send_update);
  439. break;
  440. }
  441. case SPAWN_SET_VALUE_RESPAWN:{
  442. sprintf(tmp, "%u", target->GetRespawnTime());
  443. target->SetRespawnTime(val);
  444. break;
  445. }
  446. case SPAWN_SET_VALUE_X:{
  447. sprintf(tmp, "%f", target->GetX());
  448. target->SetX(atof(value), send_update);
  449. break;
  450. }
  451. case SPAWN_SET_VALUE_Y:{
  452. sprintf(tmp, "%f", target->GetY());
  453. target->SetY(atof(value), send_update);
  454. break;
  455. }
  456. case SPAWN_SET_VALUE_Z:{
  457. sprintf(tmp, "%f", target->GetZ());
  458. target->SetZ(atof(value), send_update);
  459. break;
  460. }
  461. case SPAWN_SET_VALUE_HEADING:{
  462. sprintf(tmp, "%f", target->GetHeading());
  463. target->SetHeading(atof(value) + 360, send_update);
  464. break;
  465. }
  466. case SPAWN_SET_VALUE_VISUAL_STATE:{
  467. sprintf(tmp, "%i", target->GetVisualState());
  468. target->SetVisualState(val, send_update);
  469. break;
  470. }
  471. case SPAWN_SET_VALUE_ACTION_STATE:{
  472. sprintf(tmp, "%i", target->GetActionState());
  473. target->SetActionState(val, send_update);
  474. break;
  475. }
  476. case SPAWN_SET_VALUE_MOOD_STATE:{
  477. sprintf(tmp, "%i", target->GetMoodState());
  478. target->SetMoodState(val, send_update);
  479. break;
  480. }
  481. case SPAWN_SET_VALUE_INITIAL_STATE:{
  482. sprintf(tmp, "%i", target->GetInitialState());
  483. target->SetInitialState(val, send_update);
  484. break;
  485. }
  486. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  487. sprintf(tmp, "%i", target->GetActivityStatus());
  488. target->SetActivityStatus(val, send_update);
  489. break;
  490. }
  491. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  492. sprintf(tmp, "%i", target->GetCollisionRadius());
  493. target->SetCollisionRadius(val, send_update);
  494. break;
  495. }
  496. case SPAWN_SET_VALUE_DEVICE_ID: {
  497. if (target->IsObject()) {
  498. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  499. ((Object*)target)->SetDeviceID(val);
  500. }
  501. break;
  502. }
  503. case SPAWN_SET_VALUE_PITCH: {
  504. sprintf(tmp, "%f", target->GetPitch());
  505. target->SetPitch(atof(value), send_update);
  506. break;
  507. }
  508. case SPAWN_SET_VALUE_ROLL: {
  509. sprintf(tmp, "%f", target->GetRoll());
  510. target->SetRoll(atof(value), send_update);
  511. break;
  512. }
  513. case SPAWN_SET_VALUE_HIDE_HOOD: {
  514. sprintf(tmp, "%i", target->appearance.hide_hood);
  515. target->SetHideHood(val);
  516. break;
  517. }
  518. case SPAWN_SET_VALUE_EMOTE_STATE: {
  519. sprintf(tmp, "%i", target->appearance.emote_state);
  520. target->SetEmoteState(val);
  521. break;
  522. }
  523. case SPAWN_SET_VALUE_ICON: {
  524. sprintf(tmp, "%i", target->GetIconValue());
  525. target->SetIcon(val);
  526. break;
  527. }
  528. case SPAWN_SET_VALUE_PREFIX: {
  529. sprintf(tmp, "%s", target->GetPrefixTitle());
  530. target->SetPrefixTitle(value);
  531. if(target->GetZone())
  532. target->GetZone()->SendUpdateTitles(target);
  533. break;
  534. }
  535. case SPAWN_SET_VALUE_SUFFIX: {
  536. sprintf(tmp, "%s", target->GetSuffixTitle());
  537. target->SetSuffixTitle(value);
  538. if(target->GetZone())
  539. target->GetZone()->SendUpdateTitles(target);
  540. break;
  541. }
  542. case SPAWN_SET_VALUE_LASTNAME: {
  543. sprintf(tmp, "%s", target->GetLastName());
  544. target->SetLastName(value);
  545. if(target->GetZone())
  546. target->GetZone()->SendUpdateTitles(target);
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  550. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  551. // nothing to do must reload spawns
  552. break;
  553. }
  554. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  555. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  556. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  557. break;
  558. }
  559. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  560. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  561. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  562. break;
  563. }
  564. case SPAWN_SET_VALUE_FACTION:{
  565. sprintf(tmp, "%i", target->faction_id);
  566. ZoneServer* zone = target->GetZone();
  567. if (!zone && client)
  568. zone = client->GetCurrentZone();
  569. target->faction_id = atoul(value);
  570. if(zone)
  571. {
  572. zone->RemoveDeadEnemyList(target);
  573. if(target->IsNPC())
  574. zone->AddEnemyList((NPC*)target);
  575. }
  576. break;
  577. }
  578. case SPAWN_SET_SKIN_COLOR:
  579. case SPAWN_SET_HAIR_COLOR1:
  580. case SPAWN_SET_HAIR_COLOR2:
  581. case SPAWN_SET_HAIR_TYPE_COLOR:
  582. case SPAWN_SET_HAIR_FACE_COLOR:
  583. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  584. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  585. case SPAWN_SET_HAIR_HIGHLIGHT:
  586. case SPAWN_SET_MODEL_COLOR:
  587. case SPAWN_SET_EYE_COLOR:
  588. case SPAWN_SET_SOGA_SKIN_COLOR:
  589. case SPAWN_SET_SOGA_HAIR_COLOR1:
  590. case SPAWN_SET_SOGA_HAIR_COLOR2:
  591. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  592. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  593. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  594. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  595. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  596. case SPAWN_SET_SOGA_MODEL_COLOR:
  597. case SPAWN_SET_SOGA_EYE_COLOR:
  598. {
  599. if (target->IsEntity())
  600. {
  601. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  602. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  603. {
  604. EQ2_Color clr;
  605. clr.red = atoul(skinsep->arg[0]);
  606. clr.green = atoul(skinsep->arg[1]);
  607. clr.blue = atoul(skinsep->arg[2]);
  608. switch(type)
  609. {
  610. case SPAWN_SET_SKIN_COLOR:
  611. ((Entity*)target)->SetSkinColor(clr);
  612. break;
  613. case SPAWN_SET_HAIR_COLOR1:
  614. ((Entity*)target)->SetHairColor1(clr);
  615. break;
  616. case SPAWN_SET_HAIR_COLOR2:
  617. ((Entity*)target)->SetHairColor2(clr);
  618. break;
  619. case SPAWN_SET_HAIR_TYPE_COLOR:
  620. ((Entity*)target)->SetHairColor(clr);
  621. break;
  622. case SPAWN_SET_HAIR_FACE_COLOR:
  623. ((Entity*)target)->SetFacialHairColor(clr);
  624. break;
  625. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  626. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  627. break;
  628. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  629. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  630. break;
  631. case SPAWN_SET_HAIR_HIGHLIGHT:
  632. ((Entity*)target)->SetHairHighlightColor(clr);
  633. break;
  634. case SPAWN_SET_MODEL_COLOR:
  635. ((Entity*)target)->SetModelColor(clr);
  636. break;
  637. case SPAWN_SET_EYE_COLOR:
  638. ((Entity*)target)->SetEyeColor(clr);
  639. break;
  640. case SPAWN_SET_SOGA_SKIN_COLOR:
  641. ((Entity*)target)->SetSogaSkinColor(clr);
  642. break;
  643. case SPAWN_SET_SOGA_HAIR_COLOR1:
  644. ((Entity*)target)->SetSogaHairColor1(clr);
  645. break;
  646. case SPAWN_SET_SOGA_HAIR_COLOR2:
  647. ((Entity*)target)->SetSogaHairColor2(clr);
  648. break;
  649. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  650. ((Entity*)target)->SetSogaHairColor(clr);
  651. break;
  652. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  653. ((Entity*)target)->SetSogaFacialHairColor(clr);
  654. break;
  655. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  656. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  657. break;
  658. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  659. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  660. break;
  661. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  662. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  663. break;
  664. case SPAWN_SET_SOGA_MODEL_COLOR:
  665. ((Entity*)target)->SetSogaModelColor(clr);
  666. break;
  667. case SPAWN_SET_SOGA_EYE_COLOR:
  668. ((Entity*)target)->SetSogaEyeColor(clr);
  669. break;
  670. }
  671. }
  672. safe_delete(skinsep);
  673. }
  674. break;
  675. }
  676. case SPAWN_SET_AAXP_REWARDS: {
  677. target->SetAAXPRewards(atoul(value));
  678. break;
  679. }
  680. case SPAWN_SET_CHEEK_TYPE:{
  681. if(target->IsEntity() && index < 3){
  682. sprintf(tmp, "%i", ((Entity*)target)->features.cheek_type[index]);
  683. sint8 new_value = atoi(value);
  684. ((Entity*)target)->features.cheek_type[index] = new_value;
  685. ((Entity*)target)->info_changed = true;
  686. }
  687. break;
  688. }
  689. case SPAWN_SET_CHIN_TYPE:{
  690. if(target->IsEntity() && index < 3){
  691. sprintf(tmp, "%i", ((Entity*)target)->features.chin_type[index]);
  692. sint8 new_value = atoi(value);
  693. ((Entity*)target)->features.chin_type[index] = new_value;
  694. ((Entity*)target)->info_changed = true;
  695. }
  696. break;
  697. }
  698. case SPAWN_SET_EAR_TYPE:{
  699. if(target->IsEntity() && index < 3){
  700. sprintf(tmp, "%i", ((Entity*)target)->features.ear_type[index]);
  701. sint8 new_value = atoi(value);
  702. ((Entity*)target)->features.ear_type[index] = new_value;
  703. ((Entity*)target)->info_changed = true;
  704. }
  705. break;
  706. }
  707. case SPAWN_SET_EYE_BROW_TYPE:{
  708. if(target->IsEntity() && index < 3){
  709. sprintf(tmp, "%i", ((Entity*)target)->features.eye_brow_type[index]);
  710. sint8 new_value = atoi(value);
  711. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  712. ((Entity*)target)->info_changed = true;
  713. }
  714. break;
  715. }
  716. case SPAWN_SET_EYE_TYPE:{
  717. if(target->IsEntity() && index < 3){
  718. sprintf(tmp, "%i", ((Entity*)target)->features.eye_type[index]);
  719. sint8 new_value = atoi(value);
  720. ((Entity*)target)->features.eye_type[index] = new_value;
  721. ((Entity*)target)->info_changed = true;
  722. }
  723. break;
  724. }
  725. case SPAWN_SET_LIP_TYPE:{
  726. if(target->IsEntity() && index < 3){
  727. sprintf(tmp, "%i", ((Entity*)target)->features.lip_type[index]);
  728. sint8 new_value = atoi(value);
  729. ((Entity*)target)->features.lip_type[index] = new_value;
  730. ((Entity*)target)->info_changed = true;
  731. }
  732. break;
  733. }
  734. case SPAWN_SET_NOSE_TYPE:{
  735. if(target->IsEntity() && index < 3){
  736. sprintf(tmp, "%i", ((Entity*)target)->features.nose_type[index]);
  737. sint8 new_value = atoi(value);
  738. ((Entity*)target)->features.nose_type[index] = new_value;
  739. ((Entity*)target)->info_changed = true;
  740. }
  741. break;
  742. }
  743. case SPAWN_SET_BODY_SIZE:{
  744. if(target->IsEntity()){
  745. sprintf(tmp, "%i", ((Entity*)target)->features.body_size);
  746. int8 new_value = atoul(value);
  747. ((Entity*)target)->features.body_size = new_value;
  748. ((Entity*)target)->info_changed = true;
  749. }
  750. break;
  751. }
  752. case SPAWN_SET_BODY_AGE:{
  753. if(target->IsEntity()){
  754. sprintf(tmp, "%i", ((Entity*)target)->features.body_age);
  755. int8 new_value = atoul(value);
  756. ((Entity*)target)->features.body_age = new_value;
  757. ((Entity*)target)->info_changed = true;
  758. }
  759. break;
  760. }
  761. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  762. if(target->IsEntity() && index < 3){
  763. sprintf(tmp, "%i", ((Entity*)target)->features.soga_cheek_type[index]);
  764. sint8 new_value = atoi(value);
  765. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  766. ((Entity*)target)->info_changed = true;
  767. }
  768. break;
  769. }
  770. case SPAWN_SET_SOGA_CHIN_TYPE:{
  771. if(target->IsEntity() && index < 3){
  772. sprintf(tmp, "%i", ((Entity*)target)->features.soga_chin_type[index]);
  773. sint8 new_value = atoi(value);
  774. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  775. ((Entity*)target)->info_changed = true;
  776. }
  777. break;
  778. }
  779. case SPAWN_SET_SOGA_EAR_TYPE:{
  780. if(target->IsEntity() && index < 3){
  781. sprintf(tmp, "%i", ((Entity*)target)->features.soga_ear_type[index]);
  782. sint8 new_value = atoi(value);
  783. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  784. ((Entity*)target)->info_changed = true;
  785. }
  786. break;
  787. }
  788. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  789. if(target->IsEntity() && index < 3){
  790. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_brow_type[index]);
  791. sint8 new_value = atoi(value);
  792. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  793. ((Entity*)target)->info_changed = true;
  794. }
  795. break;
  796. }
  797. case SPAWN_SET_SOGA_EYE_TYPE:{
  798. if(target->IsEntity() && index < 3){
  799. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_type[index]);
  800. sint8 new_value = atoi(value);
  801. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  802. ((Entity*)target)->info_changed = true;
  803. }
  804. break;
  805. }
  806. case SPAWN_SET_SOGA_LIP_TYPE:{
  807. if(target->IsEntity() && index < 3){
  808. sprintf(tmp, "%i", ((Entity*)target)->features.soga_lip_type[index]);
  809. sint8 new_value = atoi(value);
  810. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  811. ((Entity*)target)->info_changed = true;
  812. }
  813. break;
  814. }
  815. case SPAWN_SET_SOGA_BODY_SIZE:{
  816. if(target->IsEntity()){
  817. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_size);
  818. int8 new_value = atoul(value);
  819. ((Entity*)target)->features.soga_body_size = new_value;
  820. ((Entity*)target)->info_changed = true;
  821. }
  822. break;
  823. }
  824. case SPAWN_SET_SOGA_BODY_AGE:{
  825. if(target->IsEntity()){
  826. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_age);
  827. int8 new_value = atoul(value);
  828. ((Entity*)target)->features.soga_body_age = new_value;
  829. ((Entity*)target)->info_changed = true;
  830. }
  831. break;
  832. }
  833. case SPAWN_SET_ATTACK_TYPE:{
  834. if(target->IsEntity()){
  835. sprintf(tmp, "%u", ((Entity*)target)->GetInfoStruct()->get_attack_type());
  836. int8 new_value = atoul(value);
  837. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  838. }
  839. break;
  840. }
  841. case SPAWN_SET_RACE_TYPE:{
  842. if(target->GetModelType() > 0){
  843. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  844. if (tmpsep->IsNumber(0))
  845. {
  846. int16 race_type = atoul(value);
  847. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  848. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  849. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  850. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  851. if(client) {
  852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Race type added to memory, however not saved to database.");
  853. }
  854. }
  855. else {
  856. client->SimpleMessage(CHANNEL_COLOR_RED, "Model type already on the race_types_list, use spawn set database to override and update database.");
  857. }
  858. }
  859. safe_delete(tmpsep);
  860. }
  861. break;
  862. }
  863. case SPAWN_SET_LOOT_TIER:{
  864. if(target->IsEntity()){
  865. sprintf(tmp, "%u", target->GetLootTier());
  866. int32 new_value = atoul(value);
  867. target->SetLootTier(new_value);
  868. }
  869. break;
  870. }
  871. case SPAWN_SET_LOOT_DROP_TYPE:{
  872. if(target->IsEntity()){
  873. sprintf(tmp, "%u", target->GetLootDropType());
  874. int32 new_value = atoul(value);
  875. target->SetLootDropType(new_value);
  876. }
  877. break;
  878. }
  879. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  880. if(target->IsNPC()){
  881. sprintf(tmp, "%u", target->IsScaredByStrongPlayers());
  882. int32 new_value = atoul(value);
  883. target->SetScaredByStrongPlayers(new_value);
  884. }
  885. break;
  886. }
  887. if(temp_value)
  888. *temp_value = string(tmp);
  889. }
  890. }
  891. else{
  892. /**** NOT TEMPORARY ELSE STATEMENT ****/
  893. /**** MUST RE-DEFINE WHAT IS ALREADY IN THE IF TEMPORARY BLOCK HERE ****/
  894. switch(type){
  895. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  896. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  897. break;
  898. }
  899. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  900. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  901. break;
  902. }
  903. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  904. if (target->GetDatabaseID() > 0)
  905. {
  906. char query[256];
  907. snprintf(query, 256, "update spawn set expansion_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  908. if (database.RunQuery(query, strnlen(query, 256)))
  909. {
  910. if(client)
  911. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  912. }
  913. }
  914. break;
  915. }
  916. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  917. if (target->GetDatabaseID() > 0)
  918. {
  919. char query[256];
  920. snprintf(query, 256, "update spawn set holiday_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  921. if (database.RunQuery(query, strnlen(query, 256)))
  922. {
  923. if(client)
  924. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  925. }
  926. }
  927. break;
  928. }
  929. case SPAWN_SET_AAXP_REWARDS: {
  930. if (target->GetDatabaseID() > 0)
  931. {
  932. char query[256];
  933. snprintf(query, 256, "update spawn set aaxp_rewards=%u where id=%u", atoul(value), target->GetDatabaseID());
  934. if (database.RunQuery(query, strnlen(query, 256)))
  935. {
  936. if(client)
  937. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  938. }
  939. }
  940. break;
  941. }
  942. case SPAWN_SET_VALUE_NAME:{
  943. target->SetName(value);
  944. if(target->GetZone())
  945. target->GetZone()->SendUpdateTitles(target);
  946. break;
  947. }
  948. case SPAWN_SET_VALUE_SUB_TITLE: {
  949. target->SetSubTitle(value);
  950. if(target->GetZone())
  951. target->GetZone()->SendUpdateTitles(target);
  952. break;
  953. }
  954. case SPAWN_SET_VALUE_X_OFFSET:
  955. {
  956. target->SetXOffset(atof(value));
  957. break;
  958. }
  959. case SPAWN_SET_VALUE_Y_OFFSET:
  960. {
  961. target->SetYOffset(atof(value));
  962. break;
  963. }
  964. case SPAWN_SET_VALUE_Z_OFFSET:
  965. {
  966. target->SetZOffset(atof(value));
  967. break;
  968. }
  969. case SPAWN_SET_VALUE_EXPIRE: {
  970. target->SetExpireTime(val);
  971. break;
  972. }
  973. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  974. target->SetExpireOffsetTime(val);
  975. break;
  976. }
  977. case SPAWN_SET_VALUE_LEVEL:{
  978. target->SetLevel(val, send_update);
  979. break;
  980. }
  981. case SPAWN_SET_VALUE_DIFFICULTY:{
  982. target->SetDifficulty(val, send_update);
  983. break;
  984. }
  985. case SPAWN_SET_VALUE_MODEL_TYPE:{
  986. target->SetModelType(val, send_update);
  987. break;
  988. }
  989. case SPAWN_SET_VALUE_CLASS:{
  990. target->SetAdventureClass(val, send_update);
  991. break;
  992. }
  993. case SPAWN_SET_VALUE_GENDER:{
  994. target->SetGender(val, send_update);
  995. break;
  996. }
  997. case SPAWN_SET_VALUE_SHOW_NAME:{
  998. target->SetShowName(val, send_update);
  999. break;
  1000. }
  1001. case SPAWN_SET_VALUE_ATTACKABLE:{
  1002. target->SetAttackable(val, send_update);
  1003. break;
  1004. }
  1005. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  1006. target->SetShowLevel(val, send_update);
  1007. break;
  1008. }
  1009. case SPAWN_SET_VALUE_TARGETABLE:{
  1010. target->SetTargetable(val, send_update);
  1011. break;
  1012. }
  1013. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  1014. target->SetShowCommandIcon(val, send_update);
  1015. break;
  1016. }
  1017. case SPAWN_SET_VALUE_HAND_ICON:{
  1018. target->SetShowHandIcon(val, send_update);
  1019. break;
  1020. }
  1021. case SPAWN_SET_VALUE_HAIR_TYPE:{
  1022. if(target->IsEntity())
  1023. ((Entity*)target)->SetHairType(val, send_update);
  1024. break;
  1025. }
  1026. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  1027. if(target->IsEntity())
  1028. ((Entity*)target)->SetFacialHairType(val, send_update);
  1029. break;
  1030. }
  1031. case SPAWN_SET_VALUE_WING_TYPE:{
  1032. if(target->IsEntity())
  1033. ((Entity*)target)->SetWingType(val, send_update);
  1034. break;
  1035. }
  1036. case SPAWN_SET_VALUE_CHEST_TYPE:{
  1037. if(target->IsEntity())
  1038. ((Entity*)target)->SetChestType(val, send_update);
  1039. break;
  1040. }
  1041. case SPAWN_SET_VALUE_LEGS_TYPE:{
  1042. if(target->IsEntity())
  1043. ((Entity*)target)->SetLegsType(val, send_update);
  1044. break;
  1045. }
  1046. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  1047. if(target->IsEntity())
  1048. ((Entity*)target)->SetSogaHairType(val, send_update);
  1049. break;
  1050. }
  1051. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  1052. if(target->IsEntity())
  1053. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  1054. break;
  1055. }
  1056. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  1057. target->SetSogaModelType(val, send_update);
  1058. break;
  1059. }
  1060. case SPAWN_SET_VALUE_SIZE:{
  1061. target->SetSize(val, send_update);
  1062. break;
  1063. }
  1064. case SPAWN_SET_VALUE_HP:{
  1065. target->SetHP(val, send_update);
  1066. break;
  1067. }
  1068. case SPAWN_SET_VALUE_POWER:{
  1069. target->SetPower(val, send_update);
  1070. break;
  1071. }
  1072. case SPAWN_SET_VALUE_HEROIC:{
  1073. target->SetHeroic(val, send_update);
  1074. break;
  1075. }
  1076. case SPAWN_SET_VALUE_RESPAWN:{
  1077. target->SetRespawnTime(val);
  1078. break;
  1079. }
  1080. case SPAWN_SET_VALUE_X:{
  1081. target->SetX(atof(value), send_update);
  1082. target->SetSpawnOrigX(target->GetX());
  1083. break;
  1084. }
  1085. case SPAWN_SET_VALUE_Y:{
  1086. target->SetY(atof(value), send_update);
  1087. target->SetSpawnOrigY(target->GetY());
  1088. break;
  1089. }
  1090. case SPAWN_SET_VALUE_Z:{
  1091. target->SetZ(atof(value), send_update);
  1092. target->SetSpawnOrigZ(target->GetZ());
  1093. break;
  1094. }
  1095. case SPAWN_SET_VALUE_HEADING:{
  1096. target->SetHeading(atof(value), send_update);
  1097. target->SetSpawnOrigHeading(target->GetHeading());
  1098. break;
  1099. }
  1100. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  1101. ZoneServer* zone = target->GetZone();
  1102. if (!zone && client)
  1103. zone = client->GetCurrentZone();
  1104. if(zone && zone->GetEntityCommandList(val))
  1105. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  1106. target->primary_command_list_id = val;
  1107. break;
  1108. }
  1109. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  1110. ZoneServer* zone = target->GetZone();
  1111. if (!zone && client)
  1112. zone = client->GetCurrentZone();
  1113. if (zone && zone->GetEntityCommandList(val))
  1114. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  1115. target->secondary_command_list_id = val;
  1116. break;
  1117. }
  1118. case SPAWN_SET_VALUE_VISUAL_STATE:{
  1119. target->SetVisualState(val, send_update);
  1120. break;
  1121. }
  1122. case SPAWN_SET_VALUE_ACTION_STATE:{
  1123. target->SetActionState(val, send_update);
  1124. break;
  1125. }
  1126. case SPAWN_SET_VALUE_MOOD_STATE:{
  1127. target->SetMoodState(val, send_update);
  1128. break;
  1129. }
  1130. case SPAWN_SET_VALUE_INITIAL_STATE:{
  1131. target->SetInitialState(val, send_update);
  1132. break;
  1133. }
  1134. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  1135. target->SetActivityStatus(val, send_update);
  1136. break;
  1137. }
  1138. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  1139. target->SetCollisionRadius(val, send_update);
  1140. break;
  1141. }
  1142. case SPAWN_SET_VALUE_FACTION:{
  1143. ZoneServer* zone = target->GetZone();
  1144. if (!zone && client)
  1145. zone = client->GetCurrentZone();
  1146. target->faction_id = val;
  1147. if(zone)
  1148. {
  1149. zone->RemoveDeadEnemyList(target);
  1150. if(target->IsNPC())
  1151. zone->AddEnemyList((NPC*)target);
  1152. }
  1153. break;
  1154. }
  1155. case SPAWN_SET_VALUE_DEVICE_ID:{
  1156. if (target->IsObject())
  1157. ((Object*)target)->SetDeviceID(val);
  1158. break;
  1159. }
  1160. case SPAWN_SET_VALUE_PITCH: {
  1161. target->SetPitch(atof(value), send_update);
  1162. target->SetSpawnOrigPitch(atof(value));
  1163. break;
  1164. }
  1165. case SPAWN_SET_VALUE_ROLL: {
  1166. target->SetRoll(atof(value), send_update);
  1167. target->SetSpawnOrigRoll(atof(value));
  1168. break;
  1169. }
  1170. case SPAWN_SET_VALUE_HIDE_HOOD: {
  1171. target->SetHideHood(val);
  1172. break;
  1173. }
  1174. case SPAWN_SET_VALUE_EMOTE_STATE: {
  1175. target->SetEmoteState(val);
  1176. break;
  1177. }
  1178. case SPAWN_SET_VALUE_ICON: {
  1179. target->SetIcon(val);
  1180. break;
  1181. }
  1182. case SPAWN_SET_VALUE_PREFIX: {
  1183. target->SetPrefixTitle(value);
  1184. if(target->GetZone())
  1185. target->GetZone()->SendUpdateTitles(target);
  1186. break;
  1187. }
  1188. case SPAWN_SET_VALUE_SUFFIX: {
  1189. target->SetSuffixTitle(value);
  1190. if(target->GetZone())
  1191. target->GetZone()->SendUpdateTitles(target);
  1192. break;
  1193. }
  1194. case SPAWN_SET_VALUE_LASTNAME: {
  1195. target->SetLastName(value);
  1196. if(target->GetZone())
  1197. target->GetZone()->SendUpdateTitles(target);
  1198. break;
  1199. }
  1200. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  1201. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1202. if(client){
  1203. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1204. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  1205. }
  1206. return false;
  1207. }
  1208. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  1209. return false;
  1210. else{
  1211. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  1212. target->SetSpawnScript(value);
  1213. }
  1214. break;
  1215. }
  1216. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  1217. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1218. if(client){
  1219. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1220. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  1221. }
  1222. return false;
  1223. }
  1224. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  1225. return false;
  1226. else{
  1227. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  1228. target->SetSpawnScript(value);
  1229. }
  1230. break;
  1231. }
  1232. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  1233. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1234. if(client){
  1235. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1236. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  1237. }
  1238. return false;
  1239. }
  1240. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  1241. return false;
  1242. else
  1243. target->SetSpawnScript(value);
  1244. break;
  1245. }
  1246. case SPAWN_SET_SKIN_COLOR:
  1247. case SPAWN_SET_HAIR_COLOR1:
  1248. case SPAWN_SET_HAIR_COLOR2:
  1249. case SPAWN_SET_HAIR_TYPE_COLOR:
  1250. case SPAWN_SET_HAIR_FACE_COLOR:
  1251. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1252. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1253. case SPAWN_SET_HAIR_HIGHLIGHT:
  1254. case SPAWN_SET_MODEL_COLOR:
  1255. case SPAWN_SET_EYE_COLOR:
  1256. case SPAWN_SET_SOGA_SKIN_COLOR:
  1257. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1258. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1259. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1260. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1261. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1262. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1263. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1264. case SPAWN_SET_SOGA_MODEL_COLOR:
  1265. case SPAWN_SET_SOGA_EYE_COLOR: {
  1266. if (target->IsNPC())
  1267. {
  1268. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  1269. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  1270. {
  1271. EQ2_Color clr;
  1272. clr.red = atoul(skinsep->arg[0]);
  1273. clr.green = atoul(skinsep->arg[1]);
  1274. clr.blue = atoul(skinsep->arg[2]);
  1275. Query replaceSkinQuery;
  1276. string fieldName("");
  1277. switch(type)
  1278. {
  1279. case SPAWN_SET_SKIN_COLOR:
  1280. ((Entity*)target)->SetSkinColor(clr);
  1281. fieldName.append("skin_color");
  1282. break;
  1283. case SPAWN_SET_HAIR_COLOR1:
  1284. ((Entity*)target)->SetHairColor1(clr);
  1285. fieldName.append("hair_color1");
  1286. break;
  1287. case SPAWN_SET_HAIR_COLOR2:
  1288. ((Entity*)target)->SetHairColor2(clr);
  1289. fieldName.append("hair_color2");
  1290. break;
  1291. case SPAWN_SET_HAIR_TYPE_COLOR:
  1292. ((Entity*)target)->SetHairColor(clr);
  1293. fieldName.append("hair_type_color");
  1294. break;
  1295. case SPAWN_SET_HAIR_FACE_COLOR:
  1296. ((Entity*)target)->SetFacialHairColor(clr);
  1297. fieldName.append("hair_face_color");
  1298. break;
  1299. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1300. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  1301. fieldName.append("hair_type_highlight_color");
  1302. break;
  1303. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1304. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  1305. fieldName.append("hair_face_highlight_color");
  1306. break;
  1307. case SPAWN_SET_HAIR_HIGHLIGHT:
  1308. ((Entity*)target)->SetHairHighlightColor(clr);
  1309. fieldName.append("hair_highlight");
  1310. break;
  1311. case SPAWN_SET_MODEL_COLOR:
  1312. ((Entity*)target)->SetModelColor(clr);
  1313. fieldName.append("model_color");
  1314. break;
  1315. case SPAWN_SET_EYE_COLOR:
  1316. ((Entity*)target)->SetEyeColor(clr);
  1317. fieldName.append("eye_color");
  1318. break;
  1319. case SPAWN_SET_SOGA_SKIN_COLOR:
  1320. ((Entity*)target)->SetSogaSkinColor(clr);
  1321. fieldName.append("soga_skin_color");
  1322. break;
  1323. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1324. ((Entity*)target)->SetSogaHairColor1(clr);
  1325. fieldName.append("soga_hair_color1");
  1326. break;
  1327. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1328. ((Entity*)target)->SetSogaHairColor2(clr);
  1329. fieldName.append("soga_hair_color2");
  1330. break;
  1331. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1332. ((Entity*)target)->SetSogaHairColor(clr);
  1333. fieldName.append("soga_hair_type_color");
  1334. break;
  1335. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1336. ((Entity*)target)->SetSogaFacialHairColor(clr);
  1337. fieldName.append("soga_hair_face_color");
  1338. break;
  1339. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1340. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  1341. fieldName.append("soga_hair_type_highlight_color");
  1342. break;
  1343. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1344. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  1345. fieldName.append("soga_hair_face_highlight_color");
  1346. break;
  1347. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1348. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  1349. fieldName.append("soga_hair_highlight");
  1350. break;
  1351. case SPAWN_SET_SOGA_MODEL_COLOR:
  1352. ((Entity*)target)->SetSogaModelColor(clr);
  1353. fieldName.append("soga_model_color");
  1354. break;
  1355. case SPAWN_SET_SOGA_EYE_COLOR:
  1356. ((Entity*)target)->SetSogaEyeColor(clr);
  1357. fieldName.append("soga_eye_color");
  1358. break;
  1359. }
  1360. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1361. replaceSkinQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into npc_appearance set spawn_id=%u, type='%s', red=%u, green=%u, blue=%u", target->GetDatabaseID(), fieldName.c_str(), clr.red, clr.green, clr.blue);
  1362. }
  1363. safe_delete(skinsep);
  1364. }
  1365. break;
  1366. }
  1367. case SPAWN_SET_CHEEK_TYPE:{
  1368. if(target->IsEntity() && index < 3){
  1369. sint8 new_value = atoi(value);
  1370. ((Entity*)target)->features.cheek_type[index] = new_value;
  1371. UpdateDatabaseAppearance(client, target, "cheek_type", ((Entity*)target)->features.cheek_type[0], ((Entity*)target)->features.cheek_type[1], ((Entity*)target)->features.cheek_type[2]);
  1372. }
  1373. break;
  1374. }
  1375. case SPAWN_SET_CHIN_TYPE:{
  1376. if(target->IsEntity() && index < 3){
  1377. sint8 new_value = atoi(value);
  1378. ((Entity*)target)->features.chin_type[index] = new_value;
  1379. UpdateDatabaseAppearance(client, target, "chin_type", ((Entity*)target)->features.chin_type[0], ((Entity*)target)->features.chin_type[1], ((Entity*)target)->features.chin_type[2]);
  1380. }
  1381. break;
  1382. }
  1383. case SPAWN_SET_EAR_TYPE:{
  1384. if(target->IsEntity() && index < 3){
  1385. sint8 new_value = atoi(value);
  1386. ((Entity*)target)->features.ear_type[index] = new_value;
  1387. UpdateDatabaseAppearance(client, target, "ear_type", ((Entity*)target)->features.ear_type[0], ((Entity*)target)->features.ear_type[1], ((Entity*)target)->features.ear_type[2]);
  1388. }
  1389. break;
  1390. }
  1391. case SPAWN_SET_EYE_BROW_TYPE:{
  1392. if(target->IsEntity() && index < 3){
  1393. sint8 new_value = atoi(value);
  1394. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  1395. UpdateDatabaseAppearance(client, target, "eye_brow_type", ((Entity*)target)->features.eye_brow_type[0], ((Entity*)target)->features.eye_brow_type[1], ((Entity*)target)->features.eye_brow_type[2]);
  1396. }
  1397. break;
  1398. }
  1399. case SPAWN_SET_EYE_TYPE:{
  1400. if(target->IsEntity() && index < 3){
  1401. sint8 new_value = atoi(value);
  1402. ((Entity*)target)->features.eye_type[index] = new_value;
  1403. UpdateDatabaseAppearance(client, target, "eye_type", ((Entity*)target)->features.eye_type[0], ((Entity*)target)->features.eye_type[1], ((Entity*)target)->features.eye_type[2]);
  1404. }
  1405. break;
  1406. }
  1407. case SPAWN_SET_LIP_TYPE:{
  1408. if(target->IsEntity() && index < 3){
  1409. sint8 new_value = atoi(value);
  1410. ((Entity*)target)->features.lip_type[index] = new_value;
  1411. UpdateDatabaseAppearance(client, target, "lip_type", ((Entity*)target)->features.lip_type[0], ((Entity*)target)->features.lip_type[1], ((Entity*)target)->features.lip_type[2]);
  1412. }
  1413. break;
  1414. }
  1415. case SPAWN_SET_NOSE_TYPE:{
  1416. if(target->IsEntity() && index < 3){
  1417. sint8 new_value = atoi(value);
  1418. ((Entity*)target)->features.nose_type[index] = new_value;
  1419. UpdateDatabaseAppearance(client, target, "nose_type", ((Entity*)target)->features.nose_type[0], ((Entity*)target)->features.nose_type[1], ((Entity*)target)->features.nose_type[2]);
  1420. }
  1421. break;
  1422. }
  1423. case SPAWN_SET_BODY_SIZE:{
  1424. if(target->IsEntity()){
  1425. int8 new_value = atoul(value);
  1426. ((Entity*)target)->features.body_size = new_value;
  1427. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1428. }
  1429. break;
  1430. }
  1431. case SPAWN_SET_BODY_AGE:{
  1432. if(target->IsEntity()){
  1433. int8 new_value = atoul(value);
  1434. ((Entity*)target)->features.body_age = new_value;
  1435. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1436. }
  1437. break;
  1438. }
  1439. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  1440. if(target->IsEntity() && index < 3){
  1441. sint8 new_value = atoi(value);
  1442. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  1443. UpdateDatabaseAppearance(client, target, "soga_cheek_type", ((Entity*)target)->features.soga_cheek_type[0], ((Entity*)target)->features.soga_cheek_type[1], ((Entity*)target)->features.soga_cheek_type[2]);
  1444. }
  1445. break;
  1446. }
  1447. case SPAWN_SET_SOGA_CHIN_TYPE:{
  1448. if(target->IsEntity() && index < 3){
  1449. sint8 new_value = atoi(value);
  1450. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  1451. UpdateDatabaseAppearance(client, target, "soga_chin_type", ((Entity*)target)->features.soga_chin_type[0], ((Entity*)target)->features.soga_chin_type[1], ((Entity*)target)->features.soga_chin_type[2]);
  1452. }
  1453. break;
  1454. }
  1455. case SPAWN_SET_SOGA_EAR_TYPE:{
  1456. if(target->IsEntity() && index < 3){
  1457. sint8 new_value = atoi(value);
  1458. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  1459. UpdateDatabaseAppearance(client, target, "soga_ear_type", ((Entity*)target)->features.soga_ear_type[0], ((Entity*)target)->features.soga_ear_type[1], ((Entity*)target)->features.soga_ear_type[2]);
  1460. }
  1461. break;
  1462. }
  1463. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  1464. if(target->IsEntity() && index < 3){
  1465. sint8 new_value = atoi(value);
  1466. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  1467. UpdateDatabaseAppearance(client, target, "soga_eye_brow_type", ((Entity*)target)->features.soga_eye_brow_type[0], ((Entity*)target)->features.soga_eye_brow_type[1], ((Entity*)target)->features.soga_eye_brow_type[2]);
  1468. }
  1469. break;
  1470. }
  1471. case SPAWN_SET_SOGA_EYE_TYPE:{
  1472. if(target->IsEntity() && index < 3){
  1473. sint8 new_value = atoi(value);
  1474. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  1475. UpdateDatabaseAppearance(client, target, "soga_eye_type", ((Entity*)target)->features.soga_eye_type[0], ((Entity*)target)->features.soga_eye_type[1], ((Entity*)target)->features.soga_eye_type[2]);
  1476. }
  1477. break;
  1478. }
  1479. case SPAWN_SET_SOGA_LIP_TYPE:{
  1480. if(target->IsEntity() && index < 3){
  1481. sint8 new_value = atoi(value);
  1482. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  1483. UpdateDatabaseAppearance(client, target, "soga_lip_type", ((Entity*)target)->features.soga_lip_type[0], ((Entity*)target)->features.soga_lip_type[1], ((Entity*)target)->features.soga_lip_type[2]);
  1484. }
  1485. break;
  1486. }
  1487. case SPAWN_SET_SOGA_NOSE_TYPE:{
  1488. if(target->IsEntity() && index < 3){
  1489. sint8 new_value = atoi(value);
  1490. ((Entity*)target)->features.soga_nose_type[index] = new_value;
  1491. UpdateDatabaseAppearance(client, target, "soga_nose_type", ((Entity*)target)->features.soga_nose_type[0], ((Entity*)target)->features.soga_nose_type[1], ((Entity*)target)->features.soga_nose_type[2]);
  1492. }
  1493. break;
  1494. }
  1495. case SPAWN_SET_SOGA_BODY_SIZE:{
  1496. if(target->IsEntity()){
  1497. int8 new_value = atoul(value);
  1498. ((Entity*)target)->features.body_size = new_value;
  1499. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1500. }
  1501. break;
  1502. }
  1503. case SPAWN_SET_SOGA_BODY_AGE:{
  1504. if(target->IsEntity()){
  1505. int8 new_value = atoul(value);
  1506. ((Entity*)target)->features.body_age = new_value;
  1507. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1508. }
  1509. break;
  1510. }
  1511. case SPAWN_SET_ATTACK_TYPE:{
  1512. if(target->IsEntity()){
  1513. int8 new_value = atoul(value);
  1514. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  1515. if(target->IsNPC()) {
  1516. if(target->GetDatabaseID()) {
  1517. Query spawnNPCQuery;
  1518. spawnNPCQuery.AddQueryAsync(0, &database, Q_INSERT, "update spawn_npcs set attack_type=%u where id=%u", new_value, target->GetDatabaseID());
  1519. } else if(client) {
  1520. client->Message(CHANNEL_COLOR_RED, "Invalid spawn to update the database (NPC only) or no database id for the NPC present.");
  1521. }
  1522. }
  1523. }
  1524. break;
  1525. }
  1526. case SPAWN_SET_RACE_TYPE:{
  1527. if(target->GetModelType() > 0){
  1528. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  1529. if (tmpsep->IsNumber(0))
  1530. {
  1531. Query typequery;
  1532. int16 race_type = atoul(value);
  1533. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  1534. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  1535. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  1536. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  1537. client->Message(CHANNEL_COLOR_YELLOW, "Model Type %u Race type %u inserted into memory + replaced into database, Model Type: %u set to Race Type: %u, Category: %s, SubCategory: %s, Model Name: %s.", race_type, target->GetModelType(), race_type, category, subcategory, model_name);
  1538. typequery.AddQueryAsync(0, &database, Q_INSERT, "insert into race_types (model_type, race_id, category, subcategory, model_name) values(%u, %u, '%s', '%s', '%s')", target->GetModelType(), race_type, category, subcategory, model_name);
  1539. }
  1540. else {
  1541. client->Message(CHANNEL_COLOR_RED, "Model Type: %u Race type %u overrided in memory + replaced into database, Model Type: %u set to Race Type: %u, Category: %s, SubCategory: %s, Model Name: %s.", race_type, target->GetModelType(), race_type, category, subcategory, model_name);
  1542. race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name, true);
  1543. typequery.AddQueryAsync(0, &database, Q_INSERT, "update race_types set race_id=%u, category='%s', subcategory='%s', model_name='%s' where model_type=%u", race_type, category, subcategory, model_name, target->GetModelType());
  1544. }
  1545. }
  1546. safe_delete(tmpsep);
  1547. }
  1548. break;
  1549. }
  1550. case SPAWN_SET_LOOT_TIER:{
  1551. int32 new_value = atoul(value);
  1552. target->SetLootTier(new_value);
  1553. if (target->GetDatabaseID() > 0)
  1554. {
  1555. char query[256];
  1556. snprintf(query, 256, "update spawn set loot_tier=%u where id=%u", atoul(value), target->GetDatabaseID());
  1557. if (database.RunQuery(query, strnlen(query, 256)))
  1558. {
  1559. if(client)
  1560. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1561. }
  1562. }
  1563. break;
  1564. }
  1565. case SPAWN_SET_LOOT_DROP_TYPE:{
  1566. int32 new_value = atoul(value);
  1567. target->SetLootDropType(new_value);
  1568. if (target->GetDatabaseID() > 0)
  1569. {
  1570. char query[256];
  1571. snprintf(query, 256, "update spawn set loot_drop_type=%u where id=%u", atoul(value), target->GetDatabaseID());
  1572. if (database.RunQuery(query, strnlen(query, 256)))
  1573. {
  1574. if(client)
  1575. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1576. }
  1577. }
  1578. break;
  1579. }
  1580. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  1581. int32 new_value = atoul(value);
  1582. target->SetScaredByStrongPlayers(new_value);
  1583. if (target->GetDatabaseID() > 0)
  1584. {
  1585. char query[256];
  1586. snprintf(query, 256, "update spawn_npcs set scared_by_strong_players=%u where id=%u", atoul(value), target->GetDatabaseID());
  1587. if (database.RunQuery(query, strnlen(query, 256)))
  1588. {
  1589. if(client)
  1590. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1591. }
  1592. }
  1593. break;
  1594. }
  1595. }
  1596. }
  1597. return true;
  1598. }
  1599. void Commands::UpdateDatabaseAppearance(Client* client, Spawn* target, string fieldName, sint8 r, sint8 g, sint8 b)
  1600. {
  1601. Query replaceQuery;
  1602. if(target->IsBot())
  1603. {
  1604. Bot* bot = (Bot*)target;
  1605. if(bot->BotID)
  1606. database.SaveBotFloats(bot->BotID, fieldName.c_str(), r, g, b);
  1607. }
  1608. else if(target->IsPlayer())
  1609. {
  1610. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from char_colors where char_id=%u and type='%s'", ((Player*)target)->GetCharacterID(), fieldName.c_str());
  1611. replaceQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into char_colors set char_id=%u, type='%s', red=%i, green=%i, blue=%i", ((Player*)target)->GetCharacterID(), fieldName.c_str(), r, g, b);
  1612. }
  1613. else
  1614. {
  1615. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1616. replaceQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into npc_appearance set spawn_id=%u, type='%s', red=%i, green=%i, blue=%i", target->GetDatabaseID(), fieldName.c_str(), r, g, b);
  1617. }
  1618. ((Entity*)target)->changed = true;
  1619. ((Entity*)target)->info_changed = true;
  1620. if(target->GetZone())
  1621. target->GetZone()->AddChangedSpawn(target);
  1622. }
  1623. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  1624. the database fields always and also update the zone in memory if it's running. */
  1625. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  1626. if (client && zone_id > 0 && type > 0 && value) {
  1627. sint32 int_value = 0;
  1628. float float_value = 0;
  1629. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  1630. try {
  1631. float_value = atof(value);
  1632. }
  1633. catch (...) {
  1634. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  1635. return false;
  1636. }
  1637. }
  1638. 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) {
  1639. try {
  1640. int_value = atoi(value);
  1641. }
  1642. catch (...) {
  1643. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  1644. return false;
  1645. }
  1646. }
  1647. switch (type) {
  1648. case ZONE_SET_VALUE_EXPANSION_ID: {
  1649. break;
  1650. }
  1651. case ZONE_SET_VALUE_NAME: {
  1652. if (zone)
  1653. zone->SetZoneName(const_cast<char*>(value));
  1654. database.SaveZoneInfo(zone_id, "name", value);
  1655. break;
  1656. }
  1657. case ZONE_SET_VALUE_FILE: {
  1658. if (zone)
  1659. zone->SetZoneFile(const_cast<char*>(value));
  1660. database.SaveZoneInfo(zone_id, "file", value);
  1661. break;
  1662. }
  1663. case ZONE_SET_VALUE_DESCRIPTION: {
  1664. if (zone)
  1665. zone->SetZoneDescription(const_cast<char*>(value));
  1666. database.SaveZoneInfo(zone_id, "description", value);
  1667. break;
  1668. }
  1669. case ZONE_SET_VALUE_SAFE_X: {
  1670. if (zone)
  1671. zone->SetSafeX(float_value);
  1672. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  1673. break;
  1674. }
  1675. case ZONE_SET_VALUE_SAFE_Y: {
  1676. if (zone)
  1677. zone->SetSafeY(float_value);
  1678. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  1679. break;
  1680. }
  1681. case ZONE_SET_VALUE_SAFE_Z: {
  1682. if (zone)
  1683. zone->SetSafeZ(float_value);
  1684. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  1685. break;
  1686. }
  1687. case ZONE_SET_VALUE_UNDERWORLD: {
  1688. if (zone)
  1689. zone->SetUnderWorld(float_value);
  1690. database.SaveZoneInfo(zone_id, "underworld", float_value);
  1691. break;
  1692. }
  1693. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  1694. break;
  1695. }
  1696. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  1697. break;
  1698. }
  1699. case ZONE_SET_VALUE_ZONE_TYPE: {
  1700. break;
  1701. }
  1702. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  1703. if (zone)
  1704. zone->SetAlwaysLoaded(int_value == 1);
  1705. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  1706. break;
  1707. }
  1708. case ZONE_SET_VALUE_CITY_ZONE: {
  1709. if (zone)
  1710. zone->SetCityZone(int_value == 1);
  1711. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  1712. break;
  1713. }
  1714. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  1715. if (zone)
  1716. zone->SetWeatherAllowed(int_value == 1);
  1717. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  1718. break;
  1719. }
  1720. case ZONE_SET_VALUE_MIN_STATUS: {
  1721. if (zone)
  1722. zone->SetMinimumStatus(int_value);
  1723. database.SaveZoneInfo(zone_id, "min_status", int_value);
  1724. break;
  1725. }
  1726. case ZONE_SET_VALUE_MIN_LEVEL: {
  1727. if (zone)
  1728. zone->SetMinimumLevel(int_value);
  1729. database.SaveZoneInfo(zone_id, "min_level", int_value);
  1730. break;
  1731. }
  1732. case ZONE_SET_VALUE_MAX_LEVEL: {
  1733. if (zone)
  1734. zone->SetMaximumLevel(int_value);
  1735. database.SaveZoneInfo(zone_id, "max_level", int_value);
  1736. break;
  1737. }
  1738. case ZONE_SET_VALUE_START_ZONE: {
  1739. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  1740. break;
  1741. }
  1742. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  1743. if (zone)
  1744. zone->SetInstanceType(int_value);
  1745. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  1746. break;
  1747. }
  1748. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  1749. if (zone)
  1750. zone->SetDefaultReenterTime(int_value);
  1751. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  1752. break;
  1753. }
  1754. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  1755. if (zone)
  1756. zone->SetDefaultResetTime(int_value);
  1757. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  1758. break;
  1759. }
  1760. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1761. if (zone)
  1762. zone->SetDefaultLockoutTime(int_value);
  1763. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1764. break;
  1765. }
  1766. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1767. if (zone)
  1768. zone->SetForceGroupZoneOption(int_value);
  1769. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1770. break;
  1771. }
  1772. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1773. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1774. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1775. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1776. return false;
  1777. }
  1778. else {
  1779. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1780. database.SaveZoneInfo(zone_id, "lua_script", value);
  1781. }
  1782. break;
  1783. }
  1784. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1785. if (zone)
  1786. zone->SetShutdownTimer(int_value);
  1787. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1788. break;
  1789. }
  1790. case ZONE_SET_VALUE_ZONE_MOTD: {
  1791. if (zone)
  1792. zone->SetZoneMOTD(string(value));
  1793. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1794. break;
  1795. }
  1796. default: {
  1797. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1798. return false;
  1799. }
  1800. }
  1801. }
  1802. else {
  1803. if (client)
  1804. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1805. return false;
  1806. }
  1807. return true;
  1808. }
  1809. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1810. if (index >= remote_commands->commands.size()) {
  1811. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1812. return;
  1813. }
  1814. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1815. EQ2_RemoteCommandString* parent_command = 0;
  1816. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1817. Seperator* sep = 0;
  1818. if (command_parms->size > 0) {
  1819. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1820. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1821. parent_command = command;
  1822. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1823. safe_delete(sep);
  1824. if (command_parms->data.length() > (command->command.data.length() + 1))
  1825. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1826. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1827. }
  1828. else
  1829. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1830. }
  1831. int ndx = 0;
  1832. if (command->required_status > client->GetAdminStatus())
  1833. {
  1834. 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());
  1835. safe_delete(sep);
  1836. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1837. return;
  1838. }
  1839. Player* player = client->GetPlayer();
  1840. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1841. switch (command->handler) {
  1842. case COMMAND_RELOAD: {
  1843. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1845. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1846. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1848. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells npc");
  1850. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload voiceovers");
  1863. break;
  1864. }
  1865. case COMMAND_RELOADSTRUCTS: {
  1866. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1867. world.SetReloadingSubsystem("Structs");
  1868. configReader.ReloadStructs();
  1869. world.RemoveReloadingSubSystem("Structs");
  1870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1871. break;
  1872. }
  1873. case COMMAND_RELOAD_QUESTS: {
  1874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1875. world.SetReloadingSubsystem("Quests");
  1876. master_quest_list.Reload();
  1877. client_list.ReloadQuests();
  1878. zone_list.ReloadClientQuests();
  1879. world.RemoveReloadingSubSystem("Quests");
  1880. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1881. break;
  1882. }
  1883. case COMMAND_RELOAD_SPAWNS: {
  1884. client->GetCurrentZone()->ReloadSpawns();
  1885. break;
  1886. }
  1887. case COMMAND_RELOAD_SPELLS: {
  1888. if (sep && sep->arg[0] && strcmp(sep->arg[0], "npc") == 0) {
  1889. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading NPC Spells Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1890. world.PurgeNPCSpells();
  1891. database.LoadNPCSpells();
  1892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1893. }
  1894. else {
  1895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells & NPC Spell Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1896. world.SetReloadingSubsystem("Spells");
  1897. zone_list.DeleteSpellProcess();
  1898. master_spell_list.Reload();
  1899. if (lua_interface)
  1900. lua_interface->ReloadSpells();
  1901. zone_list.LoadSpellProcess();
  1902. world.RemoveReloadingSubSystem("Spells");
  1903. world.PurgeNPCSpells();
  1904. database.LoadNPCSpells();
  1905. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1906. }
  1907. break;
  1908. }
  1909. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1910. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1911. world.SetReloadingSubsystem("GroundSpawns");
  1912. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1913. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1914. world.RemoveReloadingSubSystem("GroundSpawns");
  1915. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1916. break;
  1917. }
  1918. case COMMAND_RELOAD_ZONESCRIPTS: {
  1919. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1920. world.SetReloadingSubsystem("ZoneScripts");
  1921. world.ResetZoneScripts();
  1922. database.LoadZoneScriptData();
  1923. if (lua_interface)
  1924. lua_interface->DestroyZoneScripts();
  1925. world.RemoveReloadingSubSystem("ZoneScripts");
  1926. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1927. break;
  1928. }
  1929. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1930. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1931. world.SetReloadingSubsystem("EntityCommands");
  1932. client->GetCurrentZone()->ClearEntityCommands();
  1933. database.LoadEntityCommands(client->GetCurrentZone());
  1934. world.RemoveReloadingSubSystem("EntityCommands");
  1935. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1936. break;
  1937. }
  1938. case COMMAND_RELOAD_FACTIONS: {
  1939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1940. world.SetReloadingSubsystem("Factions");
  1941. master_faction_list.Clear();
  1942. database.LoadFactionList();
  1943. world.RemoveReloadingSubSystem("Factions");
  1944. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1945. break;
  1946. }
  1947. case COMMAND_RELOAD_MAIL: {
  1948. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1949. zone_list.ReloadMail();
  1950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1951. break;
  1952. }
  1953. case COMMAND_RELOAD_GUILDS: {
  1954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1955. world.ReloadGuilds();
  1956. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1957. break;
  1958. }
  1959. case COMMAND_RELOAD_LOCATIONS: {
  1960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1961. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1962. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1963. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1964. break;
  1965. }
  1966. case COMMAND_RELOAD_RULES: {
  1967. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1968. database.LoadRuleSets(true);
  1969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1970. break;
  1971. }
  1972. case COMMAND_RELOAD_TRANSPORTERS: {
  1973. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1974. database.LoadTransporters(client->GetCurrentZone());
  1975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1976. break;
  1977. }
  1978. case COMMAND_RELOAD_STARTABILITIES: {
  1979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1980. world.PurgeStartingLists();
  1981. world.LoadStartingLists();
  1982. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1983. break;
  1984. }
  1985. case COMMAND_RELOAD_VOICEOVERS: {
  1986. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Voiceovers...");
  1987. world.PurgeVoiceOvers();
  1988. world.LoadVoiceOvers();
  1989. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1990. break;
  1991. }
  1992. case COMMAND_READ: {
  1993. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1994. if (strcmp(sep->arg[0], "read") == 0) {
  1995. int32 item_index = atol(sep->arg[1]);
  1996. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1997. if (item) {
  1998. Spawn* spawn = cmdTarget;
  1999. client->SendShowBook(client->GetPlayer(), item->name, item->book_language, item->book_pages);
  2000. break;
  2001. }
  2002. }
  2003. }
  2004. break;
  2005. }
  2006. case COMMAND_USEABILITY:{
  2007. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  2008. if (!client->GetPlayer()->Alive()) {
  2009. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  2010. }
  2011. else {
  2012. int32 spell_id = atoul(sep->arg[0]);
  2013. int8 spell_tier = 0;
  2014. if (sep->arg[1][0] && sep->IsNumber(1))
  2015. spell_tier = atoi(sep->arg[1]);
  2016. else
  2017. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  2018. if (!spell_tier)
  2019. spell_tier = 1;
  2020. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  2021. if (spell) {
  2022. 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)
  2023. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  2024. else
  2025. {
  2026. if (cmdTarget)
  2027. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  2028. else
  2029. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  2030. }
  2031. }
  2032. }
  2033. }
  2034. else if (cmdTarget && cmdTarget->IsWidget())
  2035. {
  2036. Widget* widget = (Widget*)cmdTarget;
  2037. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  2038. }
  2039. else
  2040. {
  2041. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  2042. }
  2043. break;
  2044. }
  2045. case COMMAND_INFO:{
  2046. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  2047. if(strcmp(sep->arg[0], "inventory") == 0){
  2048. int32 item_index = atol(sep->arg[1]);
  2049. if(client->GetVersion() <= 546) {
  2050. item_index = (uint32)-(sint32)item_index & 0xFFFFFFFF;
  2051. item_index -= 1;
  2052. }
  2053. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  2054. if(item){
  2055. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  2056. break;
  2057. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  2058. //DumpPacket(app);
  2059. client->QueuePacket(app);
  2060. if(item->GetItemScript() && lua_interface)
  2061. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2062. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  2063. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  2064. if(quest && client->GetPlayer()->HasQuestBeenCompleted(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->HasActiveQuest(item->generic_info.offers_quest_id) == 0)
  2065. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  2066. }
  2067. }
  2068. else
  2069. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  2070. }
  2071. else if(strcmp(sep->arg[0], "equipment") == 0){
  2072. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2073. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  2074. if(item){
  2075. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2076. client->QueuePacket(app);
  2077. if(item->GetItemScript() && lua_interface)
  2078. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2079. }
  2080. else
  2081. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  2082. }
  2083. else if(strcmp(sep->arg[0], "appearance") == 0){
  2084. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2085. Item* item = client->GetPlayer()->GetAppearanceEquipmentList()->GetItem(item_index);
  2086. if(item){
  2087. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2088. client->QueuePacket(app);
  2089. if(item->GetItemScript() && lua_interface)
  2090. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2091. }
  2092. else
  2093. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  2094. }
  2095. 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){
  2096. int32 item_id = atoul(sep->arg[1]);
  2097. Item* item = master_item_list.GetItem(item_id);
  2098. if(item){
  2099. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2100. client->QueuePacket(app);
  2101. }
  2102. else
  2103. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  2104. }
  2105. else if (strcmp(sep->arg[0], "spell") == 0) {
  2106. sint32 spell_id = atol(sep->arg[1]);
  2107. int8 tier = atoi(sep->arg[3]);
  2108. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  2109. if (outapp)
  2110. client->QueuePacket(outapp);
  2111. else
  2112. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2113. }
  2114. else if (strcmp(sep->arg[0], "achievement") == 0) {
  2115. sint32 spell_id = atol(sep->arg[2]);
  2116. int8 group = atoi(sep->arg[1]);
  2117. AltAdvanceData* data = 0;
  2118. SpellBookEntry* spellentry = 0;
  2119. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2120. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  2121. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  2122. if (outapp)
  2123. client->QueuePacket(outapp);
  2124. else
  2125. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  2126. }
  2127. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  2128. sint32 spell_id = atol(sep->arg[1]);
  2129. int32 tier = atoi(sep->arg[2]);
  2130. if (tier > 255) {
  2131. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  2132. if (ent)
  2133. tier = ent->tier;
  2134. }
  2135. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  2136. if (outapp)
  2137. client->QueuePacket(outapp);
  2138. else
  2139. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2140. }
  2141. else if (strcmp(sep->arg[0], "recipe") == 0) {
  2142. sint32 recipe_id = atol(sep->arg[1]);
  2143. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  2144. if(outapp)
  2145. client->QueuePacket(outapp);
  2146. else
  2147. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  2148. }
  2149. else if (strcmp(sep->arg[0], "recipe_product") == 0) {
  2150. sint32 recipe_id = atol(sep->arg[1]);
  2151. PlayerRecipeList* prl = client->GetPlayer()->GetRecipeList();
  2152. Recipe* recipe = nullptr;
  2153. if ((recipe = prl->GetRecipe(recipe_id)) && recipe->GetProductID()) {
  2154. RecipeProducts* rp = recipe->products[1];
  2155. if (recipe->GetProductID() > 0) {
  2156. Item* item = master_item_list.GetItem(recipe->GetProductID());
  2157. if(item){
  2158. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2159. client->QueuePacket(app);
  2160. }
  2161. else
  2162. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", recipe->GetProductID());
  2163. }
  2164. else {
  2165. LogWrite(COMMAND__ERROR, 0, "Command", "recipe_product recipe->GetProductID() has value 0 for recipe id %u.", recipe_id);
  2166. }
  2167. }
  2168. else {
  2169. LogWrite(COMMAND__ERROR, 0, "Command", "recipe_product with recipe id %u not found (recipe missing or no product in stage 1 assigned).", recipe_id);
  2170. }
  2171. }
  2172. else if (strcmp(sep->arg[0], "maintained") ==0) {
  2173. int32 slot = atol(sep->arg[1]);
  2174. int32 spell_id = atol(sep->arg[2]);
  2175. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  2176. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2177. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  2178. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  2179. if(outapp)
  2180. client->QueuePacket(outapp);
  2181. else
  2182. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  2183. }
  2184. else if (strcmp(sep->arg[0], "effect") == 0) {
  2185. int32 spell_id = atol(sep->arg[1]);
  2186. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  2187. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2188. int8 type = 0;
  2189. if (client->GetVersion() <= 546)
  2190. type = 1;
  2191. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  2192. if (outapp){
  2193. client->QueuePacket(outapp);
  2194. }
  2195. else
  2196. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  2197. }
  2198. }
  2199. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  2200. Item* item = player->item_list.GetOverflowItem();
  2201. if(item) {
  2202. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2203. client->QueuePacket(app);
  2204. }
  2205. else
  2206. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  2207. }
  2208. else
  2209. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  2210. break;
  2211. }
  2212. case COMMAND_USE_EQUIPPED_ITEM:{
  2213. if (sep && sep->arg[0] && sep->IsNumber(0)){
  2214. int32 slot_id = atoul(sep->arg[0]);
  2215. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  2216. if (item && item->generic_info.usable && item->GetItemScript()) {
  2217. if(!item->CheckFlag2(INDESTRUCTABLE) && item->generic_info.condition == 0) {
  2218. client->SimpleMessage(CHANNEL_COLOR_RED, "This item is broken and must be repaired at a mender before it can be used");
  2219. }
  2220. else if (item->CheckFlag(EVIL_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_EVIL) {
  2221. client->Message(0, "%s requires an evil race.", item->name.c_str());
  2222. }
  2223. else if (item->CheckFlag(GOOD_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_GOOD) {
  2224. client->Message(0, "%s requires a good race.", item->name.c_str());
  2225. }
  2226. else {
  2227. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player, player->GetTarget());
  2228. }
  2229. }
  2230. }
  2231. break;
  2232. }
  2233. case COMMAND_USE_ITEM: {
  2234. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2235. int32 item_index = atoul(sep->arg[0]);
  2236. Item* item = player->item_list.GetItemFromIndex(item_index);
  2237. client->UseItem(item, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer());
  2238. }
  2239. break;
  2240. }
  2241. case COMMAND_SCRIBE_SCROLL_ITEM: {
  2242. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2243. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  2244. if (item) {
  2245. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  2246. if(item->generic_info.item_type == 6) {
  2247. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  2248. int8 old_slot = 0;
  2249. if (spell) {
  2250. if(!spell->ScribeAllowed(client->GetPlayer())) {
  2251. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not meet one of the requirements to scribe, due to class or level.");
  2252. break;
  2253. }
  2254. int16 tier_up = player->GetTierUp(spell->GetSpellTier());
  2255. if (rule_manager.GetGlobalRule(R_Spells, RequirePreviousTierScribe)->GetInt8() && !player->HasSpell(spell->GetSpellID(), tier_up, false, true))
  2256. client->SimpleMessage(CHANNEL_COLOR_RED, "You have not scribed the required previous version of this ability.");
  2257. else if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  2258. old_slot = player->GetSpellSlot(spell->GetSpellID());
  2259. player->RemoveSpellBookEntry(spell->GetSpellID());
  2260. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  2261. player->UnlockSpell(spell);
  2262. client->SendSpellUpdate(spell);
  2263. database.DeleteItem(client->GetCharacterID(), item, 0);
  2264. player->item_list.RemoveItem(item, true);
  2265. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  2266. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  2267. // force purge client cache and display updated spell for hover over
  2268. EQ2Packet* app = spell->SerializeSpell(client, false, false);
  2269. client->QueuePacket(app);
  2270. }
  2271. }
  2272. else
  2273. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  2274. }
  2275. else if(item->generic_info.item_type == 7){
  2276. if(item->recipebook_info) {
  2277. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->recipebook_info->recipe_id, player->GetName());
  2278. client->AddRecipeBookToPlayer(item->recipebook_info->recipe_id, item);
  2279. }
  2280. else {
  2281. client->Message(CHANNEL_NARRATIVE, "Recipe book is unavailable! Report to admin recipe id %u could not be retrieved.", item->recipebook_info ? item->recipebook_info->recipe_id : 0);
  2282. LogWrite(COMMAND__ERROR, 0, "Command", "Recipe Book %u could not be retrieved for item %s.", item->recipebook_info ? item->recipebook_info->recipe_id : 0, item->name.c_str());
  2283. }
  2284. }
  2285. else {
  2286. LogWrite(COMMAND__ERROR, 0, "Command", "Recipe Book Info is not set for item %s.", item->name.c_str());
  2287. }
  2288. }
  2289. else
  2290. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  2291. }
  2292. break;
  2293. }
  2294. case COMMAND_SUMMONITEM: {
  2295. if (sep && sep->IsNumber(0)) {
  2296. int32 item_id = atol(sep->arg[0]);
  2297. int32 quantity = 1;
  2298. if (sep->arg[1] && sep->IsNumber(1))
  2299. quantity = atoi(sep->arg[1]);
  2300. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  2301. client->AddItemToBank(item_id,quantity);
  2302. }
  2303. else {
  2304. client->AddItem(item_id, quantity);
  2305. }
  2306. }
  2307. else {
  2308. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  2309. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  2310. }
  2311. break;
  2312. }
  2313. case COMMAND_COLLECTION_ADDITEM: {
  2314. // takes 2 params: collection_id, slot
  2315. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2316. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  2317. if (item)
  2318. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  2319. else
  2320. 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]));
  2321. }
  2322. else
  2323. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  2324. break;
  2325. }
  2326. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  2327. // takes 1 param: slot
  2328. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  2329. int i = 0;
  2330. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  2331. printf("\t%u: %s\n", i, sep->arg[i]);
  2332. i++;
  2333. }
  2334. break;
  2335. }
  2336. case COMMAND_WAYPOINT: {
  2337. bool success = false;
  2338. client->ClearWaypoint();
  2339. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  2340. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  2341. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2342. }
  2343. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  2344. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  2345. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2346. }
  2347. else {
  2348. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  2349. }
  2350. break;
  2351. }
  2352. case COMMAND_WHO:{
  2353. const char* who = 0;
  2354. if(sep && sep->arg[0]){
  2355. //cout << "Who query: \n";
  2356. who = sep->argplus[0];
  2357. //cout << who << endl;
  2358. }
  2359. zone_list.ProcessWhoQuery(who, client);
  2360. break;
  2361. }
  2362. case COMMAND_SELECT_JUNCTION:{
  2363. // transporters (bells birds) use OP_SelectZoneTeleporterDestinatio / ProcessTeleportLocation(app)
  2364. // this is only used for revive it seems
  2365. int32 choice = 0;
  2366. if(sep && sep->arg[0] && sep->IsNumber(0))
  2367. choice = atoul(sep->arg[0]);
  2368. if(!client->GetPlayer()->Alive()){ //dead and this is a revive request
  2369. client->HandlePlayerRevive(choice);
  2370. }
  2371. break;
  2372. }
  2373. case COMMAND_SPAWN_MOVE: {
  2374. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  2375. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  2376. if (packet) {
  2377. float unknown2_3 = 0;
  2378. int8 placement_mode = 0;
  2379. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  2380. if (sep && sep->arg[0][0]) {
  2381. if (strcmp(sep->arg[0], "wall") == 0) {
  2382. placement_mode = 2;
  2383. unknown2_3 = 150;
  2384. }
  2385. else if (strcmp(sep->arg[0], "ceiling") == 0)
  2386. placement_mode = 1;
  2387. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  2388. {
  2389. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  2390. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  2391. }
  2392. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  2393. {
  2394. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  2395. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  2396. }
  2397. else if (strcmp(sep->arg[0], "myloc") == 0)
  2398. {
  2399. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  2400. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  2401. safe_delete(packet);
  2402. break;
  2403. }
  2404. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  2405. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  2406. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  2407. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  2408. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  2409. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  2410. safe_delete(packet);
  2411. break;
  2412. }
  2413. }
  2414. packet->setDataByName("placement_mode", placement_mode);
  2415. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  2416. packet->setDataByName("model_type", cmdTarget->GetModelType());
  2417. packet->setDataByName("unknown", 1); //size
  2418. packet->setDataByName("unknown2", 1); //size 2
  2419. packet->setDataByName("unknown2", .5, 1); //size 3
  2420. packet->setDataByName("unknown2", 3, 2);
  2421. packet->setDataByName("unknown2", unknown2_3, 3);
  2422. packet->setDataByName("max_distance", 500);
  2423. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  2424. client->QueuePacket(packet->serialize());
  2425. safe_delete(packet);
  2426. }
  2427. }
  2428. else {
  2429. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  2430. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  2431. }
  2432. break;
  2433. }
  2434. case COMMAND_HAIL:{
  2435. Spawn* spawn = cmdTarget;
  2436. if(spawn && spawn->GetTargetable())
  2437. {
  2438. char tmp[75] = {0};
  2439. sprintf(tmp, "Hail, %s", spawn->GetName());
  2440. bool show_bubble = true;
  2441. if (spawn->IsNPC())
  2442. show_bubble = false;
  2443. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble, client->GetPlayer()->GetCurrentLanguage());
  2444. if(spawn->IsPlayer() == false && spawn->Alive() && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetGlobalRule(R_Spawn, HailDistance)->GetInt32()){
  2445. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  2446. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  2447. else
  2448. {
  2449. bool pauseRunback = false;
  2450. // prime runback as the heading or anything can be altered when hailing succeeds
  2451. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  2452. {
  2453. ((NPC*)spawn)->StartRunback();
  2454. pauseRunback = true;
  2455. }
  2456. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  2457. spawn->PauseMovement(rule_manager.GetGlobalRule(R_Spawn, HailMovementPause)->GetInt32());
  2458. else if(spawn->IsNPC() && pauseRunback)
  2459. ((NPC*)spawn)->ClearRunback();
  2460. }
  2461. }
  2462. }
  2463. else {
  2464. string tmp = "Hail";
  2465. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2466. }
  2467. break;
  2468. }
  2469. case COMMAND_SAY:{
  2470. if (sep && sep->arg[0][0]) {
  2471. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2472. if (cmdTarget && !(cmdTarget->IsPlayer()))
  2473. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  2474. }
  2475. else
  2476. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  2477. break;
  2478. }
  2479. case COMMAND_TELL:{
  2480. if(sep && sep->arg[0] && sep->argplus[1]){
  2481. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1], 0, client->GetPlayer()->GetCurrentLanguage()))
  2482. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  2483. }else
  2484. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  2485. break;
  2486. }
  2487. case COMMAND_SHOUT:{
  2488. if(sep && sep->arg[0][0])
  2489. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2490. else
  2491. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  2492. break;
  2493. }
  2494. case COMMAND_AUCTION:{
  2495. if(sep && sep->arg[0][0])
  2496. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2497. else
  2498. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  2499. break;
  2500. }
  2501. case COMMAND_OOC:{
  2502. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2503. if(sep && sep->arg[0][0])
  2504. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0], 0, client->GetPlayer()->GetCurrentLanguage());
  2505. else
  2506. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2507. break;
  2508. }
  2509. case COMMAND_EMOTE:{
  2510. if(sep && sep->arg[0][0])
  2511. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2512. else
  2513. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2514. break;
  2515. }
  2516. case COMMAND_RACE:{
  2517. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2518. if(sep->arg[1][0] && sep->IsNumber(1)){
  2519. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2520. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2521. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2522. client->GetPlayer()->SetCharSheetChanged(true);
  2523. }
  2524. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2525. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2526. //client->QueuePacket(outapp);
  2527. }
  2528. else{
  2529. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2530. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2531. }
  2532. break;
  2533. }
  2534. case COMMAND_BANK_DEPOSIT:{
  2535. if(client->GetBanker() && sep && sep->arg[0]){
  2536. int64 amount = 0;
  2537. string deposit = string(sep->arg[0]);
  2538. amount = atoi64(deposit.c_str());
  2539. client->BankDeposit(amount);
  2540. }
  2541. break;
  2542. }
  2543. case COMMAND_BANK_WITHDRAWAL:{
  2544. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2545. int64 amount = 0;
  2546. string deposit = string(sep->arg[0]);
  2547. amount = atoi64(deposit.c_str());
  2548. client->BankWithdrawal(amount);
  2549. }
  2550. break;
  2551. }
  2552. case COMMAND_BANK_CANCEL:{
  2553. Spawn* banker = cmdTarget;
  2554. client->Bank(banker, true);
  2555. break;
  2556. }
  2557. case COMMAND_BANK:{
  2558. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2559. Spawn* banker = cmdTarget;
  2560. client->Bank(banker);
  2561. break;
  2562. }
  2563. case COMMAND_GUILD_BANK:{
  2564. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2565. //Spawn* banker = client->GetPlayer()->GetTarget();
  2566. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2567. break;
  2568. }
  2569. case COMMAND_START_MAIL: {
  2570. client->SetMailTransaction(cmdTarget);
  2571. client->SendMailList();
  2572. break;
  2573. }
  2574. case COMMAND_CANCEL_MAIL: {
  2575. client->SetMailTransaction(0);
  2576. break;
  2577. }
  2578. case COMMAND_GET_MAIL_MESSAGE: {
  2579. if (sep && sep->arg[0] && sep->IsNumber(0))
  2580. client->DisplayMailMessage(atoul(sep->arg[0]));
  2581. break;
  2582. }
  2583. case COMMAND_ADD_MAIL_PLAT: {
  2584. if (sep && sep->arg[0] && sep->IsNumber(0))
  2585. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2586. break;
  2587. }
  2588. case COMMAND_ADD_MAIL_GOLD: {
  2589. if (sep && sep->arg[0] && sep->IsNumber(0))
  2590. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2591. break;
  2592. }
  2593. case COMMAND_ADD_MAIL_SILVER: {
  2594. if (sep && sep->arg[0] && sep->IsNumber(0))
  2595. client->AddMailCoin(0, atoul(sep->arg[0]));
  2596. break;
  2597. }
  2598. case COMMAND_ADD_MAIL_COPPER: {
  2599. if (sep && sep->arg[0] && sep->IsNumber(0))
  2600. client->AddMailCoin(atoul(sep->arg[0]));
  2601. break;
  2602. }
  2603. case COMMAND_SET_MAIL_ITEM: {
  2604. if(sep && sep->IsNumber(0) && sep->IsNumber(1))
  2605. {
  2606. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2607. if(item)
  2608. {
  2609. int16 quantity = atoul(sep->arg[1]);
  2610. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2611. {
  2612. return;
  2613. }
  2614. if(item->IsBag())
  2615. {
  2616. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2617. if(bag_items && bag_items->size() > 0)
  2618. {
  2619. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2620. safe_delete(bag_items);
  2621. return;
  2622. }
  2623. safe_delete(bag_items);
  2624. }
  2625. Item* itemtoadd = item;
  2626. if(quantity > 0)
  2627. {
  2628. if(quantity > item->details.count)
  2629. return;
  2630. Item* tmpItem = new Item(item);
  2631. tmpItem->details.count = quantity;
  2632. itemtoadd = tmpItem;
  2633. }
  2634. if(client->AddMailItem(itemtoadd))
  2635. {
  2636. client->RemoveItem(item, quantity, true);
  2637. }
  2638. }
  2639. }
  2640. break;
  2641. }
  2642. case COMMAND_REMOVE_MAIL_PLAT: {
  2643. if (sep && sep->arg[0] && sep->IsNumber(0))
  2644. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2645. break;
  2646. }
  2647. case COMMAND_REMOVE_MAIL_GOLD: {
  2648. if (sep && sep->arg[0] && sep->IsNumber(0))
  2649. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2650. break;
  2651. }
  2652. case COMMAND_REMOVE_MAIL_SILVER: {
  2653. if (sep && sep->arg[0] && sep->IsNumber(0))
  2654. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2655. break;
  2656. }
  2657. case COMMAND_REMOVE_MAIL_COPPER: {
  2658. if (sep && sep->arg[0] && sep->IsNumber(0))
  2659. client->RemoveMailCoin(atoul(sep->arg[0]));
  2660. break;
  2661. }
  2662. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2663. if (sep && sep->arg[0] && sep->IsNumber(0))
  2664. client->TakeMailAttachments(atoul(sep->arg[0]));
  2665. break;
  2666. }
  2667. case COMMAND_CANCEL_SEND_MAIL: {
  2668. client->ResetSendMail();
  2669. break;
  2670. }
  2671. case COMMAND_DELETE_MAIL_MESSAGE: {
  2672. if (sep && sep->arg[0] && sep->IsNumber(0))
  2673. client->DeleteMail(atoul(sep->arg[0]), true);
  2674. break;
  2675. }
  2676. case COMMAND_REPORT_SPAM: {
  2677. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2678. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2679. break;
  2680. }
  2681. case COMMAND_KILL:{
  2682. Spawn* dead = 0;
  2683. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2684. dead=client->GetPlayer();
  2685. client->GetPlayer()->SetHP(0);
  2686. client->GetPlayer()->KillSpawn(dead);
  2687. }else{
  2688. dead= cmdTarget;
  2689. if(dead && dead->IsPlayer() == false){
  2690. if(dead->IsNPC() && ((NPC*)dead)->Brain()) {
  2691. client->GetPlayer()->CheckEncounterState((Entity*)dead);
  2692. ((NPC*)dead)->Brain()->AddToEncounter(client->GetPlayer());
  2693. ((NPC*)dead)->AddTargetToEncounter(client->GetPlayer());
  2694. ((NPC*)dead)->Brain()->AddHate(client->GetPlayer(), 1);
  2695. }
  2696. dead->SetHP(0);
  2697. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2698. client->GetCurrentZone()->RemoveSpawn(dead, true, true, true, true, true);
  2699. else
  2700. client->GetPlayer()->KillSpawn(dead);
  2701. }else{
  2702. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2703. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2704. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2705. }
  2706. }
  2707. break;
  2708. }
  2709. case COMMAND_LEVEL:{
  2710. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2711. int16 new_level = atoi(sep->arg[ndx]);
  2712. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2713. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2714. else {
  2715. if (new_level < 1)
  2716. new_level = 1;
  2717. if (new_level > 255)
  2718. new_level = 255;
  2719. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2720. }
  2721. }else
  2722. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2723. break;
  2724. }
  2725. case COMMAND_SIT: {
  2726. if(client->GetPlayer()->GetHP() > 0){
  2727. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2728. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2729. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2730. }
  2731. break;
  2732. }
  2733. case COMMAND_STAND: {
  2734. if(client->GetPlayer()->GetHP() > 0){
  2735. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2736. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2737. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2738. }
  2739. break;
  2740. }
  2741. case COMMAND_CLASS:{
  2742. if(sep && sep->arg[ndx][0]){
  2743. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2744. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2745. }else
  2746. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2747. break;
  2748. }
  2749. case COMMAND_FLYMODE:{
  2750. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2751. PrintSep(sep, "COMMAND_FLYMODE");
  2752. int8 val = atoul(sep->arg[0]);
  2753. ClientPacketFunctions::SendFlyMode(client, val);
  2754. }
  2755. else{
  2756. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode [1|2] 1 = fly, 2 = no clip");
  2757. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2758. }
  2759. break;
  2760. }
  2761. case COMMAND_LOOT_LIST:{
  2762. Spawn* spawn = cmdTarget;
  2763. if(spawn && spawn->IsEntity()){
  2764. if (sep && sep->arg[0]) {
  2765. if (!spawn->GetDatabaseID())
  2766. {
  2767. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  2768. break;
  2769. }
  2770. else if (!spawn->IsNPC())
  2771. {
  2772. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2773. break;
  2774. }
  2775. bool reloadLoot = false;
  2776. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2777. {
  2778. int32 loottable_id = atoul(sep->arg[1]);
  2779. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2780. {
  2781. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2782. reloadLoot = true;
  2783. }
  2784. else
  2785. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2786. }
  2787. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2788. {
  2789. int32 loottable_id = atoul(sep->arg[1]);
  2790. if (loottable_id > 0)
  2791. {
  2792. database.AddLootTableToSpawn(spawn, loottable_id);
  2793. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2794. reloadLoot = true;
  2795. }
  2796. else
  2797. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2798. }
  2799. else if (!stricmp(sep->arg[0], "clearall"))
  2800. {
  2801. if (database.RemoveSpawnLootTable(spawn, 0))
  2802. {
  2803. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2804. reloadLoot = true;
  2805. }
  2806. else
  2807. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2808. }
  2809. else
  2810. {
  2811. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2812. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2813. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2814. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2815. break;
  2816. }
  2817. if (reloadLoot)
  2818. {
  2819. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2820. if (spawn->IsNPC())
  2821. {
  2822. Entity* ent = (Entity*)spawn;
  2823. ent->SetLootCoins(0);
  2824. ent->ClearLoot();
  2825. spawn->GetZone()->AddLoot((NPC*)spawn);
  2826. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2827. }
  2828. }
  2829. break; // nothing further this is the end of these sub commands
  2830. }
  2831. else
  2832. {
  2833. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()), spawn);
  2834. if (loot_list.size() > 0) {
  2835. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2836. vector<int32>::iterator list_itr;
  2837. LootTable* table = 0;
  2838. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2839. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2840. if (table)
  2841. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2842. }
  2843. }
  2844. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2845. vector<Item*>* items = spawn->GetLootItems();
  2846. if (items) {
  2847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2848. vector<Item*>::iterator itr;
  2849. Item* item = 0;
  2850. for (itr = items->begin(); itr != items->end(); itr++) {
  2851. item = *itr;
  2852. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2853. }
  2854. }
  2855. else
  2856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2857. }
  2858. }
  2859. break;
  2860. }
  2861. case COMMAND_LOOT_SETCOIN:{
  2862. Spawn* spawn = cmdTarget;
  2863. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2864. spawn->SetLootCoins(atoul(sep->arg[0]));
  2865. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2866. }
  2867. else
  2868. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2869. break;
  2870. }
  2871. case COMMAND_LOOT_ADDITEM:{
  2872. Spawn* spawn = cmdTarget;
  2873. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2874. int16 charges = 1;
  2875. if(sep->arg[1] && sep->IsNumber(1))
  2876. charges = atoi(sep->arg[1]);
  2877. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2878. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2879. }
  2880. else
  2881. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2882. break;
  2883. }
  2884. case COMMAND_LOOT_REMOVEITEM:{
  2885. Spawn* spawn = cmdTarget;
  2886. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2887. Item* item = spawn->LootItem(atoul(sep->arg[0]));
  2888. lua_interface->SetLuaUserDataStale(item);
  2889. safe_delete(item);
  2890. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2891. }
  2892. else
  2893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2894. break;
  2895. }
  2896. case COMMAND_LOOT_CORPSE:
  2897. case COMMAND_DISARM:
  2898. case COMMAND_LOOT:{
  2899. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2900. {
  2901. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2902. break;
  2903. }
  2904. if(cmdTarget && cmdTarget->IsEntity()){
  2905. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2906. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2907. client->OpenChest(cmdTarget, true);
  2908. else
  2909. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2910. if (!(cmdTarget)->HasLoot()){
  2911. if (((Entity*)cmdTarget)->IsNPC())
  2912. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2913. }
  2914. }
  2915. else
  2916. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2917. }
  2918. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2919. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2920. break;
  2921. }
  2922. case COMMAND_RELOADSPAWNSCRIPTS:{
  2923. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2924. if (lua_interface)
  2925. lua_interface->SetLuaSystemReloading(true);
  2926. world.ResetSpawnScripts();
  2927. database.LoadSpawnScriptData();
  2928. if(lua_interface) {
  2929. lua_interface->DestroySpawnScripts();
  2930. lua_interface->SetLuaSystemReloading(false);
  2931. }
  2932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2933. break;
  2934. }
  2935. case COMMAND_RELOADREGIONSCRIPTS:{
  2936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2937. if(lua_interface) {
  2938. lua_interface->DestroyRegionScripts();
  2939. }
  2940. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2941. break;
  2942. }
  2943. case COMMAND_RELOADLUASYSTEM:{
  2944. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2945. world.SetReloadingSubsystem("LuaSystem");
  2946. if(lua_interface) {
  2947. lua_interface->SetLuaSystemReloading(true);
  2948. }
  2949. zone_list.DeleteSpellProcess();
  2950. master_spell_list.Reload();
  2951. if (lua_interface)
  2952. lua_interface->ReloadSpells();
  2953. zone_list.LoadSpellProcess();
  2954. if(lua_interface){
  2955. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2956. map<Client*, int32>::iterator itr;
  2957. for(itr = debug_clients.begin(); itr != debug_clients.end(); itr++){
  2958. if(lua_interface)
  2959. lua_interface->UpdateDebugClients(itr->first);
  2960. }
  2961. }
  2962. world.ResetSpawnScripts();
  2963. database.LoadSpawnScriptData();
  2964. world.ResetZoneScripts();
  2965. database.LoadZoneScriptData();
  2966. if(lua_interface) {
  2967. lua_interface->DestroySpawnScripts();
  2968. lua_interface->DestroyRegionScripts();
  2969. lua_interface->DestroyQuests();
  2970. lua_interface->DestroyItemScripts();
  2971. lua_interface->DestroyZoneScripts();
  2972. }
  2973. int32 quest_count = database.LoadQuests();
  2974. int32 spell_count = 0;
  2975. if(lua_interface) {
  2976. spell_count = database.LoadSpellScriptData();
  2977. lua_interface->SetLuaSystemReloading(false);
  2978. }
  2979. world.RemoveReloadingSubSystem("LuaSystem");
  2980. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2981. break;
  2982. }
  2983. case COMMAND_DECLINE_QUEST:{
  2984. int32 quest_id = 0;
  2985. if(sep && sep->arg[0] && sep->IsNumber(0))
  2986. quest_id = atoul(sep->arg[0]);
  2987. if(quest_id > 0){
  2988. client->RemovePendingQuest(quest_id);
  2989. }
  2990. break;
  2991. }
  2992. case COMMAND_DELETE_QUEST:{
  2993. int32 quest_id = 0;
  2994. if(sep && sep->arg[0] && sep->IsNumber(0))
  2995. quest_id = atoul(sep->arg[0]);
  2996. if(quest_id > 0){
  2997. client->GetPlayer()->MPlayerQuests.readlock(__FUNCTION__, __LINE__);
  2998. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2999. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  3000. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3001. if (quest && quest->CanDeleteQuest()) {
  3002. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  3003. client->RemovePlayerQuest(quest_id);
  3004. client->GetCurrentZone()->SendQuestUpdates(client);
  3005. }
  3006. }
  3007. else {
  3008. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3009. }
  3010. }
  3011. break;
  3012. }
  3013. case COMMAND_ACCEPT_QUEST:{
  3014. int32 quest_id = 0;
  3015. if(sep && sep->arg[0] && sep->IsNumber(0))
  3016. quest_id = atoul(sep->arg[0]);
  3017. if(quest_id > 0){
  3018. client->AcceptQuest(quest_id);
  3019. }
  3020. break;
  3021. }
  3022. case COMMAND_NAME:{
  3023. if(sep && sep->arg[ndx][0]){
  3024. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  3025. client->GetPlayer()->SetCharSheetChanged(true);
  3026. }else
  3027. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  3028. break;
  3029. }
  3030. case COMMAND_GROUP: {
  3031. if(sep && sep->arg[0])
  3032. printf("Group: %s\n",sep->argplus[0]);
  3033. break;
  3034. }
  3035. case COMMAND_GROUPSAY:{
  3036. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3037. if(sep && sep->arg[0] && gmi)
  3038. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), client->GetPlayer()->GetCurrentLanguage(), sep->argplus[0]);
  3039. break;
  3040. }
  3041. case COMMAND_GROUPINVITE: {
  3042. Entity* target = 0;
  3043. Client* target_client = 0;
  3044. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3045. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  3046. return;
  3047. }
  3048. // name provided with command so it has to be a player, npc not supported here
  3049. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  3050. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  3051. if (target_client) {
  3052. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  3053. target = 0;
  3054. else
  3055. target = target_client->GetPlayer();
  3056. }
  3057. }
  3058. // if name was not provided use the players target, npc or player supported here
  3059. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  3060. target = (Entity*)client->GetPlayer()->GetTarget();
  3061. if (target->IsPlayer()) {
  3062. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  3063. }
  3064. }
  3065. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  3066. if (result == 0) {
  3067. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  3068. if (target_client) {
  3069. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  3070. if (packet) {
  3071. packet->setDataByName("type", 1);
  3072. packet->setDataByName("name", client->GetPlayer()->GetName());
  3073. packet->setDataByName("unknown2", 1);
  3074. target_client->QueuePacket(packet->serialize());
  3075. safe_delete(packet);
  3076. }
  3077. }
  3078. }
  3079. else if (result == 1)
  3080. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  3081. else if (result == 2)
  3082. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  3083. else if (result == 3)
  3084. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  3085. else if (result == 4)
  3086. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  3087. else if (result == 5)
  3088. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  3089. else if (result == 6)
  3090. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  3091. else
  3092. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  3093. break;
  3094. }
  3095. case COMMAND_GROUPDISBAND: {
  3096. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3097. if (gmi) { // TODO: Leader check
  3098. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  3099. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  3100. }
  3101. break;
  3102. }
  3103. case COMMAND_GROUP_LEAVE: {
  3104. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3105. if (gmi) {
  3106. int32 group_id = gmi->group_id;
  3107. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  3108. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  3109. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  3110. }
  3111. else {
  3112. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  3113. }
  3114. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  3115. }
  3116. break;
  3117. }
  3118. case COMMAND_FRIEND_ADD:{
  3119. string name = "";
  3120. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3121. name = database.GetPlayerName(sep->arg[0]);
  3122. else if(cmdTarget && cmdTarget->IsPlayer())
  3123. name = string(cmdTarget->GetName());
  3124. if(name.length() > 0){
  3125. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3126. if(client->GetPlayer()->IsIgnored(name.c_str())){
  3127. client->GetPlayer()->RemoveIgnore(name.c_str());
  3128. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3129. client->SendChatRelationship(3, name.c_str());
  3130. }
  3131. client->GetPlayer()->AddFriend(name.c_str(), true);
  3132. client->SendChatRelationship(0, name.c_str());
  3133. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  3134. if(zone_list.GetClientByCharName(name))
  3135. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  3136. }
  3137. else
  3138. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  3139. }
  3140. else
  3141. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3142. break;
  3143. }
  3144. case COMMAND_FRIEND_REMOVE:{
  3145. string name = "";
  3146. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3147. name = database.GetPlayerName(sep->arg[0]);
  3148. else if(cmdTarget && cmdTarget->IsPlayer())
  3149. name = string(cmdTarget->GetName());
  3150. if(name.length() > 0){
  3151. client->GetPlayer()->RemoveFriend(name.c_str());
  3152. client->SendChatRelationship(1, name.c_str());
  3153. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3154. }
  3155. else
  3156. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3157. break;
  3158. }
  3159. case COMMAND_FRIENDS:{
  3160. break;
  3161. }
  3162. case COMMAND_IGNORE_ADD:{
  3163. string name = "";
  3164. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3165. name = database.GetPlayerName(sep->arg[0]);
  3166. else if(cmdTarget && cmdTarget->IsPlayer())
  3167. name = string(cmdTarget->GetName());
  3168. if(name.length() > 0){
  3169. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3170. if(client->GetPlayer()->IsFriend(name.c_str())){
  3171. client->GetPlayer()->RemoveFriend(name.c_str());
  3172. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3173. client->SendChatRelationship(1, name.c_str());
  3174. }
  3175. client->GetPlayer()->AddIgnore(name.c_str(), true);
  3176. client->SendChatRelationship(2, name.c_str());
  3177. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  3178. }
  3179. else
  3180. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  3181. }
  3182. else
  3183. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3184. break;
  3185. }
  3186. case COMMAND_IGNORE_REMOVE:{
  3187. string name = "";
  3188. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3189. name = database.GetPlayerName(sep->arg[0]);
  3190. else if(cmdTarget && cmdTarget->IsPlayer())
  3191. name = string(cmdTarget->GetName());
  3192. if(name.length() > 0){
  3193. client->GetPlayer()->RemoveIgnore(name.c_str());
  3194. client->SendChatRelationship(3, name.c_str());
  3195. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3196. }
  3197. break;
  3198. }
  3199. case COMMAND_IGNORES:{
  3200. break;
  3201. }
  3202. case COMMAND_GROUP_KICK:{
  3203. Entity* kicked = 0;
  3204. Client* kicked_client = 0;
  3205. int32 group_id = 0;
  3206. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  3207. return;
  3208. if (sep && sep->arg[0]) {
  3209. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  3210. if (kicked_client)
  3211. kicked = kicked_client->GetPlayer();
  3212. }
  3213. else if (cmdTarget && cmdTarget->IsEntity()) {
  3214. kicked = (Entity*)cmdTarget;
  3215. }
  3216. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  3217. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  3218. if (kicked)
  3219. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  3220. if(send_kicked_message)
  3221. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  3222. else
  3223. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  3224. if (kicked_client)
  3225. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  3226. break;
  3227. }
  3228. case COMMAND_GROUP_MAKE_LEADER:{
  3229. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3230. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  3231. return;
  3232. }
  3233. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  3234. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  3235. if (new_leader && new_leader->GetPlayer()->GetGroupMemberInfo() && new_leader->GetPlayer()->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3236. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  3237. if(world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer())) {
  3238. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", new_leader->GetPlayer()->GetName());
  3239. }
  3240. }
  3241. }
  3242. else
  3243. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  3244. }
  3245. else if (cmdTarget && cmdTarget->IsPlayer() && ((Player*)cmdTarget)->GetGroupMemberInfo() && ((Player*)cmdTarget)->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3246. if(client->GetPlayer()->IsGroupMember((Player*)cmdTarget) && world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget)) {
  3247. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", cmdTarget->GetName());
  3248. }
  3249. }
  3250. else
  3251. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  3252. break;
  3253. }
  3254. case COMMAND_GROUP_ACCEPT_INVITE: {
  3255. if((sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) || (!sep && client->GetVersion() <= 546)) {
  3256. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  3257. if (result == 0)
  3258. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  3259. else if (result == 1)
  3260. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  3261. else if (result == 2)
  3262. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  3263. else
  3264. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  3265. }
  3266. break;
  3267. }
  3268. case COMMAND_GROUP_DECLINE_INVITE: {
  3269. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  3270. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  3271. }
  3272. break;
  3273. }
  3274. case COMMAND_SUMMON:{
  3275. char* search_name = 0;
  3276. if(sep && sep->arg[0][0])
  3277. search_name = sep->arg[0];
  3278. if(!search_name && !cmdTarget){
  3279. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  3280. 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.");
  3281. }
  3282. else{
  3283. if(!client->Summon(search_name))
  3284. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3285. }
  3286. break;
  3287. }
  3288. case COMMAND_GOTO:{
  3289. const char* search_name = 0;
  3290. if(sep && sep->arg[0][0])
  3291. search_name = sep->argplus[0];
  3292. if(!search_name && !cmdTarget){
  3293. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  3294. 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.");
  3295. }
  3296. else{
  3297. if(!client->GotoSpawn(search_name))
  3298. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3299. }
  3300. break;
  3301. }
  3302. case COMMAND_MOVE:{
  3303. bool success = false;
  3304. try{
  3305. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  3306. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  3307. if(app){
  3308. client->QueuePacket(app);
  3309. success = true;
  3310. }
  3311. }
  3312. }
  3313. catch(...){}
  3314. if(!success){
  3315. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  3316. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  3317. }
  3318. break;
  3319. }
  3320. case COMMAND_SETTIME:{
  3321. if(sep && sep->arg[0]){
  3322. world.MWorldTime.writelock(__FUNCTION__, __LINE__);
  3323. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  3324. if(sep->arg[1] && sep->IsNumber(1))
  3325. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  3326. if(sep->arg[2] && sep->IsNumber(2))
  3327. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  3328. if(sep->arg[3] && sep->IsNumber(3))
  3329. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  3330. world.MWorldTime.releasewritelock(__FUNCTION__, __LINE__);
  3331. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  3332. }
  3333. else{
  3334. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  3335. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  3336. }
  3337. break;
  3338. }
  3339. case COMMAND_VERSION:{
  3340. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  3341. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  3342. break;
  3343. }
  3344. case COMMAND_ZONE:{
  3345. int32 instanceID = 0;
  3346. string zone;
  3347. int32 zone_id = 0;
  3348. bool listSearch = false;
  3349. bool isInstance = false;
  3350. ZoneServer* zsZone = 0;
  3351. if(sep && sep->arg[0][0])
  3352. {
  3353. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  3354. listSearch = true;
  3355. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  3356. {
  3357. zone_list.SendZoneList(client);
  3358. break;
  3359. }
  3360. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  3361. {
  3362. if(sep->IsNumber(1))
  3363. instanceID = atol(sep->arg[1]);
  3364. }
  3365. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  3366. {
  3367. PrintSep(sep, "ZONE LOCK");
  3368. if(sep->IsNumber(1))
  3369. zsZone = zone_list.Get(atoul(sep->arg[1]), false, false, false);
  3370. else
  3371. zsZone = zone_list.Get(sep->arg[1], false, false, false);
  3372. if( zsZone )
  3373. {
  3374. zsZone->SetZoneLockState(true);
  3375. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3376. }
  3377. else
  3378. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  3379. break;
  3380. }
  3381. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  3382. {
  3383. PrintSep(sep, "ZONE UNLOCK");
  3384. if(sep->IsNumber(1))
  3385. zsZone = zone_list.Get(atoul(sep->arg[1]), false, false, false);
  3386. else
  3387. zsZone = zone_list.Get(sep->arg[1], false, false, false);
  3388. if( zsZone )
  3389. {
  3390. zsZone->SetZoneLockState(false);
  3391. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3392. }
  3393. else
  3394. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  3395. break;
  3396. }
  3397. else
  3398. {
  3399. if(sep->IsNumber(0))
  3400. {
  3401. zone_id = atoul(sep->arg[0]);
  3402. string zonename = database.GetZoneName(zone_id);
  3403. if(zonename.length() > 0)
  3404. zone = zonename;
  3405. }
  3406. else
  3407. zone = sep->arg[0];
  3408. }
  3409. if(instanceID > 0)
  3410. {
  3411. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  3412. if(zsInstance != NULL)
  3413. {
  3414. instanceID = zsInstance->GetInstanceID();
  3415. zone = zsInstance->GetZoneName();
  3416. zone_id = zsInstance->GetZoneID();
  3417. isInstance = true;
  3418. }
  3419. }
  3420. }
  3421. if(!listSearch)
  3422. {
  3423. if(zone.length() == 0)
  3424. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  3425. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  3426. zone_id != client->GetCurrentZone()->GetZoneID())
  3427. {
  3428. const char* zonestr = zone.c_str();
  3429. if(database.VerifyZone(zonestr))
  3430. {
  3431. if(client->CheckZoneAccess(zonestr))
  3432. {
  3433. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  3434. if(isInstance)
  3435. client->Zone(instanceID,true,true,false);
  3436. else
  3437. client->Zone(zonestr);
  3438. }
  3439. }
  3440. else
  3441. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  3442. }
  3443. else
  3444. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  3445. }
  3446. else
  3447. {
  3448. const char* name = 0;
  3449. if(sep && sep->arg[1][0])
  3450. {
  3451. map<int32, string>* zone_names;
  3452. name = sep->argplus[1];
  3453. sint16 status = client->GetAdminStatus();
  3454. if( status > 0 )
  3455. {
  3456. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  3457. zone_names = database.GetZoneList(name, true);
  3458. }
  3459. else
  3460. zone_names = database.GetZoneList(name);
  3461. if(!zone_names)
  3462. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  3463. else
  3464. {
  3465. map<int32, string>::iterator itr;
  3466. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  3467. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  3468. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  3469. safe_delete(zone_names);
  3470. }
  3471. }
  3472. else
  3473. {
  3474. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  3475. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  3476. }
  3477. }
  3478. break;
  3479. }
  3480. case COMMAND_USE: {
  3481. Spawn* target = cmdTarget;
  3482. if (target && target->IsWidget())
  3483. ((Widget*)target)->HandleUse(client, "use");
  3484. break;
  3485. }
  3486. case COMMAND_OPEN: {
  3487. Spawn* target = cmdTarget;
  3488. if (target && target->IsWidget())
  3489. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  3490. break;
  3491. }
  3492. case COMMAND_CASTSPELL: {
  3493. if (sep && sep->arg[0] && sep->IsNumber(0))
  3494. {
  3495. int8 tier = 1;
  3496. if (sep->arg[1] && sep->IsNumber(1))
  3497. tier = atoul(sep->arg[1]);
  3498. int8 self = 1;
  3499. if (sep->arg[1] && sep->IsNumber(2))
  3500. {
  3501. self = atoul(sep->arg[2]);
  3502. if(self != 1 && !cmdTarget->IsEntity())
  3503. {
  3504. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  3505. self = 1;
  3506. }
  3507. }
  3508. int32 spellid = atoul(sep->arg[0]);
  3509. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  3510. if (spell)
  3511. {
  3512. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3513. SpellProcess* spellProcess = 0;
  3514. // Get the current zones spell process
  3515. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3516. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3517. }
  3518. else
  3519. {
  3520. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3521. }
  3522. }
  3523. else if (sep && sep->arg[0])
  3524. {
  3525. database.FindSpell(client, (char*)sep->argplus[0]);
  3526. }
  3527. else
  3528. {
  3529. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3530. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3531. }
  3532. break;
  3533. }
  3534. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3535. if (sep && (client->GetVersion() <= 546 && sep->GetArgNumber() == 3) || sep->GetArgNumber() == 4)
  3536. {
  3537. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3538. // cannot sort the ability book in this client it is greyed out
  3539. if (client->GetVersion() <= 546 && book == SPELL_BOOK_TYPE_ABILITY)
  3540. break;
  3541. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3542. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3543. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3544. int32 maxlvlonly = 0;
  3545. if(client->GetVersion() > 546 && sep->arg[4][0]) {
  3546. maxlvlonly = atoul(sep->arg[4]); // checkbox for newer clients
  3547. }
  3548. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3549. ClientPacketFunctions::SendSkillSlotMappings(client);
  3550. }
  3551. else
  3552. {
  3553. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3554. }
  3555. break;
  3556. }
  3557. case COMMAND_MOVE_ITEM:
  3558. {
  3559. int32 id = 0;
  3560. if (sep && sep->IsNumber(0))
  3561. id = atoul(sep->arg[0]);
  3562. Spawn* spawn = 0;
  3563. if (id == 0)
  3564. {
  3565. spawn = cmdTarget;
  3566. }
  3567. else
  3568. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3569. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3570. break;
  3571. client->SendMoveObjectMode(spawn, 0);
  3572. break;
  3573. }
  3574. case COMMAND_PICKUP:
  3575. {
  3576. int32 id = 0;
  3577. if (sep && sep->IsNumber(0))
  3578. id = atoul(sep->arg[0]);
  3579. Spawn* spawn = 0;
  3580. if (id == 0)
  3581. {
  3582. spawn = cmdTarget;
  3583. }
  3584. else
  3585. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3586. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3587. break;
  3588. if(client->AddItem(spawn->GetPickupItemID(), 1)) {
  3589. Query query;
  3590. query.RunQuery2(Q_INSERT, "delete from spawn_instance_data where spawn_id = %u and spawn_location_id = %u and pickup_item_id = %u", spawn->GetDatabaseID(), spawn->GetSpawnLocationID(), spawn->GetPickupItemID());
  3591. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3592. client->GetCurrentZone()->RemoveSpawn(spawn, true, true, true, true, true);
  3593. }
  3594. // we had a UI Window displayed, update the house items
  3595. if ( id > 0 )
  3596. client->GetCurrentZone()->SendHouseItems(client);
  3597. }
  3598. break;
  3599. }
  3600. case COMMAND_HOUSE_DEPOSIT:
  3601. {
  3602. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3603. // arg0 = ??? (set to 3)
  3604. // arg1 = coin (in copper)
  3605. // arg2 = status? (not implemented yet)
  3606. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3607. if (ph && sep && sep->IsNumber(1))
  3608. {
  3609. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3610. int32 outValStatus = 0;
  3611. if(sep->IsNumber(2))
  3612. {
  3613. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3614. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3615. outValStatus = 0; // cheat check
  3616. }
  3617. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3618. {
  3619. if(outValStatus)
  3620. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3621. char query[256];
  3622. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3623. if (itr != ph->depositsMap.end())
  3624. {
  3625. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %llu, last_amount = %llu, status = status + %u, last_status = %u where house_id = %u and instance_id = %u and name='%s'", Timer::GetUnixTimeStamp(), outValCoin, outValCoin, outValStatus, outValStatus, ph->house_id, ph->instance_id, client->GetPlayer()->GetName());
  3626. }
  3627. else
  3628. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %llu, status = %u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outValCoin, outValStatus);
  3629. if (database.RunQuery(query, strnlen(query, 256)))
  3630. {
  3631. ph->escrow_coins += outValCoin;
  3632. ph->escrow_status += outValStatus;
  3633. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3634. database.LoadDeposits(ph);
  3635. client->PlaySound("coin_cha_ching");
  3636. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3637. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3638. }
  3639. else
  3640. {
  3641. if(outValCoin)
  3642. client->GetPlayer()->AddCoins(outValCoin);
  3643. if(outValStatus)
  3644. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3645. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3646. }
  3647. }
  3648. }
  3649. break;
  3650. }
  3651. case COMMAND_HOUSE:
  3652. {
  3653. if (sep && sep->IsNumber(0))
  3654. {
  3655. int32 unique_id = atoi(sep->arg[0]);
  3656. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3657. HouseZone* hz = 0;
  3658. if (ph)
  3659. hz = world.GetHouseZone(ph->house_id);
  3660. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3661. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3662. }
  3663. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3664. {
  3665. // inside a house or something? Send the access window
  3666. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3667. HouseZone* hz = 0;
  3668. if ( ph )
  3669. hz = world.GetHouseZone(ph->house_id);
  3670. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3671. client->GetCurrentZone()->SendHouseItems(client);
  3672. }
  3673. break;
  3674. }
  3675. case COMMAND_HOUSE_UI:
  3676. {
  3677. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3678. {
  3679. int32 unique_id = atoi(sep->arg[0]);
  3680. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3681. HouseZone* hz = 0;
  3682. if ( ph )
  3683. hz = world.GetHouseZone(ph->house_id);
  3684. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3685. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3686. }
  3687. break;
  3688. }
  3689. case COMMAND_PLACE_HOUSE_ITEM: {
  3690. if (sep && sep->IsNumber(0))
  3691. {
  3692. int32 uniqueid = atoi(sep->arg[0]);
  3693. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3694. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3695. if (item && item->IsHouseItem())
  3696. {
  3697. if (!client->HasOwnerOrEditAccess())
  3698. {
  3699. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3700. break;
  3701. }
  3702. else if (!item->generic_info.appearance_id)
  3703. {
  3704. 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);
  3705. break;
  3706. }
  3707. else if(item->CheckFlag2(HOUSE_LORE) && client->GetCurrentZone()->HouseItemSpawnExists(item->details.item_id)) {
  3708. client->Message(CHANNEL_COLOR_RED, "Item %s is house lore and you cannot place another.", item->name.c_str());
  3709. break;
  3710. }
  3711. if (client->GetTempPlacementSpawn())
  3712. {
  3713. Spawn* tmp = client->GetTempPlacementSpawn();
  3714. client->GetCurrentZone()->RemoveSpawn(tmp, true, true, true, true, true);
  3715. client->SetTempPlacementSpawn(nullptr);
  3716. }
  3717. Object* obj = new Object();
  3718. Spawn* spawn = (Spawn*)obj;
  3719. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3720. strcpy(spawn->appearance.name, "temp");
  3721. spawn->SetX(client->GetPlayer()->GetX());
  3722. spawn->SetY(client->GetPlayer()->GetY());
  3723. spawn->SetZ(client->GetPlayer()->GetZ());
  3724. spawn->appearance.pos.collision_radius = 32;
  3725. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3726. spawn->SetSpawnOrigX(spawn->GetX());
  3727. spawn->SetSpawnOrigY(spawn->GetY());
  3728. spawn->SetSpawnOrigZ(spawn->GetZ());
  3729. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3730. spawn->appearance.targetable = 1;
  3731. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3732. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3733. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3734. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3735. spawn->SetZone(client->GetCurrentZone());
  3736. client->SetTempPlacementSpawn(spawn);
  3737. client->SetPlacementUniqueItemID(uniqueid);
  3738. client->GetCurrentZone()->AddSpawn(spawn);
  3739. }
  3740. }
  3741. break;
  3742. }
  3743. case COMMAND_GM:
  3744. {
  3745. if (sep && sep->arg[0] && sep->arg[1])
  3746. {
  3747. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3748. if (strcmp(sep->arg[0], "vision") == 0)
  3749. {
  3750. client->GetPlayer()->SetGMVision(onOff);
  3751. #if defined(__GNUC__)
  3752. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3753. #else
  3754. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3755. #endif
  3756. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3757. if (onOff)
  3758. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3759. else
  3760. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3761. }
  3762. else if (strcmp(sep->arg[0], "tag") == 0)
  3763. {
  3764. int32 value = 0;
  3765. int16 tag_icon = 0;
  3766. // groundspawn has special exception -1 argument so it needs to be handled here
  3767. if(sep->arg[2] && sep->arg[3] && ((tag_icon = atoul(sep->arg[3])) > 0) || (strncasecmp(sep->arg[1], "groundspawn", 11) == 0)) {
  3768. value = atoul(sep->arg[2]);
  3769. if(strncasecmp(sep->arg[1], "faction", 7) == 0){
  3770. if(!value) {
  3771. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid faction id.");
  3772. break;
  3773. }
  3774. if(!tag_icon) {
  3775. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3776. break;
  3777. }
  3778. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_FACTION, value, "", tag_icon);
  3779. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3780. client->Message(CHANNEL_COLOR_RED, "Adding faction id %u with tag icon %u.", value, tag_icon);
  3781. }
  3782. else if(strncasecmp(sep->arg[1], "spawngroup", 10) == 0){
  3783. if(value>0) {
  3784. value = 1;
  3785. }
  3786. if(!tag_icon) {
  3787. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3788. break;
  3789. }
  3790. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_SPAWNGROUP, value, "", tag_icon);
  3791. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3792. client->Message(CHANNEL_COLOR_RED, "Adding spawn group tag \"%s\" with tag icon %u.", (value == 1) ? "on" : "off", tag_icon);
  3793. }
  3794. else if(strncasecmp(sep->arg[1], "race", 4 == 0)){
  3795. if(!value) {
  3796. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid race id.");
  3797. break;
  3798. }
  3799. if(!tag_icon) {
  3800. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3801. break;
  3802. }
  3803. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_RACE, value, "", tag_icon);
  3804. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3805. client->Message(CHANNEL_COLOR_RED, "Adding race id %u with tag icon %u.", value, tag_icon);
  3806. }
  3807. else if(strncasecmp(sep->arg[1], "groundspawn", 11) == 0){
  3808. // one less argument value field not tag_icon for this one
  3809. if(!value) {
  3810. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3811. break;
  3812. }
  3813. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_GROUNDSPAWN, 1, "", value);
  3814. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3815. client->Message(CHANNEL_COLOR_RED, "Adding groundspawns with tag icon %u.", value);
  3816. }
  3817. }
  3818. else {
  3819. if(strncasecmp(sep->arg[1], "clear", 5) == 0){
  3820. client->GetPlayer()->ClearGMVisualFilters();
  3821. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Tags Cleared!");
  3822. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3823. }
  3824. else {
  3825. client->SimpleMessage(CHANNEL_COLOR_RED, "GM Tagging Missing Arguments:");
  3826. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag [type] [value] [visual_icon_display]");
  3827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag clear - Clears all GM visual tags");
  3828. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Type Options:");
  3829. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: faction, value: faction id of spawn(s)");
  3830. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: spawngroup, value: 1 to show grouped, 0 to show not grouped");
  3831. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: race, value: race id (either against base race or race id in spawn details)");
  3832. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: groundspawn, value: (not used)");
  3833. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Icon Options:");
  3834. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3835. "1 = skull, 2 = shield half dark blue / half light blue, 3 = purple? star, 4 = yellow sword, 5 = red X, 6 = green flame");
  3836. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3837. "7 = Number \"1\", 8 = Number \"2\", 9 = Number \"3\", 10 = Number \"4\", 11 = Number \"5\", 12 = Number \"6\"");
  3838. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3839. "25 = shield, 26 = green plus, 27 = crossed swords, 28 = bow with arrow in it, 29 = light blue lightning bolt");
  3840. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3841. "30 = bard instrument (hard to see), 31 = writ with shield, 32 = writ with green +, 33 = writ with crossed sword");
  3842. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3843. "34 = writ with bow, 35 = writ with light blue lightning bolt, 36 = same as 30, 37 = party with crossed sword, shield and lightning bolt");
  3844. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3845. "38 = shaking hands green background, 39 = shaking hands dark green background, unlocked keylock");
  3846. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3847. "40 = red aura icon with black shadow of person and big red aura, 41 = green aura icon with black shadow of person big green aura");
  3848. }
  3849. }
  3850. }
  3851. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3852. {
  3853. client->SetRegionDebug(onOff);
  3854. #if defined(__GNUC__)
  3855. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3856. #else
  3857. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3858. #endif
  3859. if (onOff)
  3860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  3861. else
  3862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  3863. }
  3864. else if (strcmp(sep->arg[0], "sight") == 0)
  3865. {
  3866. if(onOff && cmdTarget) {
  3867. client->SetPlayerPOVGhost(cmdTarget);
  3868. }
  3869. else
  3870. client->SetPlayerPOVGhost(nullptr);
  3871. }
  3872. else if (strcmp(sep->arg[0], "controleffects") == 0)
  3873. {
  3874. if(cmdTarget && cmdTarget->IsEntity()) {
  3875. ((Entity*)cmdTarget)->SendControlEffectDetailsToClient(client);
  3876. }
  3877. else {
  3878. client->GetPlayer()->SendControlEffectDetailsToClient(client);
  3879. }
  3880. }
  3881. else if (strcmp(sep->arg[0], "luadebug") == 0)
  3882. {
  3883. client->SetLuaDebugClient(onOff);
  3884. #if defined(__GNUC__)
  3885. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3886. #else
  3887. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  3888. #endif
  3889. if (onOff)
  3890. {
  3891. if (lua_interface)
  3892. lua_interface->UpdateDebugClients(client);
  3893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3894. }
  3895. else
  3896. {
  3897. if (lua_interface)
  3898. lua_interface->RemoveDebugClients(client);
  3899. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3900. }
  3901. }
  3902. }
  3903. break;
  3904. }
  3905. case COMMAND_ATTACK:
  3906. case COMMAND_AUTO_ATTACK:{
  3907. int8 type = 1;
  3908. bool update = false;
  3909. Player* player = client->GetPlayer();
  3910. if(!player)
  3911. break;
  3912. bool incombat = player->EngagedInCombat();
  3913. if(sep && sep->arg[0] && sep->IsNumber(0))
  3914. type = atoi(sep->arg[0]);
  3915. if(!client->GetPlayer()->Alive()){
  3916. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  3917. break;
  3918. }
  3919. if(type == 0){
  3920. if(incombat)
  3921. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3922. player->StopCombat(type);
  3923. update = true;
  3924. }
  3925. else {
  3926. if(type == 2){
  3927. player->InCombat(false);
  3928. if(incombat && player->GetRangeAttack()){
  3929. player->StopCombat(type);
  3930. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3931. update = true;
  3932. }
  3933. else{
  3934. player->SetRangeAttack(true);
  3935. player->InCombat(true, true);
  3936. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3937. update = true;
  3938. }
  3939. }
  3940. else {
  3941. player->InCombat(false, true);
  3942. player->SetRangeAttack(false);
  3943. player->InCombat(true);
  3944. if(!incombat) {
  3945. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3946. update = true;
  3947. }
  3948. }
  3949. /*else
  3950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  3951. }
  3952. if(update) {
  3953. player->SetCharSheetChanged(true);
  3954. }
  3955. break;
  3956. }
  3957. case COMMAND_DEPOP:{
  3958. bool allow_respawns = false;
  3959. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3960. if(atoi(sep->arg[0]) == 1)
  3961. allow_respawns = true;
  3962. }
  3963. client->GetCurrentZone()->Depop(allow_respawns);
  3964. break;
  3965. }
  3966. case COMMAND_REPOP:{
  3967. client->GetCurrentZone()->Depop(false, true);
  3968. break;
  3969. }
  3970. case COMMAND_BUYBACK:{
  3971. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3972. // 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
  3973. int64 id = atoi64(sep->arg[0]);
  3974. // get the first int32, the item id
  3975. //int32 item_id = (int32)id;
  3976. // get the second int32, the unique id
  3977. int32 unique_id = (int32)(id>>32);
  3978. int8 quantity = atoi(sep->arg[1]);
  3979. if(quantity == 255)
  3980. quantity = 1;
  3981. client->BuyBack(unique_id, quantity);
  3982. }
  3983. break;
  3984. }
  3985. case COMMAND_MERCHANT_BUY:{
  3986. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3987. int32 item_id = atoul(sep->arg[0]);
  3988. int8 quantity = atoi(sep->arg[1]);
  3989. client->BuyItem(item_id, quantity);
  3990. }
  3991. else
  3992. Command_SendMerchantWindow(client, sep);
  3993. break;
  3994. }
  3995. case COMMAND_MERCHANT_SELL:{
  3996. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3997. // 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
  3998. int64 id = atoi64(sep->arg[0]);
  3999. // get the first int32, the item id
  4000. int32 item_id = (int32)id;
  4001. // get the second int32, the unique id
  4002. int32 unique_id = (int32)(id>>32);
  4003. int8 quantity = atoi(sep->arg[1]);
  4004. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  4005. client->SellItem(item_id, quantity, unique_id);
  4006. }
  4007. break;
  4008. }
  4009. case COMMAND_MENDER_REPAIR: {
  4010. if (sep && sep->arg[0] && sep->IsNumber(0))
  4011. client->RepairItem(atoul(sep->arg[0]));
  4012. break;
  4013. }
  4014. case COMMAND_MENDER_REPAIR_ALL: {
  4015. client->RepairAllItems();
  4016. break;
  4017. }
  4018. case COMMAND_CANCEL_MERCHANT:{
  4019. client->SetMerchantTransaction(0);
  4020. break;
  4021. }
  4022. case COMMAND_START_MERCHANT:{
  4023. break;
  4024. }
  4025. case COMMAND_INVULNERABLE:{
  4026. sint8 val = -1;
  4027. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4028. val = atoi(sep->arg[0]);
  4029. //devn00b: Fix for linux builds
  4030. #if defined(__GNUC__)
  4031. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  4032. #else
  4033. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4034. #endif
  4035. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4036. client->GetPlayer()->SetInvulnerable(val==1);
  4037. if(client->GetPlayer()->GetInvulnerable())
  4038. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  4039. else
  4040. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  4041. }
  4042. if(val == -1)
  4043. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  4044. break;
  4045. }
  4046. case COMMAND_REPAIR: {
  4047. Spawn* spawn = cmdTarget;
  4048. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  4049. client->SendHailCommand(spawn);
  4050. client->SetMerchantTransaction(spawn);
  4051. client->SendRepairList();
  4052. }
  4053. break;
  4054. }
  4055. case COMMAND_LOTTO: {
  4056. Spawn* spawn = cmdTarget;
  4057. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  4058. client->SetMerchantTransaction(spawn);
  4059. client->ShowLottoWindow();
  4060. }
  4061. break;
  4062. }
  4063. case COMMAND_ACCEPT_REWARD:{
  4064. int32 unknown = 0;
  4065. int32 selectable_item_id = 0;
  4066. //Quest *quest = 0;
  4067. /* no idea what the first argument is for (faction maybe?)
  4068. if the reward has a selectable item reward, it's sent as the second argument
  4069. if neither of these are included in the reward, there is no sep
  4070. 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
  4071. only 1 quest or collection reward may be displayed at a time */
  4072. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  4073. unknown = atoul(sep->arg[0]);
  4074. selectable_item_id = atoul(sep->arg[1]);
  4075. }
  4076. /* this logic here may seem unexpected, but the quest queue response for GetPendingQuestAcceptance is only populated if it is the current reward displayed to the client based on a quest
  4077. ** Otherwise it will likely be a DoF client scenario (pending item rewards, selectable item rewards) which is specifying an item id
  4078. ** lastly it will be a collection which also supplies an item id and you can only have one pending collection turn in at a time (they queue against Client::HandInCollections
  4079. */
  4080. int32 item_id = 0;
  4081. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  4082. item_id = atoul(sep->arg[0]);
  4083. bool collectedItems = client->GetPlayer()->AcceptQuestReward(item_id, selectable_item_id);
  4084. if (collectedItems) {
  4085. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4086. if (outapp)
  4087. client->QueuePacket(outapp);
  4088. }
  4089. else
  4090. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  4091. break;
  4092. }
  4093. case COMMAND_BUY_FROM_BROKER:{
  4094. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4095. int32 item_id = atoul(sep->arg[0]);
  4096. int16 quantity = atoul(sep->arg[1]);
  4097. Item* item = master_item_list.GetItem(item_id);
  4098. if(item && item->generic_info.max_charges > 1)
  4099. quantity = item->generic_info.max_charges;
  4100. client->AddItem(item_id, quantity, AddItemType::BUY_FROM_BROKER);
  4101. }
  4102. break;
  4103. }
  4104. case COMMAND_SEARCH_STORES_PAGE:{
  4105. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4106. int32 page = atoul(sep->arg[0]);
  4107. client->SearchStore(page);
  4108. }
  4109. break;
  4110. }
  4111. case COMMAND_SEARCH_STORES:{
  4112. if(sep && sep->arg[0][0]){
  4113. const char* values = sep->argplus[0];
  4114. if(values){
  4115. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  4116. map<string, string> str_values = TranslateBrokerRequest(values);
  4117. vector<Item*>* items = master_item_list.GetItems(str_values, client);
  4118. if(items){
  4119. client->SetItemSearch(items);
  4120. client->SearchStore(0);
  4121. }
  4122. }
  4123. }
  4124. break;
  4125. }
  4126. case COMMAND_LUADEBUG:{
  4127. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  4128. client->SetLuaDebugClient(true);
  4129. if(lua_interface)
  4130. lua_interface->UpdateDebugClients(client);
  4131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4132. }
  4133. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  4134. client->SetLuaDebugClient(false);
  4135. if(lua_interface)
  4136. lua_interface->RemoveDebugClients(client);
  4137. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4138. }
  4139. else{
  4140. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  4141. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  4142. }
  4143. break;
  4144. }
  4145. case COMMAND_SPAWN_GROUP:
  4146. {
  4147. Spawn* target = cmdTarget;
  4148. if(target && target->IsPlayer() == false)
  4149. {
  4150. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  4151. {
  4152. if(target->GetSpawnLocationPlacementID() > 0)
  4153. {
  4154. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  4155. {
  4156. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  4157. if(id > 0)
  4158. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  4159. else
  4160. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  4161. target->SetSpawnGroupID(id);
  4162. target->AddSpawnToGroup(target);
  4163. }
  4164. else
  4165. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  4166. }
  4167. else
  4168. 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.");
  4169. }
  4170. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  4171. {
  4172. if(sep->arg[1] && sep->IsNumber(1))
  4173. {
  4174. int32 group_id = atoul(sep->arg[1]);
  4175. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  4176. if(leader)
  4177. {
  4178. leader->AddSpawnToGroup(target);
  4179. target->SetSpawnGroupID(group_id);
  4180. if(database.SpawnGroupAddSpawn(target, group_id))
  4181. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  4182. else
  4183. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  4184. }
  4185. else
  4186. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  4187. }
  4188. else
  4189. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  4190. }
  4191. else if(target->GetSpawnGroupID() == 0)
  4192. {
  4193. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  4194. }
  4195. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  4196. {
  4197. int32 group_id = target->GetSpawnGroupID();
  4198. target->RemoveSpawnFromGroup();
  4199. if(database.SpawnGroupRemoveSpawn(target, group_id))
  4200. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  4201. else
  4202. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  4203. }
  4204. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  4205. {
  4206. int32 group_id = target->GetSpawnGroupID();
  4207. if(sep->arg[1] && sep->IsNumber(1))
  4208. {
  4209. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  4210. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  4211. else
  4212. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  4213. }
  4214. else
  4215. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  4216. }
  4217. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  4218. {
  4219. int32 group_id = target->GetSpawnGroupID();
  4220. if(sep->arg[1] && sep->IsNumber(1))
  4221. {
  4222. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  4223. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  4224. else
  4225. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  4226. }
  4227. else
  4228. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  4229. }
  4230. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  4231. {
  4232. if(sep->arg[1] && sep->IsNumber(1))
  4233. {
  4234. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  4235. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  4236. else
  4237. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  4238. }
  4239. else
  4240. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  4241. }
  4242. else
  4243. {
  4244. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  4245. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  4246. }
  4247. }
  4248. else
  4249. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  4250. break;
  4251. }
  4252. case COMMAND_SPAWN_COMBINE:{
  4253. Spawn* spawn = cmdTarget;
  4254. float radius = 0;
  4255. bool failed = true;
  4256. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  4257. failed = false;
  4258. if(spawn->GetSpawnGroupID() > 0){
  4259. 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.");
  4260. }
  4261. else if(sep->IsNumber(0)){
  4262. radius = atof(sep->arg[0]);
  4263. client->CombineSpawns(radius, spawn);
  4264. }
  4265. else{
  4266. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  4267. client->AddCombineSpawn(spawn);
  4268. }
  4269. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  4270. client->RemoveCombineSpawn(spawn);
  4271. }
  4272. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  4273. const char* name = 0;
  4274. if(sep->arg[1] && sep->arg[1][0])
  4275. name = sep->argplus[1];
  4276. client->SaveCombineSpawns(name);
  4277. }
  4278. else
  4279. failed = true;
  4280. }
  4281. }
  4282. if(failed){
  4283. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  4284. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  4285. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  4286. }
  4287. break;
  4288. }
  4289. case COMMAND_SPAWN_CREATE:{
  4290. Spawn* spawn = 0;
  4291. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4292. spawn = new Object();
  4293. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4294. }
  4295. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4296. spawn = new GroundSpawn();
  4297. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4298. }
  4299. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4300. spawn = new Sign();
  4301. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4302. }
  4303. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4304. spawn = new NPC();
  4305. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4306. spawn->appearance.pos.collision_radius = 32;
  4307. spawn->secondary_command_list_id = 0;
  4308. spawn->primary_command_list_id = 0;
  4309. spawn->appearance.display_name = 1;
  4310. spawn->appearance.show_level = 1;
  4311. spawn->appearance.attackable = 1;
  4312. }
  4313. else{
  4314. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  4315. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  4316. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  4317. break;
  4318. }
  4319. spawn->SetID(Spawn::NextID());
  4320. spawn->SetX(client->GetPlayer()->GetX());
  4321. spawn->SetY(client->GetPlayer()->GetY());
  4322. spawn->SetZ(client->GetPlayer()->GetZ());
  4323. spawn->SetHeading(client->GetPlayer()->GetHeading());
  4324. spawn->SetSpawnOrigX(spawn->GetX());
  4325. spawn->SetSpawnOrigY(spawn->GetY());
  4326. spawn->SetSpawnOrigZ(spawn->GetZ());
  4327. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4328. if(spawn->IsSign())
  4329. {
  4330. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  4331. ((Sign*)spawn)->SetSignDistance(20.0f);
  4332. ((Sign*)spawn)->SetIncludeLocation(1);
  4333. ((Sign*)spawn)->SetIncludeHeading(1);
  4334. ((Sign*)spawn)->SetInitialState(1);
  4335. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  4336. ((Sign*)spawn)->SetActivityStatus(64);
  4337. spawn->appearance.race = 0;
  4338. spawn->SetLevel(0);
  4339. spawn->SetHP(0);
  4340. spawn->SetTotalHP(0);
  4341. spawn->SetPower(0);
  4342. spawn->SetTotalPower(0);
  4343. spawn->SetDifficulty(0);
  4344. spawn->SetTargetable(0);
  4345. spawn->SetSogaModelType(0);
  4346. spawn->SetCollisionRadius(19);
  4347. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  4348. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  4349. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  4350. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4351. spawn->appearance.model_type = atoul(sep->arg[1]);
  4352. }
  4353. else
  4354. {
  4355. spawn->appearance.targetable = 1;
  4356. spawn->appearance.race = 255;
  4357. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4358. spawn->SetModelType(atoi(sep->arg[1]));
  4359. spawn->SetAdventureClass(atoi(sep->arg[2]));
  4360. spawn->SetLevel(atoi(sep->arg[3]));
  4361. spawn->SetName(sep->arg[4]);
  4362. if(sep->arg[5][0] && sep->IsNumber(5))
  4363. spawn->SetDifficulty(atoi(sep->arg[5]));
  4364. if(sep->arg[6][0] && sep->IsNumber(6))
  4365. spawn->size = atoi(sep->arg[6]);
  4366. if(spawn->GetTotalHP() == 0){
  4367. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  4368. spawn->SetHP(25*spawn->GetLevel() + 1);
  4369. }
  4370. if(spawn->GetTotalPower() == 0){
  4371. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  4372. spawn->SetPower(25*spawn->GetLevel() + 1);
  4373. }
  4374. }
  4375. client->GetCurrentZone()->AddSpawn(spawn);
  4376. break;
  4377. }
  4378. case COMMAND_SPAWN_EQUIPMENT:{
  4379. Spawn* spawn = cmdTarget;
  4380. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  4381. int8 slot = atoi(sep->arg[0]);
  4382. int16 type = atoi(sep->arg[1]);
  4383. int8 red = 0;
  4384. int8 green = 0;
  4385. int8 blue = 0;
  4386. int8 h_red = 0;
  4387. int8 h_green = 0;
  4388. int8 h_blue = 0;
  4389. if(sep->arg[2])
  4390. red = atoi(sep->arg[2]);
  4391. if(sep->arg[3])
  4392. green = atoi(sep->arg[3]);
  4393. if(sep->arg[4])
  4394. blue = atoi(sep->arg[4]);
  4395. if(sep->arg[5])
  4396. h_red = atoi(sep->arg[5]);
  4397. if(sep->arg[6])
  4398. h_green = atoi(sep->arg[6]);
  4399. if(sep->arg[7])
  4400. h_blue = atoi(sep->arg[7]);
  4401. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  4402. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  4403. }
  4404. else{
  4405. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  4406. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  4407. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  4408. }
  4409. break;
  4410. }
  4411. case COMMAND_SPAWN_DETAILS: {
  4412. Spawn* spawn = cmdTarget;
  4413. if (sep && sep->arg[0][0]) {
  4414. if (cmdTarget)
  4415. {
  4416. if (ToLower(string(sep->arg[0])) == "los")
  4417. {
  4418. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  4419. if (hasLOS)
  4420. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  4421. else
  4422. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  4423. break;
  4424. }
  4425. else if (ToLower(string(sep->arg[0])) == "bestz")
  4426. {
  4427. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  4428. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  4429. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  4430. break;
  4431. }
  4432. else if (ToLower(string(sep->arg[0])) == "inwater")
  4433. {
  4434. if (cmdTarget->GetRegionMap() == nullptr)
  4435. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  4436. else
  4437. {
  4438. bool inWater = cmdTarget->InWater();
  4439. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  4440. }
  4441. break;
  4442. }
  4443. else if (ToLower(string(sep->arg[0])) == "inlava")
  4444. {
  4445. if (cmdTarget->GetRegionMap() == nullptr)
  4446. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4447. else
  4448. {
  4449. bool inLava = cmdTarget->InLava();
  4450. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  4451. }
  4452. break;
  4453. }
  4454. else if (ToLower(string(sep->arg[0])) == "regions")
  4455. {
  4456. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  4457. if (cmdTarget->GetRegionMap() == nullptr)
  4458. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4459. else
  4460. {
  4461. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  4462. }
  4463. break;
  4464. }
  4465. else if (ToLower(string(sep->arg[0])) == "behind")
  4466. {
  4467. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  4468. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  4469. break;
  4470. }
  4471. else if (ToLower(string(sep->arg[0])) == "infront")
  4472. {
  4473. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  4474. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  4475. break;
  4476. }
  4477. else if (ToLower(string(sep->arg[0])) == "flank")
  4478. {
  4479. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  4480. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  4481. break;
  4482. }
  4483. else if (ToLower(string(sep->arg[0])) == "aggro")
  4484. {
  4485. if(cmdTarget->IsNPC() && ((NPC*)cmdTarget)->Brain()) {
  4486. ((NPC*)cmdTarget)->Brain()->SendEncounterList(client);
  4487. ((NPC*)cmdTarget)->Brain()->SendHateList(client);
  4488. }
  4489. else {
  4490. client->SimpleMessage(CHANNEL_COLOR_RED, "/spawn details aggro is for NPCs only!");
  4491. }
  4492. break;
  4493. }
  4494. else if (ToLower(string(sep->arg[0])) == "angle")
  4495. {
  4496. float spawnAngle = client->GetPlayer()->GetFaceTarget(cmdTarget->GetX(), cmdTarget->GetZ());
  4497. client->Message(CHANNEL_COLOR_YELLOW, "Angle %f between player %s and target %s", spawnAngle, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget()->GetName() : client->GetPlayer()->GetName(), client->GetPlayer()->GetName());
  4498. break;
  4499. }
  4500. }
  4501. if (sep->IsNumber(0))
  4502. {
  4503. float radius = atof(sep->arg[0]);
  4504. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  4505. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  4506. break;
  4507. }
  4508. }
  4509. if (spawn) {
  4510. const char* type = "NPC";
  4511. if (spawn->IsObject())
  4512. type = "Object";
  4513. else if (spawn->IsSign())
  4514. type = "Sign";
  4515. else if (spawn->IsWidget())
  4516. type = "Widget";
  4517. else if (spawn->IsGroundSpawn())
  4518. type = "GroundSpawn";
  4519. int16 race_type = race_types_list.GetRaceType(spawn->GetModelType());
  4520. int16 race_base_type = race_types_list.GetRaceBaseType(spawn->GetModelType());
  4521. char* category = race_types_list.GetRaceTypeCategory(spawn->GetModelType());
  4522. char* subcategory = race_types_list.GetRaceTypeSubCategory(spawn->GetModelType());
  4523. char* modelname = race_types_list.GetRaceTypeModelName(spawn->GetModelType());
  4524. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  4525. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  4526. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  4527. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  4528. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  4529. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  4530. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u / %u, Power: %u / %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetTotalHP(), spawn->GetPower(), spawn->GetTotalPower());
  4531. 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());
  4532. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetDifficulty(), spawn->GetHeroic());
  4533. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  4534. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  4535. if (spawn->IsEntity()) {
  4536. 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());
  4537. 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());
  4538. }
  4539. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i, Race Type: %u, Race Base Type: %u, Race Category: %s (subcategory: %s), Model Name: %s.", spawn->GetModelType(), spawn->GetSogaModelType(), race_type, race_base_type, category, subcategory, modelname);
  4540. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  4541. 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());
  4542. 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);
  4543. if (spawn->IsNPC())
  4544. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  4545. if (spawn->IsNPC()){
  4546. client->Message(CHANNEL_COLOR_YELLOW, "Heat Resist/Base: %u/%u",((NPC*)spawn)->GetHeatResistance(), ((NPC*)spawn)->GetHeatResistanceBase());
  4547. client->Message(CHANNEL_COLOR_YELLOW, "Cold Resist/Base: %u/%u",((NPC*)spawn)->GetColdResistance(), ((NPC*)spawn)->GetColdResistanceBase());
  4548. client->Message(CHANNEL_COLOR_YELLOW, "Magic Resist/Base: %u/%u",((NPC*)spawn)->GetMagicResistance(), ((NPC*)spawn)->GetMagicResistanceBase());
  4549. client->Message(CHANNEL_COLOR_YELLOW, "Mental Resist/Base: %u/%u",((NPC*)spawn)->GetMentalResistance(), ((NPC*)spawn)->GetMentalResistanceBase());
  4550. client->Message(CHANNEL_COLOR_YELLOW, "Divine Resist/Base: %u/%u",((NPC*)spawn)->GetDivineResistance(), ((NPC*)spawn)->GetDivineResistanceBase());
  4551. client->Message(CHANNEL_COLOR_YELLOW, "Disease Resist/Base: %u/%u",((NPC*)spawn)->GetDiseaseResistance(), ((NPC*)spawn)->GetDiseaseResistanceBase());
  4552. client->Message(CHANNEL_COLOR_YELLOW, "Poison Resist/Base: %u/%u",((NPC*)spawn)->GetPoisonResistance(), ((NPC*)spawn)->GetPoisonResistanceBase());
  4553. }
  4554. string details;
  4555. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  4556. details += "Type: " + string(type) + "\n";
  4557. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  4558. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  4559. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  4560. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  4561. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  4562. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  4563. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  4564. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  4565. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  4566. details += "HP: " + to_string(spawn->GetHP()) + " / " + to_string(spawn->GetTotalHP()) + "(" + to_string(spawn->GetIntHPRatio()) + "%)\n";
  4567. details += "Power: " + to_string(spawn->GetPower()) + + " / " + to_string(spawn->GetTotalPower()) + "\n";
  4568. details += "Difficulty: " + to_string(spawn->GetDifficulty()) + "\n";
  4569. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  4570. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  4571. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  4572. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  4573. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  4574. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  4575. char x[16];
  4576. sprintf(x, "%.2f", spawn->GetX());
  4577. char y[16];
  4578. sprintf(y, "%.2f", spawn->GetY());
  4579. char z[16];
  4580. sprintf(z, "%.2f", spawn->GetZ());
  4581. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  4582. string details2;
  4583. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  4584. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  4585. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  4586. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  4587. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  4588. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  4589. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  4590. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  4591. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  4592. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  4593. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  4594. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  4595. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  4596. details2 += "Race Type: " + to_string(race_type) + "\n";
  4597. details2 += "Race Base Type: " + to_string(race_base_type) + "\n";
  4598. details2 += "Race Category (Sub Category): " + std::string(category) + " (" + std::string(subcategory) + ")\n";
  4599. details2 += "Model Name: " + std::string(modelname) + "\n";
  4600. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  4601. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  4602. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  4603. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  4604. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  4605. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  4606. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  4607. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  4608. string details3;
  4609. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  4610. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  4611. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  4612. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  4613. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  4614. if(spawn->IsSign()) {
  4615. details3 += "Sign Language: " + to_string(((Sign*)spawn)->GetLanguage()) + "\n";
  4616. }
  4617. if(spawn->IsEntity())
  4618. {
  4619. Entity* ent = (Entity*)spawn;
  4620. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  4621. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  4622. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  4623. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  4624. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  4625. }
  4626. string details4;
  4627. if (spawn->IsEntity()) {
  4628. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  4629. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4630. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4631. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4632. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4633. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4634. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4635. if (spawn->IsNPC()) {
  4636. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4637. }
  4638. }
  4639. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4640. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4641. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4642. client->SendShowBook(client->GetPlayer(), title, 0, 4, details, details2, details3, details4);
  4643. }
  4644. else {
  4645. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4646. 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.");
  4647. }
  4648. break;
  4649. }
  4650. case COMMAND_SPAWN_TARGET:{
  4651. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4652. int32 spawn_id = atoul(sep->arg[0]);
  4653. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4654. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4655. }
  4656. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4657. float distance = atof(sep->arg[1]);
  4658. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4659. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4660. }
  4661. else{
  4662. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4663. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4664. }
  4665. break;
  4666. }
  4667. case COMMAND_SPAWN_SET:
  4668. {
  4669. Spawn* spawn = cmdTarget;
  4670. sint16 set_type = -1;
  4671. string type_str;
  4672. if (spawn)
  4673. {
  4674. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4675. 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)
  4676. {
  4677. // set the type, which will be 0 if location or list or invalid
  4678. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4679. }
  4680. if(set_type > 0)
  4681. {
  4682. // check if spawn set is NOT a char update, or not location, or isn't a number
  4683. if(!(set_type >= SPAWN_SET_VALUE_PREFIX) && !(set_type <= SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL) && set_type != SPAWN_SET_VALUE_NAME && ((set_type < SPAWN_SET_VALUE_SPAWN_SCRIPT) || (set_type > SPAWN_SET_VALUE_SUB_TITLE)) && set_type != SPAWN_SET_VALUE_LOCATION && sep->IsNumber(1) == false)
  4684. {
  4685. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4686. }
  4687. else
  4688. {
  4689. string name = string(spawn->GetName());
  4690. bool customSetSpawn = false;
  4691. if(set_type >= SPAWN_SET_CHEEK_TYPE && set_type <= SPAWN_SET_SOGA_NOSE_TYPE)
  4692. {
  4693. int8 index = sep->IsNumber(2) ? atoul(sep->arg[2]) : 0;
  4694. // override the standard setspawncommand, we pass arguments different!
  4695. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1], true, false, nullptr, index))
  4696. customSetSpawn = true;
  4697. }
  4698. if(customSetSpawn || SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4699. {
  4700. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4701. {
  4702. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4703. }
  4704. else if (set_type == SPAWN_SET_VALUE_NAME)
  4705. {
  4706. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4707. }
  4708. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4709. {
  4710. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4711. }
  4712. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4713. {
  4714. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4715. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s' (DBID: %u)", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str(), spawn->GetDatabaseID());
  4716. }
  4717. else
  4718. {
  4719. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s' (DBID: %u)", sep->arg[0], sep->arg[1], name.c_str(), spawn->GetDatabaseID());
  4720. }
  4721. switch (set_type)
  4722. {
  4723. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4724. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4725. case SPAWN_SET_VALUE_FACTION:
  4726. case SPAWN_SET_AAXP_REWARDS:
  4727. case SPAWN_SET_CHEEK_TYPE:
  4728. case SPAWN_SET_CHIN_TYPE:
  4729. case SPAWN_SET_EAR_TYPE:
  4730. case SPAWN_SET_EYE_BROW_TYPE:
  4731. case SPAWN_SET_EYE_TYPE:
  4732. case SPAWN_SET_LIP_TYPE:
  4733. case SPAWN_SET_NOSE_TYPE:
  4734. case SPAWN_SET_BODY_SIZE:
  4735. case SPAWN_SET_BODY_AGE:
  4736. case SPAWN_SET_SOGA_CHEEK_TYPE:
  4737. case SPAWN_SET_SOGA_CHIN_TYPE:
  4738. case SPAWN_SET_SOGA_EAR_TYPE:
  4739. case SPAWN_SET_SOGA_EYE_BROW_TYPE:
  4740. case SPAWN_SET_SOGA_EYE_TYPE:
  4741. case SPAWN_SET_SOGA_LIP_TYPE:
  4742. case SPAWN_SET_SOGA_NOSE_TYPE:
  4743. case SPAWN_SET_SOGA_BODY_SIZE:
  4744. case SPAWN_SET_SOGA_BODY_AGE:
  4745. case SPAWN_SET_ATTACK_TYPE:
  4746. case SPAWN_SET_RACE_TYPE:
  4747. case SPAWN_SET_LOOT_TIER:
  4748. case SPAWN_SET_LOOT_DROP_TYPE:
  4749. case SPAWN_SET_SCARED_STRONG_PLAYERS:
  4750. {
  4751. // not applicable already ran db command
  4752. break;
  4753. }
  4754. default:
  4755. {
  4756. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4757. break;
  4758. }
  4759. }
  4760. 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))
  4761. {
  4762. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4763. {
  4764. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4765. }
  4766. else if(spawn->GetSpawnLocationID() > 0)
  4767. {
  4768. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4769. }
  4770. }
  4771. else
  4772. {
  4773. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4774. {
  4775. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4776. }
  4777. else if(spawn->GetDatabaseID() > 0)
  4778. {
  4779. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4780. }
  4781. }
  4782. }
  4783. }
  4784. }
  4785. else if(set_type == 0)
  4786. {
  4787. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4788. map<string, int8>::iterator itr;
  4789. int i=0;
  4790. string list;
  4791. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4792. {
  4793. if(i==10)
  4794. {
  4795. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4796. i = 0;
  4797. }
  4798. if(i>0)
  4799. {
  4800. list.append(", ").append(itr->first);
  4801. }
  4802. else
  4803. {
  4804. list = itr->first;
  4805. }
  4806. }
  4807. if(list.length() > 0)
  4808. {
  4809. // if 1 or more, display in client.
  4810. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4811. }
  4812. }
  4813. else
  4814. {
  4815. // syntax fail
  4816. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4817. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4818. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4819. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4820. }
  4821. }
  4822. break;
  4823. }
  4824. case COMMAND_SPAWN_REMOVE:{
  4825. Spawn* spawn = cmdTarget;
  4826. if(spawn && !spawn->IsPlayer()){
  4827. if(spawn->GetSpawnLocationID() > 0){
  4828. string name = string(spawn->GetName());
  4829. int32 dbid = spawn->GetDatabaseID();
  4830. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4831. client->GetCurrentZone()->RemoveSpawn(spawn, true, false, true, true, true);
  4832. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone for spawn '%s' (DBID: %u)", name.c_str(), dbid);
  4833. }
  4834. else
  4835. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4836. }
  4837. else
  4838. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4839. }
  4840. else{
  4841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4842. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4843. }
  4844. break;
  4845. }
  4846. case COMMAND_SPAWN_LIST:{
  4847. if(sep && sep->arg[0][0]){
  4848. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4849. vector<string>::iterator itr;
  4850. if(results){
  4851. for(itr=results->begin();itr!=results->end();itr++){
  4852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4853. }
  4854. safe_delete(results);
  4855. }
  4856. else
  4857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4858. }
  4859. else{
  4860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4863. }
  4864. break;
  4865. }
  4866. case COMMAND_SPAWN_ADD:{
  4867. Spawn* spawn = cmdTarget;
  4868. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  4869. if(spawn->GetSpawnLocationID() > 0){
  4870. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4871. break;
  4872. }
  4873. if(spawn->GetDatabaseID() == 0){
  4874. if(database.SaveSpawnInfo(spawn)) {
  4875. char spawn_type[32];
  4876. memset(spawn_type, 0, sizeof(spawn_type));
  4877. if (spawn->IsNPC())
  4878. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4879. else if (spawn->IsObject())
  4880. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4881. else if (spawn->IsSign())
  4882. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4883. else if (spawn->IsGroundSpawn())
  4884. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4885. else
  4886. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4887. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4888. }
  4889. else
  4890. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4891. }
  4892. int32 spawn_group_id = 0;
  4893. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4894. spawn_group_id = database.GetNextSpawnLocation();
  4895. else
  4896. spawn_group_id = atol(sep->arg[0]);
  4897. int8 percent = 100;
  4898. if(sep->arg[2] && sep->IsNumber(2))
  4899. percent = atoi(sep->arg[2]);
  4900. spawn->SetSpawnLocationID(spawn_group_id);
  4901. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4902. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4903. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4904. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4905. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4906. else
  4907. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  4908. }
  4909. else{
  4910. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  4911. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  4912. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  4913. }
  4914. break;
  4915. }
  4916. case COMMAND_SPAWN:{
  4917. int32 id = 0;
  4918. Spawn* spawn = 0;
  4919. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4920. id = atol(sep->arg[0]);
  4921. spawn = client->GetCurrentZone()->GetSpawn(id);
  4922. }
  4923. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  4924. id = 0;
  4925. if(!id || !spawn){
  4926. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  4927. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  4928. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  4929. safe_delete(sep);
  4930. return;
  4931. }
  4932. if(sep && sep->arg[1][0]){
  4933. float x = atof(sep->arg[1]);
  4934. spawn->appearance.pos.X = x;
  4935. }
  4936. else
  4937. spawn->SetX(client->GetPlayer()->GetX(), false);
  4938. if(sep && sep->arg[2][0]){
  4939. float y = atof(sep->arg[2]);
  4940. spawn->appearance.pos.Y = y;
  4941. }
  4942. else
  4943. spawn->SetY(client->GetPlayer()->GetY(), false);
  4944. if(sep && sep->arg[3][0]){
  4945. float z = atof(sep->arg[3]);
  4946. spawn->appearance.pos.Z = z;
  4947. }
  4948. else
  4949. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  4950. if(sep && sep->arg[4][0]){
  4951. float heading = atof(sep->arg[4]);
  4952. spawn->SetHeading(heading);
  4953. }
  4954. else
  4955. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  4956. spawn->SetSpawnOrigX(spawn->GetX());
  4957. spawn->SetSpawnOrigY(spawn->GetY());
  4958. spawn->SetSpawnOrigZ(spawn->GetZ());
  4959. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4960. if(sep && sep->arg[5][0])
  4961. spawn->SetLocation(atoul(sep->arg[5]));
  4962. else
  4963. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4964. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  4965. spawn->SetTotalHP(spawn->GetLevel() * 15);
  4966. spawn->SetHP(spawn->GetTotalHP());
  4967. }
  4968. if(spawn->GetTotalPower() == 0){
  4969. spawn->SetTotalPower(spawn->GetLevel() * 15);
  4970. spawn->SetPower(spawn->GetTotalPower());
  4971. }
  4972. const char* script = world.GetSpawnScript(id);
  4973. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  4974. spawn->SetSpawnScript(string(script));
  4975. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  4976. client->GetCurrentZone()->AddSpawn(spawn);
  4977. if(spawn->IsNPC())
  4978. spawn->GetZone()->AddLoot((NPC*)spawn);
  4979. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  4980. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  4981. break;
  4982. }
  4983. case COMMAND_ADMINFLAG:
  4984. {
  4985. if(sep && sep->arg[0]){
  4986. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  4987. sint16 new_status = atoi(sep->arg[1]);
  4988. if(tmp_status == -10)
  4989. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  4990. else if(tmp_status >= client->GetAdminStatus())
  4991. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  4992. else if (new_status > client->GetAdminStatus())
  4993. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  4994. else{
  4995. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  4996. if (!client2)
  4997. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  4998. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  4999. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  5000. if (client2) {
  5001. client2->SetAdminStatus(new_status);
  5002. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  5003. }
  5004. }
  5005. else
  5006. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  5007. }
  5008. }else{
  5009. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  5010. if(status != client->GetAdminStatus())
  5011. {
  5012. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  5013. client->SetAdminStatus(status);
  5014. }
  5015. else
  5016. {
  5017. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  5018. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  5019. client->Message(CHANNEL_COLOR_YELLOW," Admin User: %i", status);
  5020. }
  5021. }
  5022. break;
  5023. }
  5024. case COMMAND_CANNEDEMOTE:{
  5025. client->GetCurrentZone()->HandleEmote(client->GetPlayer(), command_parms->data);
  5026. break;
  5027. }
  5028. case COMMAND_BROADCAST: {
  5029. if (sep && sep->arg[0])
  5030. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  5031. else
  5032. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  5033. break;
  5034. }
  5035. case COMMAND_ANNOUNCE: {
  5036. if (sep && sep->arg[0])
  5037. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  5038. else
  5039. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  5040. break;
  5041. }
  5042. case COMMAND_RELOAD_ITEMS:{
  5043. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  5044. int32 item_id = (sep && sep->arg[0]) ? atoul(sep->arg[0]) : 0;
  5045. if(item_id > 0) {
  5046. client->Message(CHANNEL_COLOR_YELLOW, "Reloading item %u based on /reload items [item_id].", item_id);
  5047. }
  5048. else {
  5049. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  5050. }
  5051. database.ReloadItemList(item_id);
  5052. if(!item_id) {
  5053. database.LoadMerchantInformation(); // we skip if there is only a reload of single item not all items
  5054. }
  5055. if(item_id > 0) {
  5056. client->Message(CHANNEL_COLOR_YELLOW, "Reloaded item %u.", item_id);
  5057. }
  5058. else {
  5059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  5060. }
  5061. break;
  5062. }
  5063. case COMMAND_ENABLE_ABILITY_QUE:{
  5064. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  5065. if(app)
  5066. client->QueuePacket(app);
  5067. break;
  5068. }
  5069. case COMMAND_ITEMSEARCH:
  5070. case COMMAND_FROMBROKER:{
  5071. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  5072. if (packet) {
  5073. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  5074. //packet->setDataByName("unknown", 1);
  5075. packet->setDataByName("unknown2", 5, 0);
  5076. packet->setDataByName("unknown2", 20, 1);
  5077. packet->setDataByName("unknown2", 58, 3);
  5078. packet->setDataByName("unknown2", 40, 4);
  5079. client->QueuePacket(packet->serialize());
  5080. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  5081. if (packet2) {
  5082. packet2->setDataByName("char_id", client->GetCharacterID());
  5083. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  5084. safe_delete(packet2);
  5085. }
  5086. safe_delete(packet);
  5087. }
  5088. break;
  5089. }
  5090. case COMMAND_ANIMTEST:{
  5091. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  5092. if(command_packet){
  5093. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  5094. if (cmdTarget)
  5095. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  5096. command_packet->setDataByName ( "spawn_id" , id);
  5097. int animID = 1;
  5098. if(sep && sep->arg[0] && sep->IsNumber(0))
  5099. animID = atoi(sep->arg[0]);
  5100. VisualState* vs = NULL;
  5101. if(animID == 0)
  5102. {
  5103. vs = visual_states.FindVisualState(sep->arg[0]);
  5104. }
  5105. char msg[128];
  5106. sprintf(msg,"Animation Test ID: %i",animID);
  5107. command_packet->setMediumStringByName ( "emote_msg" , msg );
  5108. if(vs != NULL)
  5109. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  5110. else
  5111. command_packet->setDataByName ( "anim_type", animID );
  5112. command_packet->setDataByName ( "unknown0", 0 );
  5113. EQ2Packet* outapp = command_packet->serialize();
  5114. client->QueuePacket(outapp);
  5115. safe_delete(command_packet);
  5116. }
  5117. break;
  5118. }
  5119. case COMMAND_KICK:
  5120. {
  5121. if( sep == 0 || sep->arg[0] == 0)
  5122. {
  5123. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  5124. }
  5125. else
  5126. {
  5127. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  5128. if ( kickClient == client )
  5129. {
  5130. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  5131. break;
  5132. }
  5133. else if(kickClient != NULL)
  5134. {
  5135. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5136. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  5137. {
  5138. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5139. break;
  5140. }
  5141. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  5142. kickClient->Disconnect();
  5143. }
  5144. else
  5145. {
  5146. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5147. }
  5148. }
  5149. break;
  5150. }
  5151. case COMMAND_LOCK:
  5152. {
  5153. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  5154. int worldLocked = atoi(sep->arg[0]);
  5155. net.world_locked = worldLocked;
  5156. if ( worldLocked )
  5157. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  5158. else
  5159. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  5160. }
  5161. else
  5162. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  5163. break;
  5164. }
  5165. case COMMAND_BAN:{
  5166. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  5167. {
  5168. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  5169. }
  5170. else
  5171. {
  5172. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  5173. if ( kickClient == client )
  5174. {
  5175. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  5176. break;
  5177. }
  5178. else if(kickClient != NULL)
  5179. {
  5180. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5181. if ( maxStatus > client->GetAdminStatus( ) ||
  5182. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  5183. {
  5184. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5185. break;
  5186. }
  5187. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  5188. int perm = atol(sep->arg[1]);
  5189. if ( perm == 1 )
  5190. database.UpdateAdminStatus(sep->arg[0],-2);
  5191. else
  5192. database.UpdateAdminStatus(sep->arg[0],-1);
  5193. kickClient->Disconnect();
  5194. }
  5195. else
  5196. {
  5197. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5198. }
  5199. }
  5200. break;
  5201. }
  5202. case COMMAND_SET_COMBAT_VOICE:{
  5203. int32 value = 0;
  5204. if(sep && sep->arg[0] && sep->IsNumber(0))
  5205. value = atoi(sep->arg[0]);
  5206. client->GetPlayer()->SetCombatVoice(value);
  5207. break;
  5208. }
  5209. case COMMAND_SET_EMOTE_VOICE:{
  5210. int32 value = 0;
  5211. if(sep && sep->arg[0] && sep->IsNumber(0))
  5212. value = atoi(sep->arg[0]);
  5213. client->GetPlayer()->SetEmoteVoice(value);
  5214. break;
  5215. }
  5216. case COMMAND_GIVEITEM:{
  5217. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  5218. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  5219. if ( itemToClient == NULL )
  5220. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  5221. else
  5222. {
  5223. int32 item_id = atol(sep->arg[1]);
  5224. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  5225. itemToClient->AddItem(item_id);
  5226. }
  5227. }
  5228. else
  5229. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  5230. break;
  5231. }
  5232. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  5233. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  5234. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  5235. case COMMAND_SKILL :
  5236. case COMMAND_SKILL_ADD :
  5237. case COMMAND_SKILL_REMOVE :
  5238. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  5239. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  5240. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  5241. case COMMAND_ENTITYCOMMAND :
  5242. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  5243. case COMMAND_MERCHANT :
  5244. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  5245. case COMMAND_APPEARANCE :
  5246. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  5247. case COMMAND_TRACK : { Command_Track(client); break; }
  5248. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  5249. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  5250. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  5251. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  5252. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  5253. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  5254. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  5255. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  5256. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  5257. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  5258. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  5259. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  5260. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  5261. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  5262. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  5263. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  5264. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  5265. case COMMAND_LOCATION : { Command_Location(client); break; }
  5266. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  5267. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  5268. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  5269. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  5270. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  5271. case COMMAND_GRID : { Command_Grid(client, sep); break; }
  5272. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  5273. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  5274. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  5275. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  5276. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  5277. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  5278. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  5279. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  5280. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  5281. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  5282. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  5283. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  5284. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  5285. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  5286. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  5287. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  5288. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  5289. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  5290. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  5291. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  5292. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  5293. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  5294. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  5295. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  5296. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  5297. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  5298. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  5299. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  5300. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  5301. case COMMAND_MOTD : { Command_MOTD(client); break; }
  5302. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  5303. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  5304. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  5305. case COMMAND_TITLE : { Command_Title(client); break; }
  5306. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  5307. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  5308. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  5309. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  5310. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  5311. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  5312. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  5313. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  5314. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  5315. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  5316. case COMMAND_PET : { Command_Pet(client, sep); break; }
  5317. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  5318. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  5319. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  5320. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  5321. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  5322. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  5323. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  5324. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  5325. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  5326. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  5327. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  5328. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  5329. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  5330. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  5331. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  5332. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  5333. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  5334. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  5335. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  5336. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  5337. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  5338. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  5339. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  5340. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  5341. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  5342. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  5343. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  5344. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  5345. //devn00b
  5346. case COMMAND_MOOD : { Command_Mood(client, sep); break;}
  5347. case COMMAND_MODIFY : { Command_Modify(client); break; }
  5348. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  5349. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  5350. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  5351. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  5352. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  5353. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  5354. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  5355. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  5356. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  5357. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  5358. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  5359. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  5360. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  5361. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  5362. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  5363. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  5364. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  5365. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  5366. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  5367. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  5368. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  5369. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5370. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  5371. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  5372. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  5373. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  5374. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  5375. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  5376. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  5377. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  5378. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  5379. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  5380. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  5381. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  5382. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  5383. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  5384. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  5385. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  5386. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  5387. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  5388. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  5389. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  5390. case ADD_AA : { Add_AA(client, sep); break; }
  5391. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  5392. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  5393. case BACK_AA : { Back_AA(client, sep); break; }
  5394. case REMOVE_AA : { Remove_AA(client, sep); break; }
  5395. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  5396. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  5397. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  5398. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  5399. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  5400. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  5401. case COMMAND_CRAFTITEM: {
  5402. Item* item = 0;
  5403. if (sep && sep->IsNumber(0)) {
  5404. int32 item_id = atol(sep->arg[0]);
  5405. int32 quantity = 1;
  5406. if (sep->arg[1] && sep->IsNumber(1))
  5407. quantity = atoi(sep->arg[1]);
  5408. item = new Item(master_item_list.GetItem(item_id));
  5409. if (!item) {
  5410. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  5411. }
  5412. else {
  5413. item->details.count = quantity;
  5414. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  5415. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  5416. bool itemDeleted = false;
  5417. client->AddItem(item, &itemDeleted);
  5418. //Check for crafting quest updates
  5419. int8 update_amt = 0;
  5420. if (!itemDeleted && item->stack_count > 1)
  5421. update_amt = 1;
  5422. else
  5423. update_amt = quantity;
  5424. if(!itemDeleted)
  5425. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  5426. }
  5427. }
  5428. else {
  5429. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  5430. }
  5431. break;
  5432. }
  5433. case COMMAND_UNMENTOR:
  5434. case COMMAND_MENTOR: {
  5435. client->GetPlayer()->MentorTarget();
  5436. break;
  5437. }
  5438. case COMMAND_CANCEL_EFFECT: { Command_CancelEffect(client, sep); break; }
  5439. case COMMAND_CUREPLAYER: { Command_CurePlayer(client, sep); break; }
  5440. case COMMAND_SHARE_QUEST: { Command_ShareQuest(client, sep); break; }
  5441. case COMMAND_YELL: { Command_Yell(client, sep); break; }
  5442. default:
  5443. {
  5444. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  5445. break;
  5446. }
  5447. }
  5448. safe_delete(sep);
  5449. }
  5450. /******************** New COMMAND Handler Functions ********************/
  5451. /*
  5452. Started breaking apart the huge switch() for commands into sepErate
  5453. functions so it is easier to locate the blocks of code by command
  5454. -- JA 2012.03.03
  5455. */
  5456. // sample function header
  5457. /*
  5458. Function:
  5459. Purpose :
  5460. Params :
  5461. Dev :
  5462. Example :
  5463. */
  5464. //void Commands::Command()
  5465. //{
  5466. //}
  5467. /*
  5468. Function: Command_AcceptAdvancement()
  5469. Purpose : Player accepts a new advancement option
  5470. Params : Spell ID
  5471. Dev : Jabantiz
  5472. */
  5473. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  5474. {
  5475. Player *player = client->GetPlayer();
  5476. if (sep && sep->IsSet(0)) {
  5477. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  5478. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  5479. if (!player->HasSpell(trait->spellID, 0, true))
  5480. {
  5481. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5482. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5483. }
  5484. else
  5485. {
  5486. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5487. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  5488. player->RemoveSpellBookEntry(spell->GetSpellID());
  5489. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5490. player->UnlockSpell(spell);
  5491. client->SendSpellUpdate(spell);
  5492. }
  5493. // Spell book update
  5494. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  5495. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  5496. }
  5497. }
  5498. /*
  5499. Function:
  5500. Purpose :
  5501. Params :
  5502. Dev :
  5503. Example :
  5504. */
  5505. void Commands::Command_AFK(Client* client, Seperator* sep)
  5506. {
  5507. Player* player = client->GetPlayer();
  5508. player->toggle_character_flag(CF_AFK);
  5509. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  5510. if (player->get_character_flag(CF_AFK))
  5511. {
  5512. if (sep && sep->argplus[0])
  5513. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  5514. else
  5515. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  5516. string message = string(player->GetName()) + " is going afk.";
  5517. Spawn* target = player->GetTarget();
  5518. if (target && target != player)
  5519. {
  5520. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  5521. player->GetGender() == 1 ? message += "he" : message += "she";
  5522. message += " is going afk.";
  5523. }
  5524. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  5525. }
  5526. }
  5527. /*
  5528. Function: Command_Appearance()
  5529. Purpose : Handles /appearance commands
  5530. Params : list
  5531. Dev : Scatman
  5532. Example : /appearance list
  5533. */
  5534. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  5535. {
  5536. if( handler == COMMAND_APPEARANCE )
  5537. {
  5538. // /appearance command by itself shows help (to be extended)
  5539. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5540. return;
  5541. }
  5542. else if( handler == COMMAND_APPEARANCE_LIST )
  5543. {
  5544. // /appearance list command expects "name" param
  5545. if (sep && sep->arg[0])
  5546. {
  5547. const char* appearance_name = sep->argplus[0];
  5548. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  5549. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  5550. if (appearances)
  5551. {
  5552. vector<int16>::iterator itr;
  5553. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  5554. {
  5555. int16 id = *itr;
  5556. string name = database.GetAppearanceName(id);
  5557. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  5558. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  5559. }
  5560. safe_delete(appearances);
  5561. }
  5562. }
  5563. else // no param
  5564. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5565. }
  5566. }
  5567. /*
  5568. Function: Command_Claim()
  5569. Purpose : Summon veteran rewards
  5570. Params : nothing = show claim window, any number claims that item.
  5571. Dev : devn00b
  5572. Example : /claim 0 (claims the 1st item added to the list claim[0])
  5573. */
  5574. void Commands::Command_Claim(Client* client, Seperator* sep)
  5575. {
  5576. //if we were passed a claim id
  5577. if (sep && sep->argplus[0] && sep->IsNumber(0))
  5578. {
  5579. int32 char_id = client->GetCharacterID();
  5580. int8 my_claim_id = atoi(sep->argplus[0]);
  5581. vector<ClaimItems> claim = database.LoadCharacterClaimItems(char_id);
  5582. Item* item = master_item_list.GetItem(claim[my_claim_id].item_id);
  5583. database.ClaimItem(char_id, item->details.item_id, client);
  5584. return;
  5585. }
  5586. else {
  5587. //if no arg just send the window.
  5588. client->ShowClaimWindow();
  5589. return;
  5590. }
  5591. return;
  5592. }
  5593. /*
  5594. Function: Command_ClearAllQueued()
  5595. Purpose :
  5596. Params :
  5597. Dev :
  5598. Example :
  5599. */
  5600. void Commands::Command_ClearAllQueued(Client* client)
  5601. {
  5602. ZoneServer* zone = client->GetPlayer()->GetZone();
  5603. if (zone && zone->GetSpellProcess())
  5604. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  5605. }
  5606. /*
  5607. Function: Command_CancelMaintained()
  5608. Purpose : Cancels maintained spells
  5609. Params : Maintained Spell Index
  5610. Dev : Zcoretri
  5611. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  5612. */
  5613. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  5614. {
  5615. if (sep && sep->arg[0] && sep->IsNumber(0))
  5616. {
  5617. int32 spell_index = atoul(sep->arg[0]);
  5618. if(spell_index > 29)
  5619. return;
  5620. client->GetPlayer()->MMaintainedSpells.readlock(__FUNCTION__, __LINE__);
  5621. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  5622. client->GetPlayer()->MMaintainedSpells.releasereadlock(__FUNCTION__, __LINE__);
  5623. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled", false))
  5624. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  5625. }
  5626. }
  5627. /*
  5628. Function: Command_Create()
  5629. Purpose : Handler for starting Tradeskilling table
  5630. Params :
  5631. Dev : Zcoretri
  5632. Example :
  5633. */
  5634. void Commands::Command_Create(Client* client, Seperator* sep)
  5635. {
  5636. PrintSep(sep, "COMMAND_CREATE");
  5637. client->ShowRecipeBook();
  5638. }
  5639. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  5640. {
  5641. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  5642. if (sep && sep->arg[0] && sep->IsNumber(0))
  5643. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  5644. }
  5645. /*
  5646. Function: Command_Distance()
  5647. Purpose : Displays distance from targeted spawn
  5648. Params :
  5649. Dev : Scatman
  5650. Example : /distance
  5651. */
  5652. void Commands::Command_Distance(Client* client)
  5653. {
  5654. Spawn* target = client->GetPlayer()->GetTarget();
  5655. if (target)
  5656. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  5657. else
  5658. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  5659. }
  5660. /*
  5661. Function: Command_Duel()
  5662. Purpose : Handle the /duel commands - not yet implemented
  5663. Params : unknown
  5664. Dev :
  5665. Example :
  5666. */
  5667. void Commands::Command_Duel(Client* client, Seperator* sep)
  5668. {
  5669. PrintSep(sep, "COMMAND_DUEL");
  5670. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  5671. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5672. }
  5673. /*
  5674. Function: Command_DuelBet()
  5675. Purpose : Handle the /duel commands - not yet implemented
  5676. Params : unknown
  5677. Dev :
  5678. Example :
  5679. */
  5680. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  5681. {
  5682. PrintSep(sep, "COMMAND_DUELBET");
  5683. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  5684. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5685. }
  5686. /*
  5687. Function: Command_DuelAccept()
  5688. Purpose : Handle the /duel commands - not yet implemented
  5689. Params : unknown
  5690. Dev :
  5691. Example :
  5692. */
  5693. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5694. {
  5695. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5696. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5697. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5698. }
  5699. /*
  5700. Function: Command_DuelDecline()
  5701. Purpose : Handle the /duel commands - not yet implemented
  5702. Params : unknown
  5703. Dev :
  5704. Example :
  5705. */
  5706. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5707. {
  5708. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5709. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5710. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5711. }
  5712. /*
  5713. Function: Command_DuelSurrender()
  5714. Purpose : Handle the /duel commands - not yet implemented
  5715. Params : unknown
  5716. Dev :
  5717. Example :
  5718. */
  5719. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5720. {
  5721. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5722. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5723. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5724. // JA, just messin around ;)
  5725. char surrender[64];
  5726. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5727. zone_list.HandleGlobalAnnouncement(surrender);
  5728. }
  5729. /*
  5730. Function: Command_DuelToggle()
  5731. Purpose : Handle the /duel commands - not yet implemented
  5732. Params : unknown
  5733. Dev :
  5734. Example :
  5735. */
  5736. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5737. {
  5738. PrintSep(sep, "COMMAND_DUEL");
  5739. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5740. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5741. }
  5742. /*
  5743. Function:
  5744. Purpose :
  5745. Params :
  5746. Dev :
  5747. Example :
  5748. */
  5749. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5750. {
  5751. if( handler == COMMAND_ENTITYCOMMAND )
  5752. {
  5753. // /entitycommand command by itself shows help (to be extended)
  5754. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5755. return;
  5756. }
  5757. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5758. {
  5759. // /entitycommand list command expects "name" param
  5760. if (sep && sep->arg[0])
  5761. {
  5762. const char* entity_command_name = sep->argplus[0];
  5763. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5764. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5765. map<int32, vector<EntityCommand*>*>::iterator itr;
  5766. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5767. {
  5768. vector<EntityCommand*>* entity_command_list = itr->second;
  5769. vector<EntityCommand*>::iterator itr2;
  5770. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5771. {
  5772. EntityCommand* entity_command = *itr2;
  5773. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5774. 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);
  5775. }
  5776. }
  5777. }
  5778. else // no command name
  5779. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5780. }
  5781. }
  5782. /*
  5783. Function: Command_Follow()
  5784. Purpose : Handle the /follow command - not yet implemented
  5785. Params :
  5786. Dev :
  5787. Example :
  5788. */
  5789. void Commands::Command_Follow(Client* client, Seperator* sep)
  5790. {
  5791. PrintSep(sep, "COMMAND_FOLLOW");
  5792. // flag to toggle if the players target is in the players group
  5793. bool targetInGroup = false;
  5794. // get a pointer to the players group
  5795. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5796. // If the player has a group and has a target
  5797. if (gmi && client->GetPlayer()->GetTarget()) {
  5798. deque<GroupMemberInfo*>::iterator itr;
  5799. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5800. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5801. if (group)
  5802. {
  5803. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5804. deque<GroupMemberInfo*>* members = group->GetMembers();
  5805. // Loop through the group members
  5806. for (itr = members->begin(); itr != members->end(); itr++) {
  5807. // If a group member matches a target
  5808. if ((*itr)->member && (*itr)->member == client->GetPlayer()->GetTarget()) {
  5809. // toggle the flag and break the loop
  5810. targetInGroup = true;
  5811. break;
  5812. }
  5813. }
  5814. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5815. }
  5816. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5817. }
  5818. if (targetInGroup) {
  5819. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5820. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5821. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5822. client->GetPlayer()->info_changed = true;
  5823. client->GetPlayer()->changed = true;
  5824. }
  5825. else
  5826. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5827. }
  5828. /*
  5829. Function: Command_StopFollow()
  5830. Purpose : Handle the /stop_follow command - not yet implemented
  5831. Params :
  5832. Dev :
  5833. Example :
  5834. */
  5835. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5836. {
  5837. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5838. if (client->GetPlayer()->GetFollowTarget()) {
  5839. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5840. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5841. client->GetPlayer()->SetFollowTarget(0);
  5842. client->GetPlayer()->info_changed = true;
  5843. client->GetPlayer()->changed = true;
  5844. }
  5845. }
  5846. /*
  5847. Function: Command_Grid()
  5848. Purpose : Show player's current Grid ID
  5849. Params :
  5850. Dev : Scatman
  5851. Example : /grid
  5852. */
  5853. void Commands::Command_Grid(Client* client, Seperator* sep)
  5854. {
  5855. if (client->GetPlayer()->GetMap() != nullptr) {
  5856. if(sep && sep->arg[0][0] && strncasecmp("spawns", sep->arg[0], 6) == 0) {
  5857. int32 grid = client->GetPlayer()->GetLocation();
  5858. if(sep->IsNumber(1))
  5859. grid = atoul(sep->arg[1]);
  5860. client->GetCurrentZone()->SendClientSpawnListInGrid(client, grid);
  5861. }
  5862. else {
  5863. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->GetLocation());
  5864. auto loc = glm::vec3(client->GetPlayer()->GetX(), client->GetPlayer()->GetZ(), client->GetPlayer()->GetY());
  5865. uint32 GridID = 0;
  5866. uint32 WidgetID = 0;
  5867. float new_z = client->GetPlayer()->FindBestZ(loc, nullptr, &GridID, &WidgetID);
  5868. float minY = client->GetPlayer()->GetMap()->GetMinY();
  5869. float maxY = client->GetPlayer()->GetMap()->GetMaxY();
  5870. float minZ = client->GetPlayer()->GetMap()->GetMinZ();
  5871. float maxZ = client->GetPlayer()->GetMap()->GetMaxZ();
  5872. int32 grid_spawn_count = client->GetPlayer()->GetZone()->GetSpawnCountInGrid(GridID);
  5873. client->Message(CHANNEL_COLOR_YELLOW, "Grid result is %u, at EQ2 Y coordinate %f. Spawns on grid: %u. Min/Max Y %f/%f Z %f/%f. Widget ID: %u", GridID, new_z, grid_spawn_count, minY, maxY, minZ, maxZ, WidgetID);
  5874. }
  5875. }
  5876. }
  5877. /*
  5878. Function: Command_Guild()
  5879. Purpose : Handler for all UI-related guild commands
  5880. Dev : Scatman
  5881. */
  5882. void Commands::Command_Guild(Client* client, Seperator* sep)
  5883. {
  5884. Guild* guild = client->GetPlayer()->GetGuild();
  5885. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  5886. {
  5887. const char* command = sep->arg[0];
  5888. int32 length = strlen(command);
  5889. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  5890. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  5891. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  5892. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5893. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5894. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5895. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5896. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  5897. guild->KickGuildMember(client, sep->arg[1]);
  5898. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  5899. guild->DemoteGuildMember(client, sep->arg[1]);
  5900. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  5901. guild->PromoteGuildMember(client, sep->arg[1]);
  5902. else if (strncmp(command, "points", length) == 0 && guild)
  5903. {
  5904. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  5905. {
  5906. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5907. {
  5908. float points = atof(sep->arg[2]);
  5909. const char* option = sep->arg[3];
  5910. const char* comment = sep->argplus[4];
  5911. if (strncmp(option, "all", strlen(option)) == 0)
  5912. guild->AddPointsToAll(client, points, comment);
  5913. else if (strncmp(option, "online", strlen(option)) == 0)
  5914. guild->AddPointsToAllOnline(client, points, comment);
  5915. else if (strncmp(option, "group", strlen(option)) == 0)
  5916. guild->AddPointsToGroup(client, points, comment);
  5917. else if (strncmp(option, "raid", strlen(option)) == 0)
  5918. guild->AddPointsToRaid(client, points, comment);
  5919. else
  5920. guild->AddPointsToGuildMember(client, points, option, comment);
  5921. }
  5922. }
  5923. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  5924. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  5925. else
  5926. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  5927. }
  5928. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  5929. guild->SetMOTD(sep->argplus[1]);
  5930. else if (strncmp(command, "recruiting", length) == 0 && guild)
  5931. {
  5932. if (sep->arg[1])
  5933. {
  5934. const char* option = sep->arg[1];
  5935. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  5936. guild->SetRecruitingShortDesc(sep->argplus[2]);
  5937. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  5938. guild->SetRecruitingFullDesc(sep->argplus[2]);
  5939. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5940. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5941. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5942. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  5943. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5944. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  5945. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  5946. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  5947. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  5948. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5949. else
  5950. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5951. }
  5952. else
  5953. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5954. }
  5955. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  5956. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5957. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  5958. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5959. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5960. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5961. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  5962. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  5963. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5964. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5965. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  5966. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  5967. else if (strncmp(command, "invite", length) == 0 && guild)
  5968. {
  5969. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5970. guild->InvitePlayer(client, sep->arg[1]);
  5971. else
  5972. {
  5973. Spawn* target = client->GetPlayer()->GetTarget();
  5974. if (target)
  5975. {
  5976. if (target->IsPlayer())
  5977. guild->InvitePlayer(client, target->GetName());
  5978. else
  5979. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  5980. }
  5981. }
  5982. }
  5983. else if (strncmp(command, "accept", length) == 0)
  5984. {
  5985. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5986. if (pgi && pgi->guild && pgi->invited_by)
  5987. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  5988. client->SetPendingGuildInvite(0);
  5989. }
  5990. else if (strncmp(command, "decline", length) == 0)
  5991. {
  5992. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5993. if (pgi && pgi->guild && pgi->invited_by)
  5994. {
  5995. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  5996. if (client_inviter)
  5997. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  5998. }
  5999. client->SetPendingGuildInvite(0);
  6000. }
  6001. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  6002. {
  6003. const char* guild_name = sep->argplus[1];
  6004. if (!guild_list.GetGuild(guild_name))
  6005. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6006. else
  6007. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  6008. }
  6009. else if (strncmp(command, "search", length) == 0)
  6010. client->ShowGuildSearchWindow();
  6011. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6012. {
  6013. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6014. if (to_guild)
  6015. to_guild->SendGuildRecruitingDetails(client);
  6016. }
  6017. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6018. {
  6019. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6020. if (to_guild)
  6021. to_guild->SendGuildRecruitingImages(client);
  6022. }
  6023. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  6024. {
  6025. if (sep->arg[1])
  6026. {
  6027. const char* option = sep->arg[1];
  6028. if (strncmp(option, "toggle", strlen(option)) == 0)
  6029. guild->ToggleGuildRecruiterAdventureClass(client);
  6030. }
  6031. else
  6032. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  6033. }
  6034. else if (strncmp(command, "display_heraldry", length) == 0)
  6035. {
  6036. // JA: not sure this is right...
  6037. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  6038. client->GetPlayer()->SetCharSheetChanged(true);
  6039. }
  6040. else
  6041. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  6042. }
  6043. }
  6044. /*
  6045. Function: Command_GuildCreate()
  6046. Purpose : Display's in-game Guild Creation window
  6047. Dev : Scatman
  6048. */
  6049. void Commands::Command_CreateGuild(Client* client)
  6050. {
  6051. client->SendGuildCreateWindow();
  6052. }
  6053. /*
  6054. Function: Command_SetGuildOfficerNote()
  6055. Purpose :
  6056. Dev : Scatman
  6057. */
  6058. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  6059. {
  6060. if (sep && sep->arg[0] && sep->arg[1])
  6061. {
  6062. Guild* guild = client->GetPlayer()->GetGuild();
  6063. if (guild)
  6064. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  6065. }
  6066. }
  6067. /*
  6068. Function: Command_SetGuildMemberNote()
  6069. Purpose :
  6070. Dev : Scatman
  6071. */
  6072. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  6073. {
  6074. if (sep && sep->arg[0] && sep->arg[1])
  6075. {
  6076. Guild* guild = client->GetPlayer()->GetGuild();
  6077. if (guild)
  6078. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  6079. }
  6080. }
  6081. /*
  6082. Function: Command_GuildSay()
  6083. Purpose :
  6084. Dev : Scatman
  6085. */
  6086. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  6087. {
  6088. Guild* guild = client->GetPlayer()->GetGuild();
  6089. if (guild)
  6090. {
  6091. if (sep && sep->arg[0])
  6092. guild->HandleGuildSay(client, sep->argplus[0]);
  6093. }
  6094. else
  6095. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6096. }
  6097. /*
  6098. Function: Command_OfficerSay()
  6099. Purpose :
  6100. Dev : Scatman
  6101. */
  6102. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  6103. {
  6104. Guild* guild = client->GetPlayer()->GetGuild();
  6105. if (guild)
  6106. {
  6107. if (sep && sep->arg[0])
  6108. guild->HandleOfficerSay(client, sep->argplus[0]);
  6109. }
  6110. else
  6111. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6112. }
  6113. /*
  6114. Function: Command_Guilds()
  6115. Purpose : Shows help for /guild command
  6116. Params :
  6117. Dev : Scatman
  6118. Example :
  6119. */
  6120. void Commands::Command_Guilds(Client* client)
  6121. {
  6122. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  6123. }
  6124. /*
  6125. Function: Command_GuildsAdd()
  6126. Purpose : Add's players to a guild
  6127. Params : guild_name|guild_id, player name
  6128. Dev : Scatman
  6129. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  6130. */
  6131. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  6132. {
  6133. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6134. {
  6135. Guild* guild = 0;
  6136. bool found = true;
  6137. if (sep->IsNumber(0))
  6138. {
  6139. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6140. if (!guild)
  6141. {
  6142. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6143. found = false;
  6144. }
  6145. }
  6146. else
  6147. {
  6148. guild = guild_list.GetGuild(sep->arg[0]);
  6149. if (!guild)
  6150. {
  6151. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6152. found = false;
  6153. }
  6154. }
  6155. if (found)
  6156. {
  6157. Client* to_client = 0;
  6158. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6159. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6160. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6161. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6162. if (to_client)
  6163. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  6164. else
  6165. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6166. }
  6167. }
  6168. else
  6169. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  6170. }
  6171. /*
  6172. Function: Command_GuildsCreate()
  6173. Purpose : Creates a guild
  6174. Params : guild_name, player_name (optional)
  6175. Dev : Scatman
  6176. Example : /guilds create [guild name] (player name)
  6177. */
  6178. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  6179. {
  6180. if (sep && sep->arg[0])
  6181. {
  6182. const char* guild_name = sep->arg[0];
  6183. if (!guild_list.GetGuild(guild_name))
  6184. {
  6185. bool ret = false;
  6186. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6187. {
  6188. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6189. if (to_client)
  6190. {
  6191. world.CreateGuild(guild_name, to_client);
  6192. ret = true;
  6193. }
  6194. else
  6195. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  6196. }
  6197. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6198. {
  6199. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6200. if (to_client)
  6201. {
  6202. world.CreateGuild(guild_name, to_client);
  6203. ret = true;
  6204. }
  6205. }
  6206. else
  6207. {
  6208. world.CreateGuild(guild_name);
  6209. ret = true;
  6210. }
  6211. if (ret)
  6212. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  6213. else
  6214. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  6215. }
  6216. else
  6217. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  6218. }
  6219. else
  6220. 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.");
  6221. }
  6222. /*
  6223. Function: Command_GuildsDelete()
  6224. Purpose : Delete's a guild
  6225. Params : guild name
  6226. Dev : Scatman
  6227. Example : /guilds delete Test
  6228. */
  6229. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  6230. {
  6231. if (sep && sep->arg[0])
  6232. {
  6233. Guild* guild = 0;
  6234. bool found = true;
  6235. if (sep->IsNumber(0))
  6236. {
  6237. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6238. if (!guild)
  6239. {
  6240. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6241. found = false;
  6242. }
  6243. }
  6244. else
  6245. {
  6246. guild = guild_list.GetGuild(sep->arg[0]);
  6247. if (!guild)
  6248. {
  6249. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6250. found = false;
  6251. }
  6252. }
  6253. if (found)
  6254. {
  6255. guild->RemoveAllGuildMembers();
  6256. database.DeleteGuild(guild);
  6257. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  6258. guild_list.RemoveGuild(guild, true);
  6259. }
  6260. }
  6261. else
  6262. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  6263. }
  6264. /*
  6265. Function: Command_GuildsList()
  6266. Purpose : Lists current guilds on server
  6267. Params :
  6268. Dev : Scatman
  6269. Example : /guilds list
  6270. */
  6271. void Commands::Command_GuildsList(Client* client)
  6272. {
  6273. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  6274. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  6275. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  6276. if (guilds->size() == 0)
  6277. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  6278. else {
  6279. while (itr.Next()) {
  6280. Guild* guild = itr.second;
  6281. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  6282. }
  6283. }
  6284. }
  6285. /*
  6286. Function: Command_GuildsRemove()
  6287. Purpose : Removes a player from a guild
  6288. Params : guild name|guild id, player name
  6289. Dev : Scatman
  6290. Example : /guilds remove 1 Admin = removes Admin from guild 1
  6291. */
  6292. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  6293. {
  6294. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6295. {
  6296. Guild* guild = 0;
  6297. bool found = true;
  6298. if (sep->IsNumber(0))
  6299. {
  6300. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6301. if (!guild)
  6302. {
  6303. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6304. found = false;
  6305. }
  6306. }
  6307. else
  6308. {
  6309. guild = guild_list.GetGuild(sep->arg[0]);
  6310. if (!guild)
  6311. {
  6312. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6313. found = false;
  6314. }
  6315. }
  6316. if (found)
  6317. {
  6318. Client* to_client = 0;
  6319. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6320. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6321. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6322. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6323. if (to_client)
  6324. {
  6325. Player* to_player = to_client->GetPlayer();
  6326. if (to_player->GetGuild())
  6327. {
  6328. if (to_player->GetGuild() == guild)
  6329. {
  6330. guild->KickGuildMember(client, to_player->GetName());
  6331. }
  6332. else
  6333. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  6334. }
  6335. else
  6336. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  6337. }
  6338. else
  6339. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6340. }
  6341. }
  6342. else
  6343. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  6344. }
  6345. /*
  6346. Function: Command_InspectPlayer()
  6347. Purpose : Handle the Inspect functions
  6348. Params : Client to inspect
  6349. Dev : Scatman
  6350. Example : /inspect Scatman
  6351. */
  6352. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  6353. {
  6354. if (sep && sep->arg[0])
  6355. {
  6356. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  6357. if (inspect_client)
  6358. client->InspectPlayer(inspect_client->GetPlayer());
  6359. }
  6360. else
  6361. {
  6362. Spawn* target = client->GetPlayer()->GetTarget();
  6363. if (target && target->IsPlayer())
  6364. client->InspectPlayer((Player*)target);
  6365. }
  6366. }
  6367. /*
  6368. Function: Command_Inventory()
  6369. Purpose : Handle changes in player inventory
  6370. Params : <TBD>
  6371. Dev : All
  6372. Example : /inventory delete item_id
  6373. */
  6374. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  6375. {
  6376. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  6377. Player* player = client->GetPlayer();
  6378. if(sep && sep->arg[0][0])
  6379. {
  6380. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  6381. if(!client->GetPlayer()->Alive())
  6382. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  6383. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6384. {
  6385. int16 index = atoi(sep->arg[1]);
  6386. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6387. if(item)
  6388. {
  6389. if(item->details.item_locked) {
  6390. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item in use.");
  6391. return;
  6392. }
  6393. else if(item->CheckFlag(NO_DESTROY)) {
  6394. client->SimpleMessage(CHANNEL_COLOR_RED, "You can't destroy this item.");
  6395. return;
  6396. }
  6397. if(item->GetItemScript() && lua_interface)
  6398. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  6399. //reobtain item make sure it wasn't removed
  6400. item = player->item_list.GetItemFromIndex(index);
  6401. int32 bag_id = 0;
  6402. if(item){
  6403. bag_id = item->details.inv_slot_id;
  6404. database.DeleteItem(client->GetCharacterID(), item, 0);
  6405. }
  6406. client->GetPlayer()->item_list.DestroyItem(index);
  6407. client->GetPlayer()->UpdateInventory(bag_id);
  6408. }
  6409. }
  6410. 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))
  6411. {
  6412. int16 from_index = atoi(sep->arg[1]);
  6413. sint16 to_slot = atoi(sep->arg[2]); // don't convert slot since this is inventory not equipment
  6414. sint32 bag_id = atol(sep->arg[3]);
  6415. int8 charges = atoi(sep->arg[4]);
  6416. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  6417. if(!item) {
  6418. client->SimpleMessage(CHANNEL_COLOR_RED, "You have no item.");
  6419. return;
  6420. }
  6421. if(to_slot == item->details.slot_id && (bag_id < 0 || bag_id == item->details.inv_slot_id)) {
  6422. return;
  6423. }
  6424. if(item->details.item_locked)
  6425. {
  6426. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot move the item in use.");
  6427. return;
  6428. }
  6429. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  6430. {
  6431. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  6432. return;
  6433. }
  6434. sint32 old_inventory_id = 0;
  6435. if(item)
  6436. old_inventory_id = item->details.inv_slot_id;
  6437. //autobank
  6438. if (bag_id == -3 && to_slot == -1)
  6439. {
  6440. if (player->HasFreeBankSlot())
  6441. to_slot = player->FindFreeBankSlot();
  6442. else
  6443. {
  6444. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  6445. return;
  6446. }
  6447. }
  6448. //auto inventory
  6449. if (bag_id == 0 && to_slot == -1)
  6450. {
  6451. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6452. {
  6453. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  6454. return;
  6455. }
  6456. }
  6457. bool item_deleted = false;
  6458. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, &item_deleted, client->GetVersion());
  6459. client->QueuePacket(outapp);
  6460. if(item_deleted)
  6461. item = nullptr;
  6462. //removed from bag send update
  6463. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  6464. {
  6465. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  6466. if(outapp)
  6467. client->QueuePacket(outapp);
  6468. }
  6469. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  6470. {
  6471. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  6472. if(outapp)
  6473. client->QueuePacket(outapp);
  6474. }
  6475. }
  6476. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  6477. {
  6478. if(client->GetPlayer()->EngagedInCombat())
  6479. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  6480. else
  6481. {
  6482. int16 index = atoi(sep->arg[1]);
  6483. int8 slot_id = 255;
  6484. int8 unk3 = 0;
  6485. int8 appearance_equip = 0;
  6486. if(sep->arg[2][0] && sep->IsNumber(2))
  6487. slot_id = player->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6488. if(sep->arg[3][0] && sep->IsNumber(3))
  6489. unk3 = atoul(sep->arg[3]);
  6490. if(sep->arg[4][0] && sep->IsNumber(4))
  6491. appearance_equip = atoul(sep->arg[4]);
  6492. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  6493. EQ2Packet* outapp = 0;
  6494. for(int32 i=0;i<packets.size();i++)
  6495. {
  6496. outapp = packets[i];
  6497. if(outapp)
  6498. client->QueuePacket(outapp);
  6499. }
  6500. client->GetPlayer()->UpdateWeapons();
  6501. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6502. client->QueuePacket(characterSheetPackets);
  6503. }
  6504. }
  6505. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6506. {
  6507. if (client->GetPlayer()->EngagedInCombat())
  6508. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  6509. else {
  6510. int16 index = atoi(sep->arg[1]);
  6511. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6512. if (item) {
  6513. if(item->details.item_locked)
  6514. {
  6515. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot unpack the item in use.");
  6516. return;
  6517. }
  6518. // client->GetPlayer()->item_list.DestroyItem(index);
  6519. if (item->item_sets.size() > 0) {
  6520. for (int32 i = 0; i < item->item_sets.size(); i++) {
  6521. ItemSet* set = item->item_sets[i];
  6522. if (set->item_stack_size == 0)
  6523. set->item_stack_size += 1;
  6524. client->AddItem(set->item_id, set->item_stack_size);
  6525. }
  6526. }
  6527. }
  6528. client->RemoveItem(item, 1);
  6529. }
  6530. }
  6531. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  6532. {
  6533. if(client->GetPlayer()->EngagedInCombat())
  6534. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  6535. else
  6536. {
  6537. int16 index = player->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6538. sint32 bag_id = -999;
  6539. int8 to_slot = 255;
  6540. if(sep->arg[3][0])
  6541. {
  6542. if(sep->IsNumber(2))
  6543. bag_id = atol(sep->arg[2]);
  6544. if(sep->IsNumber(3))
  6545. to_slot = atoi(sep->arg[3]);
  6546. }
  6547. sint8 unk4 = 0;
  6548. int8 appearance_equip = 0;
  6549. if(sep->arg[4][0] && sep->IsNumber(4))
  6550. unk4 = atoi(sep->arg[4]);
  6551. if(sep->arg[5][0] && sep->IsNumber(5))
  6552. appearance_equip = atoul(sep->arg[5]);
  6553. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  6554. EQ2Packet* outapp = 0;
  6555. for(int32 i=0;i<packets.size();i++)
  6556. {
  6557. outapp = packets[i];
  6558. if(outapp)
  6559. client->QueuePacket(outapp);
  6560. }
  6561. client->UnequipItem(index, bag_id, to_slot, appearance_equip);
  6562. }
  6563. }
  6564. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6565. {
  6566. if(client->GetPlayer()->EngagedInCombat()) {
  6567. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not swap items while in combat.");
  6568. }
  6569. else {
  6570. int16 index1 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6571. int16 index2 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6572. int8 type = 0;
  6573. if(sep->IsNumber(3))
  6574. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  6575. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  6576. if(outapp)
  6577. client->QueuePacket(outapp);
  6578. else
  6579. {
  6580. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  6581. return;
  6582. }
  6583. }
  6584. }
  6585. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6586. {
  6587. sint16 to_slot = atoi(sep->arg[1]);
  6588. sint32 bag_id = atoi(sep->arg[2]);
  6589. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  6590. if (item) {
  6591. //auto inventory
  6592. if (bag_id == 0 && to_slot == -1)
  6593. {
  6594. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6595. {
  6596. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  6597. return;
  6598. }
  6599. // Set the slot for the item
  6600. item->details.inv_slot_id = bag_id;
  6601. item->details.slot_id = to_slot;
  6602. // Flag the item so it gets saved in its new location
  6603. item->save_needed = true;
  6604. // Add the item to its new location
  6605. if(player->item_list.AddItem(item)) {
  6606. // Remove the item from the overflow list
  6607. player->item_list.RemoveOverflowItem(item);
  6608. }
  6609. // Send the inventory update packet
  6610. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6611. return;
  6612. }
  6613. else if (bag_id == -3 && to_slot == -1) {
  6614. // Auto Bank
  6615. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  6616. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  6617. return;
  6618. }
  6619. item->details.inv_slot_id = bag_id;
  6620. item->details.slot_id = to_slot;
  6621. item->save_needed = true;
  6622. if(player->item_list.AddItem(item)) {
  6623. player->item_list.RemoveOverflowItem(item);
  6624. }
  6625. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6626. }
  6627. else if (bag_id == -4) {
  6628. // Shared Bank
  6629. if (!player->item_list.SharedBankAddAllowed(item)) {
  6630. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  6631. return;
  6632. }
  6633. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  6634. if (tmp_item) {
  6635. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6636. return;
  6637. }
  6638. else {
  6639. item->details.inv_slot_id = bag_id;
  6640. item->details.slot_id = to_slot;
  6641. item->save_needed = true;
  6642. if(player->item_list.AddItem(item)) {
  6643. player->item_list.RemoveOverflowItem(item);
  6644. }
  6645. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6646. return;
  6647. }
  6648. }
  6649. else {
  6650. // Try to get an item from the given bag id and slot id
  6651. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  6652. // Check to see if we got an item, if we do send an error,
  6653. // if we don't put the overflow item into this slot
  6654. if (tmp_item) {
  6655. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6656. }
  6657. else {
  6658. item->details.inv_slot_id = bag_id;
  6659. item->details.slot_id = to_slot;
  6660. item->save_needed = true;
  6661. if(player->item_list.AddItem(item)) {
  6662. player->item_list.RemoveOverflowItem(item);
  6663. }
  6664. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6665. return;
  6666. }
  6667. }
  6668. }
  6669. }
  6670. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6671. {
  6672. sint64 data = strtoull(sep->arg[1], NULL, 0);
  6673. int32 character_item_id = (int32) (data >> 32);
  6674. int32 item_id = (int32) (data & 0xffffffffL);
  6675. int8 sale_setting = atoi(sep->arg[2]);
  6676. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  6677. if(item)
  6678. {
  6679. item->no_sale = sale_setting;
  6680. item->save_needed = true;
  6681. client->SendSellMerchantList();
  6682. }
  6683. }
  6684. }
  6685. else
  6686. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  6687. }
  6688. /*
  6689. Function: Command_Languages()
  6690. Purpose : Show's languages the player knows
  6691. Params :
  6692. Dev : Zcoretri
  6693. Example :
  6694. */
  6695. void Commands::Command_Languages(Client* client, Seperator* sep)
  6696. {
  6697. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6698. list<Language*>::iterator itr;
  6699. Language* language;
  6700. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6701. for(itr = languages->begin(); itr != languages->end(); itr++)
  6702. {
  6703. language = *itr;
  6704. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6705. }
  6706. }
  6707. /*
  6708. Function: Command_SetLanguage()
  6709. Purpose : Handles language commands
  6710. Params : Language ID
  6711. Dev : Zcoretri
  6712. Example :
  6713. */
  6714. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6715. {
  6716. Player* player = client->GetPlayer();
  6717. if (sep && sep->arg[0])
  6718. {
  6719. if(!sep->IsNumber(0))
  6720. {
  6721. //String passed in
  6722. const char* value = sep->arg[0];
  6723. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6724. {
  6725. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6726. client->SendLanguagesUpdate(0);
  6727. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6728. }
  6729. else
  6730. {
  6731. if(player->HasLanguage(value))
  6732. {
  6733. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6734. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6735. client->SendLanguagesUpdate(language->GetID());
  6736. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6737. }
  6738. else
  6739. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6740. }
  6741. }
  6742. else
  6743. {
  6744. //Number passed in
  6745. int32 id = atoul(sep->arg[0]);
  6746. if(player->HasLanguage(id))
  6747. {
  6748. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6749. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6750. client->SendLanguagesUpdate(id);
  6751. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6752. }
  6753. else
  6754. {
  6755. Language* language = master_languages_list.GetLanguage(id);
  6756. if(language)
  6757. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6758. }
  6759. }
  6760. }
  6761. else
  6762. {
  6763. //No value was passed in
  6764. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6765. if(id > 0)
  6766. {
  6767. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6768. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6769. }
  6770. else
  6771. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6772. }
  6773. }
  6774. /*
  6775. Function: Command_LastName()
  6776. Purpose : Sets player surname
  6777. Params : Name text
  6778. Dev : theFoof
  6779. Example :
  6780. */
  6781. void Commands::Command_LastName(Client* client, Seperator* sep)
  6782. {
  6783. if (!client)
  6784. return;
  6785. if (sep && sep->arg[0])
  6786. {
  6787. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6788. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6789. return;
  6790. }
  6791. client->RemovePendingLastName();
  6792. uchar* checkname = (uchar*)sep->arg[0];
  6793. bool valid_name = true;
  6794. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6795. if (!alpha_check(checkname[i])) {
  6796. valid_name = false;
  6797. break;
  6798. }
  6799. }
  6800. if (!valid_name) {
  6801. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6802. return;
  6803. }
  6804. string last_name = (string)sep->arg[0];
  6805. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6806. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6807. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6808. client->SetPendingLastName(last_name);
  6809. client->SendLastNameConfirmation();
  6810. }
  6811. else
  6812. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6813. }
  6814. }
  6815. /*
  6816. Function: Command_ConfirmLastName()
  6817. Purpose : Confirms setting of player surname
  6818. Params : Name text
  6819. Dev : theFoof
  6820. Example :
  6821. */
  6822. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6823. {
  6824. if (!client)
  6825. return;
  6826. string* name = client->GetPendingLastName();
  6827. if (name){
  6828. Player* player = client->GetPlayer();
  6829. player->SetLastName(name->c_str(), false);
  6830. client->SendTitleUpdate();
  6831. player->SetCharSheetChanged(true);
  6832. client->RemovePendingLastName();
  6833. }
  6834. }
  6835. /*
  6836. Function: Command_Location()
  6837. Purpose : Display's Help for /location commands
  6838. Params :
  6839. Dev : Scatman
  6840. Example : /location = show's help for command
  6841. */
  6842. void Commands::Command_Location(Client* client)
  6843. {
  6844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6845. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6846. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6848. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6850. }
  6851. /*
  6852. Function: Command_LocationAdd()
  6853. Purpose : Add's a location to an existing location config
  6854. Params : location_id
  6855. Dev : Scatman
  6856. Example : /location add {location_id}
  6857. */
  6858. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6859. {
  6860. if (sep && sep->arg[0] && sep->IsNumber(0))
  6861. {
  6862. int32 location_id = atoul(sep->arg[0]);
  6863. float x = client->GetPlayer()->GetX();
  6864. float y = client->GetPlayer()->GetY();
  6865. float z = client->GetPlayer()->GetZ();
  6866. if (database.AddLocationPoint(location_id, x, y, z))
  6867. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6868. else
  6869. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6870. }
  6871. else
  6872. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6873. }
  6874. /*
  6875. Function: Command_LocationCreate()
  6876. Purpose : Creates a new location config
  6877. Params : location name, 0/1 for include_y (optional)
  6878. Dev : Scatman
  6879. Example : /location create Test 1 = creates a new location named Test with include_y True
  6880. */
  6881. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6882. {
  6883. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6884. {
  6885. const char* name = sep->arg[0];
  6886. bool include_y = false;
  6887. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6888. include_y = true;
  6889. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->GetLocation(), name, include_y);
  6890. if (location_id > 0)
  6891. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6892. else
  6893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6894. }
  6895. else
  6896. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6897. }
  6898. /*
  6899. Function: Command_LocationDelete()
  6900. Purpose : Delete's a location config and all it's location points
  6901. Params : location_id
  6902. Dev : Scatman
  6903. Example : /location delete {location_id}
  6904. */
  6905. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6906. {
  6907. if (sep && sep->arg[0] && sep->IsNumber(0))
  6908. {
  6909. int32 location_id = atoul(sep->arg[0]);
  6910. if (database.DeleteLocation(location_id))
  6911. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6912. else
  6913. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6914. }
  6915. else
  6916. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6917. }
  6918. /*
  6919. Function: Command_LocationList()
  6920. Purpose : Display's a list of location points
  6921. Params : location_id
  6922. Dev : Scatman
  6923. Example : /location list {location_id}
  6924. */
  6925. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6926. {
  6927. if (sep && sep->arg[0])
  6928. {
  6929. const char* option = sep->arg[0];
  6930. if (strncmp(option, "locations", strlen(option)) == 0)
  6931. database.ListLocations(client);
  6932. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  6933. {
  6934. int32 location_id = atoul(sep->arg[1]);
  6935. database.ListLocationPoints(client, location_id);
  6936. }
  6937. else
  6938. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6939. }
  6940. else
  6941. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6942. }
  6943. /*
  6944. Function: Command_LocationRemove()
  6945. Purpose : Removes a single location point from a location config
  6946. Params : location_point_id (gotten from /location list {id})
  6947. Dev : Scatman
  6948. Example : /location remove 1 = will remove location_point_id 1
  6949. */
  6950. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  6951. {
  6952. if (sep && sep->arg[0] && sep->IsNumber(0))
  6953. {
  6954. int32 location_point_id = atoul(sep->arg[0]);
  6955. if (database.DeleteLocationPoint(location_point_id))
  6956. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  6957. else
  6958. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  6959. }
  6960. else
  6961. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  6962. }
  6963. /*
  6964. Function: Command_Merchant()
  6965. Purpose : Handles Merchant commands
  6966. Params : list
  6967. Dev : Scatman
  6968. Example : /merchant list
  6969. */
  6970. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  6971. {
  6972. if( handler == COMMAND_MERCHANT )
  6973. {
  6974. // /merchant command by itself shows help (to be extended)
  6975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6976. return;
  6977. }
  6978. else if( handler == COMMAND_MERCHANT_LIST )
  6979. {
  6980. // /merchant list command expects "description" param
  6981. if (sep && sep->arg[0])
  6982. {
  6983. const char* merchant_description = sep->argplus[0];
  6984. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  6985. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  6986. map<int32, MerchantInfo*>::iterator itr;
  6987. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  6988. {
  6989. string description = database.GetMerchantDescription(itr->first);
  6990. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  6991. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  6992. }
  6993. }
  6994. else // no description
  6995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6996. }
  6997. }
  6998. /*
  6999. Function: Command_Modify()
  7000. Purpose : to replace our other "set" commands
  7001. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  7002. Dev : John Adams
  7003. Example : /modify spell set name "Aegolism III"
  7004. */
  7005. void Commands::Command_Modify(Client* client)
  7006. {
  7007. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  7008. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  7009. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  7010. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  7011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  7012. }
  7013. /*
  7014. Function: Command_ModifySpawn()
  7015. Purpose : replace "spawn set" commands
  7016. Params : Action : the action to perform (or special handler)
  7017. : Field : the DB field to change
  7018. : Value : what to set the value to
  7019. : Target : what object to change (my target, or spawn_id)
  7020. Dev : John Adams
  7021. Example : /modify spawn set name "Lady Vox"
  7022. :
  7023. Note : Special Handlers, like "zoneto" for Signs
  7024. : /modify spawn zoneto
  7025. : Will set a sign's zone x/y/z to my current coords
  7026. */
  7027. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  7028. {
  7029. PrintSep(sep, "COMMAND_MODIFY");
  7030. // need at least 2 args for a valid command
  7031. if( sep && sep->arg[1] )
  7032. {
  7033. // JA: just a quick implementation because I need it :)
  7034. if (strcmp(sep->arg[0], "zoneto") == 0)
  7035. {
  7036. if( sep->IsNumber(1) )
  7037. {
  7038. int32 spawn_id = atoul(sep->arg[1]);
  7039. float x_coord = client->GetPlayer()->GetX();
  7040. float y_coord = client->GetPlayer()->GetY();
  7041. float z_coord = client->GetPlayer()->GetZ();
  7042. float h_coord = client->GetPlayer()->GetHeading();
  7043. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  7044. }
  7045. else
  7046. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  7047. }
  7048. }
  7049. else
  7050. Command_Modify(client);
  7051. }
  7052. /*
  7053. Function: Command_ModifyCharacter()
  7054. Purpose : to replace our other "set" commands
  7055. Params : Action : Add, Remove
  7056. : Field : copper, silver, gold, plat
  7057. : Value : min 1, max unlimited
  7058. : Target : Self, Player
  7059. Dev : Cynnar
  7060. Example : /modify character add gold 50
  7061. : /modify character remove silver 25
  7062. */
  7063. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  7064. {
  7065. PrintSep(sep, "COMMAND_MODIFY");
  7066. int64 value = 0;
  7067. Player* player = client->GetPlayer();
  7068. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7069. player = (Player*)player->GetTarget();
  7070. // need at least 2 args for a valid command
  7071. if( sep && sep->arg[1] )
  7072. {
  7073. if (strcmp(sep->arg[0], "add") == 0)
  7074. {
  7075. if (strcmp(sep->arg[1], "copper") == 0)
  7076. {
  7077. value = atoi64(sep->arg[2]);
  7078. player->AddCoins(value);
  7079. if (client->GetPlayer() == player)
  7080. {
  7081. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  7082. }
  7083. else {
  7084. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7085. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7086. }
  7087. }
  7088. else if (strcmp(sep->arg[1], "silver") == 0)
  7089. {
  7090. value = atoi64(sep->arg[2]) * 100;
  7091. player->AddCoins(value);
  7092. if (client->GetPlayer() == player)
  7093. {
  7094. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  7095. }
  7096. else {
  7097. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  7098. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7099. }
  7100. }
  7101. else if (strcmp(sep->arg[1], "gold") == 0)
  7102. {
  7103. value = atoi64(sep->arg[2]) * 10000;
  7104. player->AddCoins(value);
  7105. if (client->GetPlayer() == player)
  7106. {
  7107. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  7108. }
  7109. else {
  7110. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7111. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7112. }
  7113. }
  7114. else if (strcmp(sep->arg[1], "plat") == 0)
  7115. {
  7116. value = atoi64(sep->arg[2]) * 1000000;
  7117. player->AddCoins(value);
  7118. if (client->GetPlayer() == player)
  7119. {
  7120. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  7121. }
  7122. else {
  7123. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7124. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7125. }
  7126. }
  7127. else
  7128. {
  7129. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7130. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7131. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7132. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  7133. }
  7134. }
  7135. else if (strcmp(sep->arg[0], "remove") == 0)
  7136. {
  7137. if (strcmp(sep->arg[1], "copper") == 0)
  7138. {
  7139. value = atoi64(sep->arg[2]);
  7140. player->RemoveCoins(value);
  7141. if (client->GetPlayer() == player)
  7142. {
  7143. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  7144. }
  7145. else {
  7146. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  7147. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7148. }
  7149. }
  7150. else if (strcmp(sep->arg[1], "silver") == 0)
  7151. {
  7152. value = atoi64(sep->arg[2]) * 100;
  7153. player->RemoveCoins(value);
  7154. if (client->GetPlayer() == player)
  7155. {
  7156. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  7157. }
  7158. else {
  7159. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  7160. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7161. }
  7162. }
  7163. else if (strcmp(sep->arg[1], "gold") == 0)
  7164. {
  7165. value = atoi64(sep->arg[2]) * 10000;
  7166. player->RemoveCoins(value);
  7167. if (client->GetPlayer() == player)
  7168. {
  7169. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  7170. }
  7171. else {
  7172. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  7173. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7174. }
  7175. }
  7176. else if (strcmp(sep->arg[1], "plat") == 0)
  7177. {
  7178. value = atoi64(sep->arg[2]) * 1000000;
  7179. player->RemoveCoins(value);
  7180. if (client->GetPlayer() == player)
  7181. {
  7182. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  7183. }
  7184. else {
  7185. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  7186. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7187. }
  7188. }
  7189. else
  7190. {
  7191. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7192. }
  7193. }
  7194. else if (strcmp(sep->arg[0], "set") == 0) {
  7195. if (strcmp(sep->arg[1], "tslevel") == 0) {
  7196. int8 level = atoi(sep->arg[2]);
  7197. if (level > 0 && level < 256) {
  7198. if (player) {
  7199. if (client->GetPlayer() == player)
  7200. client->ChangeTSLevel(player->GetTSLevel(), level);
  7201. else
  7202. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  7203. }
  7204. }
  7205. else
  7206. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  7207. }
  7208. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  7209. int8 tsclass = atoi(sep->arg[2]);
  7210. player->SetTradeskillClass(tsclass);
  7211. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  7212. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  7213. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  7214. player->SetCharSheetChanged(true);
  7215. }
  7216. else if (strcmp(sep->arg[1], "gender") == 0) {
  7217. int8 gender = atoi(sep->arg[2]);
  7218. client->GetPlayer()->GetInfoStruct()->set_gender(gender);
  7219. client->GetPlayer()->SetCharSheetChanged(true);
  7220. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  7221. }
  7222. }
  7223. }
  7224. else
  7225. {
  7226. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7227. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7228. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7229. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7230. }
  7231. }
  7232. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  7233. {
  7234. PrintSep(sep, "COMMAND_MODIFY");
  7235. // need at least 2 args for a valid command
  7236. if( sep && sep->arg[1] )
  7237. {
  7238. }
  7239. else
  7240. Command_Modify(client);
  7241. }
  7242. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  7243. {
  7244. PrintSep(sep, "COMMAND_MODIFY");
  7245. // need at least 2 args for a valid command
  7246. if( sep && sep->arg[1] )
  7247. {
  7248. }
  7249. else
  7250. Command_Modify(client);
  7251. }
  7252. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  7253. {
  7254. PrintSep(sep, "COMMAND_MODIFY");
  7255. // need at least 2 args for a valid command
  7256. if( sep && sep->arg[1] )
  7257. {
  7258. }
  7259. else
  7260. Command_Modify(client);
  7261. }
  7262. /*
  7263. Function: Command_ModifyQuest()
  7264. Purpose : to list players quest and completed quests
  7265. Params : Action : list, completed
  7266. : Target : Self, Player
  7267. Dev : Cynnar
  7268. Example : /modify quest list
  7269. : /modify quest completed
  7270. */
  7271. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  7272. {
  7273. PrintSep(sep, "COMMAND_MODIFY");
  7274. int64 value = 0;
  7275. Player* player = client->GetPlayer();
  7276. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7277. player = (Player*)player->GetTarget();
  7278. // need at least 2 args for a valid command
  7279. if (sep && sep->arg[1])
  7280. {
  7281. if (strcmp(sep->arg[0], "list") == 0)
  7282. {
  7283. map<int32, Quest*>* quests = player->GetPlayerQuests();
  7284. map<int32, Quest*>::iterator itr;
  7285. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  7286. if (quests->size() == 0)
  7287. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  7288. else
  7289. {
  7290. for (itr = quests->begin(); itr != quests->end(); itr++)
  7291. {
  7292. Quest* quest = itr->second;
  7293. if(quest) {
  7294. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7295. }
  7296. }
  7297. }
  7298. }
  7299. else if (strcmp(sep->arg[0], "completed") == 0)
  7300. {
  7301. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  7302. map<int32, Quest*>::iterator itr;
  7303. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  7304. if (quests->size() == 0)
  7305. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  7306. else
  7307. {
  7308. for (itr = quests->begin(); itr != quests->end(); itr++)
  7309. {
  7310. Quest* quest = itr->second;
  7311. if(quest) {
  7312. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7313. }
  7314. }
  7315. }
  7316. }
  7317. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  7318. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  7319. else if (strcmp(sep->arg[0], "remove") == 0)
  7320. {
  7321. int32 quest_id = 0;
  7322. if (sep && sep->arg[1] && sep->IsNumber(1))
  7323. quest_id = atoul(sep->arg[1]);
  7324. if (quest_id > 0)
  7325. {
  7326. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  7327. {
  7328. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7329. if (quest)
  7330. if (client->GetPlayer() == player)
  7331. {
  7332. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  7333. }
  7334. else
  7335. {
  7336. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  7337. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  7338. }
  7339. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  7340. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  7341. }
  7342. client->RemovePlayerQuest(quest_id);
  7343. client->GetCurrentZone()->SendQuestUpdates(client);
  7344. }
  7345. }
  7346. else if (strcmp(sep->arg[0], "advance") == 0)
  7347. {
  7348. int32 quest_id = 0;
  7349. int32 step = 0;
  7350. if (sep && sep->arg[1] && sep->IsNumber(1))
  7351. {
  7352. quest_id = atoul(sep->arg[1]);
  7353. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7354. if(!quest) {
  7355. client->Message(CHANNEL_COLOR_RED, "Quest not found!");
  7356. return;
  7357. }
  7358. if (sep && sep->arg[2] && sep->IsNumber(1))
  7359. {
  7360. step = atoul(sep->arg[2]);
  7361. if (quest_id > 0 && step > 0)
  7362. {
  7363. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  7364. {
  7365. if (client)
  7366. {
  7367. client->AddPendingQuestUpdate(quest_id, step);
  7368. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  7369. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  7370. }
  7371. }
  7372. }
  7373. else
  7374. {
  7375. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  7376. }
  7377. }
  7378. else
  7379. {
  7380. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  7381. }
  7382. }
  7383. else
  7384. {
  7385. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  7386. }
  7387. }
  7388. else
  7389. {
  7390. Command_Modify(client);
  7391. }
  7392. }
  7393. else
  7394. {
  7395. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  7396. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  7397. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  7398. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  7399. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  7400. }
  7401. }
  7402. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  7403. {
  7404. PrintSep(sep, "COMMAND_MODIFY");
  7405. // need at least 2 args for a valid command
  7406. if( sep && sep->arg[1] )
  7407. {
  7408. if (strcmp(sep->arg[0], "add") == 0) {
  7409. const char* skill_name = sep->argplus[1];
  7410. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7411. if (skill) {
  7412. Player* player = 0;
  7413. Client* to_client = 0;
  7414. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7415. player = (Player*)client->GetPlayer()->GetTarget();
  7416. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7417. }
  7418. else {
  7419. player = client->GetPlayer();
  7420. to_client = client;
  7421. }
  7422. if (player)
  7423. {
  7424. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7425. {
  7426. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7427. if (to_client == client) {
  7428. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  7429. }
  7430. else {
  7431. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7432. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7433. }
  7434. }
  7435. else
  7436. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  7437. }
  7438. }
  7439. else
  7440. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7441. }
  7442. else if (strcmp(sep->arg[0], "remove") == 0) {
  7443. const char* skill_name = sep->argplus[1];
  7444. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7445. if (skill) {
  7446. Player* player = 0;
  7447. Client* to_client = 0;
  7448. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7449. player = (Player*)client->GetPlayer()->GetTarget();
  7450. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7451. }
  7452. else {
  7453. player = client->GetPlayer();
  7454. to_client = client;
  7455. }
  7456. if (player)
  7457. {
  7458. if (player->GetSkills()->HasSkill(skill->skill_id))
  7459. {
  7460. player->RemoveSkillFromDB(skill, true);
  7461. if (client == to_client) {
  7462. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  7463. }
  7464. else {
  7465. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7466. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7467. }
  7468. }
  7469. else {
  7470. if (client == to_client)
  7471. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  7472. else
  7473. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7474. }
  7475. }
  7476. }
  7477. else
  7478. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7479. }
  7480. else if (strcmp(sep->arg[0], "set") == 0) {
  7481. if (!sep->IsNumber(2)) {
  7482. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  7483. return;
  7484. }
  7485. const char* skill_name = sep->arg[1];
  7486. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7487. if (skill) {
  7488. int16 val = atoi(sep->arg[2]);
  7489. Player* player = 0;
  7490. Client* to_client = 0;
  7491. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7492. player = (Player*)client->GetPlayer()->GetTarget();
  7493. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7494. }
  7495. else {
  7496. player = client->GetPlayer();
  7497. to_client = client;
  7498. }
  7499. if (player)
  7500. {
  7501. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  7502. player->GetSkills()->SetSkill(skill->skill_id, val);
  7503. if (client != to_client)
  7504. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  7505. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  7506. }
  7507. else {
  7508. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  7509. }
  7510. }
  7511. }
  7512. else {
  7513. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7514. }
  7515. }
  7516. else {
  7517. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7518. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7519. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7520. }
  7521. }
  7522. else {
  7523. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7524. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7525. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7526. }
  7527. }
  7528. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  7529. {
  7530. PrintSep(sep, "COMMAND_MODIFY");
  7531. // need at least 2 args for a valid command
  7532. if( sep && sep->arg[1] )
  7533. {
  7534. }
  7535. else
  7536. Command_Modify(client);
  7537. }
  7538. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  7539. {
  7540. PrintSep(sep, "COMMAND_MODIFY");
  7541. // need at least 2 args for a valid command
  7542. if( sep && sep->arg[1] )
  7543. {
  7544. }
  7545. else
  7546. Command_Modify(client);
  7547. }
  7548. /*
  7549. Function: Command_MOTD()
  7550. Purpose : Displays server MOTD
  7551. Params :
  7552. Dev : LethalEncounter
  7553. Example : /motd
  7554. */
  7555. void Commands::Command_MOTD(Client* client)
  7556. {
  7557. if (client)
  7558. ClientPacketFunctions::SendMOTD(client);
  7559. }
  7560. /*
  7561. Function: Command_Pet()
  7562. Purpose : Handle Pet {Command} commands
  7563. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  7564. Dev :
  7565. Example : /pet preserve_master
  7566. */
  7567. void Commands::Command_Pet(Client* client, Seperator* sep)
  7568. {
  7569. PrintSep(sep, "COMMAND_PET");
  7570. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  7571. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7572. if (!sep || !sep->arg[0])
  7573. return; // should have sep->arg[0] filled
  7574. if (strcmp(sep->arg[0], "hide") == 0) {
  7575. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  7576. Entity* pet = client->GetPlayer()->GetDeityPet();
  7577. if (pet) {
  7578. if (pet->IsPrivateSpawn())
  7579. client->GetPlayer()->HideDeityPet(false);
  7580. else
  7581. client->GetPlayer()->HideDeityPet(true);
  7582. }
  7583. pet = client->GetPlayer()->GetCosmeticPet();
  7584. if (pet) {
  7585. if (pet->IsPrivateSpawn())
  7586. client->GetPlayer()->HideCosmeticPet(false);
  7587. else
  7588. client->GetPlayer()->HideCosmeticPet(true);
  7589. }
  7590. return;
  7591. }
  7592. // below is for all combat pets
  7593. if (!client->GetPlayer()->HasPet()) {
  7594. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  7595. return;
  7596. }
  7597. if (strcmp(sep->arg[0], "stay") == 0) {
  7598. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  7599. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  7600. client->GetPlayer()->SetCharSheetChanged(true);
  7601. if (client->GetPlayer()->GetPet())
  7602. client->GetPlayer()->GetPet()->following = false;
  7603. if (client->GetPlayer()->GetCharmedPet())
  7604. client->GetPlayer()->GetCharmedPet()->following = false;
  7605. }
  7606. else if (strcmp(sep->arg[0], "follow") == 0) {
  7607. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  7608. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  7609. client->GetPlayer()->SetCharSheetChanged(true);
  7610. }
  7611. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  7612. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  7613. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  7614. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  7615. }
  7616. else {
  7617. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  7618. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  7619. }
  7620. client->GetPlayer()->SetCharSheetChanged(true);
  7621. }
  7622. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  7623. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  7624. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  7625. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  7626. }
  7627. else {
  7628. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  7629. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  7630. }
  7631. client->GetPlayer()->SetCharSheetChanged(true);
  7632. }
  7633. else if (strcmp(sep->arg[0], "backoff") == 0) {
  7634. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  7635. if (client->GetPlayer()->GetPet())
  7636. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  7637. if (client->GetPlayer()->GetCharmedPet())
  7638. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  7639. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  7640. client->GetPlayer()->SetCharSheetChanged(true);
  7641. }
  7642. else if (strcmp(sep->arg[0], "attack") == 0) {
  7643. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  7644. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  7645. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  7646. if (client->GetPlayer()->GetPet())
  7647. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7648. if (client->GetPlayer()->GetCharmedPet())
  7649. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7650. }
  7651. else
  7652. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  7653. }
  7654. else
  7655. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  7656. }
  7657. else if (strcmp(sep->arg[0], "getlost") == 0) {
  7658. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  7659. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  7660. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  7661. }
  7662. else
  7663. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  7664. }
  7665. /*
  7666. Function: Command_PetName()
  7667. Purpose : Pet your name (???)
  7668. Params :
  7669. Dev :
  7670. Example :
  7671. */
  7672. void Commands::Command_PetName(Client* client, Seperator* sep)
  7673. {
  7674. if (sep && sep->arg[0]) {
  7675. const char* pet_name = sep->argplus[0];
  7676. client->SetPetName(pet_name);
  7677. }
  7678. else {
  7679. client->GetPlayer()->GetInfoStruct()->set_pet_name("");
  7680. }
  7681. }
  7682. /*
  7683. Function: Command_NamePet()
  7684. Purpose : Name your pet
  7685. Params :
  7686. Dev :
  7687. Example :
  7688. */
  7689. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7690. {
  7691. PrintSep(sep, "COMMAND_NAME_PET");
  7692. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7693. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7694. }
  7695. /*
  7696. Function: Command_Rename()
  7697. Purpose : Renames existing pet
  7698. Params :
  7699. Dev :
  7700. Example :
  7701. */
  7702. void Commands::Command_Rename(Client* client, Seperator* sep)
  7703. {
  7704. PrintSep(sep, "COMMAND_RENAME");
  7705. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7706. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7707. }
  7708. /*
  7709. Function: Command_ConfirmRename()
  7710. Purpose : Confirms renaming your pet
  7711. Params :
  7712. Dev :
  7713. Example :
  7714. */
  7715. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7716. {
  7717. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7718. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7719. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7720. }
  7721. /*
  7722. Function: Command_PetOptions()
  7723. Purpose : Sets various pet options
  7724. Params :
  7725. Dev :
  7726. Example :
  7727. */
  7728. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7729. {
  7730. PrintSep(sep, "COMMAND_PETOPTIONS");
  7731. Player* player = client->GetPlayer();
  7732. Spawn* target = player->GetTarget();
  7733. if (!target)
  7734. return;
  7735. if (target == player->GetPet())
  7736. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7737. else if (target == player->GetCharmedPet())
  7738. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7739. else if (target == player->GetCosmeticPet())
  7740. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7741. else if (target == player->GetDeityPet())
  7742. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7743. }
  7744. /*
  7745. Function: Command_Random()
  7746. Purpose : Handles /random dice roll in-game
  7747. Params : 1-100
  7748. Dev : Scatman
  7749. Example : /randon 1 100
  7750. */
  7751. void Commands::Command_Random(Client* client, Seperator* sep)
  7752. {
  7753. char message[256] = {0};
  7754. if (sep)
  7755. {
  7756. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7757. 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])));
  7758. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7759. 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])));
  7760. else
  7761. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7762. }
  7763. else
  7764. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7765. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7766. }
  7767. /*
  7768. Function: Command_Randomize()
  7769. Purpose : Sets randomize (appearance) values for NPCs
  7770. Params : Attrib Name
  7771. Dev : Scatman
  7772. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7773. */
  7774. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7775. {
  7776. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7777. if (target)
  7778. {
  7779. if (target->IsNPC())
  7780. {
  7781. if (sep && sep->arg[0] && !sep->IsNumber(0))
  7782. {
  7783. const char* value = sep->arg[0];
  7784. if (strncasecmp(value, "show", strlen(value)) == 0)
  7785. {
  7786. client->DisplayRandomizeFeatures(target->GetRandomize());
  7787. }
  7788. else
  7789. {
  7790. if (sep->arg[1] && sep->IsNumber(1))
  7791. {
  7792. int8 option = atoi(sep->arg[1]);
  7793. if (option == 0 || option == 1)
  7794. {
  7795. int32 feature = 0;
  7796. char feature_text[32] = {0};
  7797. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7798. feature = RANDOMIZE_GENDER;
  7799. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7800. }
  7801. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7802. feature = RANDOMIZE_RACE;
  7803. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7804. }
  7805. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7806. feature = RANDOMIZE_MODEL_TYPE;
  7807. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7808. }
  7809. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7810. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7811. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7812. }
  7813. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7814. feature = RANDOMIZE_HAIR_TYPE;
  7815. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7816. }
  7817. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7818. feature = RANDOMIZE_WING_TYPE;
  7819. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7820. }
  7821. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7822. feature = RANDOMIZE_CHEEK_TYPE;
  7823. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7824. }
  7825. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7826. feature = RANDOMIZE_CHIN_TYPE;
  7827. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7828. }
  7829. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7830. feature = RANDOMIZE_EAR_TYPE;
  7831. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7832. }
  7833. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7834. feature = RANDOMIZE_EYE_BROW_TYPE;
  7835. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7836. }
  7837. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7838. feature = RANDOMIZE_EYE_TYPE;
  7839. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7840. }
  7841. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7842. feature = RANDOMIZE_LIP_TYPE;
  7843. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7844. }
  7845. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7846. feature = RANDOMIZE_NOSE_TYPE;
  7847. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7848. }
  7849. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7850. feature = RANDOMIZE_EYE_COLOR;
  7851. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7852. }
  7853. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7854. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7855. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7856. }
  7857. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7858. feature = RANDOMIZE_HAIR_COLOR1;
  7859. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7860. }
  7861. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7862. feature = RANDOMIZE_HAIR_COLOR2;
  7863. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7864. }
  7865. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7866. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7867. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7868. }
  7869. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7870. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7871. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7872. }
  7873. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7874. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7875. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7876. }
  7877. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7878. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7879. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7880. }
  7881. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7882. feature = RANDOMIZE_SKIN_COLOR;
  7883. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7884. }
  7885. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7886. feature = RANDOMIZE_WING_COLOR1;
  7887. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7888. }
  7889. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7890. feature = RANDOMIZE_WING_COLOR2;
  7891. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7892. }
  7893. else {
  7894. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7895. 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'.");
  7896. }
  7897. if (feature > 0) {
  7898. if (option == 1) {
  7899. if (target->GetRandomize() & feature)
  7900. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  7901. else {
  7902. target->AddRandomize(feature);
  7903. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  7904. database.UpdateRandomize(target->GetDatabaseID(), feature);
  7905. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  7906. }
  7907. }
  7908. else {
  7909. if (target->GetRandomize() & feature) {
  7910. target->AddRandomize(-feature);
  7911. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  7912. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  7913. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  7914. }
  7915. else
  7916. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  7917. }
  7918. }
  7919. }
  7920. else
  7921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7922. }
  7923. else
  7924. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7925. }
  7926. }
  7927. else {
  7928. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  7929. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  7930. 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'.");
  7931. }
  7932. }
  7933. else
  7934. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  7935. }
  7936. else
  7937. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  7938. }
  7939. /*
  7940. Function: Command_ShowCloak()
  7941. Purpose : Character Settings combo box for Show Cloak
  7942. Params : true/false
  7943. Dev : John Adams
  7944. Example :
  7945. */
  7946. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  7947. {
  7948. Player* player = client->GetPlayer();
  7949. if (sep && sep->arg[0])
  7950. {
  7951. const char* value = sep->arg[0];
  7952. if (strncasecmp(value, "true", strlen(value)) == 0)
  7953. {
  7954. player->set_character_flag(CF_SHOW_CLOAK);
  7955. player->reset_character_flag(CF2_SHOW_RANGED);
  7956. }
  7957. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7958. player->reset_character_flag(CF_SHOW_CLOAK);
  7959. else
  7960. {
  7961. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7962. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7963. }
  7964. }
  7965. }
  7966. /*
  7967. Function: Command_ShowHelm()
  7968. Purpose : Character Settings combo box for Show Helm
  7969. Params : true/false
  7970. Dev : John Adams
  7971. Example :
  7972. */
  7973. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  7974. {
  7975. Player* player = client->GetPlayer();
  7976. if (sep && sep->arg[0])
  7977. {
  7978. const char* value = sep->arg[0];
  7979. if (strncasecmp(value, "true", strlen(value)) == 0)
  7980. {
  7981. player->reset_character_flag(CF_HIDE_HELM);
  7982. player->set_character_flag(CF_HIDE_HOOD);
  7983. }
  7984. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7985. player->set_character_flag(CF_HIDE_HELM);
  7986. else
  7987. {
  7988. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7989. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7990. }
  7991. }
  7992. }
  7993. /*
  7994. Function: Command_ShowHood()
  7995. Purpose : Character Settings combo box for Show Hood
  7996. Params : true/false
  7997. Dev : John Adams
  7998. Example :
  7999. */
  8000. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  8001. {
  8002. Player* player = client->GetPlayer();
  8003. if (sep && sep->arg[0])
  8004. {
  8005. const char* value = sep->arg[0];
  8006. if (strncasecmp(value, "true", strlen(value)) == 0)
  8007. {
  8008. player->reset_character_flag(CF_HIDE_HOOD);
  8009. player->set_character_flag(CF_HIDE_HELM);
  8010. }
  8011. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8012. player->set_character_flag(CF_HIDE_HOOD);
  8013. else
  8014. {
  8015. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8016. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8017. }
  8018. }
  8019. }
  8020. /*
  8021. Function: Command_ShowHoodHelm()
  8022. Purpose : Character Settings combo box for Show Helm or Hood
  8023. Params : true/false
  8024. Dev : John Adams
  8025. Example :
  8026. */
  8027. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  8028. {
  8029. Player* player = client->GetPlayer();
  8030. if (sep && sep->arg[0])
  8031. {
  8032. const char* value = sep->arg[0];
  8033. if (strncasecmp(value, "true", strlen(value)) == 0)
  8034. {
  8035. player->reset_character_flag(CF_HIDE_HOOD);
  8036. player->reset_character_flag(CF_HIDE_HELM);
  8037. }
  8038. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8039. {
  8040. // don't think we ever wind up in here...
  8041. player->set_character_flag(CF_HIDE_HOOD);
  8042. player->set_character_flag(CF_HIDE_HELM);
  8043. }
  8044. else
  8045. {
  8046. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8047. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8048. }
  8049. }
  8050. }
  8051. /*
  8052. Function: Command_ShowRanged()
  8053. Purpose : Character Settings combo box for Show Ranged weapon
  8054. Params : true/false
  8055. Dev : John Adams
  8056. Example :
  8057. */
  8058. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  8059. {
  8060. Player* player = client->GetPlayer();
  8061. if (sep && sep->arg[0])
  8062. {
  8063. const char* value = sep->arg[0];
  8064. if (strncasecmp(value, "true", strlen(value)) == 0)
  8065. {
  8066. player->set_character_flag(CF2_SHOW_RANGED);
  8067. player->reset_character_flag(CF_SHOW_CLOAK);
  8068. }
  8069. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8070. player->reset_character_flag(CF2_SHOW_RANGED);
  8071. else
  8072. {
  8073. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8074. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8075. }
  8076. }
  8077. }
  8078. /*
  8079. Function:
  8080. Purpose :
  8081. Params :
  8082. Dev :
  8083. Example :
  8084. */
  8085. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  8086. {
  8087. Player* player = 0;
  8088. Client* to_client = 0;
  8089. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  8090. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  8091. switch(handler)
  8092. {
  8093. case COMMAND_SKILL:
  8094. {
  8095. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  8096. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  8097. break;
  8098. }
  8099. case COMMAND_SKILL_ADD:
  8100. {
  8101. if (sep && sep->arg[0])
  8102. {
  8103. const char* skill_name = sep->argplus[0];
  8104. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8105. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  8106. {
  8107. player = to_client->GetPlayer();
  8108. if (player)
  8109. {
  8110. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8111. {
  8112. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8113. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  8114. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  8115. }
  8116. else
  8117. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  8118. }
  8119. }
  8120. else if (skill) // add skill to yourself
  8121. {
  8122. player = client->GetPlayer();
  8123. if (player)
  8124. {
  8125. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8126. {
  8127. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8128. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  8129. }
  8130. else
  8131. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  8132. }
  8133. }
  8134. else
  8135. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8136. }
  8137. else
  8138. {
  8139. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  8140. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8141. }
  8142. break;
  8143. }
  8144. case COMMAND_SKILL_REMOVE:
  8145. {
  8146. if (sep && sep->arg[0])
  8147. {
  8148. const char* skill_name = sep->argplus[0];
  8149. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8150. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  8151. {
  8152. player = to_client->GetPlayer();
  8153. if (player)
  8154. {
  8155. if (player->GetSkills()->HasSkill(skill->skill_id))
  8156. {
  8157. player->RemoveSkillFromDB(skill, true);
  8158. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  8159. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  8160. }
  8161. else
  8162. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  8163. }
  8164. }
  8165. else if(skill) // remove skill from yourself
  8166. {
  8167. Player* player = client->GetPlayer();
  8168. if (player)
  8169. {
  8170. if (player->GetSkills()->HasSkill(skill->skill_id))
  8171. {
  8172. player->RemoveSkillFromDB(skill, true);
  8173. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  8174. }
  8175. else
  8176. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  8177. }
  8178. }
  8179. else
  8180. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8181. }
  8182. else
  8183. {
  8184. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  8185. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8186. }
  8187. break;
  8188. }
  8189. case COMMAND_SKILL_LIST:
  8190. {
  8191. if (sep && sep->arg[0])
  8192. {
  8193. const char* skill_name = sep->argplus[0];
  8194. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  8195. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  8196. map<int32, Skill*>::iterator itr;
  8197. if (skills && skills->size() > 0)
  8198. {
  8199. for (itr = skills->begin(); itr != skills->end(); itr++)
  8200. {
  8201. Skill* skill = itr->second;
  8202. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  8203. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  8204. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  8205. }
  8206. }
  8207. }
  8208. else
  8209. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  8210. break;
  8211. }
  8212. }
  8213. }
  8214. /*
  8215. Function: Command_SpawnTemplate()
  8216. Purpose : Create or Use defined Spawn Templates
  8217. Params : create, save, rempve, list
  8218. Dev : John Adams
  8219. Example : /spawn template create "Test"
  8220. */
  8221. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  8222. {
  8223. if (sep == NULL || sep->arg[0] == NULL)
  8224. {
  8225. 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.");
  8226. return;
  8227. }
  8228. // got params, continue
  8229. const char * template_cmd = sep->arg[0];
  8230. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  8231. {
  8232. if (!sep->IsSet(1))
  8233. {
  8234. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  8235. 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.");
  8236. return;
  8237. }
  8238. map<int32, string>* template_names = 0;
  8239. if (sep->IsNumber(1))
  8240. {
  8241. int32 location_id = 0;
  8242. location_id = atoi(sep->arg[1]);
  8243. template_names = database.GetSpawnTemplateListByID(location_id);
  8244. }
  8245. else
  8246. {
  8247. const char* name = 0;
  8248. name = sep->argplus[1];
  8249. template_names = database.GetSpawnTemplateListByName(name);
  8250. }
  8251. if(!template_names)
  8252. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  8253. else
  8254. {
  8255. map<int32, string>::iterator itr;
  8256. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  8257. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  8258. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  8259. safe_delete(template_names);
  8260. }
  8261. }
  8262. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  8263. {
  8264. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8265. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  8266. {
  8267. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  8268. {
  8269. // first, lookup to see if template name already exists
  8270. const char* name = 0;
  8271. name = sep->argplus[1];
  8272. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  8273. if(!template_names)
  8274. {
  8275. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  8276. if( new_template_id > 0 )
  8277. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  8278. else
  8279. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  8280. }
  8281. else
  8282. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  8283. }
  8284. else
  8285. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  8286. }
  8287. else
  8288. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  8289. }
  8290. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  8291. {
  8292. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  8293. {
  8294. int32 template_id = 0;
  8295. template_id = atoi(sep->arg[1]);
  8296. if (database.RemoveSpawnTemplate(template_id))
  8297. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  8298. else
  8299. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  8300. }
  8301. else
  8302. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  8303. }
  8304. // Renamed create to spawn
  8305. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  8306. {
  8307. if (sep && sep->arg[1][0])
  8308. {
  8309. int32 new_location = 0;
  8310. if (sep->IsNumber(1))
  8311. {
  8312. int32 template_id = 0;
  8313. template_id = atoi(sep->arg[1]);
  8314. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  8315. if( new_location > 0 )
  8316. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  8317. else
  8318. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  8319. }
  8320. else
  8321. {
  8322. const char* name = 0;
  8323. name = sep->argplus[1];
  8324. new_location = database.CreateSpawnFromTemplateByName(client, name);
  8325. if( new_location > 0 )
  8326. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  8327. else
  8328. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  8329. }
  8330. }
  8331. else
  8332. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  8333. }
  8334. else
  8335. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  8336. }
  8337. void Commands::Command_Speed(Client* client, Seperator* sep) {
  8338. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  8339. float new_speed = atof(sep->arg[0]);
  8340. if (new_speed > 0.0f)
  8341. {
  8342. client->GetPlayer()->SetSpeed(new_speed, true);
  8343. client->GetPlayer()->SetCharSheetChanged(true);
  8344. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  8345. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  8346. }
  8347. else
  8348. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  8349. }
  8350. else{
  8351. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  8352. }
  8353. }
  8354. /*
  8355. Function: Command_StationMarketPlace()
  8356. Purpose : just trying to eat the console spam for now
  8357. Params :
  8358. Dev : John
  8359. */
  8360. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  8361. {
  8362. PrintSep(sep, "COMMAND_SMP");
  8363. // This will reduce the spam from once every 10 sec to once every 30 sec,
  8364. // can't seem to reduce it any more get rid of it completely...
  8365. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  8366. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  8367. if (packet) {
  8368. packet->setDataByName("account_id", client->GetAccountID());
  8369. packet->setDataByName("character_id", client->GetCharacterID());
  8370. packet->setDataByName("unknown1", 1, 5);
  8371. packet->setDataByName("unknown1", 26, 6);
  8372. packet->setDataByName("unknown2", 0xFFFFFFFF);
  8373. packet->setDataByName("unknown3", 248, 1);
  8374. client->QueuePacket(packet->serialize());
  8375. }
  8376. safe_delete(packet);
  8377. }
  8378. }
  8379. /*
  8380. Function: Command_StopDrinking()
  8381. Purpose : Stops player from auto-consuming drink
  8382. Params :
  8383. Dev : Zcoretri
  8384. Example : /stopdrinking
  8385. */
  8386. void Commands::Command_StopDrinking(Client* client)
  8387. {
  8388. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  8389. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  8390. }
  8391. /*
  8392. Function: Command_StopEating()
  8393. Purpose : Stops player from auto-consuming food
  8394. Params :
  8395. Dev : Zcoretri
  8396. Example : /stopeating
  8397. */
  8398. void Commands::Command_StopEating(Client* client)
  8399. {
  8400. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  8401. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  8402. }
  8403. /*
  8404. Function: Command_Title()
  8405. Purpose : Help for /title command
  8406. Params : n/a
  8407. Dev : Zcoretri
  8408. Example : /title
  8409. */
  8410. void Commands::Command_Title(Client* client)
  8411. {
  8412. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  8413. }
  8414. /*
  8415. Function: Command_TitleList()
  8416. Purpose : List available titles for player
  8417. Params : n/a
  8418. Dev : Zcoretri
  8419. Example : /title list
  8420. */
  8421. void Commands::Command_TitleList(Client* client)
  8422. {
  8423. // must call release read lock before leaving function on GetPlayerTitles
  8424. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  8425. vector<Title*>::iterator itr;
  8426. Title* title;
  8427. sint32 i = 0;
  8428. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  8429. for(itr = titles->begin(); itr != titles->end(); itr++)
  8430. {
  8431. title = *itr;
  8432. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  8433. i++;
  8434. }
  8435. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  8436. }
  8437. /*
  8438. Function: Command_TitleSetPrefix()
  8439. Purpose : Set Prefix title for player
  8440. Params : Title ID
  8441. Dev : Zcoretri
  8442. Example : /title setprefix 1
  8443. */
  8444. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  8445. {
  8446. if (sep && sep->arg[0] && sep->IsNumber(0))
  8447. {
  8448. sint32 index = atoul(sep->arg[0]);
  8449. if(index > -1)
  8450. {
  8451. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8452. if(!title)
  8453. {
  8454. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8455. return;
  8456. }
  8457. else if(!title->GetPrefix())
  8458. {
  8459. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  8460. return;
  8461. }
  8462. }
  8463. else // make sure client doesn't pass some bogus negative index
  8464. index = -1;
  8465. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  8466. client->SendTitleUpdate();
  8467. }
  8468. }
  8469. /*
  8470. Function: Command_TitleSetSuffix()
  8471. Purpose : Set Suffix title for player
  8472. Params : Title ID
  8473. Dev : Zcoretri
  8474. Example : /title setsuffix 1
  8475. */
  8476. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  8477. {
  8478. if (sep && sep->arg[0] && sep->IsNumber(0))
  8479. {
  8480. sint32 index = atoul(sep->arg[0]);
  8481. if(index > -1)
  8482. {
  8483. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8484. if(!title)
  8485. {
  8486. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8487. return;
  8488. }
  8489. else if(title->GetPrefix())
  8490. {
  8491. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  8492. return;
  8493. }
  8494. }
  8495. else // make sure client doesn't pass some bogus negative index
  8496. index = -1;
  8497. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  8498. client->SendTitleUpdate();
  8499. }
  8500. }
  8501. /*
  8502. Function: Command_TitleFix()
  8503. Purpose : Fix title for player (???)
  8504. Params :
  8505. Dev : Zcoretri
  8506. Example :
  8507. */
  8508. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  8509. {
  8510. PrintSep(sep, "COMMAND_TITLE_FIX");
  8511. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  8512. }
  8513. /*
  8514. Function: Command_Toggle_Anonymous()
  8515. Purpose : Toggles player Anonymous
  8516. Params :
  8517. Dev : paulgh
  8518. Example : /anon
  8519. */
  8520. void Commands::Command_Toggle_Anonymous(Client* client)
  8521. {
  8522. Player* player = client->GetPlayer();
  8523. player->toggle_character_flag(CF_ANONYMOUS);
  8524. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  8525. if (player->get_character_flag(CF_ANONYMOUS))
  8526. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  8527. else
  8528. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  8529. }
  8530. /*
  8531. Function: Command_Toggle_AutoConsume()
  8532. Purpose : Toggles player food/drink auto consume
  8533. Params : unknown
  8534. Dev : paulgh
  8535. Example : /set_auto_consume
  8536. */
  8537. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  8538. {
  8539. Player* player = client->GetPlayer();
  8540. if (sep && sep->arg[0])
  8541. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  8542. if (sep && sep->arg[0] && sep->IsNumber(0))
  8543. {
  8544. int8 slot = atoi(sep->arg[0]);
  8545. int8 flag = atoi(sep->arg[1]);
  8546. if (client->GetVersion() <= 283) {
  8547. slot += 4;
  8548. }
  8549. else if (client->GetVersion() <= 546) {
  8550. slot += 2;
  8551. }
  8552. if (slot == EQ2_FOOD_SLOT)
  8553. {
  8554. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  8555. player->SetCharSheetChanged(true);
  8556. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8557. if (flag == 1)
  8558. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  8559. else
  8560. {
  8561. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  8562. return;
  8563. }
  8564. }
  8565. else
  8566. {
  8567. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  8568. player->SetCharSheetChanged(true);
  8569. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8570. if (flag == 1)
  8571. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  8572. else
  8573. {
  8574. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  8575. return;
  8576. }
  8577. }
  8578. if(!client->CheckConsumptionAllowed(slot, false))
  8579. return;
  8580. Item* item = player->GetEquipmentList()->GetItem(slot);
  8581. if(item)
  8582. client->ConsumeFoodDrink(item, slot);
  8583. }
  8584. }
  8585. /*
  8586. Function: Command_Toggle_BonusXP()
  8587. Purpose : Toggles player Bonus XP
  8588. Params :
  8589. Dev : John Adams
  8590. Example : /disable_char_bonus_exp
  8591. */
  8592. void Commands::Command_Toggle_BonusXP(Client* client)
  8593. {
  8594. Player* player = client->GetPlayer();
  8595. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  8596. player->SetCharSheetChanged(true);
  8597. }
  8598. /*
  8599. Function: Command_Toggle_CombatXP()
  8600. Purpose : Toggles player Adventure XP
  8601. Params :
  8602. Dev : John Adams
  8603. Example : /disable_combat_exp
  8604. */
  8605. void Commands::Command_Toggle_CombatXP(Client* client)
  8606. {
  8607. Player* player = client->GetPlayer();
  8608. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  8609. player->SetCharSheetChanged(true);
  8610. }
  8611. /*
  8612. Function: Command_Toggle_GMHide()
  8613. Purpose : Toggles hiding player GM status
  8614. Params :
  8615. Dev : Scatman
  8616. Example : /gm_hide
  8617. */
  8618. void Commands::Command_Toggle_GMHide(Client* client)
  8619. {
  8620. Player* player = client->GetPlayer();
  8621. player->toggle_character_flag(CF_HIDE_STATUS);
  8622. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  8623. }
  8624. /*
  8625. Function: Command_Toggle_GMVanish()
  8626. Purpose : Toggles hiding GM players from /who searches
  8627. Params :
  8628. Dev : Scatman
  8629. Example : /gm_vanish
  8630. */
  8631. void Commands::Command_Toggle_GMVanish(Client* client)
  8632. {
  8633. Player* player = client->GetPlayer();
  8634. player->toggle_character_flag(CF_GM_HIDDEN);
  8635. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  8636. }
  8637. /*
  8638. Function: Command_Toggle_Illusions()
  8639. Purpose : Toggles player illusion form
  8640. Params : not sure sep is needed, testing
  8641. Dev : paulgh
  8642. Example : /hide_illusions
  8643. */
  8644. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  8645. {
  8646. if (sep && sep->arg[0])
  8647. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  8648. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  8649. }
  8650. /*
  8651. Function: Command_Toggle_LFG()
  8652. Purpose : Toggles player LFG Flag
  8653. Params :
  8654. Dev : paulgh
  8655. Example : /lfg
  8656. */
  8657. void Commands::Command_Toggle_LFG(Client* client)
  8658. {
  8659. Player* player = client->GetPlayer();
  8660. player->toggle_character_flag(CF_LFG);
  8661. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  8662. if (player->get_character_flag(CF_LFG))
  8663. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  8664. else
  8665. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  8666. }
  8667. /*
  8668. Function: Command_Toggle_LFW()
  8669. Purpose : Toggles player LFW Flag
  8670. Params :
  8671. Dev : paulgh
  8672. Example : /lfw
  8673. */
  8674. void Commands::Command_Toggle_LFW(Client* client)
  8675. {
  8676. Player* player = client->GetPlayer();
  8677. player->toggle_character_flag(CF_LFW);
  8678. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8679. if (player->get_character_flag(CF_LFW))
  8680. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8681. else
  8682. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8683. }
  8684. /*
  8685. Function: Command_Toggle_QuestXP()
  8686. Purpose : Toggles player Quest XP
  8687. Params :
  8688. Dev : John Adams
  8689. Example : /disable_quest_exp
  8690. */
  8691. void Commands::Command_Toggle_QuestXP(Client* client)
  8692. {
  8693. Player* player = client->GetPlayer();
  8694. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8695. player->SetCharSheetChanged(true);
  8696. }
  8697. /*
  8698. Function: Command_Toggle_Roleplaying()
  8699. Purpose : Toggles player Roleplaying flag
  8700. Params :
  8701. Dev : paulgh
  8702. Example : /role
  8703. */
  8704. void Commands::Command_Toggle_Roleplaying(Client* client)
  8705. {
  8706. Player* player = client->GetPlayer();
  8707. player->toggle_character_flag(CF_ROLEPLAYING);
  8708. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8709. if (player->get_character_flag(CF_ROLEPLAYING))
  8710. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8711. else
  8712. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8713. }
  8714. void Commands::Command_Toggle_Duels(Client* client)
  8715. {
  8716. Player* player = client->GetPlayer();
  8717. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8718. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8719. }
  8720. void Commands::Command_Toggle_Trades(Client* client)
  8721. {
  8722. Player* player = client->GetPlayer();
  8723. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8724. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8725. }
  8726. void Commands::Command_Toggle_Guilds(Client* client)
  8727. {
  8728. Player* player = client->GetPlayer();
  8729. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8730. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8731. }
  8732. void Commands::Command_Toggle_Groups(Client* client)
  8733. {
  8734. Player* player = client->GetPlayer();
  8735. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8736. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8737. }
  8738. void Commands::Command_Toggle_Raids(Client* client)
  8739. {
  8740. Player* player = client->GetPlayer();
  8741. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8742. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8743. }
  8744. void Commands::Command_Toggle_LON(Client* client)
  8745. {
  8746. Player* player = client->GetPlayer();
  8747. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8748. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8749. }
  8750. void Commands::Command_Toggle_VoiceChat(Client* client)
  8751. {
  8752. Player* player = client->GetPlayer();
  8753. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8754. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8755. }
  8756. /*
  8757. Function: Command_TradeStart()
  8758. Purpose : Starts item/coin trade between players
  8759. Params :
  8760. Dev :
  8761. Example :
  8762. */
  8763. #include "../Trade.h"
  8764. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  8765. {
  8766. PrintSep(sep, "COMMAND_START_TRADE");
  8767. Entity* trader = client->GetPlayer();
  8768. Entity* trader2 = 0;
  8769. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8770. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  8771. if (spawn) {
  8772. if (spawn->IsEntity())
  8773. trader2 = (Entity*)spawn;
  8774. }
  8775. }
  8776. else if (client->GetPlayer()->GetTarget()) {
  8777. if (client->GetPlayer()->GetTarget()->IsEntity())
  8778. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  8779. }
  8780. // can only trade with player or bots
  8781. if (trader && trader2) {
  8782. if (trader == trader2) {
  8783. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  8784. }
  8785. else if (trader2->IsPlayer() || trader2->IsBot()) {
  8786. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  8787. if (trader->trade)
  8788. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  8789. else if (trader2->trade)
  8790. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  8791. else {
  8792. Trade* trade = new Trade(trader, trader2);
  8793. trader->trade = trade;
  8794. trader2->trade = trade;
  8795. }
  8796. }
  8797. else {
  8798. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8799. }
  8800. }
  8801. else
  8802. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8803. }
  8804. /*
  8805. Function: Command_Track()
  8806. Purpose : Starts/Stops Tracking for a player
  8807. Params :
  8808. Dev : Scatman
  8809. Example : /track
  8810. */
  8811. void Commands::Command_Track(Client* client)
  8812. {
  8813. if (!client->GetPlayer()->GetIsTracking())
  8814. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8815. else
  8816. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8817. }
  8818. /*
  8819. Function: Command_TradeAccept()
  8820. Purpose : Accepts item/coin trade between players
  8821. Params :
  8822. Dev :
  8823. Example :
  8824. */
  8825. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8826. {
  8827. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8828. Trade* trade = client->GetPlayer()->trade;
  8829. if (trade) {
  8830. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8831. if (trade_complete)
  8832. safe_delete(trade);
  8833. }
  8834. else
  8835. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8836. }
  8837. /*
  8838. Function: Command_TradeReject()
  8839. Purpose : Rejects item/coin trade between players
  8840. Params :
  8841. Dev :
  8842. Example :
  8843. */
  8844. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8845. {
  8846. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8847. Command_TradeCancel(client, sep);
  8848. }
  8849. /*
  8850. Function: Command_TradeCancel()
  8851. Purpose : Cancels item/coin trade between players
  8852. Params :
  8853. Dev :
  8854. Example :
  8855. */
  8856. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8857. {
  8858. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8859. Trade* trade = client->GetPlayer()->trade;
  8860. if (trade) {
  8861. trade->CancelTrade(client->GetPlayer());
  8862. safe_delete(trade);
  8863. }
  8864. else
  8865. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8866. }
  8867. /*
  8868. Function: Command_TradeSetCoin()
  8869. Purpose : Sets coin trade between players
  8870. Params :
  8871. Dev :
  8872. Example :
  8873. */
  8874. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8875. {
  8876. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8877. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8878. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8879. }
  8880. /*
  8881. Function: Command_TradeAddCoin()
  8882. Purpose : Adds coin to trade between players
  8883. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8884. Dev :
  8885. Example :
  8886. */
  8887. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  8888. {
  8889. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  8890. Trade* trade = client->GetPlayer()->trade;
  8891. if (trade) {
  8892. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8893. int32 amount = atoi(sep->arg[0]);
  8894. int64 val = 0;
  8895. switch (handler) {
  8896. case COMMAND_ADD_TRADE_COPPER:
  8897. {
  8898. val = amount;
  8899. trade->AddCoinToTrade(client->GetPlayer(), val);
  8900. break;
  8901. }
  8902. case COMMAND_ADD_TRADE_SILVER:
  8903. {
  8904. val = amount * 100;
  8905. trade->AddCoinToTrade(client->GetPlayer(), val);
  8906. break;
  8907. }
  8908. case COMMAND_ADD_TRADE_GOLD:
  8909. {
  8910. val = amount * 10000;
  8911. trade->AddCoinToTrade(client->GetPlayer(), val);
  8912. break;
  8913. }
  8914. case COMMAND_ADD_TRADE_PLAT:
  8915. {
  8916. val = amount * 1000000;
  8917. trade->AddCoinToTrade(client->GetPlayer(), val);
  8918. break;
  8919. }
  8920. default:
  8921. {
  8922. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8923. break;
  8924. }
  8925. }
  8926. }
  8927. else
  8928. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  8929. }
  8930. else
  8931. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8932. }
  8933. /*
  8934. Function: Command_TradeRemoveCoin()
  8935. Purpose : Removes coin from trade between players
  8936. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8937. Dev :
  8938. Example :
  8939. */
  8940. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  8941. {
  8942. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  8943. Trade* trade = client->GetPlayer()->trade;
  8944. if (trade) {
  8945. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8946. int32 amount = atoi(sep->arg[0]);
  8947. int64 val = 0;
  8948. switch (handler) {
  8949. case COMMAND_REMOVE_TRADE_COPPER:
  8950. {
  8951. val = amount;
  8952. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8953. break;
  8954. }
  8955. case COMMAND_REMOVE_TRADE_SILVER:
  8956. {
  8957. val = amount * 100;
  8958. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8959. break;
  8960. }
  8961. case COMMAND_REMOVE_TRADE_GOLD:
  8962. {
  8963. val = amount * 10000;
  8964. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8965. break;
  8966. }
  8967. case COMMAND_REMOVE_TRADE_PLAT:
  8968. {
  8969. val = amount * 1000000;
  8970. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8971. break;
  8972. }
  8973. default:
  8974. {
  8975. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8976. break;
  8977. }
  8978. }
  8979. }
  8980. else
  8981. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  8982. }
  8983. else
  8984. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8985. }
  8986. /*
  8987. Function: Command_TradeAddItem()
  8988. Purpose : Adds item to trade between players
  8989. Params :
  8990. Dev :
  8991. Example :
  8992. */
  8993. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  8994. {
  8995. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  8996. /*
  8997. arg[0] = item index
  8998. arg[1] = slot
  8999. arg[2] = quantity
  9000. */
  9001. if (!client->GetPlayer()->trade) {
  9002. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  9003. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9004. return;
  9005. }
  9006. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  9007. Item* item = 0;
  9008. int32 index = atoi(sep->arg[0]);
  9009. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  9010. if (item) {
  9011. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  9012. if (result == 1)
  9013. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  9014. else if (result == 2)
  9015. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  9016. else if (result == 3)
  9017. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  9018. else if (result == 255)
  9019. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  9020. }
  9021. else {
  9022. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  9023. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  9024. }
  9025. }
  9026. else
  9027. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9028. }
  9029. /*
  9030. Function: Command_TradeRemoveItem()
  9031. Purpose : Removes item from trade between players
  9032. Params :
  9033. Dev :
  9034. Example :
  9035. */
  9036. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  9037. {
  9038. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  9039. /*
  9040. arg[0] = trade window slot
  9041. */
  9042. Trade* trade = client->GetPlayer()->trade;
  9043. if (trade) {
  9044. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9045. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  9046. }
  9047. else
  9048. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9049. }
  9050. else
  9051. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9052. }
  9053. void Commands::Command_TryOn(Client* client, Seperator* sep)
  9054. {
  9055. Item *item = 0;
  9056. sint32 crc;
  9057. if (sep) {
  9058. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  9059. if (client->GetVersion() < 1096) {
  9060. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  9061. {
  9062. item = master_item_list.GetItem(atoul(sep->arg[1]));
  9063. crc = atol(sep->arg[2]);
  9064. }
  9065. }
  9066. else {
  9067. // From the broker and links in chat
  9068. if (strcmp(sep->arg[0], "crc") == 0) {
  9069. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  9070. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9071. crc = atol(sep->arg[3]);
  9072. }
  9073. }
  9074. // From inventory
  9075. if (strcmp(sep->arg[0], "dbid") == 0) {
  9076. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  9077. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9078. crc = atol(sep->arg[4]);
  9079. }
  9080. }
  9081. }
  9082. if (item)
  9083. client->ShowDressingRoom(item, crc);
  9084. }
  9085. }
  9086. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  9087. const char *channel_name, *password = NULL;
  9088. if (sep == NULL || !sep->IsSet(0)) {
  9089. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  9090. return;
  9091. }
  9092. channel_name = sep->arg[0];
  9093. if (sep->IsSet(1))
  9094. password = sep->arg[1];
  9095. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  9096. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  9097. return;
  9098. }
  9099. if (chat.IsInChannel(client, channel_name)) {
  9100. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  9101. return;
  9102. }
  9103. if (chat.HasPassword(channel_name)) {
  9104. if (password == NULL) {
  9105. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  9106. return;
  9107. }
  9108. if (!chat.PasswordMatches(channel_name, password)) {
  9109. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  9110. return;
  9111. }
  9112. }
  9113. if (!chat.JoinChannel(client, channel_name))
  9114. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  9115. }
  9116. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  9117. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  9118. Command_JoinChannel(client, sep);
  9119. }
  9120. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  9121. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  9122. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  9123. PrintSep(sep, "tellchannel");
  9124. return;
  9125. }
  9126. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  9127. }
  9128. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  9129. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9130. if (sep->IsSet(0)) {
  9131. if (atoi(sep->arg[0]) == 1) {
  9132. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  9133. if (packet2) {
  9134. packet2->setDataByName("spell_type", 2);
  9135. packet2->setDataByName("spell_id", 8308);
  9136. packet2->setDataByName("spell_name", "Sprint");
  9137. packet2->setDataByName("add_silently", 0);
  9138. packet2->setDataByName("tier", 1);
  9139. packet2->setDataByName("blah1", 1);
  9140. packet2->setDataByName("blah2", 1);
  9141. EQ2Packet* outapp = packet2->serialize();
  9142. DumpPacket(outapp);
  9143. client->QueuePacket(outapp);
  9144. safe_delete(packet2);
  9145. }
  9146. }
  9147. else if (atoi(sep->arg[0]) == 2) {
  9148. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  9149. if (packet2) {
  9150. packet2->setDataByName("guild_name", "Test");
  9151. packet2->setDataByName("guild_motd", "Test MOTD");
  9152. packet2->setDataByName("guild_id", 1234);
  9153. packet2->setDataByName("guild_level", 1);
  9154. packet2->setDataByName("unknown", 2);
  9155. packet2->setDataByName("unknown2", 3);
  9156. packet2->setDataByName("exp_current", 1);
  9157. packet2->setDataByName("exp_to_next_level", 4);
  9158. EQ2Packet* outapp = packet2->serialize();
  9159. DumpPacket(outapp);
  9160. client->QueuePacket(outapp);
  9161. safe_delete(packet2);
  9162. }
  9163. }
  9164. else if (atoi(sep->arg[0]) == 3) {
  9165. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  9166. if (packet2) {
  9167. packet2->setDataByName("guild_id", 1234);
  9168. packet2->setDataByName("character_id", 1);
  9169. packet2->setDataByName("account_id", 2);
  9170. packet2->setDataByName("guild_level", 1);
  9171. packet2->setDataByName("name", "Test");
  9172. packet2->setDataByName("unknown2", 0);
  9173. packet2->setDataByName("unknown3", 1);
  9174. packet2->setDataByName("adventure_class", 6);
  9175. packet2->setDataByName("adventure_level", 7);
  9176. packet2->setDataByName("tradeskill_class", 4);
  9177. packet2->setDataByName("tradeskill_level", 5);
  9178. packet2->setDataByName("rank", 0);
  9179. packet2->setDataByName("member_flags", 2);
  9180. packet2->setDataByName("join_date", 1591112273);
  9181. packet2->setDataByName("guild_status", 2);
  9182. packet2->setDataByName("last_login", 1591132273);
  9183. packet2->setDataByName("recruiter_id", 1);
  9184. packet2->setDataByName("points", 2345);
  9185. packet2->setDataByName("note", "note");
  9186. packet2->setMediumStringByName("officer_note", "O note");
  9187. packet2->setMediumStringByName("zone", "Blah");
  9188. EQ2Packet* outapp = packet2->serialize();
  9189. DumpPacket(outapp);
  9190. client->QueuePacket(outapp);
  9191. safe_delete(packet2);
  9192. }
  9193. }
  9194. else if (atoi(sep->arg[0]) == 5) {
  9195. int16 offset = atoi(sep->arg[1]);
  9196. int32 value1 = atol(sep->arg[2]);
  9197. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  9198. client->QueuePacket(outapp);
  9199. }
  9200. else if (atoi(sep->arg[0]) == 6) {
  9201. Spawn* spawn = client->GetPlayer()->GetTarget();
  9202. if (!spawn)
  9203. spawn = client->GetPlayer();
  9204. else if (spawn->IsEntity())
  9205. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  9206. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  9207. }
  9208. else if (atoi(sep->arg[0]) == 7) {
  9209. int32 id = 0;
  9210. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  9211. if (spawn) {
  9212. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9213. spawn->SetY(client->GetPlayer()->GetY(), false);
  9214. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9215. float heading = client->GetPlayer()->GetHeading() + 180;
  9216. if (heading > 360)
  9217. heading -= 360;
  9218. spawn->SetLevel(5);
  9219. spawn->SetAdventureClass(4);
  9220. spawn->SetHeading(heading, false);
  9221. spawn->SetSpawnOrigX(spawn->GetX());
  9222. spawn->SetSpawnOrigY(spawn->GetY());
  9223. spawn->SetSpawnOrigZ(spawn->GetZ());
  9224. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9225. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9226. spawn->appearance.targetable = 1;
  9227. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9228. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9229. spawn->SetHP(spawn->GetTotalHP());
  9230. }
  9231. if (spawn->GetTotalPower() == 0) {
  9232. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9233. spawn->SetPower(spawn->GetTotalPower());
  9234. }
  9235. int16 offset = atoi(sep->arg[1]);
  9236. int32 value1 = atol(sep->arg[2]);
  9237. sprintf(spawn->appearance.name, "Offset %i", offset);
  9238. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  9239. DumpPacket(ret);
  9240. client->QueuePacket(ret);
  9241. }
  9242. }
  9243. else if (atoi(sep->arg[0]) == 8) {
  9244. int32 id = atoi(sep->arg[1]);
  9245. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  9246. if (spawn) {
  9247. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9248. spawn->SetY(client->GetPlayer()->GetY(), false);
  9249. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9250. float heading = client->GetPlayer()->GetHeading() + 180;
  9251. if (heading > 360)
  9252. heading -= 360;
  9253. spawn->SetLevel(5);
  9254. spawn->SetAdventureClass(4);
  9255. spawn->SetHeading(heading, false);
  9256. spawn->SetSpawnOrigX(spawn->GetX());
  9257. spawn->SetSpawnOrigY(spawn->GetY());
  9258. spawn->SetSpawnOrigZ(spawn->GetZ());
  9259. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9260. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9261. spawn->appearance.targetable = 1;
  9262. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9263. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9264. spawn->SetHP(spawn->GetTotalHP());
  9265. }
  9266. if (spawn->GetTotalPower() == 0) {
  9267. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9268. spawn->SetPower(spawn->GetTotalPower());
  9269. }
  9270. int16 offset = atoi(sep->arg[2]);
  9271. int16 offset2 = atoi(sep->arg[3]);
  9272. int32 value1 = atol(sep->arg[4]);
  9273. int16 offset3 = 0;
  9274. int16 offset4 = 0;
  9275. int32 value2 = 0;
  9276. if (sep->IsSet(7)) {
  9277. offset3 = atoi(sep->arg[5]);
  9278. offset4 = atoi(sep->arg[6]);
  9279. value2 = atol(sep->arg[7]);
  9280. }
  9281. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  9282. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  9283. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  9284. DumpPacket(ret);
  9285. client->QueuePacket(ret);
  9286. }
  9287. }
  9288. else if (atoi(sep->arg[0]) == 9) {
  9289. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  9290. if (packet2) {
  9291. packet2->setArrayLengthByName("location_count", 1);
  9292. packet2->setArrayDataByName("location_ida", 1234);
  9293. packet2->setArrayDataByName("unknown2a", 3);
  9294. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  9295. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  9296. packet2->setArrayDataByName("distance", 134);
  9297. EQ2Packet* app = packet2->serialize();
  9298. if (sep->IsSet(2)) {
  9299. int8 offset = atoi(sep->arg[1]);
  9300. uchar* ptr2 = app->pBuffer;
  9301. ptr2 += offset;
  9302. if (sep->IsNumber(2)) {
  9303. int32 value1 = atol(sep->arg[2]);
  9304. if (value1 > 0xFFFF)
  9305. memcpy(ptr2, (uchar*)&value1, 4);
  9306. else if (value1 > 0xFF)
  9307. memcpy(ptr2, (uchar*)&value1, 2);
  9308. else
  9309. memcpy(ptr2, (uchar*)&value1, 1);
  9310. }
  9311. else {
  9312. int8 len = strlen(sep->arg[2]);
  9313. memcpy(ptr2, (uchar*)&len, 1);
  9314. ptr2 += 1;
  9315. memcpy(ptr2, sep->arg[2], len);
  9316. }
  9317. }
  9318. DumpPacket(app);
  9319. client->QueuePacket(app);
  9320. safe_delete(packet2);
  9321. }
  9322. }
  9323. else if (atoi(sep->arg[0]) == 10) {
  9324. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  9325. if (packet2) {
  9326. packet2->setArrayLengthByName("num_quests", 1);
  9327. packet2->setArrayDataByName("active", 1);
  9328. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  9329. packet2->setArrayDataByName("quest_type", "Hallmark");
  9330. packet2->setArrayDataByName("quest_zone", "Hallmark");
  9331. packet2->setArrayDataByName("journal_updated", 1);
  9332. packet2->setArrayDataByName("quest_id", 524);
  9333. packet2->setArrayDataByName("day", 19);
  9334. packet2->setArrayDataByName("month", 6);
  9335. packet2->setArrayDataByName("year", 20);
  9336. packet2->setArrayDataByName("level", 2);
  9337. packet2->setArrayDataByName("encounter_level", 4);
  9338. packet2->setArrayDataByName("difficulty", 3);
  9339. packet2->setArrayDataByName("visible", 1);
  9340. packet2->setDataByName("visible_quest_id", 524);
  9341. packet2->setDataByName("player_crc", 2900677088);
  9342. packet2->setDataByName("player_name", "LethalEncounter");
  9343. EQ2Packet* app = packet2->serialize();
  9344. if (sep->IsSet(2)) {
  9345. int8 offset = atoi(sep->arg[1]);
  9346. uchar* ptr2 = app->pBuffer;
  9347. ptr2 += offset;
  9348. if (sep->IsNumber(2)) {
  9349. int32 value1 = atol(sep->arg[2]);
  9350. if (value1 > 0xFFFF)
  9351. memcpy(ptr2, (uchar*)&value1, 4);
  9352. else if (value1 > 0xFF)
  9353. memcpy(ptr2, (uchar*)&value1, 2);
  9354. else
  9355. memcpy(ptr2, (uchar*)&value1, 1);
  9356. }
  9357. else {
  9358. int8 len = strlen(sep->arg[2]);
  9359. memcpy(ptr2, (uchar*)&len, 1);
  9360. ptr2 += 1;
  9361. memcpy(ptr2, sep->arg[2], len);
  9362. }
  9363. }
  9364. DumpPacket(app);
  9365. client->QueuePacket(app);
  9366. safe_delete(packet2);
  9367. }
  9368. }
  9369. else if (atoi(sep->arg[0]) == 11) {
  9370. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9371. if (packet2) {
  9372. packet2->setDataByName("quest_id", 524);
  9373. packet2->setDataByName("player_crc", 2900677088);
  9374. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  9375. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  9376. packet2->setDataByName("type", "Hallmark");
  9377. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9378. packet2->setDataByName("day", 19);
  9379. packet2->setDataByName("month", 6);
  9380. packet2->setDataByName("year", 20);
  9381. packet2->setDataByName("level", 1);
  9382. packet2->setDataByName("encounter_level", 1);
  9383. packet2->setDataByName("difficulty", 1);
  9384. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9385. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9386. //packet2->setDataByName("timer_duration", 300);
  9387. //packet2->setDataByName("timer_running", 1);
  9388. packet2->setArrayLengthByName("task_groups_completed", 9);
  9389. packet2->setArrayLengthByName("num_task_groups", 10);
  9390. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  9391. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  9392. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  9393. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  9394. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  9395. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  9396. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  9397. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  9398. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  9399. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  9400. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  9401. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9402. packet2->setSubArrayLengthByName("num_updates", 1);
  9403. packet2->setSubArrayDataByName("update_currentval", 0);
  9404. packet2->setSubArrayDataByName("update_maxval", 1);
  9405. packet2->setSubArrayDataByName("icon", 11);
  9406. */
  9407. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9408. packet2->setDataByName("journal_updated", 1);
  9409. packet2->setDataByName("bullets", 1);
  9410. EQ2Packet* app = packet2->serialize();
  9411. if (sep->IsSet(2)) {
  9412. int16 offset = atoi(sep->arg[1]);
  9413. uchar* ptr2 = app->pBuffer;
  9414. ptr2 += offset;
  9415. if (sep->IsNumber(2)) {
  9416. int32 value1 = atol(sep->arg[2]);
  9417. if (value1 > 0xFFFF)
  9418. memcpy(ptr2, (uchar*)&value1, 4);
  9419. else if (value1 > 0xFF)
  9420. memcpy(ptr2, (uchar*)&value1, 2);
  9421. else
  9422. memcpy(ptr2, (uchar*)&value1, 1);
  9423. }
  9424. else {
  9425. int16 len = strlen(sep->arg[2]);
  9426. memcpy(ptr2, (uchar*)&len, 2);
  9427. ptr2 += 2;
  9428. memcpy(ptr2, sep->arg[2], len);
  9429. }
  9430. }
  9431. DumpPacket(app);
  9432. client->QueuePacket(app);
  9433. safe_delete(packet2);
  9434. }
  9435. }
  9436. else if (atoi(sep->arg[0]) == 12) {
  9437. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9438. if (packet2) {
  9439. packet2->setDataByName("quest_id", 524);
  9440. packet2->setDataByName("player_crc", 2900677088);
  9441. packet2->setDataByName("name", "Archetype Selection");
  9442. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  9443. packet2->setDataByName("type", "Hallmark");
  9444. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9445. packet2->setDataByName("day", 19);
  9446. packet2->setDataByName("month", 6);
  9447. packet2->setDataByName("year", 20);
  9448. packet2->setDataByName("level", 2);
  9449. packet2->setDataByName("encounter_level", 4);
  9450. packet2->setDataByName("difficulty", 3);
  9451. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9452. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9453. packet2->setDataByName("timer_duration", 300);
  9454. packet2->setDataByName("timer_running", 1);
  9455. packet2->setArrayLengthByName("task_groups_completed", 0);
  9456. packet2->setArrayLengthByName("num_task_groups", 1);
  9457. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  9458. packet2->setSubArrayLengthByName("num_tasks", 1);
  9459. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9460. packet2->setSubArrayLengthByName("num_updates", 1);
  9461. packet2->setSubArrayDataByName("update_currentval", 0);
  9462. packet2->setSubArrayDataByName("update_maxval", 1);
  9463. packet2->setSubArrayDataByName("icon", 11);
  9464. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9465. packet2->setDataByName("journal_updated", 1);
  9466. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9467. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9468. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  9469. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9470. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9471. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9472. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9473. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  9474. Item* item = master_item_list.GetItem(152755);
  9475. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9476. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9477. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  9478. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  9479. packet2->setSubstructDataByName("item", "icon", 0xe7);
  9480. packet2->setSubstructDataByName("item", "tier", 4);
  9481. packet2->setSubstructDataByName("item", "flags", 0x60);
  9482. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  9483. packet2->setSubstructDataByName("item", "stat_type", 1);
  9484. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  9485. packet2->setSubstructDataByName("item", "value", 3);
  9486. packet2->setSubstructDataByName("item", "condition", 100);
  9487. packet2->setSubstructDataByName("item", "weight", 1);
  9488. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  9489. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  9490. packet2->setSubstructDataByName("item", "skill_min", 1);
  9491. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  9492. packet2->setSubstructDataByName("item", "adventure_class", 1);
  9493. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  9494. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  9495. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  9496. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  9497. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  9498. packet2->setSubstructDataByName("item", "level", 0x1e);
  9499. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  9500. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  9501. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  9502. //packet2->PrintPacket();
  9503. EQ2Packet* app = packet2->serialize();
  9504. if (sep->IsSet(2)) {
  9505. int16 offset = atoi(sep->arg[1]);
  9506. uchar* ptr2 = app->pBuffer;
  9507. ptr2 += offset;
  9508. if (sep->IsNumber(2)) {
  9509. int32 value1 = atol(sep->arg[2]);
  9510. if (value1 > 0xFFFF)
  9511. memcpy(ptr2, (uchar*)&value1, 4);
  9512. else if (value1 > 0xFF)
  9513. memcpy(ptr2, (uchar*)&value1, 2);
  9514. else
  9515. memcpy(ptr2, (uchar*)&value1, 1);
  9516. }
  9517. else {
  9518. int16 len = strlen(sep->arg[2]);
  9519. memcpy(ptr2, (uchar*)&len, 2);
  9520. ptr2 += 2;
  9521. memcpy(ptr2, sep->arg[2], len);
  9522. }
  9523. }
  9524. DumpPacket(app);
  9525. client->QueuePacket(app);
  9526. safe_delete(packet2);
  9527. }
  9528. }
  9529. else if (atoi(sep->arg[0]) == 13) {
  9530. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  9531. if (packet2 && sep->IsSet(7)) {
  9532. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  9533. char blah[128];
  9534. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  9535. packet2->setDataByName("text", blah);
  9536. packet2->setDataByName("message_type", sep->arg[3]);
  9537. packet2->setDataByName("size", atof(sep->arg[4]));
  9538. packet2->setDataByName("red", atoi(sep->arg[5]));
  9539. packet2->setDataByName("green", atoi(sep->arg[6]));
  9540. packet2->setDataByName("blue", atoi(sep->arg[7]));
  9541. EQ2Packet* app = packet2->serialize();
  9542. DumpPacket(app);
  9543. client->QueuePacket(app);
  9544. safe_delete(packet2);
  9545. }
  9546. }
  9547. else if (atoi(sep->arg[0]) == 14) {
  9548. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  9549. if (packet2 && sep->IsSet(3)) {
  9550. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  9551. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  9552. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  9553. packet2->setDataByName("text", "Welcome to Norrath, the world of EverQuest II. Left click on the help button at any time for more detailed help and information.");
  9554. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  9555. packet2->setArrayLengthByName("num_goals", 1);
  9556. //packet2->setArrayDataByName("goal_text", )
  9557. packet2->setSubArrayLengthByName("num_tasks", 1);
  9558. packet2->setSubArrayDataByName("task_text", "continue");
  9559. packet2->setDataByName("complete_sound", "click");
  9560. packet2->setDataByName("signal", "introduction");
  9561. packet2->setDataByName("voice_key1", 0xcda65173);
  9562. packet2->setDataByName("voice_key2", 0x984bfc6d);
  9563. EQ2Packet* app = packet2->serialize();
  9564. DumpPacket(app);
  9565. client->QueuePacket(app);
  9566. safe_delete(packet2);
  9567. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  9568. packet2->setDataByName("window", "MainHUD.StartMenu");
  9569. packet2->setDataByName("show", 1);
  9570. app = packet2->serialize();
  9571. DumpPacket(app);
  9572. client->QueuePacket(app);
  9573. safe_delete(packet2);
  9574. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  9575. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  9576. packet2->setDataByName("flash_seconds", 10);
  9577. app = packet2->serialize();
  9578. DumpPacket(app);
  9579. client->QueuePacket(app);
  9580. safe_delete(packet2);
  9581. }
  9582. }
  9583. else if (atoi(sep->arg[0]) == 15) {
  9584. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9585. if (packet2) {
  9586. packet2->setArrayLengthByName("loot_count", 1);
  9587. packet2->setArrayDataByName("name", "Test");
  9588. packet2->setArrayDataByName("item_id", 1234);
  9589. packet2->setArrayDataByName("count", 1);
  9590. packet2->setArrayDataByName("icon", 258);
  9591. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  9592. Spawn* spawn = client->GetPlayer()->GetTarget();
  9593. if (spawn)
  9594. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9595. packet2->setDataByName("unknown3", 1);
  9596. packet2->setDataByName("unknown4", 1);
  9597. packet2->setDataByName("unknown5", 60);
  9598. EQ2Packet* app = packet2->serialize();
  9599. DumpPacket(app);
  9600. client->QueuePacket(app);
  9601. safe_delete(packet2);
  9602. }
  9603. }
  9604. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  9605. char blah[32];
  9606. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  9607. client->SimpleMessage(atoi(sep->arg[1]), blah);
  9608. }
  9609. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  9610. if (sep->IsSet(2)) {
  9611. int16 offset = atoi(sep->arg[1]);
  9612. if (sep->IsNumber(2)) {
  9613. int32 value1 = atol(sep->arg[2]);
  9614. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  9615. cout << "Sent" << endl;
  9616. }
  9617. }
  9618. }
  9619. else if (atoi(sep->arg[0]) == 18) {
  9620. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  9621. if (packet2) {
  9622. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9623. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9624. packet2->setSubstructDataByName("reward_data", "max_coin", 0);
  9625. packet2->setSubstructDataByName("reward_data", "text", "Some custom text to mess things up?");
  9626. //packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9627. //packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9628. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9629. Item* item = new Item(master_item_list.GetItem(9357));
  9630. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9631. //item->stack_count = 20;
  9632. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9633. safe_delete(item);
  9634. /*item = new Item(master_item_list.GetItem(36685));
  9635. item->stack_count = 20;
  9636. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9637. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  9638. safe_delete(item);
  9639. item = master_item_list.GetItem(1414);
  9640. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9641. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  9642. item = master_item_list.GetItem(75057);
  9643. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9644. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);*/
  9645. EQ2Packet* app = packet2->serialize();
  9646. if (sep->IsSet(2)) {
  9647. int16 offset = atoi(sep->arg[1]);
  9648. uchar* ptr2 = app->pBuffer;
  9649. ptr2 += offset;
  9650. if (sep->IsNumber(2)) {
  9651. int32 value1 = atol(sep->arg[2]);
  9652. if (value1 > 0xFFFF)
  9653. memcpy(ptr2, (uchar*)&value1, 4);
  9654. else if (value1 > 0xFF)
  9655. memcpy(ptr2, (uchar*)&value1, 2);
  9656. else
  9657. memcpy(ptr2, (uchar*)&value1, 1);
  9658. }
  9659. else {
  9660. int16 len = strlen(sep->arg[2]);
  9661. memcpy(ptr2, (uchar*)&len, 2);
  9662. ptr2 += 2;
  9663. memcpy(ptr2, sep->arg[2], len);
  9664. }
  9665. }
  9666. DumpPacket(app);
  9667. client->QueuePacket(app);
  9668. safe_delete(packet2);
  9669. }
  9670. }
  9671. else if (atoi(sep->arg[0]) == 19) {
  9672. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9673. Spawn* spawn = client->GetPlayer()->GetTarget();
  9674. if (packet2 && spawn) {
  9675. Item* item = master_item_list.GetItem(130053);
  9676. packet2->setArrayLengthByName("loot_count", 1);
  9677. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9678. packet2->setArrayDataByName("unknown2", 1);
  9679. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9680. packet2->setDataByName("display", 1);
  9681. packet2->setDataByName("unknown2b", 1);
  9682. packet2->setDataByName("unknown3", 0x3c);
  9683. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9684. packet2->PrintPacket();
  9685. EQ2Packet* app = packet2->serialize();
  9686. if (sep->IsSet(2)) {
  9687. int16 offset = atoi(sep->arg[1]);
  9688. int16 offset2 = 0;
  9689. int32 value1 = 0;
  9690. if (sep->IsSet(3)) {
  9691. offset2 = atoi(sep->arg[2]);
  9692. value1 = atol(sep->arg[3]);
  9693. }
  9694. else
  9695. value1 = atol(sep->arg[2]);
  9696. int16 offset3 = 0;
  9697. int16 offset4 = 0;
  9698. int32 value2 = 0;
  9699. if (sep->IsSet(6)) {
  9700. offset3 = atoi(sep->arg[4]);
  9701. offset4 = atoi(sep->arg[5]);
  9702. value2 = atol(sep->arg[6]);
  9703. }
  9704. offset--;
  9705. if (offset2 > 0 && offset2 >= offset) {
  9706. offset2--;
  9707. uchar* ptr2 = app->pBuffer;
  9708. ptr2 += offset;
  9709. for (int i = offset; i <= offset2; i++) {
  9710. if (value1 > 0xFFFF) {
  9711. memcpy(ptr2, (uchar*)&value1, 4);
  9712. i += 3;
  9713. ptr2 += 3;
  9714. }
  9715. else if (value1 > 0xFF) {
  9716. memcpy(ptr2, (uchar*)&value1, 2);
  9717. i++;
  9718. ptr2++;
  9719. }
  9720. else
  9721. memcpy(ptr2, (uchar*)&value1, 1);
  9722. ptr2++;
  9723. }
  9724. }
  9725. if (offset4 > 0 && offset4 >= offset3) {
  9726. offset3--;
  9727. offset4--;
  9728. uchar* ptr2 = app->pBuffer;
  9729. ptr2 += offset3;
  9730. for (int i = offset3; i <= offset4; i++) {
  9731. if (value2 > 0xFFFF) {
  9732. memcpy(ptr2, (uchar*)&value2, 4);
  9733. i += 3;
  9734. ptr2 += 3;
  9735. }
  9736. else if (value2 > 0xFF) {
  9737. memcpy(ptr2, (uchar*)&value2, 2);
  9738. i++;
  9739. ptr2++;
  9740. }
  9741. else
  9742. memcpy(ptr2, (uchar*)&value2, 1);
  9743. ptr2++;
  9744. }
  9745. }
  9746. }
  9747. DumpPacket(app);
  9748. client->QueuePacket(app);
  9749. safe_delete(packet2);
  9750. }
  9751. }
  9752. else if (atoi(sep->arg[0]) == 21) {
  9753. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9754. if (packet2) {
  9755. packet2->setDataByName("unknown0", 255);
  9756. packet2->setDataByName("reward", "New Quest");
  9757. packet2->setDataByName("title", "Title");
  9758. packet2->setDataByName("description", "description");
  9759. packet2->setDataByName("quest_difficulty", 3);
  9760. packet2->setDataByName("unknown1", 5);
  9761. packet2->setDataByName("level", 3);
  9762. packet2->setDataByName("coin", 150);
  9763. packet2->setDataByName("status_points", 5);
  9764. packet2->setDataByName("exp_bonus", 10);
  9765. packet2->setArrayLengthByName("num_rewards", 1);
  9766. Item* item = new Item(master_item_list.GetItem(36212));
  9767. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9768. item->stack_count = 20;
  9769. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9770. safe_delete(item);
  9771. char accept[35] = { 0 };
  9772. char decline[35] = { 0 };
  9773. sprintf(accept, "q_accept_pending_quest %u", 0);
  9774. sprintf(decline, "q_deny_pending_quest %u", 0);
  9775. packet2->setDataByName("accept_command", accept);
  9776. packet2->setDataByName("decline_command", decline);
  9777. EQ2Packet* app = packet2->serialize();
  9778. if (sep->IsSet(2)) {
  9779. int16 offset = atoi(sep->arg[1]);
  9780. uchar* ptr2 = app->pBuffer;
  9781. ptr2 += offset;
  9782. if (sep->IsNumber(2)) {
  9783. int32 value1 = atol(sep->arg[2]);
  9784. if (value1 > 0xFFFF)
  9785. memcpy(ptr2, (uchar*)&value1, 4);
  9786. else if (value1 > 0xFF)
  9787. memcpy(ptr2, (uchar*)&value1, 2);
  9788. else
  9789. memcpy(ptr2, (uchar*)&value1, 1);
  9790. }
  9791. DumpPacket(app);
  9792. client->QueuePacket(app);
  9793. safe_delete(packet2);
  9794. }
  9795. }
  9796. }
  9797. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9798. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9799. if (packet2) {
  9800. packet2->setDataByName("unknown0", 255);
  9801. packet2->setDataByName("reward", "New Quest");
  9802. packet2->setDataByName("title", "Title");
  9803. packet2->setDataByName("description", "description");
  9804. packet2->setDataByName("quest_difficulty", 3);
  9805. packet2->setDataByName("unknown1", 5);
  9806. packet2->setDataByName("level", 3);
  9807. packet2->setDataByName("coin", 150);
  9808. packet2->setDataByName("status_points", 5);
  9809. packet2->setDataByName("exp_bonus", 10);
  9810. packet2->setArrayLengthByName("num_rewards", 1);
  9811. Item* item = new Item(master_item_list.GetItem(36212));
  9812. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9813. item->stack_count = 20;
  9814. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9815. safe_delete(item);
  9816. char accept[35] = { 0 };
  9817. char decline[35] = { 0 };
  9818. sprintf(accept, "q_accept_pending_quest %u", 0);
  9819. sprintf(decline, "q_deny_pending_quest %u", 0);
  9820. packet2->setDataByName("accept_command", accept);
  9821. packet2->setDataByName("decline_command", decline);
  9822. EQ2Packet* app = packet2->serialize();
  9823. if (sep->IsSet(2)) {
  9824. int16 offset = atoi(sep->arg[1]);
  9825. uchar* ptr2 = app->pBuffer;
  9826. ptr2 += offset;
  9827. if (sep->IsNumber(2)) {
  9828. int32 value1 = atol(sep->arg[2]);
  9829. if (value1 > 0xFFFF)
  9830. memcpy(ptr2, (uchar*)&value1, 4);
  9831. else if (value1 > 0xFF)
  9832. memcpy(ptr2, (uchar*)&value1, 2);
  9833. else
  9834. memcpy(ptr2, (uchar*)&value1, 1);
  9835. }
  9836. else {
  9837. int8 len = strlen(sep->arg[2]);
  9838. memcpy(ptr2, (uchar*)&len, 1);
  9839. ptr2 += 1;
  9840. memcpy(ptr2, sep->arg[2], len);
  9841. }
  9842. }
  9843. DumpPacket(app);
  9844. client->QueuePacket(app);
  9845. safe_delete(packet2);
  9846. }
  9847. }
  9848. else if (atoi(sep->arg[0]) == 23) {
  9849. if (client->GetPlayer()->GetTarget()) {
  9850. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9851. if (packet2) {
  9852. Spawn* target = client->GetPlayer()->GetTarget();
  9853. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9854. Item* item = new Item(master_item_list.GetItem(12565));
  9855. int8 i = 0;
  9856. packet2->setArrayLengthByName("num_items", 1);
  9857. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9858. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9859. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9860. packet2->setArrayDataByName("icon", item->details.icon, i);
  9861. int8 tmp_level = 0;
  9862. if (item->generic_info.adventure_default_level > 0)
  9863. tmp_level = item->generic_info.adventure_default_level;
  9864. else
  9865. tmp_level = item->generic_info.tradeskill_default_level;
  9866. packet2->setArrayDataByName("level", tmp_level, i);
  9867. packet2->setArrayDataByName("tier", item->details.tier, i);
  9868. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9869. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9870. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9871. item_difficulty = ARROW_COLOR_WHITE;
  9872. item_difficulty -= 6;
  9873. if (item_difficulty < 0)
  9874. item_difficulty *= -1;
  9875. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9876. packet2->setArrayDataByName("quantity", 2, i);
  9877. packet2->setArrayDataByName("unknown5", 255, i);
  9878. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9879. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9880. packet2->setDataByName("type", 2);
  9881. EQ2Packet* app = packet2->serialize();
  9882. if (sep->IsSet(2)) {
  9883. int16 offset = atoi(sep->arg[1]);
  9884. uchar* ptr2 = app->pBuffer;
  9885. ptr2 += offset;
  9886. if (sep->IsNumber(2)) {
  9887. int32 value1 = atol(sep->arg[2]);
  9888. if (value1 > 0xFFFF)
  9889. memcpy(ptr2, (uchar*)&value1, 4);
  9890. else if (value1 > 0xFF)
  9891. memcpy(ptr2, (uchar*)&value1, 2);
  9892. else
  9893. memcpy(ptr2, (uchar*)&value1, 1);
  9894. }
  9895. else {
  9896. int8 len = strlen(sep->arg[2]);
  9897. memcpy(ptr2, (uchar*)&len, 1);
  9898. ptr2 += 1;
  9899. memcpy(ptr2, sep->arg[2], len);
  9900. }
  9901. }
  9902. DumpPacket(app);
  9903. client->QueuePacket(app);
  9904. safe_delete(packet2);
  9905. }
  9906. }
  9907. }
  9908. else if (atoi(sep->arg[0]) == 24) {
  9909. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  9910. if (packet2) {
  9911. if (sep->IsSet(2)) {
  9912. packet2->setDataByName("event_name", sep->arg[1]);
  9913. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  9914. EQ2Packet* app = packet2->serialize();
  9915. DumpPacket(app);
  9916. client->QueuePacket(app);
  9917. safe_delete(packet2);
  9918. }
  9919. }
  9920. }
  9921. else if (atoi(sep->arg[0]) == 25) {
  9922. if (sep->IsSet(1)) {
  9923. Widget* new_spawn = new Widget();
  9924. int32 id = atoul(sep->arg[1]);
  9925. new_spawn->SetWidgetID(id);
  9926. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9927. client->QueuePacket(ret);
  9928. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  9929. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  9930. if (packet2) {
  9931. packet2->setDataByName("spawn_index", index);
  9932. packet2->setDataByName("delete", 1);
  9933. EQ2Packet* app = packet2->serialize();
  9934. client->QueuePacket(app);
  9935. safe_delete(packet2);
  9936. }
  9937. }
  9938. }
  9939. else if (atoi(sep->arg[0]) == 26) {
  9940. if (sep->IsSet(4)) {
  9941. Widget* new_spawn = new Widget();
  9942. int32 id = atoul(sep->arg[1]);
  9943. new_spawn->SetWidgetID(id);
  9944. float x = atof(sep->arg[2]);
  9945. float y = atof(sep->arg[3]);
  9946. float z = atof(sep->arg[4]);
  9947. new_spawn->SetLocation(client->GetPlayer()->GetLocation());
  9948. new_spawn->SetWidgetX(x);
  9949. new_spawn->SetWidgetY(y);
  9950. new_spawn->SetWidgetZ(z);
  9951. new_spawn->SetX(x);
  9952. new_spawn->SetY(y);
  9953. new_spawn->SetZ(z);
  9954. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9955. client->QueuePacket(ret);
  9956. }
  9957. }
  9958. else if (atoi(sep->arg[0]) == 27) {
  9959. Spawn* target = client->GetPlayer()->GetTarget();
  9960. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  9961. if (packet2 && target && sep->IsSet(4)) {
  9962. client->GetPlayer()->GetZone()->SendDamagePacket(client->GetPlayer(), target, atoul(sep->arg[1]), atoul(sep->arg[2]), atoul(sep->arg[3]), atoul(sep->arg[4]), sep->arg[5] != nullptr ? sep->arg[5] : "");
  9963. }
  9964. }
  9965. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  9966. World::newValue = strtoull(sep->arg[1], NULL, 0);
  9967. }
  9968. else if (atoi(sep->arg[0]) == 29 && sep->IsNumber(1)) {
  9969. PacketStruct* packet = configReader.getStruct("WS_HearCastSpell", client->GetVersion());
  9970. if (packet) {
  9971. int32 caster_id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  9972. int32 target_id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  9973. packet->setDataByName("spawn_id", caster_id);
  9974. packet->setArrayLengthByName("num_targets", 1);
  9975. packet->setArrayDataByName("target", target_id);
  9976. packet->setDataByName("num_targets", 1);
  9977. packet->setDataByName("spell_visual", strtoull(sep->arg[1], NULL, 0)); //result
  9978. packet->setDataByName("cast_time", sep->IsNumber(2) ? strtof(sep->arg[2], NULL)*.01f : 2500); //delay
  9979. packet->setDataByName("spell_id", 1);
  9980. packet->setDataByName("spell_level", 1);
  9981. packet->setDataByName("spell_tier", 1);
  9982. EQ2Packet* outapp = packet->serialize();
  9983. DumpPacket(outapp);
  9984. client->QueuePacket(outapp);
  9985. safe_delete(packet);
  9986. }
  9987. }
  9988. else if (atoi(sep->arg[0]) == 30) {
  9989. PacketStruct* packet = configReader.getStruct("WS_UpdateSkillBook", client->GetVersion());
  9990. if (packet) {
  9991. packet->setDataByName("unknown", World::newValue);
  9992. EQ2Packet* outapp = packet->serialize();
  9993. DumpPacket(outapp);
  9994. client->QueuePacket(outapp);
  9995. safe_delete(packet);
  9996. }
  9997. }
  9998. else if (atoi(sep->arg[0]) == 31) {
  9999. client->SendRecipeList();
  10000. }
  10001. else if (atoi(sep->arg[0]) == 32 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10002. if(client->GetVersion() <= 546) {
  10003. int32 param = atoul(sep->arg[1]);
  10004. int32 paramvalue = atoul(sep->arg[2]);
  10005. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param %u param value %u", param, paramvalue);
  10006. ClientPacketFunctions::SendServerControlFlagsClassic(client, param, paramvalue);
  10007. }
  10008. else if(sep->IsNumber(3)) {
  10009. int8 param1 = atoul(sep->arg[1]);
  10010. int8 param2 = atoul(sep->arg[2]);
  10011. int8 paramval = atoul(sep->arg[3]);
  10012. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param1 %u param2 %u param value %u", param1, param2, paramval);
  10013. ClientPacketFunctions::SendServerControlFlags(client, param1, param2, paramval);
  10014. }
  10015. }
  10016. }
  10017. else {
  10018. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  10019. if (packet2) {
  10020. packet2->setSubstructDataByName("info_header", "show_name", 1);
  10021. packet2->setSubstructDataByName("info_header", "unknown", 7);
  10022. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  10023. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  10024. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  10025. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  10026. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  10027. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  10028. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  10029. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  10030. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  10031. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  10032. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  10033. packet2->setSubstructDataByName("info_header", "packettype", 3);
  10034. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  10035. packet2->setSubstructDataByName("spell_info", "level", 19);
  10036. packet2->setSubstructDataByName("spell_info", "tier", 1);
  10037. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  10038. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  10039. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  10040. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  10041. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  10042. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  10043. packet2->setSubstructDataByName("spell_info", "recast", 280);
  10044. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  10045. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  10046. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  10047. packet2->setSubstructDataByName("spell_info", "quality", 3);
  10048. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  10049. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  10050. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  10051. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  10052. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  10053. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  10054. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  10055. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  10056. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  10057. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  10058. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  10059. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  10060. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  10061. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  10062. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  10063. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  10064. packet2->setArrayDataByName("reagent", "Alcohol");
  10065. packet2->setArrayDataByName("consumed", "123");
  10066. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  10067. packet2->setSubstructDataByName("spell_info", "id", 8308);
  10068. packet2->setSubstructDataByName("spell_info", "icon", 303);
  10069. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  10070. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  10071. packet2->setSubstructDataByName("spell_info", "type", 2);
  10072. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  10073. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  10074. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  10075. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  10076. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  10077. EQ2Packet* outapp = packet2->serialize();
  10078. DumpPacket(outapp);
  10079. client->QueuePacket(outapp);
  10080. safe_delete(packet2);
  10081. }
  10082. }
  10083. return;
  10084. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  10085. if (!p) return;
  10086. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10087. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  10088. //}
  10089. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10090. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  10091. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  10092. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  10093. if (packet) {
  10094. client->QueuePacket(packet->serialize());
  10095. safe_delete(packet);
  10096. }
  10097. }*/
  10098. /*if (client->GetCurrentZone()->Grid != nullptr) {
  10099. int32 numFaces = 0;
  10100. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  10101. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  10102. map<int32, vector<Face*> >::iterator itr;
  10103. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  10104. numFaces += (*itr).second.size();
  10105. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  10106. }*/
  10107. //uchar blah[] = {
  10108. // 1208 - OP_EQUpdateStoreCmd
  10109. // /*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
  10110. // /*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
  10111. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  10112. // /*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
  10113. /*};
  10114. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10115. int8 val = 0;
  10116. int16 pos = 0;
  10117. int idx = 0;
  10118. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  10119. pos = atoi(sep2->arg[idx]);
  10120. val = atoi(sep2->arg[idx+1]);
  10121. memset(blah+pos, val, 1);
  10122. idx+=2;
  10123. }
  10124. DumpPacket(blah, sizeof(blah));
  10125. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  10126. if (client->GetPlayer()->GetTarget()) {
  10127. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  10128. if (packet) {
  10129. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10130. packet->setDataByName("size", 0);
  10131. packet->setDataByName("unknown2", 0);
  10132. EQ2Packet* app = packet->serialize();
  10133. client->QueuePacket(app);
  10134. safe_delete(packet);
  10135. }
  10136. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  10137. if (set_pov) {
  10138. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10139. EQ2Packet* app_pov = set_pov->serialize();
  10140. client->QueuePacket(app_pov);
  10141. safe_delete(set_pov);
  10142. }
  10143. }
  10144. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10145. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  10146. if (packet) {
  10147. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  10148. packet->setDataByName("Type", atoi(sep2->arg[0]));
  10149. else
  10150. packet->setDataByName("Type", 2);
  10151. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  10152. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  10153. else
  10154. packet->setDataByName("race_id", 0);
  10155. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  10156. packet->setDataByName("gender", atoi(sep2->arg[2]));
  10157. else
  10158. packet->setDataByName("gender", 2);
  10159. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  10160. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  10161. else
  10162. packet->setDataByName("unknown", 0, 0);
  10163. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  10164. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  10165. else
  10166. packet->setDataByName("unknown", 0, 1);
  10167. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  10168. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  10169. else
  10170. packet->setDataByName("unknown", 0, 2);
  10171. client->QueuePacket(packet->serialize());
  10172. }
  10173. safe_delete(packet);
  10174. safe_delete(sep2);
  10175. }
  10176. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  10177. const char *channel_name;
  10178. if (sep == NULL || !sep->IsSet(0)) {
  10179. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  10180. PrintSep(sep);
  10181. return;
  10182. }
  10183. channel_name = sep->arg[0];
  10184. if (!chat.IsInChannel(client, channel_name))
  10185. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  10186. else if (!chat.LeaveChannel(client, channel_name))
  10187. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  10188. }
  10189. /*
  10190. Function:
  10191. Purpose :
  10192. Params :
  10193. Dev :
  10194. Example :
  10195. */
  10196. void Commands::Command_WeaponStats(Client* client)
  10197. {
  10198. Player* player = client->GetPlayer();
  10199. Spawn* target = player->GetTarget();
  10200. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10201. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10202. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10203. const char* charName = player->GetName();
  10204. if(target && target->IsEntity()) {
  10205. primary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10206. secondary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10207. ranged = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10208. charName = target->GetName();
  10209. }
  10210. else {
  10211. target = nullptr;
  10212. }
  10213. client->Message(0, "WeaponStats for %s", charName);
  10214. client->SimpleMessage(0, "Primary:");
  10215. if (primary) {
  10216. client->Message(0, "Name: %s", primary->name.c_str());
  10217. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  10218. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10219. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10220. client->Message(0, "Actual Delay: %u", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay());
  10221. client->Message(0, "Proc Percent: %d%%", 0);
  10222. client->Message(0, "Procs Per Minute: %d", 0);
  10223. }
  10224. else {
  10225. client->SimpleMessage(0, "Name: fist");
  10226. client->Message(0, "Base Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10227. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10228. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10229. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10230. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay() * 0.1);
  10231. client->Message(0, "Proc Percent: %d%%", 0);
  10232. client->Message(0, "Procs Per Minute: %d", 0);
  10233. }
  10234. client->SimpleMessage(0, " ");
  10235. client->SimpleMessage(0, " ");
  10236. if (secondary) {
  10237. client->SimpleMessage(0, "Secondary:");
  10238. client->Message(0, "Name: %s", secondary->name.c_str());
  10239. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  10240. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetSecondaryWeaponMinDamage() : player->GetSecondaryWeaponMinDamage(),
  10241. target ? ((Entity*)target)->GetSecondaryWeaponMaxDamage() : player->GetSecondaryWeaponMaxDamage());
  10242. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetSecondaryWeaponDelay() : player->GetSecondaryWeaponDelay() * 0.1);
  10243. client->Message(0, "Proc Percent: %d%%", 0);
  10244. client->Message(0, "Procs Per Minute: %d", 0);
  10245. client->SimpleMessage(0, " ");
  10246. client->SimpleMessage(0, " ");
  10247. }
  10248. client->SimpleMessage(0, "Ranged:");
  10249. if (ranged) {
  10250. client->Message(0, "Name: %s", ranged->name.c_str());
  10251. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  10252. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetRangedWeaponMinDamage() : player->GetRangedWeaponMinDamage(),
  10253. target ? ((Entity*)target)->GetRangedWeaponMaxDamage() : player->GetRangedWeaponMaxDamage());
  10254. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetRangeWeaponDelay() : player->GetRangeWeaponDelay() * 0.1);
  10255. client->Message(0, "Proc Percent: %d%%", 0);
  10256. client->Message(0, "Procs Per Minute: %d", 0);
  10257. }
  10258. else
  10259. client->SimpleMessage(0, "None");
  10260. }
  10261. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  10262. const char *channel_name;
  10263. if (sep == NULL || !sep->IsSet(0)) {
  10264. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  10265. return;
  10266. }
  10267. channel_name = sep->arg[0];
  10268. if (!chat.ChannelExists(channel_name))
  10269. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  10270. else
  10271. chat.SendChannelUserList(client, channel_name);
  10272. }
  10273. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  10274. {
  10275. ZoneServer* zone = 0;
  10276. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  10277. if (zone_id > 0)
  10278. {
  10279. zone = zone_list.Get(zone_id, false, false, false);
  10280. if (zone)
  10281. {
  10282. zone->SetSafeX(client->GetPlayer()->GetX());
  10283. zone->SetSafeY(client->GetPlayer()->GetY());
  10284. zone->SetSafeZ(client->GetPlayer()->GetZ());
  10285. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  10286. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  10287. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  10288. else
  10289. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  10290. }
  10291. }
  10292. }
  10293. /*
  10294. Function:
  10295. Purpose :
  10296. Params :
  10297. Dev :
  10298. Example :
  10299. */
  10300. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  10301. {
  10302. ZoneInfo* zone_info = new ZoneInfo;
  10303. if (sep && sep->arg[0])
  10304. {
  10305. if (sep->IsNumber(0))
  10306. zone_info->id = atoi(sep->arg[0]);
  10307. else
  10308. zone_info->id = database.GetZoneID(sep->arg[0]);
  10309. if (zone_info->id > 0)
  10310. {
  10311. database.LoadZoneInfo(zone_info);
  10312. 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);
  10313. 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);
  10314. 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);
  10315. 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);
  10316. 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);
  10317. 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);
  10318. 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);
  10319. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  10320. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  10321. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  10322. }
  10323. else
  10324. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10325. }
  10326. else
  10327. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  10328. safe_delete(zone_info);
  10329. }
  10330. /*
  10331. Function:
  10332. Purpose :
  10333. Params :
  10334. Dev :
  10335. Example :
  10336. */
  10337. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  10338. {
  10339. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  10340. {
  10341. ZoneServer* zone = 0;
  10342. int32 zone_id = 0;
  10343. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  10344. {
  10345. zone_id = atoi(sep->arg[0]);
  10346. zone = zone_list.Get(atoi(sep->arg[0]), false, false, false);
  10347. }
  10348. else
  10349. {
  10350. zone_id = database.GetZoneID(sep->arg[0]);
  10351. if (zone_id > 0)
  10352. zone = zone_list.Get(sep->arg[0], false, false, false);
  10353. }
  10354. if (zone_id > 0)
  10355. {
  10356. if (zone_set_values.count(string(sep->arg[1])) > 0)
  10357. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  10358. else
  10359. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  10360. }
  10361. else
  10362. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10363. }
  10364. else
  10365. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  10366. }
  10367. void Commands::Command_Rain(Client* client, Seperator* sep) {
  10368. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10369. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  10370. return;
  10371. }
  10372. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  10373. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  10374. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  10375. }
  10376. void Commands::Command_Wind(Client* client, Seperator* sep) {
  10377. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10378. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  10379. return;
  10380. }
  10381. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  10382. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  10383. }
  10384. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  10385. Spawn* spawn = client->GetPlayer()->GetTarget();
  10386. if(client->GetVersion() <= 546) {
  10387. sell = false; // doesn't support in the same way as AoM just open the normal buy/sell window
  10388. }
  10389. if(spawn) {
  10390. client->SetMerchantTransaction(spawn);
  10391. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  10392. client->SendHailCommand(spawn);
  10393. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  10394. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  10395. client->SendBuyMerchantList(sell);
  10396. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  10397. client->SendSellMerchantList(sell);
  10398. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  10399. client->SendBuyBackList(sell);
  10400. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10401. if (packet) {
  10402. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  10403. packet->setDataByName("type", 16);
  10404. EQ2Packet* outapp = packet->serialize();
  10405. if (outapp)
  10406. client->QueuePacket(outapp);
  10407. safe_delete(packet);
  10408. }
  10409. }
  10410. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  10411. client->SendRepairList();
  10412. }
  10413. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  10414. }
  10415. void Commands::Command_Weather(Client* client, Seperator* sep)
  10416. {
  10417. //PrintSep(sep, "Weather");
  10418. if( sep && sep->arg[0] )
  10419. {
  10420. ZoneServer* zsZone = client->GetCurrentZone();
  10421. const char* value = sep->arg[0];
  10422. // process single-param commands first
  10423. if( strncasecmp(value, "details", strlen(value)) == 0 )
  10424. {
  10425. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  10426. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  10427. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  10428. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  10429. }
  10430. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  10431. {
  10432. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10433. zsZone->ProcessWeather();
  10434. }
  10435. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  10436. {
  10437. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  10438. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  10439. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  10440. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  10441. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  10442. zsZone->SetWeatherPattern(1);
  10443. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  10444. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  10445. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  10446. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10447. zsZone->ProcessWeather();
  10448. }
  10449. // process commands with params
  10450. if( sep->arg[1] )
  10451. {
  10452. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  10453. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  10454. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  10455. zsZone->SetWeatherType(atoi(sep->arg[1]));
  10456. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  10457. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  10458. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  10459. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  10460. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  10461. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  10462. }
  10463. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  10464. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  10465. zsZone->SetRain(zsZone->GetCurrentWeather());
  10466. }
  10467. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  10468. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  10469. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  10470. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  10471. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10472. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  10473. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10474. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  10475. }
  10476. }
  10477. else
  10478. {
  10479. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  10480. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  10481. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  10482. return;
  10483. }
  10484. }
  10485. void Commands::Command_Select(Client* client, Seperator* sep) {
  10486. if (sep && sep->arg[1]) {
  10487. Spawn* spawn = client->GetPlayer()->GetTarget();
  10488. if (spawn && strlen(sep->arg[1]) > 0)
  10489. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  10490. }
  10491. }
  10492. /*
  10493. Function: Command_ConsumeFood()
  10494. Purpose : Consume Food/Drink and apply mods
  10495. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  10496. Dev : Zcoretri
  10497. Example : /consume_food 22
  10498. */
  10499. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  10500. if (sep && sep->arg[0] && sep->IsNumber(0))
  10501. {
  10502. Player* player = client->GetPlayer();
  10503. int8 slot = atoi(sep->arg[0]);
  10504. if (client->GetVersion() <= 283) {
  10505. slot += 4;
  10506. }
  10507. else if (client->GetVersion() <= 546) {
  10508. slot += 2;
  10509. }
  10510. Item* item = player->GetEquipmentList()->GetItem(slot);
  10511. if(client->CheckConsumptionAllowed(slot)) {
  10512. client->ConsumeFoodDrink(item, slot);
  10513. }
  10514. }
  10515. }
  10516. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  10517. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10518. if (atoi(sep->arg[0]) == 1) {
  10519. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  10520. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  10521. client->GetPlayer()->SetCharSheetChanged(true);
  10522. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  10523. }
  10524. else {
  10525. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  10526. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  10527. client->GetPlayer()->SetCharSheetChanged(true);
  10528. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  10529. }
  10530. }
  10531. else
  10532. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  10533. }
  10534. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  10535. {
  10536. if(sep)
  10537. {
  10538. string data;
  10539. if(sep->arg[0]){
  10540. data = string(sep->arg[0]);
  10541. }
  10542. for(int i=1;i<sep->GetMaxArgNum();i++){
  10543. if(sep->arg[i])
  10544. data.append(" ").append(sep->arg[i]);
  10545. }
  10546. const char* target_name = 0;
  10547. int32 spawn_id = 0;
  10548. if(client->GetPlayer()->GetTarget())
  10549. {
  10550. target_name = client->GetPlayer()->GetTarget()->GetName();
  10551. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10552. }
  10553. else
  10554. target_name = "N/A";
  10555. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  10556. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  10557. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  10558. else
  10559. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  10560. }
  10561. }
  10562. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  10563. PrintSep(sep, "Command_Attune_Inv");
  10564. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10565. // Get the item index from the first parameter
  10566. int16 index = atoi(sep->arg[0]);
  10567. // Check to see if this is a valid item index for the player, if not exit out of the function
  10568. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  10569. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  10570. return;
  10571. }
  10572. // Get the item
  10573. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  10574. if(item) {
  10575. // Valid item lets check to make sure this item is attunable, if not return out
  10576. if (!item->CheckFlag(ATTUNEABLE)) {
  10577. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  10578. return;
  10579. }
  10580. // Remove the attunable flag
  10581. item->generic_info.item_flags -= ATTUNEABLE;
  10582. // Set the attuned flag
  10583. item->generic_info.item_flags += ATTUNED;
  10584. // Flag this item for saving
  10585. item->save_needed = true;
  10586. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  10587. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  10588. EQ2Packet* outapp = 0;
  10589. for (int32 i=0;i<packets.size();i++) {
  10590. outapp = packets[i];
  10591. if(outapp)
  10592. client->QueuePacket(outapp);
  10593. }
  10594. }
  10595. }
  10596. }
  10597. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  10598. PrintSep(sep, "Command_Reset_Zone_Timer");
  10599. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10600. int32 db_id = atoul(sep->arg[0]);
  10601. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  10602. if (data) {
  10603. // TODO: add a check to timers to ensure it can be reset
  10604. // Delete the character from the instance
  10605. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  10606. data->instance_id = 0;
  10607. // Update the success time and set to 0 so the player can enter it again
  10608. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  10609. data->last_success_timestamp = 0;
  10610. }
  10611. }*/
  10612. }
  10613. void Commands::Command_Player(Client* client, Seperator* sep) {
  10614. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  10615. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  10616. }
  10617. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  10618. // /player coins add 10
  10619. // /player coins add plat 10
  10620. Player* player = client->GetPlayer();
  10621. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  10622. player = (Player*)player->GetTarget();
  10623. if (sep && sep->arg[0] && sep->arg[1]) {
  10624. const char* action = sep->arg[0];
  10625. int64 value = 0;
  10626. if (strncasecmp(action, "add", strlen(action)) == 0) {
  10627. if (sep->IsNumber(1)) {
  10628. value = atoi64(sep->arg[1]);
  10629. player->AddCoins(value);
  10630. if (client->GetPlayer() == player)
  10631. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10632. else {
  10633. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10634. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10635. }
  10636. return;
  10637. }
  10638. else if (sep->arg[2] && sep->IsNumber(2)) {
  10639. const char* type = sep->arg[1];
  10640. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  10641. value = atoi64(sep->arg[2]);
  10642. }
  10643. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  10644. value = atoi64(sep->arg[2]) * 100;
  10645. }
  10646. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  10647. value = atoi64(sep->arg[2]) * 10000;
  10648. }
  10649. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  10650. value = atoi64(sep->arg[2]) * 1000000;
  10651. }
  10652. player->AddCoins(value);
  10653. if (client->GetPlayer() == player)
  10654. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10655. else {
  10656. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10657. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10658. }
  10659. return;
  10660. }
  10661. }
  10662. }
  10663. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  10664. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  10665. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  10666. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  10667. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  10668. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  10669. }
  10670. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  10671. PrintSep(sep, "ACHIEVEMENT_ADD");
  10672. if (sep && sep->IsSet(0)) {
  10673. int32 spell_id = atoul(sep->arg[1]);
  10674. int8 spell_tier = 0;
  10675. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10676. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10677. // addspellbookentry here
  10678. if (spell_tier >= data->maxRank) {
  10679. return;
  10680. }
  10681. if (!spell_tier) {
  10682. spell_tier = 1;
  10683. }
  10684. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10685. {
  10686. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10687. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10688. client->GetPlayer()->UnlockSpell(spell);
  10689. client->SendSpellUpdate(spell);
  10690. }
  10691. else
  10692. {
  10693. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  10694. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10695. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10696. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10697. client->GetPlayer()->UnlockSpell(spell);
  10698. client->SendSpellUpdate(spell);
  10699. }
  10700. // cast spell here
  10701. if (!spell_tier)
  10702. spell_tier = 1;
  10703. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10704. if (spell) {
  10705. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10706. }
  10707. }
  10708. else {
  10709. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10710. }
  10711. master_aa_list.DisplayAA(client, 0, 0);
  10712. }
  10713. void Commands::Command_Editor(Client* client, Seperator* sep) {
  10714. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  10715. if (packet) {
  10716. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  10717. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  10718. char command[255];
  10719. url = "browser " + url;
  10720. int32 spawn_id = 0;
  10721. int32 zone_id = 0;
  10722. string type;
  10723. if (client->GetCurrentZone())
  10724. zone_id = client->GetCurrentZone()->GetZoneID();
  10725. if (client->GetPlayer()->GetTarget()) {
  10726. Spawn* target = client->GetPlayer()->GetTarget();
  10727. if (target->IsWidget())
  10728. type = "widgets";
  10729. else if (target->IsSign())
  10730. type = "signs";
  10731. else if (target->IsObject())
  10732. type = "objects";
  10733. else if (target->IsNPC())
  10734. type = "npcs";
  10735. else if (target->IsGroundSpawn())
  10736. type = "ground";
  10737. else
  10738. type = "spawn";
  10739. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10740. }
  10741. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  10742. packet->setDataByName("accept_command", command);
  10743. }
  10744. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  10745. char command[255];
  10746. url = "browser " + url;
  10747. if (client->GetPlayer()->GetTarget())
  10748. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  10749. packet->setDataByName("accept_command", command);
  10750. }
  10751. else {
  10752. string command = "browser " + url;
  10753. packet->setDataByName("accept_command", command.c_str());
  10754. }
  10755. packet->setDataByName("text", "Open the web editor?");
  10756. packet->setDataByName("accept_text", "Open");
  10757. packet->setDataByName("cancel_text", "Cancel");
  10758. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  10759. packet->setDataByName("unknown2", 50);
  10760. packet->setDataByName("unknown4", 1);
  10761. client->QueuePacket(packet->serialize());
  10762. safe_delete(packet);
  10763. }
  10764. }
  10765. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  10766. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10767. return;
  10768. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10769. if(client->GetCurrentRez()->active)
  10770. client->AcceptResurrection();
  10771. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10772. }
  10773. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  10774. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10775. return;
  10776. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10777. if(client->GetCurrentRez()->active)
  10778. client->GetCurrentRez()->should_delete = true;
  10779. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10780. }
  10781. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  10782. PrintSep(sep, "Switch_AA_Profile");
  10783. if (sep && sep->IsSet(0)) {
  10784. string type = sep->arg[0];
  10785. int8 newtemplate = atoul(sep->arg[1]);
  10786. master_aa_list.DisplayAA(client, newtemplate, 1);
  10787. }
  10788. }
  10789. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  10790. PrintSep(sep, "Get_AA_Xml");
  10791. if (sep && sep->IsSet(0)) {
  10792. string tabnum = sep->arg[0];
  10793. string spellid = sep->arg[1];
  10794. }
  10795. }
  10796. void Commands::Add_AA(Client* client, Seperator* sep) {
  10797. PrintSep(sep, "Add_AA");
  10798. if (sep && sep->IsSet(0)) {
  10799. int32 spell_id = atoul(sep->arg[1]);
  10800. int8 spell_tier = 0;
  10801. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10802. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10803. // addspellbookentry here
  10804. if(!data) {
  10805. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  10806. return;
  10807. }
  10808. if (spell_tier >= data->maxRank) {
  10809. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  10810. return;
  10811. }
  10812. if (!spell_tier) {
  10813. spell_tier = 1;
  10814. }
  10815. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10816. {
  10817. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10818. if(spell)
  10819. {
  10820. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10821. client->GetPlayer()->UnlockSpell(spell);
  10822. client->SendSpellUpdate(spell);
  10823. }
  10824. }
  10825. else
  10826. {
  10827. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10828. if(spell)
  10829. {
  10830. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10831. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10832. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10833. client->GetPlayer()->UnlockSpell(spell);
  10834. client->SendSpellUpdate(spell);
  10835. }
  10836. }
  10837. // cast spell here
  10838. if (!spell_tier)
  10839. spell_tier = 1;
  10840. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10841. if (spell) {
  10842. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10843. }
  10844. }
  10845. else {
  10846. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10847. }
  10848. master_aa_list.DisplayAA(client, 0, 0);
  10849. }
  10850. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  10851. PrintSep(sep, "Commit_AA_Profile");
  10852. if (sep && sep->IsSet(0)) {
  10853. }
  10854. }
  10855. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  10856. PrintSep(sep, "Begin_AA_Profile");
  10857. if (sep && sep->IsSet(0)) {
  10858. master_aa_list.DisplayAA(client, 100, 2);
  10859. }
  10860. }
  10861. void Commands::Back_AA(Client* client, Seperator* sep) {
  10862. if (sep && sep->IsSet(0)) {
  10863. PrintSep(sep, "Back_AA");
  10864. }
  10865. }
  10866. void Commands::Remove_AA(Client* client, Seperator* sep) {
  10867. if (sep && sep->IsSet(0)) {
  10868. PrintSep(sep, "Remove_AA");
  10869. }
  10870. }
  10871. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  10872. MasterAAList master_aa_list;
  10873. PrintSep(sep, "Cancel_AA_Profile");
  10874. master_aa_list.DisplayAA(client, 0, 0);
  10875. }
  10876. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  10877. if (sep && sep->IsSet(0)) {
  10878. PrintSep(sep, "Save_AA_Profile");
  10879. }
  10880. }
  10881. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  10882. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  10883. if (!sep->IsNumber(0)) return;
  10884. int32 request_id = atoul(sep->arg[0]);
  10885. if (!sep->IsNumber(1)) return;
  10886. sint32 item_id = atoi(sep->arg[1]);
  10887. if (client->IsCurrentTransmuteID(request_id)) {
  10888. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  10889. }
  10890. else if (client->IsCurrentTransmuteID(item_id)) {
  10891. if (!sep->IsSet(2)) return;
  10892. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  10893. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  10894. }
  10895. }
  10896. }
  10897. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  10898. if(sep)
  10899. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  10900. }
  10901. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  10902. if(sep && sep->arg[0][0] && sep->arg[1][0])
  10903. {
  10904. char* name = sep->arg[0];
  10905. char* zoneName = sep->arg[1];
  10906. char query[256];
  10907. snprintf(query, 256, "UPDATE characters c, zones z set c.x = z.safe_x, c.y = z.safe_y, c.z = z.safe_z, c.heading = z.safe_heading, c.current_zone_id = z.id where c.name = '%s' and z.name='%s'", name, zoneName);
  10908. if (database.RunQuery(query, strnlen(query, 256)))
  10909. {
  10910. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  10911. }
  10912. else
  10913. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  10914. }
  10915. }
  10916. void Commands::Command_Mood(Client* client, Seperator* sep) {
  10917. Player* player = client->GetPlayer();
  10918. if( sep && sep->arg[0] )
  10919. {
  10920. const char* value = sep->arg[0];
  10921. InfoStruct* info = player->GetInfoStruct();
  10922. int32 cid = client->GetCharacterID();
  10923. char* characterName = database.GetCharacterName(cid);
  10924. char tmp[1024]; // our emote string "xyz appears zyx"
  10925. //char properties vals
  10926. char* pname = "mood";
  10927. char* pval; // mood value
  10928. bool pt; //used to verify return from DB.
  10929. //This should never be seen.
  10930. sprintf(tmp, " ");
  10931. if( strncasecmp(value, "angry", strlen(value)) == 0 )
  10932. {
  10933. sprintf(tmp, "%s appears angry", characterName);
  10934. pval = "11852";
  10935. player->SetMoodState(11852, 1);
  10936. info->set_mood(11852);
  10937. pt = database.insertCharacterProperty(client, pname, pval);
  10938. }
  10939. else if( strncasecmp(value, "afraid", strlen(value)) == 0 )
  10940. {
  10941. sprintf(tmp, "%s appears afraid", characterName);
  10942. pval = "11851";
  10943. player->SetMoodState(11851, 1);
  10944. info->set_mood(11851);
  10945. pt = database.insertCharacterProperty(client, pname, pval);
  10946. }
  10947. else if( strncasecmp(value, "happy", strlen(value)) == 0 )
  10948. {
  10949. sprintf(tmp, "%s appears happy", characterName);
  10950. pval = "11854";
  10951. player->SetMoodState(11854, 1);
  10952. info->set_mood(11854);
  10953. pt = database.insertCharacterProperty(client, pname, pval);
  10954. }
  10955. else if( strncasecmp(value, "sad", strlen(value)) == 0 ) {
  10956. sprintf(tmp, "%s appears sad", characterName);
  10957. pval = "11856";
  10958. player->SetMoodState(11856, 1);
  10959. info->set_mood(11856);
  10960. pt = database.insertCharacterProperty(client, pname, pval);
  10961. }
  10962. else if( strncasecmp(value, "tired", strlen(value)) == 0 )
  10963. {
  10964. sprintf(tmp, "%s appears tired", characterName);
  10965. pval = "11857";
  10966. player->SetMoodState(11857, 1);
  10967. info->set_mood(11857);
  10968. pt = database.insertCharacterProperty(client, pname, pval);
  10969. }
  10970. else if( strncasecmp(value, "none", strlen(value)) == 0 )
  10971. {
  10972. //using 11855 mood_idle for none, I assume thats what its for?
  10973. pval = "11855";
  10974. player->SetMoodState(11855, 1);
  10975. info->set_mood(11855);
  10976. pt = database.insertCharacterProperty(client, pname, pval);
  10977. //return since we have nothing left to do. No emote for none.
  10978. return;
  10979. }else{
  10980. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  10981. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  10982. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  10983. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  10984. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  10985. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  10986. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  10987. return;
  10988. }
  10989. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, tmp);
  10990. return;
  10991. }
  10992. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  10993. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  10994. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  10995. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  10996. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  10997. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  10998. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  10999. return;
  11000. }
  11001. /*
  11002. Function: Command_CancelEffect()
  11003. Purpose : Cancels (good) effect spells
  11004. Example : /cancel_effect spell_id - would cancel the spell with the <spell_id> value in spell effects list
  11005. */
  11006. void Commands::Command_CancelEffect(Client* client, Seperator* sep)
  11007. {
  11008. if (sep && sep->arg[0] && sep->IsNumber(0))
  11009. {
  11010. int32 spell_id = atoul(sep->arg[0]);
  11011. SpellEffects* effect = client->GetPlayer()->GetSpellEffect(spell_id);
  11012. if(!effect || effect->spell->spell->GetSpellData()->det_type) {
  11013. return;
  11014. }
  11015. MaintainedEffects* meffect = effect->caster->GetMaintainedSpell(spell_id);
  11016. if (!meffect || !meffect->spell || !meffect->spell->caster || !meffect->spell->caster->GetZone() ||
  11017. !meffect->spell->caster->GetZone()->GetSpellProcess()->DeleteCasterSpell(meffect->spell, "canceled", false, client->GetPlayer()))
  11018. client->Message(CHANNEL_COLOR_RED, "The spell effect could not be cancelled.");
  11019. }
  11020. }
  11021. /*
  11022. Function: Command_CurePlayer()
  11023. Purpose : Identifies spell to cast for cure based on type
  11024. Example : /cureplayer ??
  11025. https://eq2.fandom.com/wiki/Update:58
  11026. New command /cureplayer [playername|group or raid position][trauma|arcane|noxious|elemental|curse] optional [spell|potion]
  11027. Example: /cureplayer g0 noxious spell
  11028. Will attempt to cure yourself of a noxious detriment with only spells and without using potions (even if you have them).
  11029. Example: /cureplayer r4 noxious
  11030. Will attempt to cure the character in raid slot 4 of a noxious detriment using a spell or potion (whichever is available).
  11031. */
  11032. void Commands::Command_CurePlayer(Client* client, Seperator* sep)
  11033. {
  11034. Entity* target = nullptr;
  11035. bool use_spells = true;
  11036. bool use_potions = true;
  11037. if (sep && sep->arg[0] && sep->arg[1]) {
  11038. if(sep->arg[2]) {
  11039. std::string type(sep->arg[2]);
  11040. boost::algorithm::to_lower(type);
  11041. if(type == "potion")
  11042. use_spells = false;
  11043. else if(type == "spell")
  11044. use_potions = false;
  11045. }
  11046. if(strlen(sep->arg[0]) > 1 && isdigit(sep->arg[0][1])) {
  11047. int32 mapped_position = (int32)(sep->arg[0][1]) - 48;
  11048. // TODO: RAID Support ('r' argument)
  11049. if(sep->arg[0][0] == 'g' && !mapped_position) {
  11050. target = (Entity*)client->GetPlayer();
  11051. }
  11052. else {
  11053. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11054. if (gmi && gmi->group_id) {
  11055. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11056. if(group) {
  11057. target = group->GetGroupMemberByPosition(client->GetPlayer(), mapped_position);
  11058. }
  11059. }
  11060. }
  11061. }
  11062. else {
  11063. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11064. if(target_client && target_client->GetPlayer() && target_client->GetPlayer()->GetZone() == client->GetPlayer()->GetZone()) {
  11065. target = (Entity*)target_client->GetPlayer();
  11066. }
  11067. }
  11068. ItemEffectType type = EFFECT_CURE_TYPE_ALL;
  11069. bool successful_spell = false;
  11070. bool successful_potion = false;
  11071. if(target) {
  11072. SpellBookEntry* entry = nullptr;
  11073. std::string str(sep->arg[1]);
  11074. boost::algorithm::to_lower(str);
  11075. if(str == "arcane") {
  11076. type = EFFECT_CURE_TYPE_ARCANE;
  11077. // cure arcane spell missing in DB?
  11078. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()) {
  11079. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()); // cure noxious
  11080. }
  11081. }
  11082. else if(str == "trauma") {
  11083. type = EFFECT_CURE_TYPE_TRAUMA;
  11084. // cure trauma spell missing in DB?
  11085. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()) {
  11086. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()); // cure noxious
  11087. }
  11088. }
  11089. else if(str == "noxious") {
  11090. type = EFFECT_CURE_TYPE_NOXIOUS;
  11091. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()) {
  11092. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()); // cure noxious
  11093. }
  11094. }
  11095. else if(str == "curse") {
  11096. type = EFFECT_CURE_TYPE_CURSE;
  11097. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()) {
  11098. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()); // cure curse
  11099. }
  11100. }
  11101. else if(str == "magic") {
  11102. type = EFFECT_CURE_TYPE_MAGIC;
  11103. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()) {
  11104. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()); // cure magic
  11105. }
  11106. }
  11107. if(use_spells) {
  11108. // check if any of the specific cure types are available, if not then check the base cures
  11109. if(!entry && rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()) {
  11110. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()); // cure
  11111. }
  11112. if(entry && entry->spell_id) {
  11113. Spell* spell = master_spell_list.GetSpell(entry->spell_id, entry->tier);
  11114. target->GetZone()->ProcessSpell(spell, (Entity*)client->GetPlayer(), target, true, false);
  11115. successful_spell = true;
  11116. }
  11117. }
  11118. }
  11119. if(!successful_spell && use_potions && target && type != NO_EFFECT_TYPE) {
  11120. vector<Item*>* potential_items = client->GetItemsByEffectType(type, EFFECT_CURE_TYPE_ALL);
  11121. if (potential_items && potential_items->size() > 0) {
  11122. vector<Item*>::iterator itr;
  11123. for (itr = potential_items->begin(); itr != potential_items->end(); itr++)
  11124. {
  11125. Item* item = *itr;
  11126. if(client->UseItem(item, target)) {
  11127. successful_potion = true;
  11128. break;
  11129. }
  11130. }
  11131. }
  11132. safe_delete(potential_items);
  11133. }
  11134. }
  11135. }
  11136. /*
  11137. Function: Command_ShareQuest()
  11138. Purpose : Share quest with the group
  11139. Example : /share_quest [quest_id]
  11140. */
  11141. void Commands::Command_ShareQuest(Client* client, Seperator* sep)
  11142. {
  11143. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  11144. int32 quest_id = atoul(sep->arg[0]);
  11145. bool hasQuest = client->GetPlayer()->HasAnyQuest(quest_id);
  11146. if(hasQuest) {
  11147. Quest* quest = master_quest_list.GetQuest(quest_id, false);
  11148. if(quest) {
  11149. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11150. if (gmi && gmi->group_id) {
  11151. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11152. if (group) {
  11153. group->ShareQuestWithGroup(client, quest);
  11154. }
  11155. }
  11156. }
  11157. }
  11158. else {
  11159. client->SimpleMessage(CHANNEL_COLOR_RED, "Cannot find quest.");
  11160. }
  11161. }
  11162. }
  11163. /*
  11164. Function: Command_Yell()
  11165. Purpose : Yell to break an encounter
  11166. Example : /yell
  11167. * Uses self target, encounter target or no target
  11168. */
  11169. void Commands::Command_Yell(Client* client, Seperator* sep) {
  11170. Entity* player = (Entity*)client->GetPlayer();
  11171. Spawn* res = nullptr;
  11172. Spawn* prev = nullptr;
  11173. bool cycleAll = false;
  11174. if(player->GetTarget() == player) {
  11175. cycleAll = true; // self target breaks all encounters
  11176. }
  11177. else if(player->GetTarget()) {
  11178. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11179. }
  11180. if(res && !client->GetPlayer()->IsEngagedBySpawnID(res->GetID()))
  11181. return;
  11182. bool alreadyYelled = false;
  11183. do {
  11184. if(!res && player->IsEngagedInEncounter(&res)) { // no target is set, dis-engage top of hated by list
  11185. }
  11186. if(!res || prev == res) {
  11187. return;
  11188. }
  11189. if(res->IsNPC() && ((NPC*)res)->Brain()) {
  11190. if(!alreadyYelled) {
  11191. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You yell for help!");
  11192. string yellMsg = std::string(client->GetPlayer()->GetName()) + " yelled for help!";
  11193. client->GetPlayer()->GetZone()->SimpleMessage(CHANNEL_COLOR_RED, yellMsg.c_str(), client->GetPlayer(), 35.0f, false);
  11194. client->GetPlayer()->GetZone()->SendYellPacket(client->GetPlayer());
  11195. }
  11196. alreadyYelled = true;
  11197. NPC* npc = (NPC*)res;
  11198. npc->Brain()->ClearEncounter();
  11199. npc->SetLockedNoLoot(ENCOUNTER_STATE_BROKEN);
  11200. npc->UpdateEncounterState(ENCOUNTER_STATE_BROKEN);
  11201. }
  11202. prev = res;
  11203. res = nullptr;
  11204. }while(cycleAll);
  11205. if(!player->IsEngagedInEncounter()) {
  11206. if(player->GetInfoStruct()->get_engaged_encounter()) {
  11207. player->GetInfoStruct()->set_engaged_encounter(0);
  11208. player->SetRegenValues((player->GetInfoStruct()->get_effective_level() > 0) ? player->GetInfoStruct()->get_effective_level() : player->GetLevel());
  11209. client->GetPlayer()->SetCharSheetChanged(true);
  11210. player->info_changed = true;
  11211. }
  11212. }
  11213. }