Commands.cpp 391 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include "Commands.h"
  18. #include "../ClientPacketFunctions.h"
  19. #include "../../common/version.h"
  20. #include "../../common/seperator.h"
  21. #include "../../common/servertalk.h"
  22. #include "../WorldDatabase.h"
  23. #include "../World.h"
  24. #include "../../common/ConfigReader.h"
  25. #include "../VisualStates.h"
  26. #include "../../common/debug.h"
  27. #include "../LuaInterface.h"
  28. #include "../Quests.h"
  29. #include "../client.h"
  30. #include "../NPC.h"
  31. #include "../Guilds/Guild.h"
  32. #include "../SpellProcess.h"
  33. #include "../Tradeskills/Tradeskills.h"
  34. #include "../../common/Log.h"
  35. #include "../../common/MiscFunctions.h"
  36. #include "../Languages.h"
  37. #include "../IRC/IRC.h"
  38. #include "../Traits/Traits.h"
  39. #include "../Chat/Chat.h"
  40. #include "../Rules/Rules.h"
  41. #include "../AltAdvancement/AltAdvancement.h"
  42. #include "../RaceTypes/RaceTypes.h"
  43. #include "../classes.h"
  44. #include "../Transmute.h"
  45. #include "../Zone/SPGrid.h"
  46. extern WorldDatabase database;
  47. extern MasterSpellList master_spell_list;
  48. extern MasterTraitList master_trait_list;
  49. extern MasterRecipeList master_recipe_list;
  50. extern MasterRecipeBookList master_recipebook_list;
  51. extern World world;
  52. extern ClientList client_list;
  53. extern ConfigReader configReader;
  54. extern VisualStates visual_states;
  55. extern ZoneList zone_list;
  56. extern LuaInterface* lua_interface;
  57. extern MasterQuestList master_quest_list;
  58. extern MasterCollectionList master_collection_list;
  59. extern MasterSkillList master_skill_list;
  60. extern MasterFactionList master_faction_list;
  61. extern GuildList guild_list;
  62. extern MasterLanguagesList master_languages_list;
  63. extern IRC irc;
  64. extern Chat chat;
  65. extern RuleManager rule_manager;
  66. extern MasterAAList master_aa_list;
  67. extern MasterRaceTypeList race_types_list;
  68. extern Classes classes;
  69. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  70. #if defined(__GNUC__)
  71. #define stricmp strcasecmp
  72. #define strnicmp strncasecmp
  73. #endif
  74. EQ2Packet* RemoteCommands::serialize(){
  75. buffer.clear();
  76. vector<EQ2_RemoteCommandString>::iterator command_list;
  77. buffer.append((char*)&num_commands, sizeof(int16));
  78. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  79. AddDataCommand(&(*command_list));
  80. }
  81. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  82. return app;
  83. }
  84. Commands::Commands(){
  85. remote_commands = new RemoteCommands();
  86. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  87. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  88. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  89. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  90. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  91. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  92. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  93. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  94. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  95. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  96. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  97. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  98. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  99. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  100. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  101. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  102. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  103. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  104. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  105. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  106. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  107. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  108. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  109. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  110. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  111. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  112. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  113. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  114. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  115. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  116. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  117. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  118. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  119. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  120. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  121. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  122. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  123. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  124. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  125. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  126. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  127. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  128. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  129. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  130. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  131. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  132. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  133. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  134. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  135. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  136. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  137. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  138. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  139. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  140. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  141. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  142. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  143. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  144. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  145. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  146. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  147. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  148. 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. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  170. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  171. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  172. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  173. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  174. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  175. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  176. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  177. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  178. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  179. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  180. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  181. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  182. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  183. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  184. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  185. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  186. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  187. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  188. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  189. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  190. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  191. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  192. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  193. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  194. }
  195. Commands::~Commands() {
  196. safe_delete(remote_commands);
  197. }
  198. int32 Commands::GetSpawnSetType(string val){
  199. if(spawn_set_values.count(val) > 0)
  200. return spawn_set_values[val];
  201. return 0xFFFFFFFF;
  202. }
  203. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  204. if(!target)
  205. return false;
  206. int32 val = 0;
  207. try{
  208. if(type != SPAWN_SET_VALUE_NAME &&
  209. !(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))
  210. {
  211. switch(type)
  212. {
  213. case SPAWN_SET_SKIN_COLOR:
  214. case SPAWN_SET_HAIR_COLOR1:
  215. case SPAWN_SET_HAIR_COLOR2:
  216. case SPAWN_SET_HAIR_TYPE_COLOR:
  217. case SPAWN_SET_HAIR_FACE_COLOR:
  218. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  219. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  220. case SPAWN_SET_HAIR_HIGHLIGHT:
  221. case SPAWN_SET_EYE_COLOR:
  222. case SPAWN_SET_SOGA_SKIN_COLOR:
  223. case SPAWN_SET_SOGA_HAIR_COLOR1:
  224. case SPAWN_SET_SOGA_HAIR_COLOR2:
  225. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  226. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  227. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  228. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  229. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  230. case SPAWN_SET_SOGA_EYE_COLOR:
  231. // ignore these are colors can't pass as a integer value
  232. break;
  233. default:
  234. val = atoul(value);
  235. }
  236. }
  237. }
  238. catch(...){
  239. if(client)
  240. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  241. return false;
  242. }
  243. if(temporary){
  244. char tmp[128] = {0};
  245. switch(type){
  246. case SPAWN_SET_VALUE_NAME:{
  247. sprintf(tmp, "%s", target->GetName());
  248. target->SetName(value);
  249. if(target->GetZone())
  250. target->GetZone()->SendUpdateTitles(target);
  251. break;
  252. }
  253. case SPAWN_SET_VALUE_X_OFFSET:
  254. {
  255. sprintf(tmp, "%f", target->GetXOffset());
  256. target->SetXOffset(float(val));
  257. break;
  258. }
  259. case SPAWN_SET_VALUE_Y_OFFSET:
  260. {
  261. sprintf(tmp, "%f", target->GetYOffset());
  262. target->SetYOffset(float(val));
  263. break;
  264. }
  265. case SPAWN_SET_VALUE_Z_OFFSET:
  266. {
  267. sprintf(tmp, "%f", target->GetZOffset());
  268. target->SetZOffset(float(val));
  269. break;
  270. }
  271. case SPAWN_SET_VALUE_EXPIRE: {
  272. sprintf(tmp, "%u", target->GetExpireTime());
  273. target->SetExpireTime(val);
  274. break;
  275. }
  276. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  277. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  278. target->SetExpireOffsetTime(val);
  279. break;
  280. }
  281. case SPAWN_SET_VALUE_SUB_TITLE: {
  282. sprintf(tmp, "%s", target->GetSubTitle());
  283. target->SetSubTitle(value);
  284. if(target->GetZone())
  285. target->GetZone()->SendUpdateTitles(target);
  286. break;
  287. }
  288. case SPAWN_SET_VALUE_LEVEL:{
  289. sprintf(tmp, "%i", target->GetLevel());
  290. target->SetLevel(val, send_update);
  291. break;
  292. }
  293. case SPAWN_SET_VALUE_DIFFICULTY:{
  294. sprintf(tmp, "%i", target->GetEncounterLevel());
  295. target->SetEncounterLevel(val, send_update);
  296. break;
  297. }
  298. case SPAWN_SET_VALUE_MODEL_TYPE:{
  299. sprintf(tmp, "%i", target->GetModelType());
  300. target->SetModelType(val, send_update);
  301. break;
  302. }
  303. case SPAWN_SET_VALUE_CLASS:{
  304. sprintf(tmp, "%i", target->GetAdventureClass());
  305. target->SetAdventureClass(val, send_update);
  306. break;
  307. }
  308. case SPAWN_SET_VALUE_GENDER:{
  309. sprintf(tmp, "%i", target->GetGender());
  310. target->SetGender(val, send_update);
  311. break;
  312. }
  313. case SPAWN_SET_VALUE_SHOW_NAME:{
  314. sprintf(tmp, "%i", target->GetShowName());
  315. target->SetShowName(val, send_update);
  316. break;
  317. }
  318. case SPAWN_SET_VALUE_ATTACKABLE:{
  319. sprintf(tmp, "%i", target->GetAttackable());
  320. target->SetAttackable(val, send_update);
  321. break;
  322. }
  323. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  324. sprintf(tmp, "%i", target->GetShowLevel());
  325. target->SetShowLevel(val, send_update);
  326. break;
  327. }
  328. case SPAWN_SET_VALUE_TARGETABLE:{
  329. sprintf(tmp, "%i", target->GetTargetable());
  330. target->SetTargetable(val, send_update);
  331. break;
  332. }
  333. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  334. sprintf(tmp, "%i", target->GetShowCommandIcon());
  335. target->SetShowCommandIcon(val, send_update);
  336. break;
  337. }
  338. case SPAWN_SET_VALUE_HAND_ICON:{
  339. sprintf(tmp, "%i", target->GetShowHandIcon());
  340. target->SetShowHandIcon(val, send_update);
  341. break;
  342. }
  343. case SPAWN_SET_VALUE_HAIR_TYPE:{
  344. if(target->IsEntity()){
  345. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  346. ((Entity*)target)->SetHairType(val, send_update);
  347. }
  348. break;
  349. }
  350. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  351. if(target->IsEntity()){
  352. sprintf(tmp, "%i", ((Entity*)target)->GetFacialHairType());
  353. ((Entity*)target)->SetFacialHairType(val, send_update);
  354. }
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_WING_TYPE:{
  358. if(target->IsEntity()){
  359. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  360. ((Entity*)target)->SetWingType(val, send_update);
  361. }
  362. break;
  363. }
  364. case SPAWN_SET_VALUE_CHEST_TYPE:{
  365. if(target->IsEntity()){
  366. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  367. ((Entity*)target)->SetChestType(val, send_update);
  368. }
  369. break;
  370. }
  371. case SPAWN_SET_VALUE_LEGS_TYPE:{
  372. if(target->IsEntity()){
  373. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  374. ((Entity*)target)->SetLegsType(val, send_update);
  375. }
  376. break;
  377. }
  378. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  379. if(target->IsEntity()){
  380. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  381. ((Entity*)target)->SetSogaHairType(val, send_update);
  382. }
  383. break;
  384. }
  385. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  386. if(target->IsEntity()){
  387. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  388. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  389. }
  390. break;
  391. }
  392. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  393. sprintf(tmp, "%i", target->GetSogaModelType());
  394. target->SetSogaModelType(val, send_update);
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_SIZE:{
  398. sprintf(tmp, "%i", target->GetSize());
  399. target->SetSize(val, send_update);
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_HP:{
  403. sprintf(tmp, "%i", target->GetHP());
  404. target->SetHP(val, send_update);
  405. break;
  406. }
  407. case SPAWN_SET_VALUE_POWER:{
  408. sprintf(tmp, "%i", target->GetPower());
  409. target->SetPower(val, send_update);
  410. break;
  411. }
  412. case SPAWN_SET_VALUE_HEROIC:{
  413. sprintf(tmp, "%i", target->GetHeroic());
  414. target->SetHeroic(val, send_update);
  415. break;
  416. }
  417. case SPAWN_SET_VALUE_RESPAWN:{
  418. sprintf(tmp, "%u", target->GetRespawnTime());
  419. target->SetRespawnTime(val);
  420. break;
  421. }
  422. case SPAWN_SET_VALUE_X:{
  423. sprintf(tmp, "%f", target->GetX());
  424. target->SetX(atof(value), send_update);
  425. break;
  426. }
  427. case SPAWN_SET_VALUE_Y:{
  428. sprintf(tmp, "%f", target->GetY());
  429. target->SetY(atof(value), send_update);
  430. break;
  431. }
  432. case SPAWN_SET_VALUE_Z:{
  433. sprintf(tmp, "%f", target->GetZ());
  434. target->SetZ(atof(value), send_update);
  435. break;
  436. }
  437. case SPAWN_SET_VALUE_HEADING:{
  438. sprintf(tmp, "%f", target->GetHeading());
  439. target->SetHeading(atof(value) + 360, send_update);
  440. break;
  441. }
  442. case SPAWN_SET_VALUE_VISUAL_STATE:{
  443. sprintf(tmp, "%i", target->GetVisualState());
  444. target->SetVisualState(val, send_update);
  445. break;
  446. }
  447. case SPAWN_SET_VALUE_ACTION_STATE:{
  448. sprintf(tmp, "%i", target->GetActionState());
  449. target->SetActionState(val, send_update);
  450. break;
  451. }
  452. case SPAWN_SET_VALUE_MOOD_STATE:{
  453. sprintf(tmp, "%i", target->GetMoodState());
  454. target->SetMoodState(val, send_update);
  455. break;
  456. }
  457. case SPAWN_SET_VALUE_INITIAL_STATE:{
  458. sprintf(tmp, "%i", target->GetInitialState());
  459. target->SetInitialState(val, send_update);
  460. break;
  461. }
  462. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  463. sprintf(tmp, "%i", target->GetActivityStatus());
  464. target->SetActivityStatus(val, send_update);
  465. break;
  466. }
  467. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  468. sprintf(tmp, "%i", target->GetCollisionRadius());
  469. target->SetCollisionRadius(val, send_update);
  470. break;
  471. }
  472. case SPAWN_SET_VALUE_DEVICE_ID: {
  473. if (target->IsObject()) {
  474. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  475. ((Object*)target)->SetDeviceID(val);
  476. }
  477. break;
  478. }
  479. case SPAWN_SET_VALUE_PITCH: {
  480. sprintf(tmp, "%f", target->GetPitch());
  481. target->SetPitch(atof(value), send_update);
  482. break;
  483. }
  484. case SPAWN_SET_VALUE_ROLL: {
  485. sprintf(tmp, "%f", target->GetRoll());
  486. target->SetRoll(atof(value), send_update);
  487. break;
  488. }
  489. case SPAWN_SET_VALUE_HIDE_HOOD: {
  490. sprintf(tmp, "%i", target->appearance.hide_hood);
  491. target->SetHideHood(val);
  492. break;
  493. }
  494. case SPAWN_SET_VALUE_EMOTE_STATE: {
  495. sprintf(tmp, "%i", target->appearance.emote_state);
  496. target->SetEmoteState(val);
  497. break;
  498. }
  499. case SPAWN_SET_VALUE_ICON: {
  500. sprintf(tmp, "%i", target->GetIconValue());
  501. target->SetIcon(val);
  502. break;
  503. }
  504. case SPAWN_SET_VALUE_PREFIX: {
  505. sprintf(tmp, "%s", target->GetPrefixTitle());
  506. target->SetPrefixTitle(value);
  507. if(target->GetZone())
  508. target->GetZone()->SendUpdateTitles(target);
  509. break;
  510. }
  511. case SPAWN_SET_VALUE_SUFFIX: {
  512. sprintf(tmp, "%s", target->GetSuffixTitle());
  513. target->SetSuffixTitle(value);
  514. if(target->GetZone())
  515. target->GetZone()->SendUpdateTitles(target);
  516. break;
  517. }
  518. case SPAWN_SET_VALUE_LASTNAME: {
  519. sprintf(tmp, "%s", target->GetLastName());
  520. target->SetLastName(value);
  521. if(target->GetZone())
  522. target->GetZone()->SendUpdateTitles(target);
  523. break;
  524. }
  525. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  526. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  527. // nothing to do must reload spawns
  528. break;
  529. }
  530. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  531. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  532. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  533. break;
  534. }
  535. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  536. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  537. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  538. break;
  539. }
  540. case SPAWN_SET_VALUE_FACTION:{
  541. sprintf(tmp, "%i", target->faction_id);
  542. ZoneServer* zone = target->GetZone();
  543. if (!zone && client)
  544. zone = client->GetCurrentZone();
  545. target->faction_id = atoul(value);
  546. if(zone)
  547. {
  548. zone->RemoveDeadEnemyList(target);
  549. if(target->IsNPC())
  550. zone->AddEnemyList((NPC*)target);
  551. }
  552. break;
  553. }
  554. case SPAWN_SET_SKIN_COLOR:
  555. case SPAWN_SET_HAIR_COLOR1:
  556. case SPAWN_SET_HAIR_COLOR2:
  557. case SPAWN_SET_HAIR_TYPE_COLOR:
  558. case SPAWN_SET_HAIR_FACE_COLOR:
  559. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  560. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  561. case SPAWN_SET_HAIR_HIGHLIGHT:
  562. case SPAWN_SET_MODEL_COLOR:
  563. case SPAWN_SET_EYE_COLOR:
  564. case SPAWN_SET_SOGA_SKIN_COLOR:
  565. case SPAWN_SET_SOGA_HAIR_COLOR1:
  566. case SPAWN_SET_SOGA_HAIR_COLOR2:
  567. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  568. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  569. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  570. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  571. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  572. case SPAWN_SET_SOGA_MODEL_COLOR:
  573. case SPAWN_SET_SOGA_EYE_COLOR:
  574. {
  575. if (target->IsEntity())
  576. {
  577. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  578. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  579. {
  580. EQ2_Color clr;
  581. clr.red = atoul(skinsep->arg[0]);
  582. clr.green = atoul(skinsep->arg[1]);
  583. clr.blue = atoul(skinsep->arg[2]);
  584. switch(type)
  585. {
  586. case SPAWN_SET_SKIN_COLOR:
  587. ((Entity*)target)->SetSkinColor(clr);
  588. break;
  589. case SPAWN_SET_HAIR_COLOR1:
  590. ((Entity*)target)->SetHairColor1(clr);
  591. break;
  592. case SPAWN_SET_HAIR_COLOR2:
  593. ((Entity*)target)->SetHairColor2(clr);
  594. break;
  595. case SPAWN_SET_HAIR_TYPE_COLOR:
  596. ((Entity*)target)->SetHairColor(clr);
  597. break;
  598. case SPAWN_SET_HAIR_FACE_COLOR:
  599. ((Entity*)target)->SetFacialHairColor(clr);
  600. break;
  601. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  602. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  603. break;
  604. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  605. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  606. break;
  607. case SPAWN_SET_HAIR_HIGHLIGHT:
  608. ((Entity*)target)->SetHairHighlightColor(clr);
  609. break;
  610. case SPAWN_SET_MODEL_COLOR:
  611. ((Entity*)target)->SetModelColor(clr);
  612. break;
  613. case SPAWN_SET_EYE_COLOR:
  614. ((Entity*)target)->SetEyeColor(clr);
  615. break;
  616. case SPAWN_SET_SOGA_SKIN_COLOR:
  617. ((Entity*)target)->SetSogaSkinColor(clr);
  618. break;
  619. case SPAWN_SET_SOGA_HAIR_COLOR1:
  620. ((Entity*)target)->SetSogaHairColor1(clr);
  621. break;
  622. case SPAWN_SET_SOGA_HAIR_COLOR2:
  623. ((Entity*)target)->SetSogaHairColor2(clr);
  624. break;
  625. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  626. ((Entity*)target)->SetSogaHairColor(clr);
  627. break;
  628. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  629. ((Entity*)target)->SetSogaFacialHairColor(clr);
  630. break;
  631. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  632. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  633. break;
  634. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  635. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  636. break;
  637. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  638. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  639. break;
  640. case SPAWN_SET_SOGA_MODEL_COLOR:
  641. ((Entity*)target)->SetSogaModelColor(clr);
  642. break;
  643. case SPAWN_SET_SOGA_EYE_COLOR:
  644. ((Entity*)target)->SetSogaEyeColor(clr);
  645. break;
  646. }
  647. }
  648. safe_delete(skinsep);
  649. }
  650. break;
  651. }
  652. case SPAWN_SET_AAXP_REWARDS: {
  653. target->SetAAXPRewards(atoul(value));
  654. break;
  655. }
  656. if(temp_value)
  657. *temp_value = string(tmp);
  658. }
  659. }
  660. else{
  661. switch(type){
  662. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  663. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  664. break;
  665. }
  666. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  667. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  668. break;
  669. }
  670. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  671. if (target->GetDatabaseID() > 0)
  672. {
  673. char query[256];
  674. snprintf(query, 256, "update spawn set expansion_flag=%u where id=%i", atoul(value), target->GetDatabaseID());
  675. if (database.RunQuery(query, strnlen(query, 256)))
  676. {
  677. if(client)
  678. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  679. }
  680. }
  681. break;
  682. }
  683. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  684. if (target->GetDatabaseID() > 0)
  685. {
  686. char query[256];
  687. snprintf(query, 256, "update spawn set holiday_flag=%u where id=%i", atoul(value), target->GetDatabaseID());
  688. if (database.RunQuery(query, strnlen(query, 256)))
  689. {
  690. if(client)
  691. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  692. }
  693. }
  694. break;
  695. }
  696. case SPAWN_SET_AAXP_REWARDS: {
  697. if (target->GetDatabaseID() > 0)
  698. {
  699. char query[256];
  700. snprintf(query, 256, "update spawn set aaxp_rewards=%u where id=%i", atoul(value), target->GetDatabaseID());
  701. if (database.RunQuery(query, strnlen(query, 256)))
  702. {
  703. if(client)
  704. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  705. }
  706. }
  707. break;
  708. }
  709. case SPAWN_SET_VALUE_NAME:{
  710. target->SetName(value);
  711. if(target->GetZone())
  712. target->GetZone()->SendUpdateTitles(target);
  713. break;
  714. }
  715. case SPAWN_SET_VALUE_SUB_TITLE: {
  716. target->SetSubTitle(value);
  717. if(target->GetZone())
  718. target->GetZone()->SendUpdateTitles(target);
  719. break;
  720. }
  721. case SPAWN_SET_VALUE_X_OFFSET:
  722. {
  723. target->SetXOffset(atof(value));
  724. break;
  725. }
  726. case SPAWN_SET_VALUE_Y_OFFSET:
  727. {
  728. target->SetYOffset(atof(value));
  729. break;
  730. }
  731. case SPAWN_SET_VALUE_Z_OFFSET:
  732. {
  733. target->SetZOffset(atof(value));
  734. break;
  735. }
  736. case SPAWN_SET_VALUE_EXPIRE: {
  737. target->SetExpireTime(val);
  738. break;
  739. }
  740. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  741. target->SetExpireOffsetTime(val);
  742. break;
  743. }
  744. case SPAWN_SET_VALUE_LEVEL:{
  745. target->SetLevel(val, send_update);
  746. break;
  747. }
  748. case SPAWN_SET_VALUE_DIFFICULTY:{
  749. target->SetEncounterLevel(val, send_update);
  750. break;
  751. }
  752. case SPAWN_SET_VALUE_MODEL_TYPE:{
  753. target->SetModelType(val, send_update);
  754. break;
  755. }
  756. case SPAWN_SET_VALUE_CLASS:{
  757. target->SetAdventureClass(val, send_update);
  758. break;
  759. }
  760. case SPAWN_SET_VALUE_GENDER:{
  761. target->SetGender(val, send_update);
  762. break;
  763. }
  764. case SPAWN_SET_VALUE_SHOW_NAME:{
  765. target->SetShowName(val, send_update);
  766. break;
  767. }
  768. case SPAWN_SET_VALUE_ATTACKABLE:{
  769. target->SetAttackable(val, send_update);
  770. break;
  771. }
  772. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  773. target->SetShowLevel(val, send_update);
  774. break;
  775. }
  776. case SPAWN_SET_VALUE_TARGETABLE:{
  777. target->SetTargetable(val, send_update);
  778. break;
  779. }
  780. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  781. target->SetShowCommandIcon(val, send_update);
  782. break;
  783. }
  784. case SPAWN_SET_VALUE_HAND_ICON:{
  785. target->SetShowHandIcon(val, send_update);
  786. break;
  787. }
  788. case SPAWN_SET_VALUE_HAIR_TYPE:{
  789. if(target->IsEntity())
  790. ((Entity*)target)->SetHairType(val, send_update);
  791. break;
  792. }
  793. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  794. if(target->IsEntity())
  795. ((Entity*)target)->SetFacialHairType(val, send_update);
  796. break;
  797. }
  798. case SPAWN_SET_VALUE_WING_TYPE:{
  799. if(target->IsEntity())
  800. ((Entity*)target)->SetWingType(val, send_update);
  801. break;
  802. }
  803. case SPAWN_SET_VALUE_CHEST_TYPE:{
  804. if(target->IsEntity())
  805. ((Entity*)target)->SetChestType(val, send_update);
  806. break;
  807. }
  808. case SPAWN_SET_VALUE_LEGS_TYPE:{
  809. if(target->IsEntity())
  810. ((Entity*)target)->SetLegsType(val, send_update);
  811. break;
  812. }
  813. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  814. if(target->IsEntity())
  815. ((Entity*)target)->SetSogaHairType(val, send_update);
  816. break;
  817. }
  818. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  819. if(target->IsEntity())
  820. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  821. break;
  822. }
  823. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  824. target->SetSogaModelType(val, send_update);
  825. break;
  826. }
  827. case SPAWN_SET_VALUE_SIZE:{
  828. target->SetSize(val, send_update);
  829. break;
  830. }
  831. case SPAWN_SET_VALUE_HP:{
  832. target->SetHP(val, send_update);
  833. break;
  834. }
  835. case SPAWN_SET_VALUE_POWER:{
  836. target->SetPower(val, send_update);
  837. break;
  838. }
  839. case SPAWN_SET_VALUE_HEROIC:{
  840. target->SetHeroic(val, send_update);
  841. break;
  842. }
  843. case SPAWN_SET_VALUE_RESPAWN:{
  844. target->SetRespawnTime(val);
  845. break;
  846. }
  847. case SPAWN_SET_VALUE_X:{
  848. target->SetX(atof(value), send_update);
  849. target->SetSpawnOrigX(target->GetX());
  850. break;
  851. }
  852. case SPAWN_SET_VALUE_Y:{
  853. target->SetY(atof(value), send_update);
  854. target->SetSpawnOrigY(target->GetY());
  855. break;
  856. }
  857. case SPAWN_SET_VALUE_Z:{
  858. target->SetZ(atof(value), send_update);
  859. target->SetSpawnOrigZ(target->GetZ());
  860. break;
  861. }
  862. case SPAWN_SET_VALUE_HEADING:{
  863. target->SetHeading(atof(value), send_update);
  864. target->SetSpawnOrigHeading(target->GetHeading());
  865. break;
  866. }
  867. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  868. ZoneServer* zone = target->GetZone();
  869. if (!zone && client)
  870. zone = client->GetCurrentZone();
  871. if(zone && zone->GetEntityCommandList(val))
  872. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  873. target->primary_command_list_id = val;
  874. break;
  875. }
  876. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  877. ZoneServer* zone = target->GetZone();
  878. if (!zone && client)
  879. zone = client->GetCurrentZone();
  880. if (zone && zone->GetEntityCommandList(val))
  881. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  882. target->secondary_command_list_id = val;
  883. break;
  884. }
  885. case SPAWN_SET_VALUE_VISUAL_STATE:{
  886. target->SetVisualState(val, send_update);
  887. break;
  888. }
  889. case SPAWN_SET_VALUE_ACTION_STATE:{
  890. target->SetActionState(val, send_update);
  891. break;
  892. }
  893. case SPAWN_SET_VALUE_MOOD_STATE:{
  894. target->SetMoodState(val, send_update);
  895. break;
  896. }
  897. case SPAWN_SET_VALUE_INITIAL_STATE:{
  898. target->SetInitialState(val, send_update);
  899. break;
  900. }
  901. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  902. target->SetActivityStatus(val, send_update);
  903. break;
  904. }
  905. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  906. target->SetCollisionRadius(val, send_update);
  907. break;
  908. }
  909. case SPAWN_SET_VALUE_FACTION:{
  910. ZoneServer* zone = target->GetZone();
  911. if (!zone && client)
  912. zone = client->GetCurrentZone();
  913. target->faction_id = val;
  914. if(zone)
  915. {
  916. zone->RemoveDeadEnemyList(target);
  917. if(target->IsNPC())
  918. zone->AddEnemyList((NPC*)target);
  919. }
  920. break;
  921. }
  922. case SPAWN_SET_VALUE_DEVICE_ID:{
  923. if (target->IsObject())
  924. ((Object*)target)->SetDeviceID(val);
  925. break;
  926. }
  927. case SPAWN_SET_VALUE_PITCH: {
  928. target->SetPitch(atof(value), send_update);
  929. target->SetSpawnOrigPitch(atof(value));
  930. break;
  931. }
  932. case SPAWN_SET_VALUE_ROLL: {
  933. target->SetRoll(atof(value), send_update);
  934. target->SetSpawnOrigRoll(atof(value));
  935. break;
  936. }
  937. case SPAWN_SET_VALUE_HIDE_HOOD: {
  938. target->SetHideHood(val);
  939. break;
  940. }
  941. case SPAWN_SET_VALUE_EMOTE_STATE: {
  942. target->SetEmoteState(val);
  943. break;
  944. }
  945. case SPAWN_SET_VALUE_ICON: {
  946. target->SetIcon(val);
  947. break;
  948. }
  949. case SPAWN_SET_VALUE_PREFIX: {
  950. target->SetPrefixTitle(value);
  951. if(target->GetZone())
  952. target->GetZone()->SendUpdateTitles(target);
  953. break;
  954. }
  955. case SPAWN_SET_VALUE_SUFFIX: {
  956. target->SetSuffixTitle(value);
  957. if(target->GetZone())
  958. target->GetZone()->SendUpdateTitles(target);
  959. break;
  960. }
  961. case SPAWN_SET_VALUE_LASTNAME: {
  962. target->SetLastName(value);
  963. if(target->GetZone())
  964. target->GetZone()->SendUpdateTitles(target);
  965. break;
  966. }
  967. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  968. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  969. if(client){
  970. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  971. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  972. }
  973. return false;
  974. }
  975. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  976. return false;
  977. else{
  978. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  979. target->SetSpawnScript(value);
  980. }
  981. break;
  982. }
  983. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  984. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  985. if(client){
  986. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  987. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  988. }
  989. return false;
  990. }
  991. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  992. return false;
  993. else{
  994. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  995. target->SetSpawnScript(value);
  996. }
  997. break;
  998. }
  999. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  1000. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1001. if(client){
  1002. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1003. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  1004. }
  1005. return false;
  1006. }
  1007. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  1008. return false;
  1009. else
  1010. target->SetSpawnScript(value);
  1011. break;
  1012. }
  1013. case SPAWN_SET_SKIN_COLOR:
  1014. case SPAWN_SET_HAIR_COLOR1:
  1015. case SPAWN_SET_HAIR_COLOR2:
  1016. case SPAWN_SET_HAIR_TYPE_COLOR:
  1017. case SPAWN_SET_HAIR_FACE_COLOR:
  1018. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1019. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1020. case SPAWN_SET_HAIR_HIGHLIGHT:
  1021. case SPAWN_SET_MODEL_COLOR:
  1022. case SPAWN_SET_EYE_COLOR:
  1023. case SPAWN_SET_SOGA_SKIN_COLOR:
  1024. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1025. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1026. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1027. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1028. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1029. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1030. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1031. case SPAWN_SET_SOGA_MODEL_COLOR:
  1032. case SPAWN_SET_SOGA_EYE_COLOR: {
  1033. if (target->IsNPC())
  1034. {
  1035. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  1036. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  1037. {
  1038. EQ2_Color clr;
  1039. clr.red = atoul(skinsep->arg[0]);
  1040. clr.green = atoul(skinsep->arg[1]);
  1041. clr.blue = atoul(skinsep->arg[2]);
  1042. Query replaceSkinQuery;
  1043. string fieldName("");
  1044. switch(type)
  1045. {
  1046. case SPAWN_SET_SKIN_COLOR:
  1047. ((Entity*)target)->SetSkinColor(clr);
  1048. fieldName.append("skin_color");
  1049. break;
  1050. case SPAWN_SET_HAIR_COLOR1:
  1051. ((Entity*)target)->SetHairColor1(clr);
  1052. fieldName.append("hair_color1");
  1053. break;
  1054. case SPAWN_SET_HAIR_COLOR2:
  1055. ((Entity*)target)->SetHairColor2(clr);
  1056. fieldName.append("hair_color2");
  1057. break;
  1058. case SPAWN_SET_HAIR_TYPE_COLOR:
  1059. ((Entity*)target)->SetHairColor(clr);
  1060. fieldName.append("hair_type_color");
  1061. break;
  1062. case SPAWN_SET_HAIR_FACE_COLOR:
  1063. ((Entity*)target)->SetFacialHairColor(clr);
  1064. fieldName.append("hair_face_color");
  1065. break;
  1066. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1067. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  1068. fieldName.append("hair_type_highlight_color");
  1069. break;
  1070. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1071. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  1072. fieldName.append("hair_face_highlight_color");
  1073. break;
  1074. case SPAWN_SET_HAIR_HIGHLIGHT:
  1075. ((Entity*)target)->SetHairHighlightColor(clr);
  1076. fieldName.append("hair_highlight");
  1077. break;
  1078. case SPAWN_SET_MODEL_COLOR:
  1079. ((Entity*)target)->SetModelColor(clr);
  1080. fieldName.append("model_color");
  1081. break;
  1082. case SPAWN_SET_EYE_COLOR:
  1083. ((Entity*)target)->SetEyeColor(clr);
  1084. fieldName.append("eye_color");
  1085. break;
  1086. case SPAWN_SET_SOGA_SKIN_COLOR:
  1087. ((Entity*)target)->SetSogaSkinColor(clr);
  1088. fieldName.append("soga_skin_color");
  1089. break;
  1090. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1091. ((Entity*)target)->SetSogaHairColor1(clr);
  1092. fieldName.append("soga_hair_color1");
  1093. break;
  1094. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1095. ((Entity*)target)->SetSogaHairColor2(clr);
  1096. fieldName.append("soga_hair_color2");
  1097. break;
  1098. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1099. ((Entity*)target)->SetSogaHairColor(clr);
  1100. fieldName.append("soga_hair_type_color");
  1101. break;
  1102. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1103. ((Entity*)target)->SetSogaFacialHairColor(clr);
  1104. fieldName.append("soga_hair_face_color");
  1105. break;
  1106. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1107. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  1108. fieldName.append("soga_hair_type_highlight_color");
  1109. break;
  1110. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1111. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  1112. fieldName.append("soga_hair_face_highlight_color");
  1113. break;
  1114. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1115. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  1116. fieldName.append("soga_hair_highlight");
  1117. break;
  1118. case SPAWN_SET_SOGA_MODEL_COLOR:
  1119. ((Entity*)target)->SetSogaModelColor(clr);
  1120. fieldName.append("soga_model_color");
  1121. break;
  1122. case SPAWN_SET_SOGA_EYE_COLOR:
  1123. ((Entity*)target)->SetSogaEyeColor(clr);
  1124. fieldName.append("soga_eye_color");
  1125. break;
  1126. }
  1127. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1128. 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);
  1129. }
  1130. safe_delete(skinsep);
  1131. }
  1132. break;
  1133. }
  1134. }
  1135. }
  1136. return true;
  1137. }
  1138. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  1139. the database fields always and also update the zone in memory if it's running. */
  1140. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  1141. if (client && zone_id > 0 && type > 0 && value) {
  1142. sint32 int_value = 0;
  1143. float float_value = 0;
  1144. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  1145. try {
  1146. float_value = atof(value);
  1147. }
  1148. catch (...) {
  1149. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  1150. return false;
  1151. }
  1152. }
  1153. 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) {
  1154. try {
  1155. int_value = atoi(value);
  1156. }
  1157. catch (...) {
  1158. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  1159. return false;
  1160. }
  1161. }
  1162. switch (type) {
  1163. case ZONE_SET_VALUE_EXPANSION_ID: {
  1164. break;
  1165. }
  1166. case ZONE_SET_VALUE_NAME: {
  1167. if (zone)
  1168. zone->SetZoneName(const_cast<char*>(value));
  1169. database.SaveZoneInfo(zone_id, "name", value);
  1170. break;
  1171. }
  1172. case ZONE_SET_VALUE_FILE: {
  1173. if (zone)
  1174. zone->SetZoneFile(const_cast<char*>(value));
  1175. database.SaveZoneInfo(zone_id, "file", value);
  1176. break;
  1177. }
  1178. case ZONE_SET_VALUE_DESCRIPTION: {
  1179. if (zone)
  1180. zone->SetZoneDescription(const_cast<char*>(value));
  1181. database.SaveZoneInfo(zone_id, "description", value);
  1182. break;
  1183. }
  1184. case ZONE_SET_VALUE_SAFE_X: {
  1185. if (zone)
  1186. zone->SetSafeX(float_value);
  1187. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  1188. break;
  1189. }
  1190. case ZONE_SET_VALUE_SAFE_Y: {
  1191. if (zone)
  1192. zone->SetSafeY(float_value);
  1193. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  1194. break;
  1195. }
  1196. case ZONE_SET_VALUE_SAFE_Z: {
  1197. if (zone)
  1198. zone->SetSafeZ(float_value);
  1199. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  1200. break;
  1201. }
  1202. case ZONE_SET_VALUE_UNDERWORLD: {
  1203. if (zone)
  1204. zone->SetUnderWorld(float_value);
  1205. database.SaveZoneInfo(zone_id, "underworld", float_value);
  1206. break;
  1207. }
  1208. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  1209. break;
  1210. }
  1211. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  1212. break;
  1213. }
  1214. case ZONE_SET_VALUE_ZONE_TYPE: {
  1215. break;
  1216. }
  1217. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  1218. if (zone)
  1219. zone->SetAlwaysLoaded(int_value == 1);
  1220. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  1221. break;
  1222. }
  1223. case ZONE_SET_VALUE_CITY_ZONE: {
  1224. if (zone)
  1225. zone->SetCityZone(int_value == 1);
  1226. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  1227. break;
  1228. }
  1229. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  1230. if (zone)
  1231. zone->SetWeatherAllowed(int_value == 1);
  1232. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  1233. break;
  1234. }
  1235. case ZONE_SET_VALUE_MIN_STATUS: {
  1236. if (zone)
  1237. zone->SetMinimumStatus(int_value);
  1238. database.SaveZoneInfo(zone_id, "min_status", int_value);
  1239. break;
  1240. }
  1241. case ZONE_SET_VALUE_MIN_LEVEL: {
  1242. if (zone)
  1243. zone->SetMinimumLevel(int_value);
  1244. database.SaveZoneInfo(zone_id, "min_level", int_value);
  1245. break;
  1246. }
  1247. case ZONE_SET_VALUE_MAX_LEVEL: {
  1248. if (zone)
  1249. zone->SetMaximumLevel(int_value);
  1250. database.SaveZoneInfo(zone_id, "max_level", int_value);
  1251. break;
  1252. }
  1253. case ZONE_SET_VALUE_START_ZONE: {
  1254. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  1255. break;
  1256. }
  1257. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  1258. if (zone)
  1259. zone->SetInstanceType(int_value);
  1260. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  1261. break;
  1262. }
  1263. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  1264. if (zone)
  1265. zone->SetDefaultReenterTime(int_value);
  1266. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  1267. break;
  1268. }
  1269. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  1270. if (zone)
  1271. zone->SetDefaultResetTime(int_value);
  1272. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  1273. break;
  1274. }
  1275. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1276. if (zone)
  1277. zone->SetDefaultLockoutTime(int_value);
  1278. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1279. break;
  1280. }
  1281. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1282. if (zone)
  1283. zone->SetForceGroupZoneOption(int_value);
  1284. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1285. break;
  1286. }
  1287. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1288. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1289. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1290. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1291. return false;
  1292. }
  1293. else {
  1294. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1295. database.SaveZoneInfo(zone_id, "lua_script", value);
  1296. }
  1297. break;
  1298. }
  1299. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1300. if (zone)
  1301. zone->SetShutdownTimer(int_value);
  1302. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1303. break;
  1304. }
  1305. case ZONE_SET_VALUE_ZONE_MOTD: {
  1306. if (zone)
  1307. zone->SetZoneMOTD(string(value));
  1308. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1309. break;
  1310. }
  1311. default: {
  1312. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1313. return false;
  1314. }
  1315. }
  1316. }
  1317. else {
  1318. if (client)
  1319. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1320. return false;
  1321. }
  1322. return true;
  1323. }
  1324. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1325. if (index >= remote_commands->commands.size()) {
  1326. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1327. return;
  1328. }
  1329. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1330. EQ2_RemoteCommandString* parent_command = 0;
  1331. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1332. Seperator* sep = 0;
  1333. if (command_parms->size > 0) {
  1334. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1335. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1336. parent_command = command;
  1337. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1338. safe_delete(sep);
  1339. if (command_parms->data.length() > (command->command.data.length() + 1))
  1340. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1341. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1342. }
  1343. else
  1344. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1345. }
  1346. int ndx = 0;
  1347. if (command->required_status > client->GetAdminStatus())
  1348. {
  1349. 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());
  1350. safe_delete(sep);
  1351. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1352. return;
  1353. }
  1354. Player* player = client->GetPlayer();
  1355. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1356. switch (command->handler) {
  1357. case COMMAND_RELOAD: {
  1358. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1359. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1360. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1361. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1362. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1363. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1364. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1365. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1366. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1367. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1368. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1369. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1370. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1371. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1372. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1373. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1374. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1375. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1376. break;
  1377. }
  1378. case COMMAND_RELOADSTRUCTS: {
  1379. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1380. world.SetReloadingSubsystem("Structs");
  1381. configReader.ReloadStructs();
  1382. world.RemoveReloadingSubSystem("Structs");
  1383. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1384. break;
  1385. }
  1386. case COMMAND_RELOAD_QUESTS: {
  1387. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1388. world.SetReloadingSubsystem("Quests");
  1389. master_quest_list.Reload();
  1390. client_list.ReloadQuests();
  1391. zone_list.ReloadClientQuests();
  1392. world.RemoveReloadingSubSystem("Quests");
  1393. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1394. break;
  1395. }
  1396. case COMMAND_RELOAD_SPAWNS: {
  1397. client->GetCurrentZone()->ReloadSpawns();
  1398. break;
  1399. }
  1400. case COMMAND_RELOAD_SPELLS: {
  1401. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1402. world.SetReloadingSubsystem("Spells");
  1403. zone_list.DeleteSpellProcess();
  1404. master_spell_list.Reload();
  1405. if (lua_interface)
  1406. lua_interface->ReloadSpells();
  1407. zone_list.LoadSpellProcess();
  1408. world.RemoveReloadingSubSystem("Spells");
  1409. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1410. break;
  1411. }
  1412. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1413. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1414. world.SetReloadingSubsystem("GroundSpawns");
  1415. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1416. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1417. world.RemoveReloadingSubSystem("GroundSpawns");
  1418. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1419. break;
  1420. }
  1421. case COMMAND_RELOAD_ZONESCRIPTS: {
  1422. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1423. world.SetReloadingSubsystem("ZoneScripts");
  1424. world.ResetZoneScripts();
  1425. database.LoadZoneScriptData();
  1426. if (lua_interface)
  1427. lua_interface->DestroyZoneScripts();
  1428. world.RemoveReloadingSubSystem("ZoneScripts");
  1429. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1430. break;
  1431. }
  1432. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1433. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1434. world.SetReloadingSubsystem("EntityCommands");
  1435. client->GetCurrentZone()->ClearEntityCommands();
  1436. database.LoadEntityCommands(client->GetCurrentZone());
  1437. world.RemoveReloadingSubSystem("EntityCommands");
  1438. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1439. break;
  1440. }
  1441. case COMMAND_RELOAD_FACTIONS: {
  1442. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1443. world.SetReloadingSubsystem("Factions");
  1444. master_faction_list.Clear();
  1445. database.LoadFactionList();
  1446. world.RemoveReloadingSubSystem("Factions");
  1447. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1448. break;
  1449. }
  1450. case COMMAND_RELOAD_MAIL: {
  1451. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1452. zone_list.ReloadMail();
  1453. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1454. break;
  1455. }
  1456. case COMMAND_RELOAD_GUILDS: {
  1457. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1458. world.ReloadGuilds();
  1459. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1460. break;
  1461. }
  1462. case COMMAND_RELOAD_LOCATIONS: {
  1463. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1464. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1465. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1466. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1467. break;
  1468. }
  1469. case COMMAND_RELOAD_RULES: {
  1470. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1471. database.LoadRuleSets(true);
  1472. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1473. break;
  1474. }
  1475. case COMMAND_RELOAD_TRANSPORTERS: {
  1476. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1477. database.LoadTransporters(client->GetCurrentZone());
  1478. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1479. break;
  1480. }
  1481. case COMMAND_RELOAD_STARTABILITIES: {
  1482. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1483. world.PurgeStartingLists();
  1484. world.LoadStartingLists();
  1485. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1486. break;
  1487. }
  1488. case COMMAND_READ: {
  1489. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1490. if (strcmp(sep->arg[0], "read") == 0) {
  1491. int32 item_index = atol(sep->arg[1]);
  1492. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1493. if (item) {
  1494. Spawn* spawn = cmdTarget;
  1495. client->SendShowBook(client->GetPlayer(), item->name, item->book_pages);
  1496. break;
  1497. }
  1498. }
  1499. }
  1500. break;
  1501. }
  1502. case COMMAND_USEABILITY:{
  1503. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1504. if (client->GetPlayer()->GetHP() == 0) {
  1505. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1506. }
  1507. else {
  1508. int32 spell_id = atoul(sep->arg[0]);
  1509. int8 spell_tier = 0;
  1510. if (sep->arg[1][0] && sep->IsNumber(1))
  1511. spell_tier = atoi(sep->arg[1]);
  1512. else
  1513. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1514. if (!spell_tier)
  1515. spell_tier = 1;
  1516. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1517. if (spell) {
  1518. 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)
  1519. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1520. else
  1521. {
  1522. if (cmdTarget)
  1523. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1524. else
  1525. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1526. }
  1527. }
  1528. }
  1529. }
  1530. else if (cmdTarget && cmdTarget->IsWidget())
  1531. {
  1532. Widget* widget = (Widget*)cmdTarget;
  1533. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1534. }
  1535. else
  1536. {
  1537. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1538. }
  1539. break;
  1540. }
  1541. case COMMAND_INFO:{
  1542. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1543. if(strcmp(sep->arg[0], "inventory") == 0){
  1544. int32 item_index = atol(sep->arg[1]);
  1545. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1546. if(item){
  1547. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1548. break;
  1549. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1550. //DumpPacket(app);
  1551. client->QueuePacket(app);
  1552. if(item->GetItemScript() && lua_interface)
  1553. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1554. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1555. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  1556. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1557. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  1558. }
  1559. }
  1560. else
  1561. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1562. }
  1563. else if(strcmp(sep->arg[0], "equipment") == 0){
  1564. int32 item_index = atol(sep->arg[1]);
  1565. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1566. if(item){
  1567. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1568. client->QueuePacket(app);
  1569. if(item->GetItemScript() && lua_interface)
  1570. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1571. }
  1572. else
  1573. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1574. }
  1575. 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){
  1576. int32 item_id = atoul(sep->arg[1]);
  1577. Item* item = master_item_list.GetItem(item_id);
  1578. if(item){
  1579. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1580. client->QueuePacket(app);
  1581. }
  1582. else
  1583. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1584. }
  1585. else if (strcmp(sep->arg[0], "spell") == 0) {
  1586. sint32 spell_id = atol(sep->arg[1]);
  1587. int8 tier = atoi(sep->arg[3]);
  1588. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1589. if (outapp)
  1590. client->QueuePacket(outapp);
  1591. else
  1592. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1593. }
  1594. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1595. sint32 spell_id = atol(sep->arg[2]);
  1596. int8 group = atoi(sep->arg[1]);
  1597. AltAdvanceData* data = 0;
  1598. SpellBookEntry* spellentry = 0;
  1599. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1600. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1601. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1602. if (outapp)
  1603. client->QueuePacket(outapp);
  1604. else
  1605. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1606. }
  1607. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1608. sint32 spell_id = atol(sep->arg[1]);
  1609. int32 tier = atoi(sep->arg[2]);
  1610. if (tier > 255) {
  1611. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  1612. if (ent)
  1613. tier = ent->tier;
  1614. }
  1615. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  1616. if (outapp)
  1617. client->QueuePacket(outapp);
  1618. else
  1619. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1620. }
  1621. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1622. sint32 recipe_id = atol(sep->arg[1]);
  1623. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1624. if(outapp)
  1625. client->QueuePacket(outapp);
  1626. else
  1627. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1628. }
  1629. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1630. int32 slot = atol(sep->arg[1]);
  1631. int32 spell_id = atol(sep->arg[2]);
  1632. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1633. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1634. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1635. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1636. if(outapp)
  1637. client->QueuePacket(outapp);
  1638. else
  1639. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1640. }
  1641. else if (strcmp(sep->arg[0], "effect") == 0) {
  1642. int32 spell_id = atol(sep->arg[1]);
  1643. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1644. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1645. int8 type = 0;
  1646. if (client->GetVersion() <= 546)
  1647. type = 1;
  1648. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  1649. if (outapp){
  1650. client->QueuePacket(outapp);
  1651. }
  1652. else
  1653. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1654. }
  1655. }
  1656. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1657. Item* item = player->item_list.GetOverflowItem();
  1658. if(item) {
  1659. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1660. client->QueuePacket(app);
  1661. }
  1662. else
  1663. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1664. }
  1665. else
  1666. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1667. break;
  1668. }
  1669. case COMMAND_USE_EQUIPPED_ITEM:{
  1670. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1671. int32 slot_id = atoul(sep->arg[0]);
  1672. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1673. if (item && item->generic_info.usable && item->GetItemScript())
  1674. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1675. }
  1676. break;
  1677. }
  1678. case COMMAND_USE_ITEM: {
  1679. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1680. int32 item_index = atoul(sep->arg[0]);
  1681. Item* item = player->item_list.GetItemFromIndex(item_index);
  1682. if (item && item->GetItemScript()) {
  1683. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1684. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1685. else {
  1686. if (item->generic_info.display_charges > 0) {
  1687. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1688. item->generic_info.display_charges -= 1;
  1689. item->save_needed = true;
  1690. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1691. }
  1692. else
  1693. LogWrite(PLAYER__ERROR, 0, "Command", "%s: Item %s (%i) attempted to be used, however display_charges is 0.", client->GetPlayer()->GetName(), item->name.c_str(), item->details.item_id);
  1694. }
  1695. }
  1696. }
  1697. break;
  1698. }
  1699. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1700. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1701. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1702. if (item) {
  1703. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1704. if(item->generic_info.item_type == 6) {
  1705. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1706. int8 old_slot = 0;
  1707. if (spell) {
  1708. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1709. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1710. player->RemoveSpellBookEntry(spell->GetSpellID());
  1711. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1712. player->UnlockSpell(spell);
  1713. client->SendSpellUpdate(spell);
  1714. database.DeleteItem(client->GetCharacterID(), item, 0);
  1715. player->item_list.RemoveItem(item, true);
  1716. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1717. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1718. }
  1719. }
  1720. else
  1721. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1722. }
  1723. else if(item->generic_info.item_type == 7){
  1724. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1725. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1726. // if valid recipe book and the player doesn't have it
  1727. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1728. client->Message(CHANNEL_NARRATIVE, "Your tradeskill level is not high enough to scribe this book.");
  1729. safe_delete(recipe_book);
  1730. }
  1731. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1732. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1733. // Add recipe book to the players list
  1734. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1735. // Get a list of all recipes this book contains
  1736. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1737. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1738. // Create the packet to send to update the players recipe list
  1739. PacketStruct* packet = 0;
  1740. if (client->GetRecipeListSent()) {
  1741. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1742. if (packet)
  1743. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1744. }
  1745. // loop through the list
  1746. vector<Recipe*>::iterator itr;
  1747. int16 i = 0;
  1748. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1749. // check to see if the player already has this recipe some how
  1750. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1751. // Player doesn't already have this recipe so lets add it
  1752. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1753. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1754. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1755. client->Message(CHANNEL_NARRATIVE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1756. if (packet && client->GetRecipeListSent()) {
  1757. packet->setArrayDataByName("id", recipe->GetID(), i);
  1758. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1759. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1760. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1761. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1762. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1763. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1764. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1765. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1766. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1767. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1768. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1769. i++;
  1770. }
  1771. }
  1772. }
  1773. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1774. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1775. database.DeleteItem(client->GetCharacterID(), item, 0);
  1776. client->GetPlayer()->item_list.RemoveItem(item, true);
  1777. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1778. if (packet && client->GetRecipeListSent())
  1779. client->QueuePacket(packet->serialize());
  1780. safe_delete(packet);
  1781. }
  1782. else {
  1783. if (recipe_book)
  1784. client->Message(CHANNEL_NARRATIVE, "You have already learned all you can from this item.");
  1785. safe_delete(recipe_book);
  1786. }
  1787. }
  1788. }
  1789. else
  1790. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1791. }
  1792. break;
  1793. }
  1794. case COMMAND_SUMMONITEM: {
  1795. if (sep && sep->IsNumber(0)) {
  1796. int32 item_id = atol(sep->arg[0]);
  1797. int32 quantity = 1;
  1798. if (sep->arg[1] && sep->IsNumber(1))
  1799. quantity = atoi(sep->arg[1]);
  1800. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1801. client->AddItemToBank(item_id,quantity);
  1802. }
  1803. else {
  1804. client->AddItem(item_id, quantity);
  1805. }
  1806. }
  1807. else {
  1808. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1809. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1810. }
  1811. break;
  1812. }
  1813. case COMMAND_COLLECTION_ADDITEM: {
  1814. // takes 2 params: collection_id, slot
  1815. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1816. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1817. if (item)
  1818. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1819. else
  1820. 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]));
  1821. }
  1822. else
  1823. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1824. break;
  1825. }
  1826. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1827. // takes 1 param: slot
  1828. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1829. int i = 0;
  1830. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1831. printf("\t%u: %s\n", i, sep->arg[i]);
  1832. i++;
  1833. }
  1834. break;
  1835. }
  1836. case COMMAND_WAYPOINT: {
  1837. bool success = false;
  1838. client->ClearWaypoint();
  1839. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  1840. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  1841. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  1842. }
  1843. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  1844. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  1845. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  1846. }
  1847. else {
  1848. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  1849. }
  1850. break;
  1851. }
  1852. case COMMAND_WHO:{
  1853. const char* who = 0;
  1854. if(sep && sep->arg[0]){
  1855. //cout << "Who query: \n";
  1856. who = sep->argplus[0];
  1857. //cout << who << endl;
  1858. }
  1859. zone_list.ProcessWhoQuery(who, client);
  1860. break;
  1861. }
  1862. case COMMAND_SELECT_JUNCTION:{
  1863. LogWrite(MISC__TODO, 1, "TODO", "For access/travel selections (i.e. Mariner Bells, Player Death Window, etc.)\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1864. int32 choice = 0;
  1865. if(sep && sep->arg[0] && sep->IsNumber(0))
  1866. choice = atoul(sep->arg[0]);
  1867. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1868. client->HandlePlayerRevive(choice);
  1869. }
  1870. break;
  1871. }
  1872. case COMMAND_SPAWN_MOVE: {
  1873. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  1874. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1875. if (packet) {
  1876. float unknown2_3 = 0;
  1877. int8 placement_mode = 0;
  1878. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1879. if (sep && sep->arg[0][0]) {
  1880. if (strcmp(sep->arg[0], "wall") == 0) {
  1881. placement_mode = 2;
  1882. unknown2_3 = 150;
  1883. }
  1884. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1885. placement_mode = 1;
  1886. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1887. {
  1888. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1889. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1890. }
  1891. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1892. {
  1893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1894. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1895. }
  1896. else if (strcmp(sep->arg[0], "myloc") == 0)
  1897. {
  1898. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1899. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1900. safe_delete(packet);
  1901. break;
  1902. }
  1903. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1904. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1905. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1906. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1907. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1908. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1909. safe_delete(packet);
  1910. break;
  1911. }
  1912. }
  1913. packet->setDataByName("placement_mode", placement_mode);
  1914. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1915. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1916. packet->setDataByName("unknown", 1); //size
  1917. packet->setDataByName("unknown2", 1); //size 2
  1918. packet->setDataByName("unknown2", .5, 1); //size 3
  1919. packet->setDataByName("unknown2", 3, 2);
  1920. packet->setDataByName("unknown2", unknown2_3, 3);
  1921. packet->setDataByName("max_distance", 500);
  1922. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1923. client->QueuePacket(packet->serialize());
  1924. safe_delete(packet);
  1925. }
  1926. }
  1927. else {
  1928. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1929. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1930. }
  1931. break;
  1932. }
  1933. case COMMAND_HAIL:{
  1934. Spawn* spawn = cmdTarget;
  1935. if(spawn && spawn->GetTargetable())
  1936. {
  1937. char tmp[75] = {0};
  1938. sprintf(tmp, "Hail, %s", spawn->GetName());
  1939. bool show_bubble = true;
  1940. if (spawn->IsNPC())
  1941. show_bubble = false;
  1942. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1943. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetGlobalRule(R_Spawn, HailDistance)->GetInt32()){
  1944. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1945. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1946. else
  1947. {
  1948. bool pauseRunback = false;
  1949. // prime runback as the heading or anything can be altered when hailing succeeds
  1950. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  1951. {
  1952. ((NPC*)spawn)->StartRunback();
  1953. pauseRunback = true;
  1954. }
  1955. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  1956. spawn->PauseMovement(rule_manager.GetGlobalRule(R_Spawn, HailMovementPause)->GetInt32());
  1957. else if(spawn->IsNPC() && pauseRunback)
  1958. ((NPC*)spawn)->ClearRunback();
  1959. }
  1960. }
  1961. }
  1962. else {
  1963. string tmp = "Hail";
  1964. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1965. }
  1966. break;
  1967. }
  1968. case COMMAND_SAY:{
  1969. if (sep && sep->arg[0][0]) {
  1970. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1971. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1972. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1973. }
  1974. else
  1975. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1976. break;
  1977. }
  1978. case COMMAND_TELL:{
  1979. if(sep && sep->arg[0] && sep->argplus[1]){
  1980. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1]))
  1981. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1982. }else
  1983. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1984. break;
  1985. }
  1986. case COMMAND_SHOUT:{
  1987. if(sep && sep->arg[0][0])
  1988. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1989. else
  1990. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1991. break;
  1992. }
  1993. case COMMAND_AUCTION:{
  1994. if(sep && sep->arg[0][0])
  1995. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1996. else
  1997. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1998. break;
  1999. }
  2000. case COMMAND_OOC:{
  2001. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2002. if(sep && sep->arg[0][0])
  2003. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0]);
  2004. else
  2005. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2006. break;
  2007. }
  2008. case COMMAND_EMOTE:{
  2009. if(sep && sep->arg[0][0])
  2010. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2011. else
  2012. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2013. break;
  2014. }
  2015. case COMMAND_RACE:{
  2016. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2017. if(sep->arg[1][0] && sep->IsNumber(1)){
  2018. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2019. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2020. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2021. client->GetPlayer()->SetCharSheetChanged(true);
  2022. }
  2023. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2024. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2025. //client->QueuePacket(outapp);
  2026. }
  2027. else{
  2028. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2029. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2030. }
  2031. break;
  2032. }
  2033. case COMMAND_BANK_DEPOSIT:{
  2034. if(client->GetBanker() && sep && sep->arg[0]){
  2035. int64 amount = 0;
  2036. string deposit = string(sep->arg[0]);
  2037. amount = atoi64(deposit.c_str());
  2038. client->BankDeposit(amount);
  2039. }
  2040. break;
  2041. }
  2042. case COMMAND_BANK_WITHDRAWAL:{
  2043. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2044. int64 amount = 0;
  2045. string deposit = string(sep->arg[0]);
  2046. amount = atoi64(deposit.c_str());
  2047. client->BankWithdrawal(amount);
  2048. }
  2049. break;
  2050. }
  2051. case COMMAND_BANK_CANCEL:{
  2052. Spawn* banker = cmdTarget;
  2053. client->Bank(banker, true);
  2054. break;
  2055. }
  2056. case COMMAND_BANK:{
  2057. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2058. Spawn* banker = cmdTarget;
  2059. client->Bank(banker);
  2060. break;
  2061. }
  2062. case COMMAND_GUILD_BANK:{
  2063. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2064. //Spawn* banker = client->GetPlayer()->GetTarget();
  2065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2066. break;
  2067. }
  2068. case COMMAND_START_MAIL: {
  2069. client->SetMailTransaction(cmdTarget);
  2070. client->SendMailList();
  2071. break;
  2072. }
  2073. case COMMAND_CANCEL_MAIL: {
  2074. client->SetMailTransaction(0);
  2075. break;
  2076. }
  2077. case COMMAND_GET_MAIL_MESSAGE: {
  2078. if (sep && sep->arg[0] && sep->IsNumber(0))
  2079. client->DisplayMailMessage(atoul(sep->arg[0]));
  2080. break;
  2081. }
  2082. case COMMAND_ADD_MAIL_PLAT: {
  2083. if (sep && sep->arg[0] && sep->IsNumber(0))
  2084. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2085. break;
  2086. }
  2087. case COMMAND_ADD_MAIL_GOLD: {
  2088. if (sep && sep->arg[0] && sep->IsNumber(0))
  2089. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2090. break;
  2091. }
  2092. case COMMAND_ADD_MAIL_SILVER: {
  2093. if (sep && sep->arg[0] && sep->IsNumber(0))
  2094. client->AddMailCoin(0, atoul(sep->arg[0]));
  2095. break;
  2096. }
  2097. case COMMAND_ADD_MAIL_COPPER: {
  2098. if (sep && sep->arg[0] && sep->IsNumber(0))
  2099. client->AddMailCoin(atoul(sep->arg[0]));
  2100. break;
  2101. }
  2102. case COMMAND_SET_MAIL_ITEM: {
  2103. if(sep && sep->IsNumber(0))
  2104. {
  2105. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2106. if(item)
  2107. {
  2108. int16 quantity = atoul(sep->arg[1]);
  2109. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2110. {
  2111. return;
  2112. }
  2113. if(item->IsBag())
  2114. {
  2115. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2116. if(bag_items && bag_items->size() > 0)
  2117. {
  2118. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2119. safe_delete(bag_items);
  2120. return;
  2121. }
  2122. safe_delete(bag_items);
  2123. }
  2124. Item* itemtoadd = item;
  2125. if(quantity > 0)
  2126. {
  2127. if(quantity > item->details.count)
  2128. return;
  2129. Item* tmpItem = new Item(item);
  2130. tmpItem->details.count = quantity;
  2131. itemtoadd = tmpItem;
  2132. }
  2133. if(client->AddMailItem(itemtoadd))
  2134. {
  2135. client->RemoveItem(item, quantity, true);
  2136. }
  2137. }
  2138. }
  2139. break;
  2140. }
  2141. case COMMAND_REMOVE_MAIL_PLAT: {
  2142. if (sep && sep->arg[0] && sep->IsNumber(0))
  2143. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2144. break;
  2145. }
  2146. case COMMAND_REMOVE_MAIL_GOLD: {
  2147. if (sep && sep->arg[0] && sep->IsNumber(0))
  2148. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2149. break;
  2150. }
  2151. case COMMAND_REMOVE_MAIL_SILVER: {
  2152. if (sep && sep->arg[0] && sep->IsNumber(0))
  2153. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2154. break;
  2155. }
  2156. case COMMAND_REMOVE_MAIL_COPPER: {
  2157. if (sep && sep->arg[0] && sep->IsNumber(0))
  2158. client->RemoveMailCoin(atoul(sep->arg[0]));
  2159. break;
  2160. }
  2161. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2162. if (sep && sep->arg[0] && sep->IsNumber(0))
  2163. client->TakeMailAttachments(atoul(sep->arg[0]));
  2164. break;
  2165. }
  2166. case COMMAND_CANCEL_SEND_MAIL: {
  2167. client->ResetSendMail();
  2168. break;
  2169. }
  2170. case COMMAND_DELETE_MAIL_MESSAGE: {
  2171. if (sep && sep->arg[0] && sep->IsNumber(0))
  2172. client->DeleteMail(atoul(sep->arg[0]), true);
  2173. break;
  2174. }
  2175. case COMMAND_REPORT_SPAM: {
  2176. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2177. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2178. break;
  2179. }
  2180. case COMMAND_KILL:{
  2181. Spawn* dead = 0;
  2182. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2183. dead=client->GetPlayer();
  2184. client->GetPlayer()->SetHP(0);
  2185. client->GetPlayer()->KillSpawn(dead);
  2186. }else{
  2187. dead= cmdTarget;
  2188. if(dead && dead->IsPlayer() == false){
  2189. dead->SetHP(0);
  2190. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2191. client->GetCurrentZone()->RemoveSpawn(dead, true);
  2192. else
  2193. client->GetPlayer()->KillSpawn(dead);
  2194. }else{
  2195. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2196. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2197. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2198. }
  2199. }
  2200. break;
  2201. }
  2202. case COMMAND_LEVEL:{
  2203. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2204. int16 new_level = atoi(sep->arg[ndx]);
  2205. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2206. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2207. else {
  2208. if (new_level < 1)
  2209. new_level = 1;
  2210. if (new_level > 255)
  2211. new_level = 255;
  2212. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2213. }
  2214. }else
  2215. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2216. break;
  2217. }
  2218. case COMMAND_SIT: {
  2219. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2220. if(client->GetPlayer()->GetHP() > 0){
  2221. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2222. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2223. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2224. }
  2225. break;
  2226. }
  2227. case COMMAND_STAND: {
  2228. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2229. if(client->GetPlayer()->GetHP() > 0){
  2230. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2231. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2232. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2233. }
  2234. break;
  2235. }
  2236. case COMMAND_CLASS:{
  2237. if(sep && sep->arg[ndx][0]){
  2238. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2239. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2240. }else
  2241. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2242. break;
  2243. }
  2244. case COMMAND_GENDER:{
  2245. if(sep && sep->arg[ndx][0]){
  2246. client->GetPlayer()->GetInfoStruct()->set_gender(atoi(sep->arg[ndx]));
  2247. client->GetPlayer()->SetCharSheetChanged(true);
  2248. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  2249. }else{
  2250. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  2251. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  2252. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  2253. }
  2254. break;
  2255. }
  2256. case COMMAND_FLYMODE:{
  2257. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2258. PrintSep(sep, "COMMAND_FLYMODE");
  2259. int8 val = atoi(sep->arg[0]);
  2260. ClientPacketFunctions::SendFlyMode(client, val);
  2261. }
  2262. else{
  2263. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  2264. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2265. }
  2266. break;
  2267. }
  2268. case COMMAND_LOOT_LIST:{
  2269. Spawn* spawn = cmdTarget;
  2270. if(spawn && spawn->IsEntity()){
  2271. if (sep && sep->arg[0]) {
  2272. if (!spawn->GetDatabaseID())
  2273. {
  2274. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  2275. break;
  2276. }
  2277. else if (!spawn->IsNPC())
  2278. {
  2279. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2280. break;
  2281. }
  2282. bool reloadLoot = false;
  2283. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2284. {
  2285. int32 loottable_id = atoul(sep->arg[1]);
  2286. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2287. {
  2288. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2289. reloadLoot = true;
  2290. }
  2291. else
  2292. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2293. }
  2294. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2295. {
  2296. int32 loottable_id = atoul(sep->arg[1]);
  2297. if (loottable_id > 0)
  2298. {
  2299. database.AddLootTableToSpawn(spawn, loottable_id);
  2300. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2301. reloadLoot = true;
  2302. }
  2303. else
  2304. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2305. }
  2306. else if (!stricmp(sep->arg[0], "clearall"))
  2307. {
  2308. if (database.RemoveSpawnLootTable(spawn, 0))
  2309. {
  2310. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2311. reloadLoot = true;
  2312. }
  2313. else
  2314. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2315. }
  2316. else
  2317. {
  2318. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2319. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2320. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2321. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2322. break;
  2323. }
  2324. if (reloadLoot)
  2325. {
  2326. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2327. if (spawn->IsNPC())
  2328. {
  2329. Entity* ent = (Entity*)spawn;
  2330. ent->SetLootCoins(0);
  2331. ent->ClearLootList();
  2332. spawn->GetZone()->AddLoot((NPC*)spawn);
  2333. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2334. }
  2335. }
  2336. break; // nothing further this is the end of these sub commands
  2337. }
  2338. else
  2339. {
  2340. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  2341. if (loot_list.size() > 0) {
  2342. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2343. vector<int32>::iterator list_itr;
  2344. LootTable* table = 0;
  2345. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2346. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2347. if (table)
  2348. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2349. }
  2350. }
  2351. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2352. vector<Item*>* items = spawn->GetLootItems();
  2353. if (items) {
  2354. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2355. vector<Item*>::iterator itr;
  2356. Item* item = 0;
  2357. for (itr = items->begin(); itr != items->end(); itr++) {
  2358. item = *itr;
  2359. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2360. }
  2361. }
  2362. else
  2363. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2364. }
  2365. }
  2366. break;
  2367. }
  2368. case COMMAND_LOOT_SETCOIN:{
  2369. Spawn* spawn = cmdTarget;
  2370. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2371. spawn->SetLootCoins(atoul(sep->arg[0]));
  2372. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2373. }
  2374. else
  2375. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2376. break;
  2377. }
  2378. case COMMAND_LOOT_ADDITEM:{
  2379. Spawn* spawn = cmdTarget;
  2380. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2381. int16 charges = 1;
  2382. if(sep->arg[1] && sep->IsNumber(1))
  2383. charges = atoi(sep->arg[1]);
  2384. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2385. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2386. }
  2387. else
  2388. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2389. break;
  2390. }
  2391. case COMMAND_LOOT_REMOVEITEM:{
  2392. Spawn* spawn = cmdTarget;
  2393. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2394. spawn->LootItem(atoul(sep->arg[0]));
  2395. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2396. }
  2397. else
  2398. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2399. break;
  2400. }
  2401. case COMMAND_LOOT_CORPSE:
  2402. case COMMAND_DISARM:
  2403. case COMMAND_LOOT:{
  2404. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2405. {
  2406. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2407. break;
  2408. }
  2409. if(cmdTarget && cmdTarget->IsEntity()){
  2410. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2411. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2412. client->OpenChest(cmdTarget, true);
  2413. else
  2414. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2415. if (!(cmdTarget)->HasLoot()){
  2416. if (((Entity*)cmdTarget)->IsNPC())
  2417. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2418. }
  2419. }
  2420. else
  2421. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2422. }
  2423. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2424. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2425. break;
  2426. }
  2427. case COMMAND_RELOADSPAWNSCRIPTS:{
  2428. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2429. if (lua_interface)
  2430. lua_interface->SetSpawnScriptsReloading(true);
  2431. world.ResetSpawnScripts();
  2432. database.LoadSpawnScriptData();
  2433. if(lua_interface) {
  2434. lua_interface->DestroySpawnScripts();
  2435. lua_interface->SetSpawnScriptsReloading(false);
  2436. }
  2437. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2438. break;
  2439. }
  2440. case COMMAND_RELOADREGIONSCRIPTS:{
  2441. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2442. if(lua_interface) {
  2443. lua_interface->DestroyRegionScripts();
  2444. }
  2445. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2446. break;
  2447. }
  2448. case COMMAND_RELOADLUASYSTEM:{
  2449. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2450. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2451. safe_delete(lua_interface);
  2452. lua_interface = new LuaInterface();
  2453. if(lua_interface)
  2454. lua_interface->SetSpawnScriptsReloading(true);
  2455. if(lua_interface && debug_clients.size() > 0){
  2456. map<Client*, int32>::iterator itr;
  2457. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2458. if(lua_interface)
  2459. lua_interface->UpdateDebugClients(itr->first);
  2460. }
  2461. }
  2462. world.ResetSpawnScripts();
  2463. database.LoadSpawnScriptData();
  2464. world.ResetZoneScripts();
  2465. database.LoadZoneScriptData();
  2466. int32 quest_count = database.LoadQuests();
  2467. zone_list.DeleteSpellProcess();
  2468. master_spell_list.Reload();
  2469. int32 spell_count = 0;
  2470. if(lua_interface) {
  2471. lua_interface->DestroySpawnScripts();
  2472. lua_interface->DestroySpells();
  2473. spell_count = database.LoadSpellScriptData();
  2474. lua_interface->SetSpawnScriptsReloading(false);
  2475. }
  2476. zone_list.LoadSpellProcess();
  2477. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2478. break;
  2479. }
  2480. case COMMAND_DECLINE_QUEST:{
  2481. int32 quest_id = 0;
  2482. if(sep && sep->arg[0] && sep->IsNumber(0))
  2483. quest_id = atoul(sep->arg[0]);
  2484. if(quest_id > 0){
  2485. Quest* quest = client->GetPendingQuest(quest_id);
  2486. if(quest){
  2487. client->RemovePendingQuest(quest);
  2488. if(lua_interface)
  2489. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2490. safe_delete(quest);
  2491. client->GetCurrentZone()->SendQuestUpdates(client);
  2492. }
  2493. }
  2494. break;
  2495. }
  2496. case COMMAND_DELETE_QUEST:{
  2497. int32 quest_id = 0;
  2498. if(sep && sep->arg[0] && sep->IsNumber(0))
  2499. quest_id = atoul(sep->arg[0]);
  2500. if(quest_id > 0){
  2501. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2502. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2503. if (quest)
  2504. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2505. }
  2506. client->RemovePlayerQuest(quest_id);
  2507. client->GetCurrentZone()->SendQuestUpdates(client);
  2508. }
  2509. break;
  2510. }
  2511. case COMMAND_ACCEPT_QUEST:{
  2512. int32 quest_id = 0;
  2513. if(sep && sep->arg[0] && sep->IsNumber(0))
  2514. quest_id = atoul(sep->arg[0]);
  2515. if(quest_id > 0){
  2516. client->AcceptQuest(quest_id);
  2517. }
  2518. break;
  2519. }
  2520. case COMMAND_NAME:{
  2521. if(sep && sep->arg[ndx][0]){
  2522. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  2523. client->GetPlayer()->SetCharSheetChanged(true);
  2524. }else
  2525. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2526. break;
  2527. }
  2528. case COMMAND_GROUPSAY:{
  2529. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2530. if(sep && sep->arg[0] && gmi)
  2531. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2532. break;
  2533. }
  2534. case COMMAND_GROUPINVITE: {
  2535. Entity* target = 0;
  2536. Client* target_client = 0;
  2537. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2538. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2539. return;
  2540. }
  2541. // name provided with command so it has to be a player, npc not supported here
  2542. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2543. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2544. if (target_client) {
  2545. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2546. target = 0;
  2547. else
  2548. target = target_client->GetPlayer();
  2549. }
  2550. }
  2551. // if name was not provided use the players target, npc or player supported here
  2552. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2553. target = (Entity*)client->GetPlayer()->GetTarget();
  2554. if (target->IsPlayer()) {
  2555. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2556. }
  2557. }
  2558. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2559. if (result == 0) {
  2560. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2561. if (target_client) {
  2562. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2563. if (packet) {
  2564. packet->setDataByName("type", 1);
  2565. packet->setDataByName("name", client->GetPlayer()->GetName());
  2566. packet->setDataByName("unknown2", 1);
  2567. target_client->QueuePacket(packet->serialize());
  2568. safe_delete(packet);
  2569. }
  2570. }
  2571. }
  2572. else if (result == 1)
  2573. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2574. else if (result == 2)
  2575. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2576. else if (result == 3)
  2577. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2578. else if (result == 4)
  2579. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2580. else if (result == 5)
  2581. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2582. else if (result == 6)
  2583. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2584. else
  2585. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2586. break;
  2587. }
  2588. case COMMAND_GROUPDISBAND: {
  2589. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2590. if (gmi) { // TODO: Leader check
  2591. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2592. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2593. }
  2594. break;
  2595. }
  2596. case COMMAND_GROUP_LEAVE: {
  2597. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2598. if (gmi) {
  2599. int32 group_id = gmi->group_id;
  2600. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2601. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2602. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2603. }
  2604. else {
  2605. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2606. }
  2607. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  2608. }
  2609. break;
  2610. }
  2611. case COMMAND_FRIEND_ADD:{
  2612. string name = "";
  2613. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2614. name = database.GetPlayerName(sep->arg[0]);
  2615. else if(cmdTarget && cmdTarget->IsPlayer())
  2616. name = string(cmdTarget->GetName());
  2617. if(name.length() > 0){
  2618. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2619. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2620. client->GetPlayer()->RemoveIgnore(name.c_str());
  2621. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2622. client->SendChatRelationship(3, name.c_str());
  2623. }
  2624. client->GetPlayer()->AddFriend(name.c_str(), true);
  2625. client->SendChatRelationship(0, name.c_str());
  2626. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2627. if(zone_list.GetClientByCharName(name))
  2628. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2629. }
  2630. else
  2631. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2632. }
  2633. else
  2634. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2635. break;
  2636. }
  2637. case COMMAND_FRIEND_REMOVE:{
  2638. string name = "";
  2639. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2640. name = database.GetPlayerName(sep->arg[0]);
  2641. else if(cmdTarget && cmdTarget->IsPlayer())
  2642. name = string(cmdTarget->GetName());
  2643. if(name.length() > 0){
  2644. client->GetPlayer()->RemoveFriend(name.c_str());
  2645. client->SendChatRelationship(1, name.c_str());
  2646. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2647. }
  2648. else
  2649. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2650. break;
  2651. }
  2652. case COMMAND_FRIENDS:{
  2653. break;
  2654. }
  2655. case COMMAND_IGNORE_ADD:{
  2656. string name = "";
  2657. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2658. name = database.GetPlayerName(sep->arg[0]);
  2659. else if(cmdTarget && cmdTarget->IsPlayer())
  2660. name = string(cmdTarget->GetName());
  2661. if(name.length() > 0){
  2662. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2663. if(client->GetPlayer()->IsFriend(name.c_str())){
  2664. client->GetPlayer()->RemoveFriend(name.c_str());
  2665. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2666. client->SendChatRelationship(1, name.c_str());
  2667. }
  2668. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2669. client->SendChatRelationship(2, name.c_str());
  2670. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2671. }
  2672. else
  2673. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2674. }
  2675. else
  2676. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2677. break;
  2678. }
  2679. case COMMAND_IGNORE_REMOVE:{
  2680. string name = "";
  2681. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2682. name = database.GetPlayerName(sep->arg[0]);
  2683. else if(cmdTarget && cmdTarget->IsPlayer())
  2684. name = string(cmdTarget->GetName());
  2685. if(name.length() > 0){
  2686. client->GetPlayer()->RemoveIgnore(name.c_str());
  2687. client->SendChatRelationship(3, name.c_str());
  2688. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2689. }
  2690. break;
  2691. }
  2692. case COMMAND_IGNORES:{
  2693. break;
  2694. }
  2695. case COMMAND_GROUP_KICK:{
  2696. Entity* kicked = 0;
  2697. Client* kicked_client = 0;
  2698. int32 group_id = 0;
  2699. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2700. return;
  2701. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2702. if (sep && sep->arg[0]) {
  2703. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2704. if (kicked_client)
  2705. kicked = kicked_client->GetPlayer();
  2706. }
  2707. else if (cmdTarget && cmdTarget->IsEntity()) {
  2708. kicked = (Entity*)cmdTarget;
  2709. }
  2710. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2711. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2712. if (kicked)
  2713. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2714. if(send_kicked_message)
  2715. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2716. else
  2717. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  2718. if (kicked_client)
  2719. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  2720. break;
  2721. }
  2722. case COMMAND_GROUP_MAKE_LEADER:{
  2723. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2724. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2725. return;
  2726. }
  2727. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2728. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2729. if (new_leader) {
  2730. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2731. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2732. }
  2733. }
  2734. else
  2735. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2736. }
  2737. else if (cmdTarget && cmdTarget->IsPlayer())
  2738. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2739. else
  2740. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2741. break;
  2742. }
  2743. case COMMAND_GROUP_ACCEPT_INVITE: {
  2744. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2745. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2746. if (result == 0)
  2747. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  2748. else if (result == 1)
  2749. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  2750. else if (result == 2)
  2751. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  2752. else
  2753. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  2754. }
  2755. break;
  2756. }
  2757. case COMMAND_GROUP_DECLINE_INVITE: {
  2758. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2759. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2760. }
  2761. break;
  2762. }
  2763. case COMMAND_SUMMON:{
  2764. char* search_name = 0;
  2765. if(sep && sep->arg[0][0])
  2766. search_name = sep->arg[0];
  2767. if(!search_name && !cmdTarget){
  2768. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2769. 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.");
  2770. }
  2771. else{
  2772. if(!client->Summon(search_name))
  2773. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2774. }
  2775. break;
  2776. }
  2777. case COMMAND_GOTO:{
  2778. const char* search_name = 0;
  2779. if(sep && sep->arg[0][0])
  2780. search_name = sep->argplus[0];
  2781. if(!search_name && !cmdTarget){
  2782. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2783. 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.");
  2784. }
  2785. else{
  2786. if(!client->GotoSpawn(search_name))
  2787. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2788. }
  2789. break;
  2790. }
  2791. case COMMAND_MOVE:{
  2792. bool success = false;
  2793. try{
  2794. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2795. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2796. if(app){
  2797. client->QueuePacket(app);
  2798. success = true;
  2799. }
  2800. }
  2801. }
  2802. catch(...){}
  2803. if(!success){
  2804. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2805. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2806. }
  2807. break;
  2808. }
  2809. case COMMAND_SETTIME:{
  2810. if(sep && sep->arg[0]){
  2811. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2812. if(sep->arg[1] && sep->IsNumber(1))
  2813. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2814. if(sep->arg[2] && sep->IsNumber(2))
  2815. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2816. if(sep->arg[3] && sep->IsNumber(3))
  2817. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2818. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2819. }
  2820. else{
  2821. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2822. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2823. }
  2824. break;
  2825. }
  2826. case COMMAND_VERSION:{
  2827. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2828. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2829. break;
  2830. }
  2831. case COMMAND_ZONE:{
  2832. int32 instanceID = 0;
  2833. string zone;
  2834. int32 zone_id = 0;
  2835. bool listSearch = false;
  2836. bool isInstance = false;
  2837. ZoneServer* zsZone = 0;
  2838. if(sep && sep->arg[0][0])
  2839. {
  2840. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2841. listSearch = true;
  2842. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2843. {
  2844. zone_list.SendZoneList(client);
  2845. break;
  2846. }
  2847. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2848. {
  2849. if(sep->IsNumber(1))
  2850. instanceID = atol(sep->arg[1]);
  2851. }
  2852. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2853. {
  2854. PrintSep(sep, "ZONE LOCK");
  2855. if(sep->IsNumber(1))
  2856. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2857. else
  2858. zsZone = zone_list.Get(sep->arg[1], false);
  2859. if( zsZone )
  2860. {
  2861. zsZone->SetZoneLockState(true);
  2862. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2863. }
  2864. else
  2865. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2866. break;
  2867. }
  2868. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2869. {
  2870. PrintSep(sep, "ZONE UNLOCK");
  2871. if(sep->IsNumber(1))
  2872. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2873. else
  2874. zsZone = zone_list.Get(sep->arg[1], false);
  2875. if( zsZone )
  2876. {
  2877. zsZone->SetZoneLockState(false);
  2878. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2879. }
  2880. else
  2881. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2882. break;
  2883. }
  2884. else
  2885. {
  2886. if(sep->IsNumber(0))
  2887. {
  2888. zone_id = atoul(sep->arg[0]);
  2889. string zonename = database.GetZoneName(zone_id);
  2890. if(zonename.length() > 0)
  2891. zone = zonename;
  2892. }
  2893. else
  2894. zone = sep->arg[0];
  2895. }
  2896. if(instanceID > 0)
  2897. {
  2898. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2899. if(zsInstance != NULL)
  2900. {
  2901. instanceID = zsInstance->GetInstanceID();
  2902. zone = zsInstance->GetZoneName();
  2903. zone_id = zsInstance->GetZoneID();
  2904. isInstance = true;
  2905. }
  2906. }
  2907. }
  2908. if(!listSearch)
  2909. {
  2910. if(zone.length() == 0)
  2911. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2912. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2913. zone_id != client->GetCurrentZone()->GetZoneID())
  2914. {
  2915. const char* zonestr = zone.c_str();
  2916. if(database.VerifyZone(zonestr))
  2917. {
  2918. if(client->CheckZoneAccess(zonestr))
  2919. {
  2920. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  2921. if(isInstance)
  2922. client->Zone(instanceID,true,true);
  2923. else
  2924. client->Zone(zonestr);
  2925. }
  2926. }
  2927. else
  2928. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  2929. }
  2930. else
  2931. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2932. }
  2933. else
  2934. {
  2935. const char* name = 0;
  2936. if(sep && sep->arg[1][0])
  2937. {
  2938. map<int32, string>* zone_names;
  2939. name = sep->argplus[1];
  2940. sint16 status = client->GetAdminStatus();
  2941. if( status > 0 )
  2942. {
  2943. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2944. zone_names = database.GetZoneList(name, true);
  2945. }
  2946. else
  2947. zone_names = database.GetZoneList(name);
  2948. if(!zone_names)
  2949. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2950. else
  2951. {
  2952. map<int32, string>::iterator itr;
  2953. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2954. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2955. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2956. safe_delete(zone_names);
  2957. }
  2958. }
  2959. else
  2960. {
  2961. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2962. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2963. }
  2964. }
  2965. break;
  2966. }
  2967. case COMMAND_USE: {
  2968. Spawn* target = cmdTarget;
  2969. if (target->IsWidget())
  2970. ((Widget*)target)->HandleUse(client, "use");
  2971. break;
  2972. }
  2973. case COMMAND_OPEN: {
  2974. Spawn* target = cmdTarget;
  2975. if (target->IsWidget())
  2976. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2977. break;
  2978. }
  2979. case COMMAND_CASTSPELL: {
  2980. if (sep && sep->arg[0] && sep->IsNumber(0))
  2981. {
  2982. int8 tier = 1;
  2983. if (sep->arg[1] && sep->IsNumber(1))
  2984. tier = atoul(sep->arg[1]);
  2985. int8 self = 1;
  2986. if (sep->arg[1] && sep->IsNumber(2))
  2987. {
  2988. self = atoul(sep->arg[2]);
  2989. if(self != 1 && !cmdTarget->IsEntity())
  2990. {
  2991. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  2992. self = 1;
  2993. }
  2994. }
  2995. int32 spellid = atoul(sep->arg[0]);
  2996. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2997. if (spell)
  2998. {
  2999. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3000. SpellProcess* spellProcess = 0;
  3001. // Get the current zones spell process
  3002. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3003. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3004. }
  3005. else
  3006. {
  3007. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3008. }
  3009. }
  3010. else if (sep && sep->arg[0])
  3011. {
  3012. database.FindSpell(client, (char*)sep->argplus[0]);
  3013. }
  3014. else
  3015. {
  3016. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3017. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3018. }
  3019. break;
  3020. }
  3021. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3022. if (client->GetVersion() <= 546)
  3023. break;
  3024. if (sep && sep->GetArgNumber() == 4)
  3025. {
  3026. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3027. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3028. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3029. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3030. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  3031. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3032. ClientPacketFunctions::SendSkillSlotMappings(client);
  3033. }
  3034. else
  3035. {
  3036. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3037. }
  3038. break;
  3039. }
  3040. case COMMAND_MOVE_ITEM:
  3041. {
  3042. int32 id = 0;
  3043. if (sep->IsNumber(0))
  3044. id = atoul(sep->arg[0]);
  3045. Spawn* spawn = 0;
  3046. if (id == 0)
  3047. {
  3048. spawn = cmdTarget;
  3049. }
  3050. else
  3051. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3052. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3053. break;
  3054. client->SendMoveObjectMode(spawn, 0);
  3055. break;
  3056. }
  3057. case COMMAND_PICKUP:
  3058. {
  3059. int32 id = 0;
  3060. if (sep->IsNumber(0))
  3061. id = atoul(sep->arg[0]);
  3062. Spawn* spawn = 0;
  3063. if (id == 0)
  3064. {
  3065. spawn = cmdTarget;
  3066. }
  3067. else
  3068. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3069. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3070. break;
  3071. client->AddItem(spawn->GetPickupItemID(), 1);
  3072. Query query;
  3073. 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());
  3074. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3075. client->GetCurrentZone()->RemoveSpawn(spawn, true, true);
  3076. }
  3077. // we had a UI Window displayed, update the house items
  3078. if ( id > 0 )
  3079. client->GetCurrentZone()->SendHouseItems(client);
  3080. break;
  3081. }
  3082. case COMMAND_HOUSE_DEPOSIT:
  3083. {
  3084. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3085. // arg0 = ??? (set to 3)
  3086. // arg1 = coin (in copper)
  3087. // arg2 = status? (not implemented yet)
  3088. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3089. if (ph && sep && sep->IsNumber(1))
  3090. {
  3091. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3092. int32 outValStatus = 0;
  3093. if(sep->IsNumber(2))
  3094. {
  3095. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3096. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3097. outValStatus = 0; // cheat check
  3098. }
  3099. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3100. {
  3101. if(outValStatus)
  3102. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3103. char query[256];
  3104. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3105. if (itr != ph->depositsMap.end())
  3106. {
  3107. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %I64u, last_amount = %I64u, 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());
  3108. }
  3109. else
  3110. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %I64u, status = %u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outValCoin, outValStatus);
  3111. if (database.RunQuery(query, strnlen(query, 256)))
  3112. {
  3113. ph->escrow_coins += outValCoin;
  3114. ph->escrow_status += outValStatus;
  3115. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3116. database.LoadDeposits(ph);
  3117. client->PlaySound("coin_cha_ching");
  3118. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3119. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3120. }
  3121. else
  3122. {
  3123. if(outValCoin)
  3124. client->GetPlayer()->AddCoins(outValCoin);
  3125. if(outValStatus)
  3126. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3127. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3128. }
  3129. }
  3130. }
  3131. break;
  3132. }
  3133. case COMMAND_HOUSE:
  3134. {
  3135. if (sep && sep->IsNumber(0))
  3136. {
  3137. int32 unique_id = atoi(sep->arg[0]);
  3138. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3139. HouseZone* hz = 0;
  3140. if (ph)
  3141. hz = world.GetHouseZone(ph->house_id);
  3142. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3143. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3144. }
  3145. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3146. {
  3147. // inside a house or something? Send the access window
  3148. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3149. HouseZone* hz = 0;
  3150. if ( ph )
  3151. hz = world.GetHouseZone(ph->house_id);
  3152. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3153. client->GetCurrentZone()->SendHouseItems(client);
  3154. }
  3155. break;
  3156. }
  3157. case COMMAND_HOUSE_UI:
  3158. {
  3159. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3160. {
  3161. int32 unique_id = atoi(sep->arg[0]);
  3162. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3163. HouseZone* hz = 0;
  3164. if ( ph )
  3165. hz = world.GetHouseZone(ph->house_id);
  3166. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3167. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  3168. }
  3169. break;
  3170. }
  3171. case COMMAND_PLACE_HOUSE_ITEM: {
  3172. if (sep && sep->IsNumber(0))
  3173. {
  3174. int32 uniqueid = atoi(sep->arg[0]);
  3175. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3176. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3177. if (item && item->IsHouseItem())
  3178. {
  3179. if (!client->HasOwnerOrEditAccess())
  3180. {
  3181. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3182. break;
  3183. }
  3184. else if (!item->generic_info.appearance_id)
  3185. {
  3186. 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);
  3187. break;
  3188. }
  3189. if (client->GetTempPlacementSpawn())
  3190. {
  3191. Spawn* tmp = client->GetTempPlacementSpawn();
  3192. client->GetCurrentZone()->RemoveSpawn(tmp);
  3193. client->SetTempPlacementSpawn(nullptr);
  3194. }
  3195. Spawn* spawn = new Object();
  3196. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3197. spawn->SetID(Spawn::NextID());
  3198. spawn->SetX(client->GetPlayer()->GetX());
  3199. spawn->SetY(client->GetPlayer()->GetY());
  3200. spawn->SetZ(client->GetPlayer()->GetZ());
  3201. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3202. spawn->SetSpawnOrigX(spawn->GetX());
  3203. spawn->SetSpawnOrigY(spawn->GetY());
  3204. spawn->SetSpawnOrigZ(spawn->GetZ());
  3205. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3206. spawn->appearance.targetable = 1;
  3207. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3208. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3209. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3210. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3211. spawn->SetZone(client->GetCurrentZone());
  3212. client->GetCurrentZone()->SendSpawn(spawn, client);
  3213. client->SetTempPlacementSpawn(spawn);
  3214. client->SetPlacementUniqueItemID(uniqueid);
  3215. client->SendMoveObjectMode(spawn, 0);
  3216. }
  3217. }
  3218. break;
  3219. }
  3220. case COMMAND_GM:
  3221. {
  3222. if (sep && sep->arg[0] && sep->arg[1])
  3223. {
  3224. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3225. if (strcmp(sep->arg[0], "vision") == 0)
  3226. {
  3227. client->GetPlayer()->SetGMVision(onOff);
  3228. #if defined(__GNUC__)
  3229. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3230. #else
  3231. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3232. #endif
  3233. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3234. if (onOff)
  3235. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3236. else
  3237. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3238. }
  3239. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3240. {
  3241. client->SetRegionDebug(onOff);
  3242. #if defined(__GNUC__)
  3243. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3244. #else
  3245. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3246. #endif
  3247. if (onOff)
  3248. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  3249. else
  3250. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  3251. }
  3252. else if (strcmp(sep->arg[0], "luadebug") == 0)
  3253. {
  3254. client->SetLuaDebugClient(onOff);
  3255. #if defined(__GNUC__)
  3256. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3257. #else
  3258. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  3259. #endif
  3260. if (onOff)
  3261. {
  3262. if (lua_interface)
  3263. lua_interface->UpdateDebugClients(client);
  3264. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3265. }
  3266. else
  3267. {
  3268. if (lua_interface)
  3269. lua_interface->RemoveDebugClients(client);
  3270. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3271. }
  3272. }
  3273. }
  3274. break;
  3275. }
  3276. case COMMAND_ATTACK:
  3277. case COMMAND_AUTO_ATTACK:{
  3278. int8 type = 1;
  3279. Player* player = client->GetPlayer();
  3280. if(!player)
  3281. break;
  3282. bool incombat = player->EngagedInCombat();
  3283. if(sep && sep->arg[0] && sep->IsNumber(0))
  3284. type = atoi(sep->arg[0]);
  3285. if(client->GetPlayer()->GetHP() == 0){
  3286. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  3287. break;
  3288. }
  3289. if(type == 0){
  3290. if(incombat)
  3291. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3292. player->StopCombat(type);
  3293. }
  3294. else {
  3295. if(type == 2){
  3296. player->InCombat(false);
  3297. if(incombat && player->GetRangeAttack()){
  3298. player->StopCombat(type);
  3299. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3300. }
  3301. else{
  3302. player->SetRangeAttack(true);
  3303. player->InCombat(true, true);
  3304. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3305. }
  3306. }
  3307. else {
  3308. player->InCombat(false, true);
  3309. player->SetRangeAttack(false);
  3310. player->InCombat(true);
  3311. if(!incombat)
  3312. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3313. }
  3314. /*else
  3315. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  3316. }
  3317. player->SetCharSheetChanged(true);
  3318. break;
  3319. }
  3320. case COMMAND_DEPOP:{
  3321. bool allow_respawns = false;
  3322. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3323. if(atoi(sep->arg[0]) == 1)
  3324. allow_respawns = true;
  3325. }
  3326. client->GetCurrentZone()->Depop(allow_respawns);
  3327. break;
  3328. }
  3329. case COMMAND_REPOP:{
  3330. client->GetCurrentZone()->Depop(false, true);
  3331. break;
  3332. }
  3333. case COMMAND_BUYBACK:{
  3334. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3335. // 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
  3336. int64 id = atoi64(sep->arg[0]);
  3337. // get the first int32, the item id
  3338. //int32 item_id = (int32)id;
  3339. // get the second int32, the unique id
  3340. int32 unique_id = (int32)(id>>32);
  3341. int8 quantity = atoi(sep->arg[1]);
  3342. if(quantity == 255)
  3343. quantity = 1;
  3344. client->BuyBack(unique_id, quantity);
  3345. }
  3346. break;
  3347. }
  3348. case COMMAND_MERCHANT_BUY:{
  3349. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3350. int32 item_id = atoul(sep->arg[0]);
  3351. int8 quantity = atoi(sep->arg[1]);
  3352. client->BuyItem(item_id, quantity);
  3353. }
  3354. else
  3355. Command_SendMerchantWindow(client, sep);
  3356. break;
  3357. }
  3358. case COMMAND_MERCHANT_SELL:{
  3359. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3360. // 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
  3361. int64 id = atoi64(sep->arg[0]);
  3362. // get the first int32, the item id
  3363. int32 item_id = (int32)id;
  3364. // get the second int32, the unique id
  3365. int32 unique_id = (int32)(id>>32);
  3366. int8 quantity = atoi(sep->arg[1]);
  3367. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  3368. client->SellItem(item_id, quantity, unique_id);
  3369. }
  3370. break;
  3371. }
  3372. case COMMAND_MENDER_REPAIR: {
  3373. if (sep && sep->arg[0] && sep->IsNumber(0))
  3374. client->RepairItem(atoul(sep->arg[0]));
  3375. break;
  3376. }
  3377. case COMMAND_MENDER_REPAIR_ALL: {
  3378. client->RepairAllItems();
  3379. break;
  3380. }
  3381. case COMMAND_CANCEL_MERCHANT:{
  3382. client->SetMerchantTransaction(0);
  3383. break;
  3384. }
  3385. case COMMAND_START_MERCHANT:{
  3386. break;
  3387. }
  3388. case COMMAND_INVULNERABLE:{
  3389. sint8 val = -1;
  3390. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3391. val = atoi(sep->arg[0]);
  3392. //devn00b: Fix for linux builds
  3393. #if defined(__GNUC__)
  3394. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  3395. #else
  3396. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3397. #endif
  3398. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3399. client->GetPlayer()->SetInvulnerable(val==1);
  3400. if(client->GetPlayer()->GetInvulnerable())
  3401. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  3402. else
  3403. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  3404. }
  3405. if(val == -1)
  3406. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  3407. break;
  3408. }
  3409. case COMMAND_REPAIR: {
  3410. Spawn* spawn = cmdTarget;
  3411. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  3412. client->SendHailCommand(spawn);
  3413. client->SetMerchantTransaction(spawn);
  3414. client->SendRepairList();
  3415. }
  3416. break;
  3417. }
  3418. case COMMAND_LOTTO: {
  3419. Spawn* spawn = cmdTarget;
  3420. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  3421. client->SetMerchantTransaction(spawn);
  3422. client->ShowLottoWindow();
  3423. }
  3424. break;
  3425. }
  3426. case COMMAND_ACCEPT_REWARD:{
  3427. int32 unknown = 0;
  3428. int32 selectable_item_id = 0;
  3429. //Quest *quest = 0;
  3430. Collection *collection = 0;
  3431. /* no idea what the first argument is for (faction maybe?)
  3432. if the reward has a selectable item reward, it's sent as the second argument
  3433. if neither of these are included in the reward, there is no sep
  3434. 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
  3435. only 1 quest or collection reward may be displayed at a time */
  3436. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3437. unknown = atoul(sep->arg[0]);
  3438. selectable_item_id = atoul(sep->arg[1]);
  3439. }
  3440. //if ((quest = player->GetPendingQuestReward()))
  3441. // client->AcceptQuestRewards(quest, selectable_item_id);
  3442. /* the below needs to go away eventually and be redone */
  3443. int32 item_id = 0;
  3444. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3445. item_id = atoul(sep->arg[0]);
  3446. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3447. if(quest){
  3448. client->AcceptQuestReward(quest, item_id);
  3449. break;
  3450. }
  3451. bool collectedItems = false;
  3452. if (collection = player->GetPendingCollectionReward())
  3453. {
  3454. client->AcceptCollectionRewards(collection, selectable_item_id);
  3455. collectedItems = true;
  3456. }
  3457. else if (client->GetPlayer()->HasPendingItemRewards()) {
  3458. vector<Item*> items = client->GetPlayer()->GetPendingItemRewards();
  3459. if (items.size() > 0) {
  3460. collectedItems = true;
  3461. for (int i = 0; i < items.size(); i++) {
  3462. client->GetPlayer()->AddItem(new Item(items[i]));
  3463. }
  3464. client->GetPlayer()->ClearPendingItemRewards();
  3465. }
  3466. map<int32, Item*> selectable_item = client->GetPlayer()->GetPendingSelectableItemReward(item_id);
  3467. if (selectable_item.size() > 0) {
  3468. collectedItems = true;
  3469. map<int32, Item*>::iterator itr;
  3470. for (itr = selectable_item.begin(); itr != selectable_item.end(); itr++) {
  3471. client->GetPlayer()->AddItem(new Item(itr->second));
  3472. client->GetPlayer()->ClearPendingSelectableItemRewards(itr->first);
  3473. }
  3474. }
  3475. }
  3476. if (collectedItems) {
  3477. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  3478. if (outapp)
  3479. client->QueuePacket(outapp);
  3480. }
  3481. else
  3482. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  3483. break;
  3484. }
  3485. case COMMAND_BUY_FROM_BROKER:{
  3486. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3487. int32 item_id = atoul(sep->arg[0]);
  3488. int16 quantity = atoul(sep->arg[1]);
  3489. client->AddItem(item_id, quantity);
  3490. }
  3491. break;
  3492. }
  3493. case COMMAND_SEARCH_STORES_PAGE:{
  3494. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3495. int32 page = atoul(sep->arg[0]);
  3496. client->SearchStore(page);
  3497. }
  3498. break;
  3499. }
  3500. case COMMAND_SEARCH_STORES:{
  3501. if(sep && sep->arg[0][0]){
  3502. const char* values = sep->argplus[0];
  3503. if(values){
  3504. map<string, string> str_values = TranslateBrokerRequest(values);
  3505. vector<Item*>* items = master_item_list.GetItems(str_values);
  3506. if(items){
  3507. client->SetItemSearch(items);
  3508. client->SearchStore(0);
  3509. }
  3510. }
  3511. }
  3512. break;
  3513. }
  3514. case COMMAND_LUADEBUG:{
  3515. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  3516. client->SetLuaDebugClient(true);
  3517. if(lua_interface)
  3518. lua_interface->UpdateDebugClients(client);
  3519. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3520. }
  3521. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  3522. client->SetLuaDebugClient(false);
  3523. if(lua_interface)
  3524. lua_interface->RemoveDebugClients(client);
  3525. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3526. }
  3527. else{
  3528. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  3529. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  3530. }
  3531. break;
  3532. }
  3533. case COMMAND_SPAWN_GROUP:
  3534. {
  3535. Spawn* target = cmdTarget;
  3536. if(target && target->IsPlayer() == false)
  3537. {
  3538. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  3539. {
  3540. if(target->GetSpawnLocationPlacementID() > 0)
  3541. {
  3542. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  3543. {
  3544. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  3545. if(id > 0)
  3546. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  3547. else
  3548. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  3549. target->SetSpawnGroupID(id);
  3550. target->AddSpawnToGroup(target);
  3551. }
  3552. else
  3553. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  3554. }
  3555. else
  3556. 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.");
  3557. }
  3558. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  3559. {
  3560. if(sep->arg[1] && sep->IsNumber(1))
  3561. {
  3562. int32 group_id = atoul(sep->arg[1]);
  3563. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  3564. if(leader)
  3565. {
  3566. leader->AddSpawnToGroup(target);
  3567. target->SetSpawnGroupID(group_id);
  3568. if(database.SpawnGroupAddSpawn(target, group_id))
  3569. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  3570. else
  3571. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  3572. }
  3573. else
  3574. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  3575. }
  3576. else
  3577. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  3578. }
  3579. else if(target->GetSpawnGroupID() == 0)
  3580. {
  3581. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  3582. }
  3583. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  3584. {
  3585. int32 group_id = target->GetSpawnGroupID();
  3586. target->RemoveSpawnFromGroup();
  3587. if(database.SpawnGroupRemoveSpawn(target, group_id))
  3588. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  3589. else
  3590. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  3591. }
  3592. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  3593. {
  3594. int32 group_id = target->GetSpawnGroupID();
  3595. if(sep->arg[1] && sep->IsNumber(1))
  3596. {
  3597. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  3598. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  3599. else
  3600. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  3601. }
  3602. else
  3603. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  3604. }
  3605. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  3606. {
  3607. int32 group_id = target->GetSpawnGroupID();
  3608. if(sep->arg[1] && sep->IsNumber(1))
  3609. {
  3610. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  3611. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  3612. else
  3613. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  3614. }
  3615. else
  3616. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  3617. }
  3618. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  3619. {
  3620. if(sep->arg[1] && sep->IsNumber(1))
  3621. {
  3622. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  3623. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  3624. else
  3625. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  3626. }
  3627. else
  3628. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  3629. }
  3630. else
  3631. {
  3632. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  3633. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  3634. }
  3635. }
  3636. else
  3637. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  3638. break;
  3639. }
  3640. case COMMAND_SPAWN_COMBINE:{
  3641. Spawn* spawn = cmdTarget;
  3642. float radius = 0;
  3643. bool failed = true;
  3644. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  3645. failed = false;
  3646. if(spawn->GetSpawnGroupID() > 0){
  3647. 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.");
  3648. }
  3649. else if(sep->IsNumber(0)){
  3650. radius = atof(sep->arg[0]);
  3651. client->CombineSpawns(radius, spawn);
  3652. }
  3653. else{
  3654. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  3655. client->AddCombineSpawn(spawn);
  3656. }
  3657. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  3658. client->RemoveCombineSpawn(spawn);
  3659. }
  3660. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  3661. const char* name = 0;
  3662. if(sep->arg[1] && sep->arg[1][0])
  3663. name = sep->argplus[1];
  3664. client->SaveCombineSpawns(name);
  3665. }
  3666. else
  3667. failed = true;
  3668. }
  3669. }
  3670. if(failed){
  3671. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  3672. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  3673. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  3674. }
  3675. break;
  3676. }
  3677. case COMMAND_SPAWN_CREATE:{
  3678. Spawn* spawn = 0;
  3679. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3680. spawn = new Object();
  3681. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3682. }
  3683. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3684. spawn = new GroundSpawn();
  3685. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3686. }
  3687. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3688. spawn = new Sign();
  3689. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3690. }
  3691. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3692. spawn = new NPC();
  3693. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3694. spawn->appearance.pos.collision_radius = 32;
  3695. spawn->secondary_command_list_id = 0;
  3696. spawn->primary_command_list_id = 0;
  3697. spawn->appearance.display_name = 1;
  3698. spawn->appearance.show_level = 1;
  3699. spawn->appearance.attackable = 1;
  3700. }
  3701. else{
  3702. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  3703. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  3704. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  3705. break;
  3706. }
  3707. spawn->SetID(Spawn::NextID());
  3708. spawn->SetX(client->GetPlayer()->GetX());
  3709. spawn->SetY(client->GetPlayer()->GetY());
  3710. spawn->SetZ(client->GetPlayer()->GetZ());
  3711. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3712. spawn->SetSpawnOrigX(spawn->GetX());
  3713. spawn->SetSpawnOrigY(spawn->GetY());
  3714. spawn->SetSpawnOrigZ(spawn->GetZ());
  3715. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3716. if(spawn->IsSign())
  3717. {
  3718. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  3719. ((Sign*)spawn)->SetSignDistance(20.0f);
  3720. ((Sign*)spawn)->SetIncludeLocation(1);
  3721. ((Sign*)spawn)->SetIncludeHeading(1);
  3722. ((Sign*)spawn)->SetInitialState(1);
  3723. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  3724. ((Sign*)spawn)->SetActivityStatus(64);
  3725. spawn->appearance.race = 0;
  3726. spawn->SetLevel(0);
  3727. spawn->SetHP(0);
  3728. spawn->SetTotalHP(0);
  3729. spawn->SetPower(0);
  3730. spawn->SetTotalPower(0);
  3731. spawn->SetEncounterLevel(0);
  3732. spawn->SetTargetable(0);
  3733. spawn->SetSogaModelType(0);
  3734. spawn->SetCollisionRadius(19);
  3735. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  3736. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  3737. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  3738. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3739. spawn->appearance.model_type = atoul(sep->arg[1]);
  3740. }
  3741. else
  3742. {
  3743. spawn->appearance.targetable = 1;
  3744. spawn->appearance.race = 255;
  3745. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3746. spawn->SetModelType(atoi(sep->arg[1]));
  3747. spawn->SetAdventureClass(atoi(sep->arg[2]));
  3748. spawn->SetLevel(atoi(sep->arg[3]));
  3749. spawn->SetName(sep->arg[4]);
  3750. if(sep->arg[5][0] && sep->IsNumber(5))
  3751. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  3752. if(sep->arg[6][0] && sep->IsNumber(6))
  3753. spawn->size = atoi(sep->arg[6]);
  3754. if(spawn->GetTotalHP() == 0){
  3755. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  3756. spawn->SetHP(25*spawn->GetLevel() + 1);
  3757. }
  3758. if(spawn->GetTotalPower() == 0){
  3759. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3760. spawn->SetPower(25*spawn->GetLevel() + 1);
  3761. }
  3762. }
  3763. client->GetCurrentZone()->AddSpawn(spawn);
  3764. break;
  3765. }
  3766. case COMMAND_SPAWN_EQUIPMENT:{
  3767. Spawn* spawn = cmdTarget;
  3768. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3769. int8 slot = atoi(sep->arg[0]);
  3770. int16 type = atoi(sep->arg[1]);
  3771. int8 red = 0;
  3772. int8 green = 0;
  3773. int8 blue = 0;
  3774. int8 h_red = 0;
  3775. int8 h_green = 0;
  3776. int8 h_blue = 0;
  3777. if(sep->arg[2])
  3778. red = atoi(sep->arg[2]);
  3779. if(sep->arg[3])
  3780. green = atoi(sep->arg[3]);
  3781. if(sep->arg[4])
  3782. blue = atoi(sep->arg[4]);
  3783. if(sep->arg[5])
  3784. h_red = atoi(sep->arg[5]);
  3785. if(sep->arg[6])
  3786. h_green = atoi(sep->arg[6]);
  3787. if(sep->arg[7])
  3788. h_blue = atoi(sep->arg[7]);
  3789. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3790. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3791. }
  3792. else{
  3793. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3794. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3795. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3796. }
  3797. break;
  3798. }
  3799. case COMMAND_SPAWN_DETAILS: {
  3800. Spawn* spawn = cmdTarget;
  3801. if (sep && sep->arg[0][0]) {
  3802. if (cmdTarget)
  3803. {
  3804. if (ToLower(string(sep->arg[0])) == "los")
  3805. {
  3806. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3807. if (hasLOS)
  3808. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3809. else
  3810. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3811. break;
  3812. }
  3813. else if (ToLower(string(sep->arg[0])) == "bestz")
  3814. {
  3815. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3816. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3817. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3818. break;
  3819. }
  3820. else if (ToLower(string(sep->arg[0])) == "inwater")
  3821. {
  3822. if (cmdTarget->GetRegionMap() == nullptr)
  3823. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  3824. else
  3825. {
  3826. bool inWater = cmdTarget->InWater();
  3827. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  3828. }
  3829. break;
  3830. }
  3831. else if (ToLower(string(sep->arg[0])) == "inlava")
  3832. {
  3833. if (cmdTarget->GetRegionMap() == nullptr)
  3834. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  3835. else
  3836. {
  3837. bool inLava = cmdTarget->InLava();
  3838. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  3839. }
  3840. break;
  3841. }
  3842. else if (ToLower(string(sep->arg[0])) == "regions")
  3843. {
  3844. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  3845. if (cmdTarget->GetRegionMap() == nullptr)
  3846. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  3847. else
  3848. {
  3849. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  3850. }
  3851. break;
  3852. }
  3853. else if (ToLower(string(sep->arg[0])) == "behind")
  3854. {
  3855. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  3856. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  3857. break;
  3858. }
  3859. else if (ToLower(string(sep->arg[0])) == "infront")
  3860. {
  3861. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  3862. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  3863. break;
  3864. }
  3865. else if (ToLower(string(sep->arg[0])) == "flank")
  3866. {
  3867. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  3868. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  3869. break;
  3870. }
  3871. }
  3872. if (sep->IsNumber(0))
  3873. {
  3874. float radius = atof(sep->arg[0]);
  3875. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3876. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3877. break;
  3878. }
  3879. }
  3880. if (spawn) {
  3881. const char* type = "NPC";
  3882. if (spawn->IsObject())
  3883. type = "Object";
  3884. else if (spawn->IsSign())
  3885. type = "Sign";
  3886. else if (spawn->IsWidget())
  3887. type = "Widget";
  3888. else if (spawn->IsGroundSpawn())
  3889. type = "GroundSpawn";
  3890. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3891. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3892. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3893. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3894. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3895. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3896. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3897. 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());
  3898. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3899. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3900. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3901. if (spawn->IsEntity()) {
  3902. 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());
  3903. 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());
  3904. }
  3905. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3906. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3907. 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());
  3908. 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);
  3909. if (spawn->IsNPC())
  3910. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3911. string details;
  3912. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3913. details += "Type: " + string(type) + "\n";
  3914. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3915. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3916. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3917. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3918. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3919. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3920. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3921. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3922. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3923. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3924. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3925. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3926. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3927. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3928. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3929. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3930. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3931. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3932. char x[16];
  3933. sprintf(x, "%.2f", spawn->GetX());
  3934. char y[16];
  3935. sprintf(y, "%.2f", spawn->GetY());
  3936. char z[16];
  3937. sprintf(z, "%.2f", spawn->GetZ());
  3938. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3939. string details2;
  3940. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3941. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3942. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3943. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3944. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3945. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3946. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3947. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3948. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3949. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3950. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3951. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3952. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3953. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3954. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3955. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3956. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3957. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3958. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3959. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3960. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3961. string details3;
  3962. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3963. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3964. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3965. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  3966. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  3967. if(spawn->IsEntity())
  3968. {
  3969. Entity* ent = (Entity*)spawn;
  3970. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  3971. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  3972. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  3973. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  3974. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  3975. }
  3976. string details4;
  3977. if (spawn->IsEntity()) {
  3978. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3979. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3980. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3981. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3982. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3983. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3984. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3985. if (spawn->IsNPC()) {
  3986. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3987. }
  3988. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  3989. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  3990. }
  3991. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3992. client->SendShowBook(client->GetPlayer(), title, 4, details, details2, details3, details4);
  3993. }
  3994. else {
  3995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3996. 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.");
  3997. }
  3998. break;
  3999. }
  4000. case COMMAND_SPAWN_TARGET:{
  4001. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4002. int32 spawn_id = atoul(sep->arg[0]);
  4003. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4004. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4005. }
  4006. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4007. float distance = atof(sep->arg[1]);
  4008. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4009. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4010. }
  4011. else{
  4012. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4013. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4014. }
  4015. break;
  4016. }
  4017. case COMMAND_SPAWN_SET:
  4018. {
  4019. Spawn* spawn = cmdTarget;
  4020. sint16 set_type = -1;
  4021. string type_str;
  4022. if (spawn)
  4023. {
  4024. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4025. 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)
  4026. {
  4027. // set the type, which will be 0 if location or list or invalid
  4028. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4029. }
  4030. if(set_type > 0)
  4031. {
  4032. // check if spawn set is NOT a char update, or not location, or isn't a number
  4033. 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)
  4034. {
  4035. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4036. }
  4037. else
  4038. {
  4039. string name = string(spawn->GetName());
  4040. if(SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4041. {
  4042. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4043. {
  4044. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4045. }
  4046. else if (set_type == SPAWN_SET_VALUE_NAME)
  4047. {
  4048. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4049. }
  4050. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4051. {
  4052. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4053. }
  4054. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4055. {
  4056. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4057. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  4058. }
  4059. else
  4060. {
  4061. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  4062. }
  4063. switch (set_type)
  4064. {
  4065. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4066. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4067. case SPAWN_SET_VALUE_FACTION:
  4068. case SPAWN_SET_AAXP_REWARDS:
  4069. {
  4070. // not applicable already ran db command
  4071. break;
  4072. }
  4073. default:
  4074. {
  4075. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4076. break;
  4077. }
  4078. }
  4079. 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))
  4080. {
  4081. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4082. {
  4083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  4084. }
  4085. else if(spawn->GetSpawnLocationID() > 0)
  4086. {
  4087. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4088. }
  4089. }
  4090. else
  4091. {
  4092. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4093. {
  4094. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  4095. }
  4096. else if(spawn->GetDatabaseID() > 0)
  4097. {
  4098. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4099. }
  4100. }
  4101. }
  4102. }
  4103. }
  4104. else if(set_type == 0)
  4105. {
  4106. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4107. map<string, int8>::iterator itr;
  4108. int i=0;
  4109. string list;
  4110. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4111. {
  4112. if(i==10)
  4113. {
  4114. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4115. i = 0;
  4116. }
  4117. if(i>0)
  4118. {
  4119. list.append(", ").append(itr->first);
  4120. }
  4121. else
  4122. {
  4123. list = itr->first;
  4124. }
  4125. }
  4126. if(list.length() > 0)
  4127. {
  4128. // if 1 or more, display in client.
  4129. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4130. }
  4131. }
  4132. else
  4133. {
  4134. // syntax fail
  4135. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4136. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4137. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4138. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4139. }
  4140. }
  4141. break;
  4142. }
  4143. case COMMAND_SPAWN_REMOVE:{
  4144. Spawn* spawn = cmdTarget;
  4145. if(spawn && !spawn->IsPlayer()){
  4146. if(spawn->GetSpawnLocationID() > 0){
  4147. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4148. client->GetCurrentZone()->RemoveSpawn(spawn, true, false);
  4149. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  4150. }
  4151. else
  4152. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4153. }
  4154. else
  4155. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4156. }
  4157. else{
  4158. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4159. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4160. }
  4161. break;
  4162. }
  4163. case COMMAND_SPAWN_LIST:{
  4164. if(sep && sep->arg[0][0]){
  4165. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4166. vector<string>::iterator itr;
  4167. if(results){
  4168. for(itr=results->begin();itr!=results->end();itr++){
  4169. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4170. }
  4171. safe_delete(results);
  4172. }
  4173. else
  4174. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4175. }
  4176. else{
  4177. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4178. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4179. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4180. }
  4181. break;
  4182. }
  4183. case COMMAND_SPAWN_ADD:{
  4184. Spawn* spawn = cmdTarget;
  4185. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  4186. if(spawn->GetSpawnLocationID() > 0){
  4187. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4188. break;
  4189. }
  4190. if(spawn->GetDatabaseID() == 0){
  4191. if(database.SaveSpawnInfo(spawn)) {
  4192. char spawn_type[32];
  4193. memset(spawn_type, 0, sizeof(spawn_type));
  4194. if (spawn->IsNPC())
  4195. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4196. else if (spawn->IsObject())
  4197. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4198. else if (spawn->IsSign())
  4199. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4200. else if (spawn->IsGroundSpawn())
  4201. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4202. else
  4203. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4204. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4205. }
  4206. else
  4207. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4208. }
  4209. int32 spawn_group_id = 0;
  4210. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4211. spawn_group_id = database.GetNextSpawnLocation();
  4212. else
  4213. spawn_group_id = atol(sep->arg[0]);
  4214. int8 percent = 100;
  4215. if(sep->arg[2] && sep->IsNumber(2))
  4216. percent = atoi(sep->arg[2]);
  4217. spawn->SetSpawnLocationID(spawn_group_id);
  4218. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4219. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4220. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4221. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4222. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4223. else
  4224. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  4225. }
  4226. else{
  4227. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  4228. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  4229. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  4230. }
  4231. break;
  4232. }
  4233. case COMMAND_SPAWN:{
  4234. int32 id = 0;
  4235. Spawn* spawn = 0;
  4236. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4237. id = atol(sep->arg[0]);
  4238. spawn = client->GetCurrentZone()->GetSpawn(id);
  4239. }
  4240. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  4241. id = 0;
  4242. if(!id || !spawn){
  4243. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  4244. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  4245. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  4246. safe_delete(sep);
  4247. return;
  4248. }
  4249. if(sep && sep->arg[1][0]){
  4250. float x = atof(sep->arg[1]);
  4251. spawn->appearance.pos.X = x;
  4252. }
  4253. else
  4254. spawn->SetX(client->GetPlayer()->GetX(), false);
  4255. if(sep && sep->arg[2][0]){
  4256. float y = atof(sep->arg[2]);
  4257. spawn->appearance.pos.Y = y;
  4258. }
  4259. else
  4260. spawn->SetY(client->GetPlayer()->GetY(), false);
  4261. if(sep && sep->arg[3][0]){
  4262. float z = atof(sep->arg[3]);
  4263. spawn->appearance.pos.Z = z;
  4264. }
  4265. else
  4266. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  4267. if(sep && sep->arg[4][0]){
  4268. float heading = atof(sep->arg[4]);
  4269. spawn->SetHeading(heading);
  4270. }
  4271. else
  4272. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  4273. spawn->SetSpawnOrigX(spawn->GetX());
  4274. spawn->SetSpawnOrigY(spawn->GetY());
  4275. spawn->SetSpawnOrigZ(spawn->GetZ());
  4276. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4277. if(sep && sep->arg[5][0])
  4278. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  4279. else
  4280. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4281. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  4282. spawn->SetTotalHP(spawn->GetLevel() * 15);
  4283. spawn->SetHP(spawn->GetTotalHP());
  4284. }
  4285. if(spawn->GetTotalPower() == 0){
  4286. spawn->SetTotalPower(spawn->GetLevel() * 15);
  4287. spawn->SetPower(spawn->GetTotalPower());
  4288. }
  4289. const char* script = world.GetSpawnScript(id);
  4290. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  4291. spawn->SetSpawnScript(string(script));
  4292. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  4293. client->GetCurrentZone()->AddSpawn(spawn);
  4294. if(spawn->IsNPC())
  4295. spawn->GetZone()->AddLoot((NPC*)spawn);
  4296. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  4297. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  4298. break;
  4299. }
  4300. case COMMAND_ADMINFLAG:
  4301. {
  4302. if(sep && sep->arg[0]){
  4303. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  4304. sint16 new_status = atoi(sep->arg[1]);
  4305. if(tmp_status == -10)
  4306. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  4307. else if(tmp_status >= client->GetAdminStatus())
  4308. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  4309. else if (new_status > client->GetAdminStatus())
  4310. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  4311. else{
  4312. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  4313. if (!client2)
  4314. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  4315. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  4316. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  4317. if (client2) {
  4318. client2->SetAdminStatus(new_status);
  4319. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  4320. }
  4321. }
  4322. else
  4323. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  4324. }
  4325. }else{
  4326. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  4327. if(status != client->GetAdminStatus())
  4328. {
  4329. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  4330. client->SetAdminStatus(status);
  4331. }
  4332. else
  4333. {
  4334. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  4335. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  4336. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  4337. }
  4338. }
  4339. break;
  4340. }
  4341. case COMMAND_CANNEDEMOTE:{
  4342. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  4343. break;
  4344. }
  4345. case COMMAND_BROADCAST: {
  4346. if (sep && sep->arg[0])
  4347. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  4348. else
  4349. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  4350. break;
  4351. }
  4352. case COMMAND_ANNOUNCE: {
  4353. if (sep && sep->arg[0])
  4354. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  4355. else
  4356. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  4357. break;
  4358. }
  4359. case COMMAND_RELOAD_ITEMS:{
  4360. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  4361. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  4362. database.ReloadItemList();
  4363. database.LoadMerchantInformation();
  4364. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  4365. break;
  4366. }
  4367. case COMMAND_ENABLE_ABILITY_QUE:{
  4368. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  4369. if(app)
  4370. client->QueuePacket(app);
  4371. break;
  4372. }
  4373. case COMMAND_ITEMSEARCH:
  4374. case COMMAND_FROMBROKER:{
  4375. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  4376. if (packet) {
  4377. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  4378. //packet->setDataByName("unknown", 1);
  4379. packet->setDataByName("unknown2", 5, 0);
  4380. packet->setDataByName("unknown2", 20, 1);
  4381. packet->setDataByName("unknown2", 58, 3);
  4382. packet->setDataByName("unknown2", 40, 4);
  4383. client->QueuePacket(packet->serialize());
  4384. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  4385. if (packet2) {
  4386. packet2->setDataByName("char_id", client->GetCharacterID());
  4387. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  4388. safe_delete(packet2);
  4389. }
  4390. safe_delete(packet);
  4391. }
  4392. break;
  4393. }
  4394. case COMMAND_ANIMTEST:{
  4395. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  4396. if(command_packet){
  4397. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  4398. if (cmdTarget)
  4399. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  4400. command_packet->setDataByName ( "spawn_id" , id);
  4401. int animID = 1;
  4402. if(sep && sep->arg[0] && sep->IsNumber(0))
  4403. animID = atoi(sep->arg[0]);
  4404. VisualState* vs = NULL;
  4405. if(animID == 0)
  4406. {
  4407. vs = visual_states.FindVisualState(sep->arg[0]);
  4408. }
  4409. char msg[128];
  4410. sprintf(msg,"Animation Test ID: %i",animID);
  4411. command_packet->setMediumStringByName ( "emote_msg" , msg );
  4412. if(vs != NULL)
  4413. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  4414. else
  4415. command_packet->setDataByName ( "anim_type", animID );
  4416. command_packet->setDataByName ( "unknown0", 0 );
  4417. EQ2Packet* outapp = command_packet->serialize();
  4418. client->QueuePacket(outapp);
  4419. safe_delete(command_packet);
  4420. }
  4421. break;
  4422. }
  4423. case COMMAND_KICK:
  4424. {
  4425. if( sep == 0 || sep->arg[0] == 0)
  4426. {
  4427. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  4428. }
  4429. else
  4430. {
  4431. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  4432. if ( kickClient == client )
  4433. {
  4434. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  4435. break;
  4436. }
  4437. else if(kickClient != NULL)
  4438. {
  4439. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  4440. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  4441. {
  4442. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  4443. break;
  4444. }
  4445. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  4446. kickClient->Disconnect();
  4447. }
  4448. else
  4449. {
  4450. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  4451. }
  4452. }
  4453. break;
  4454. }
  4455. case COMMAND_LOCK:
  4456. {
  4457. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  4458. int worldLocked = atoi(sep->arg[0]);
  4459. net.world_locked = worldLocked;
  4460. if ( worldLocked )
  4461. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  4462. else
  4463. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  4464. }
  4465. else
  4466. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  4467. break;
  4468. }
  4469. case COMMAND_BAN:{
  4470. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  4471. {
  4472. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  4473. }
  4474. else
  4475. {
  4476. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  4477. if ( kickClient == client )
  4478. {
  4479. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  4480. break;
  4481. }
  4482. else if(kickClient != NULL)
  4483. {
  4484. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  4485. if ( maxStatus > client->GetAdminStatus( ) ||
  4486. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  4487. {
  4488. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  4489. break;
  4490. }
  4491. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  4492. int perm = atol(sep->arg[1]);
  4493. if ( perm == 1 )
  4494. database.UpdateAdminStatus(sep->arg[0],-2);
  4495. else
  4496. database.UpdateAdminStatus(sep->arg[0],-1);
  4497. kickClient->Disconnect();
  4498. }
  4499. else
  4500. {
  4501. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  4502. }
  4503. }
  4504. break;
  4505. }
  4506. case COMMAND_SET_COMBAT_VOICE:{
  4507. int32 value = 0;
  4508. if(sep && sep->arg[0] && sep->IsNumber(0))
  4509. value = atoi(sep->arg[0]);
  4510. client->GetPlayer()->SetCombatVoice(value);
  4511. break;
  4512. }
  4513. case COMMAND_SET_EMOTE_VOICE:{
  4514. int32 value = 0;
  4515. if(sep && sep->arg[0] && sep->IsNumber(0))
  4516. value = atoi(sep->arg[0]);
  4517. client->GetPlayer()->SetEmoteVoice(value);
  4518. break;
  4519. }
  4520. case COMMAND_GIVEITEM:{
  4521. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  4522. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  4523. if ( itemToClient == NULL )
  4524. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  4525. else
  4526. {
  4527. int32 item_id = atol(sep->arg[1]);
  4528. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  4529. itemToClient->AddItem(item_id);
  4530. }
  4531. }
  4532. else
  4533. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  4534. break;
  4535. }
  4536. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  4537. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  4538. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  4539. case COMMAND_SKILL :
  4540. case COMMAND_SKILL_ADD :
  4541. case COMMAND_SKILL_REMOVE :
  4542. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  4543. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  4544. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  4545. case COMMAND_ENTITYCOMMAND :
  4546. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  4547. case COMMAND_MERCHANT :
  4548. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  4549. case COMMAND_APPEARANCE :
  4550. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  4551. case COMMAND_TRACK : { Command_Track(client); break; }
  4552. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  4553. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  4554. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  4555. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  4556. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  4557. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  4558. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  4559. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  4560. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  4561. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  4562. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  4563. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  4564. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  4565. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  4566. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  4567. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  4568. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  4569. case COMMAND_LOCATION : { Command_Location(client); break; }
  4570. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  4571. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  4572. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  4573. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  4574. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  4575. case COMMAND_GRID : { Command_Grid(client); break; }
  4576. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  4577. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  4578. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  4579. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  4580. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  4581. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  4582. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  4583. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  4584. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  4585. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  4586. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  4587. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  4588. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  4589. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  4590. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  4591. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  4592. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  4593. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  4594. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  4595. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  4596. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  4597. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  4598. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  4599. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  4600. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  4601. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  4602. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  4603. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  4604. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  4605. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  4606. case COMMAND_MOTD : { Command_MOTD(client); break; }
  4607. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  4608. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  4609. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  4610. case COMMAND_TITLE : { Command_Title(client); break; }
  4611. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  4612. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  4613. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  4614. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  4615. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  4616. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  4617. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  4618. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  4619. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  4620. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  4621. case COMMAND_PET : { Command_Pet(client, sep); break; }
  4622. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  4623. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  4624. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  4625. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  4626. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  4627. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  4628. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  4629. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  4630. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  4631. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  4632. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  4633. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  4634. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  4635. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  4636. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  4637. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  4638. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  4639. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  4640. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  4641. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  4642. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  4643. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  4644. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  4645. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  4646. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  4647. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  4648. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  4649. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  4650. case COMMAND_MODIFY : { Command_Modify(client); break; }
  4651. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  4652. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  4653. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  4654. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  4655. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  4656. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  4657. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  4658. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  4659. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  4660. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  4661. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  4662. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  4663. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  4664. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  4665. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  4666. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  4667. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  4668. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  4669. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  4670. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  4671. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  4672. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  4673. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  4674. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  4675. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  4676. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  4677. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  4678. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  4679. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  4680. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  4681. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  4682. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  4683. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  4684. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  4685. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  4686. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  4687. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  4688. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  4689. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  4690. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  4691. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  4692. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  4693. case ADD_AA : { Add_AA(client, sep); break; }
  4694. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  4695. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  4696. case BACK_AA : { Back_AA(client, sep); break; }
  4697. case REMOVE_AA : { Remove_AA(client, sep); break; }
  4698. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  4699. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  4700. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  4701. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  4702. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  4703. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  4704. case COMMAND_CRAFTITEM: {
  4705. Item* item = 0;
  4706. if (sep && sep->IsNumber(0)) {
  4707. int32 item_id = atol(sep->arg[0]);
  4708. int32 quantity = 1;
  4709. if (sep->arg[1] && sep->IsNumber(1))
  4710. quantity = atoi(sep->arg[1]);
  4711. item = new Item(master_item_list.GetItem(item_id));
  4712. if (!item) {
  4713. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  4714. }
  4715. else {
  4716. item->details.count = quantity;
  4717. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  4718. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  4719. client->AddItem(item);
  4720. //Check for crafting quest updates
  4721. int8 update_amt = 0;
  4722. if (item->stack_count > 1)
  4723. update_amt = 1;
  4724. else
  4725. update_amt = quantity;
  4726. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  4727. }
  4728. }
  4729. else {
  4730. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  4731. }
  4732. break;
  4733. }
  4734. default:
  4735. {
  4736. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  4737. break;
  4738. }
  4739. }
  4740. safe_delete(sep);
  4741. }
  4742. /******************** New COMMAND Handler Functions ********************/
  4743. /*
  4744. Started breaking apart the huge switch() for commands into sepErate
  4745. functions so it is easier to locate the blocks of code by command
  4746. -- JA 2012.03.03
  4747. */
  4748. // sample function header
  4749. /*
  4750. Function:
  4751. Purpose :
  4752. Params :
  4753. Dev :
  4754. Example :
  4755. */
  4756. //void Commands::Command()
  4757. //{
  4758. //}
  4759. /*
  4760. Function: Command_AcceptAdvancement()
  4761. Purpose : Player accepts a new advancement option
  4762. Params : Spell ID
  4763. Dev : Jabantiz
  4764. */
  4765. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4766. {
  4767. Player *player = client->GetPlayer();
  4768. if (sep && sep->IsSet(0)) {
  4769. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4770. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4771. if (!player->HasSpell(trait->spellID, 0, true))
  4772. {
  4773. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4774. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4775. }
  4776. else
  4777. {
  4778. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4779. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4780. player->RemoveSpellBookEntry(spell->GetSpellID());
  4781. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4782. player->UnlockSpell(spell);
  4783. client->SendSpellUpdate(spell);
  4784. }
  4785. // Spell book update
  4786. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4787. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4788. }
  4789. }
  4790. /*
  4791. Function:
  4792. Purpose :
  4793. Params :
  4794. Dev :
  4795. Example :
  4796. */
  4797. void Commands::Command_AFK(Client* client, Seperator* sep)
  4798. {
  4799. Player* player = client->GetPlayer();
  4800. player->toggle_character_flag(CF_AFK);
  4801. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4802. if (player->get_character_flag(CF_AFK))
  4803. {
  4804. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4805. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  4806. if (sep && sep->argplus[0])
  4807. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4808. else
  4809. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4810. string message = string(player->GetName()) + " is going afk.";
  4811. Spawn* target = player->GetTarget();
  4812. if (target && target != player)
  4813. {
  4814. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4815. player->GetGender() == 1 ? message += "he" : message += "she";
  4816. message += " is going afk.";
  4817. }
  4818. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4819. }
  4820. /*else
  4821. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  4822. }
  4823. /*
  4824. Function: Command_Appearance()
  4825. Purpose : Handles /appearance commands
  4826. Params : list
  4827. Dev : Scatman
  4828. Example : /appearance list
  4829. */
  4830. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4831. {
  4832. if( handler == COMMAND_APPEARANCE )
  4833. {
  4834. // /appearance command by itself shows help (to be extended)
  4835. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4836. return;
  4837. }
  4838. else if( handler == COMMAND_APPEARANCE_LIST )
  4839. {
  4840. // /appearance list command expects "name" param
  4841. if (sep && sep->arg[0])
  4842. {
  4843. const char* appearance_name = sep->argplus[0];
  4844. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4845. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4846. if (appearances)
  4847. {
  4848. vector<int16>::iterator itr;
  4849. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4850. {
  4851. int16 id = *itr;
  4852. string name = database.GetAppearanceName(id);
  4853. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4854. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4855. }
  4856. safe_delete(appearances);
  4857. }
  4858. }
  4859. else // no param
  4860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4861. }
  4862. }
  4863. /*
  4864. Function: Command_Claim()
  4865. Purpose :
  4866. Params :
  4867. Dev :
  4868. Example :
  4869. */
  4870. void Commands::Command_Claim(Client* client, Seperator* sep)
  4871. {
  4872. if (sep && sep->arg[0] && sep->IsNumber(0))
  4873. {
  4874. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4875. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4876. }
  4877. else
  4878. client->ShowClaimWindow();
  4879. }
  4880. /*
  4881. Function: Command_ClearAllQueued()
  4882. Purpose :
  4883. Params :
  4884. Dev :
  4885. Example :
  4886. */
  4887. void Commands::Command_ClearAllQueued(Client* client)
  4888. {
  4889. ZoneServer* zone = client->GetPlayer()->GetZone();
  4890. if (zone && zone->GetSpellProcess())
  4891. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4892. }
  4893. /*
  4894. Function: Command_CancelMaintained()
  4895. Purpose : Cancels maintained spells
  4896. Params : Maintained Spell Index
  4897. Dev : Zcoretri
  4898. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4899. */
  4900. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4901. {
  4902. if (sep && sep->arg[0] && sep->IsNumber(0))
  4903. {
  4904. int32 spell_index = atoul(sep->arg[0]);
  4905. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4906. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4907. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4908. // just not spelleffects/dets - Foof
  4909. //{
  4910. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled"))
  4911. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4912. // }
  4913. //else
  4914. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4915. }
  4916. }
  4917. /*
  4918. Function: Command_Create()
  4919. Purpose : Handler for starting Tradeskilling table
  4920. Params :
  4921. Dev : Zcoretri
  4922. Example :
  4923. */
  4924. void Commands::Command_Create(Client* client, Seperator* sep)
  4925. {
  4926. PrintSep(sep, "COMMAND_CREATE");
  4927. client->SendRecipeList();
  4928. client->ShowRecipeBook();
  4929. }
  4930. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4931. {
  4932. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4933. if (sep && sep->arg[0] && sep->IsNumber(0))
  4934. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4935. }
  4936. /*
  4937. Function: Command_Distance()
  4938. Purpose : Displays distance from targeted spawn
  4939. Params :
  4940. Dev : Scatman
  4941. Example : /distance
  4942. */
  4943. void Commands::Command_Distance(Client* client)
  4944. {
  4945. Spawn* target = client->GetPlayer()->GetTarget();
  4946. if (target)
  4947. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4948. else
  4949. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4950. }
  4951. /*
  4952. Function: Command_Duel()
  4953. Purpose : Handle the /duel commands - not yet implemented
  4954. Params : unknown
  4955. Dev :
  4956. Example :
  4957. */
  4958. void Commands::Command_Duel(Client* client, Seperator* sep)
  4959. {
  4960. PrintSep(sep, "COMMAND_DUEL");
  4961. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4962. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4963. }
  4964. /*
  4965. Function: Command_DuelBet()
  4966. Purpose : Handle the /duel commands - not yet implemented
  4967. Params : unknown
  4968. Dev :
  4969. Example :
  4970. */
  4971. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4972. {
  4973. PrintSep(sep, "COMMAND_DUELBET");
  4974. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4975. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4976. }
  4977. /*
  4978. Function: Command_DuelAccept()
  4979. Purpose : Handle the /duel commands - not yet implemented
  4980. Params : unknown
  4981. Dev :
  4982. Example :
  4983. */
  4984. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4985. {
  4986. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4987. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4988. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4989. }
  4990. /*
  4991. Function: Command_DuelDecline()
  4992. Purpose : Handle the /duel commands - not yet implemented
  4993. Params : unknown
  4994. Dev :
  4995. Example :
  4996. */
  4997. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4998. {
  4999. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5000. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5001. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5002. }
  5003. /*
  5004. Function: Command_DuelSurrender()
  5005. Purpose : Handle the /duel commands - not yet implemented
  5006. Params : unknown
  5007. Dev :
  5008. Example :
  5009. */
  5010. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5011. {
  5012. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5013. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5014. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5015. // JA, just messin around ;)
  5016. char surrender[64];
  5017. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5018. zone_list.HandleGlobalAnnouncement(surrender);
  5019. }
  5020. /*
  5021. Function: Command_DuelToggle()
  5022. Purpose : Handle the /duel commands - not yet implemented
  5023. Params : unknown
  5024. Dev :
  5025. Example :
  5026. */
  5027. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5028. {
  5029. PrintSep(sep, "COMMAND_DUEL");
  5030. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5031. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5032. }
  5033. /*
  5034. Function:
  5035. Purpose :
  5036. Params :
  5037. Dev :
  5038. Example :
  5039. */
  5040. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5041. {
  5042. if( handler == COMMAND_ENTITYCOMMAND )
  5043. {
  5044. // /entitycommand command by itself shows help (to be extended)
  5045. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5046. return;
  5047. }
  5048. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5049. {
  5050. // /entitycommand list command expects "name" param
  5051. if (sep && sep->arg[0])
  5052. {
  5053. const char* entity_command_name = sep->argplus[0];
  5054. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5055. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5056. map<int32, vector<EntityCommand*>*>::iterator itr;
  5057. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5058. {
  5059. vector<EntityCommand*>* entity_command_list = itr->second;
  5060. vector<EntityCommand*>::iterator itr2;
  5061. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5062. {
  5063. EntityCommand* entity_command = *itr2;
  5064. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5065. 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);
  5066. }
  5067. }
  5068. }
  5069. else // no command name
  5070. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5071. }
  5072. }
  5073. /*
  5074. Function: Command_Follow()
  5075. Purpose : Handle the /follow command - not yet implemented
  5076. Params :
  5077. Dev :
  5078. Example :
  5079. */
  5080. void Commands::Command_Follow(Client* client, Seperator* sep)
  5081. {
  5082. PrintSep(sep, "COMMAND_FOLLOW");
  5083. // flag to toggle if the players target is in the players group
  5084. bool targetInGroup = false;
  5085. // get a pointer to the players group
  5086. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5087. // If the player has a group and has a target
  5088. if (gmi && client->GetPlayer()->GetTarget()) {
  5089. deque<GroupMemberInfo*>::iterator itr;
  5090. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5091. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5092. if (group)
  5093. {
  5094. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5095. deque<GroupMemberInfo*>* members = group->GetMembers();
  5096. // Loop through the group members
  5097. for (itr = members->begin(); itr != members->end(); itr++) {
  5098. // If a group member matches a target
  5099. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  5100. // toggle the flag and break the loop
  5101. targetInGroup = true;
  5102. break;
  5103. }
  5104. }
  5105. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5106. }
  5107. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5108. }
  5109. if (targetInGroup) {
  5110. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5111. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5112. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5113. client->GetPlayer()->info_changed = true;
  5114. client->GetPlayer()->changed = true;
  5115. }
  5116. else
  5117. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5118. }
  5119. /*
  5120. Function: Command_StopFollow()
  5121. Purpose : Handle the /stop_follow command - not yet implemented
  5122. Params :
  5123. Dev :
  5124. Example :
  5125. */
  5126. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5127. {
  5128. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5129. if (client->GetPlayer()->GetFollowTarget()) {
  5130. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5131. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5132. client->GetPlayer()->SetFollowTarget(0);
  5133. client->GetPlayer()->info_changed = true;
  5134. client->GetPlayer()->changed = true;
  5135. }
  5136. }
  5137. #include "../Zone/SPGrid.h"
  5138. /*
  5139. Function: Command_Grid()
  5140. Purpose : Show player's current Grid ID
  5141. Params :
  5142. Dev : Scatman
  5143. Example : /grid
  5144. */
  5145. void Commands::Command_Grid(Client* client)
  5146. {
  5147. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  5148. if (client->GetPlayer()->GetMap() != nullptr) {
  5149. int32 grid = client->GetPlayer()->GetMap()->GetGrid()->GetGridID(client->GetPlayer());
  5150. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  5151. }
  5152. }
  5153. /*
  5154. Function: Command_Guild()
  5155. Purpose : Handler for all UI-related guild commands
  5156. Dev : Scatman
  5157. */
  5158. void Commands::Command_Guild(Client* client, Seperator* sep)
  5159. {
  5160. Guild* guild = client->GetPlayer()->GetGuild();
  5161. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  5162. {
  5163. const char* command = sep->arg[0];
  5164. int32 length = strlen(command);
  5165. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  5166. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  5167. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  5168. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5169. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5170. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5171. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5172. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  5173. guild->KickGuildMember(client, sep->arg[1]);
  5174. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  5175. guild->DemoteGuildMember(client, sep->arg[1]);
  5176. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  5177. guild->PromoteGuildMember(client, sep->arg[1]);
  5178. else if (strncmp(command, "points", length) == 0 && guild)
  5179. {
  5180. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  5181. {
  5182. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5183. {
  5184. float points = atof(sep->arg[2]);
  5185. const char* option = sep->arg[3];
  5186. const char* comment = sep->argplus[4];
  5187. if (strncmp(option, "all", strlen(option)) == 0)
  5188. guild->AddPointsToAll(client, points, comment);
  5189. else if (strncmp(option, "online", strlen(option)) == 0)
  5190. guild->AddPointsToAllOnline(client, points, comment);
  5191. else if (strncmp(option, "group", strlen(option)) == 0)
  5192. guild->AddPointsToGroup(client, points, comment);
  5193. else if (strncmp(option, "raid", strlen(option)) == 0)
  5194. guild->AddPointsToRaid(client, points, comment);
  5195. else
  5196. guild->AddPointsToGuildMember(client, points, option, comment);
  5197. }
  5198. }
  5199. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  5200. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  5201. else
  5202. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  5203. }
  5204. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  5205. guild->SetMOTD(sep->argplus[1]);
  5206. else if (strncmp(command, "recruiting", length) == 0 && guild)
  5207. {
  5208. if (sep->arg[1])
  5209. {
  5210. const char* option = sep->arg[1];
  5211. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  5212. guild->SetRecruitingShortDesc(sep->argplus[2]);
  5213. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  5214. guild->SetRecruitingFullDesc(sep->argplus[2]);
  5215. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5216. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5217. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5218. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  5219. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5220. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  5221. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  5222. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  5223. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  5224. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5225. else
  5226. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5227. }
  5228. else
  5229. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5230. }
  5231. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  5232. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5233. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  5234. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5235. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5236. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5237. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  5238. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  5239. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5240. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5241. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  5242. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  5243. else if (strncmp(command, "invite", length) == 0 && guild)
  5244. {
  5245. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5246. guild->InvitePlayer(client, sep->arg[1]);
  5247. else
  5248. {
  5249. Spawn* target = client->GetPlayer()->GetTarget();
  5250. if (target)
  5251. {
  5252. if (target->IsPlayer())
  5253. guild->InvitePlayer(client, target->GetName());
  5254. else
  5255. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  5256. }
  5257. }
  5258. }
  5259. else if (strncmp(command, "accept", length) == 0)
  5260. {
  5261. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5262. if (pgi && pgi->guild && pgi->invited_by)
  5263. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  5264. client->SetPendingGuildInvite(0);
  5265. }
  5266. else if (strncmp(command, "decline", length) == 0)
  5267. {
  5268. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5269. if (pgi && pgi->guild && pgi->invited_by)
  5270. {
  5271. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  5272. if (client_inviter)
  5273. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  5274. }
  5275. client->SetPendingGuildInvite(0);
  5276. }
  5277. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  5278. {
  5279. const char* guild_name = sep->argplus[1];
  5280. if (!guild_list.GetGuild(guild_name))
  5281. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  5282. else
  5283. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  5284. }
  5285. else if (strncmp(command, "search", length) == 0)
  5286. client->ShowGuildSearchWindow();
  5287. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  5288. {
  5289. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  5290. if (to_guild)
  5291. to_guild->SendGuildRecruitingDetails(client);
  5292. }
  5293. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  5294. {
  5295. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  5296. if (to_guild)
  5297. to_guild->SendGuildRecruitingImages(client);
  5298. }
  5299. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  5300. {
  5301. if (sep->arg[1])
  5302. {
  5303. const char* option = sep->arg[1];
  5304. if (strncmp(option, "toggle", strlen(option)) == 0)
  5305. guild->ToggleGuildRecruiterAdventureClass(client);
  5306. }
  5307. else
  5308. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  5309. }
  5310. else if (strncmp(command, "display_heraldry", length) == 0)
  5311. {
  5312. // JA: not sure this is right...
  5313. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  5314. client->GetPlayer()->SetCharSheetChanged(true);
  5315. }
  5316. else
  5317. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  5318. }
  5319. }
  5320. /*
  5321. Function: Command_GuildCreate()
  5322. Purpose : Display's in-game Guild Creation window
  5323. Dev : Scatman
  5324. */
  5325. void Commands::Command_CreateGuild(Client* client)
  5326. {
  5327. client->SendGuildCreateWindow();
  5328. }
  5329. /*
  5330. Function: Command_SetGuildOfficerNote()
  5331. Purpose :
  5332. Dev : Scatman
  5333. */
  5334. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  5335. {
  5336. if (sep && sep->arg[0] && sep->arg[1])
  5337. {
  5338. Guild* guild = client->GetPlayer()->GetGuild();
  5339. if (guild)
  5340. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  5341. }
  5342. }
  5343. /*
  5344. Function: Command_SetGuildMemberNote()
  5345. Purpose :
  5346. Dev : Scatman
  5347. */
  5348. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  5349. {
  5350. if (sep && sep->arg[0] && sep->arg[1])
  5351. {
  5352. Guild* guild = client->GetPlayer()->GetGuild();
  5353. if (guild)
  5354. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  5355. }
  5356. }
  5357. /*
  5358. Function: Command_GuildSay()
  5359. Purpose :
  5360. Dev : Scatman
  5361. */
  5362. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  5363. {
  5364. Guild* guild = client->GetPlayer()->GetGuild();
  5365. if (guild)
  5366. {
  5367. if (sep && sep->arg[0])
  5368. guild->HandleGuildSay(client, sep->argplus[0]);
  5369. }
  5370. else
  5371. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  5372. }
  5373. /*
  5374. Function: Command_OfficerSay()
  5375. Purpose :
  5376. Dev : Scatman
  5377. */
  5378. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  5379. {
  5380. Guild* guild = client->GetPlayer()->GetGuild();
  5381. if (guild)
  5382. {
  5383. if (sep && sep->arg[0])
  5384. guild->HandleOfficerSay(client, sep->argplus[0]);
  5385. }
  5386. else
  5387. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  5388. }
  5389. /*
  5390. Function: Command_Guilds()
  5391. Purpose : Shows help for /guild command
  5392. Params :
  5393. Dev : Scatman
  5394. Example :
  5395. */
  5396. void Commands::Command_Guilds(Client* client)
  5397. {
  5398. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  5399. }
  5400. /*
  5401. Function: Command_GuildsAdd()
  5402. Purpose : Add's players to a guild
  5403. Params : guild_name|guild_id, player name
  5404. Dev : Scatman
  5405. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  5406. */
  5407. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  5408. {
  5409. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5410. {
  5411. Guild* guild = 0;
  5412. bool found = true;
  5413. if (sep->IsNumber(0))
  5414. {
  5415. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5416. if (!guild)
  5417. {
  5418. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5419. found = false;
  5420. }
  5421. }
  5422. else
  5423. {
  5424. guild = guild_list.GetGuild(sep->arg[0]);
  5425. if (!guild)
  5426. {
  5427. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5428. found = false;
  5429. }
  5430. }
  5431. if (found)
  5432. {
  5433. Client* to_client = 0;
  5434. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5435. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5436. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5437. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5438. if (to_client)
  5439. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  5440. else
  5441. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5442. }
  5443. }
  5444. else
  5445. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  5446. }
  5447. /*
  5448. Function: Command_GuildsCreate()
  5449. Purpose : Creates a guild
  5450. Params : guild_name, player_name (optional)
  5451. Dev : Scatman
  5452. Example : /guilds create [guild name] (player name)
  5453. */
  5454. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  5455. {
  5456. if (sep && sep->arg[0])
  5457. {
  5458. const char* guild_name = sep->arg[0];
  5459. if (!guild_list.GetGuild(guild_name))
  5460. {
  5461. bool ret = false;
  5462. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5463. {
  5464. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5465. if (to_client)
  5466. {
  5467. world.CreateGuild(guild_name, to_client);
  5468. ret = true;
  5469. }
  5470. else
  5471. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  5472. }
  5473. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5474. {
  5475. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5476. if (to_client)
  5477. {
  5478. world.CreateGuild(guild_name, to_client);
  5479. ret = true;
  5480. }
  5481. }
  5482. else
  5483. {
  5484. world.CreateGuild(guild_name);
  5485. ret = true;
  5486. }
  5487. if (ret)
  5488. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  5489. else
  5490. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  5491. }
  5492. else
  5493. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  5494. }
  5495. else
  5496. 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.");
  5497. }
  5498. /*
  5499. Function: Command_GuildsDelete()
  5500. Purpose : Delete's a guild
  5501. Params : guild name
  5502. Dev : Scatman
  5503. Example : /guilds delete Test
  5504. */
  5505. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  5506. {
  5507. if (sep && sep->arg[0])
  5508. {
  5509. Guild* guild = 0;
  5510. bool found = true;
  5511. if (sep->IsNumber(0))
  5512. {
  5513. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5514. if (!guild)
  5515. {
  5516. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5517. found = false;
  5518. }
  5519. }
  5520. else
  5521. {
  5522. guild = guild_list.GetGuild(sep->arg[0]);
  5523. if (!guild)
  5524. {
  5525. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5526. found = false;
  5527. }
  5528. }
  5529. if (found)
  5530. {
  5531. guild->RemoveAllGuildMembers();
  5532. database.DeleteGuild(guild);
  5533. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  5534. guild_list.RemoveGuild(guild, true);
  5535. }
  5536. }
  5537. else
  5538. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  5539. }
  5540. /*
  5541. Function: Command_GuildsList()
  5542. Purpose : Lists current guilds on server
  5543. Params :
  5544. Dev : Scatman
  5545. Example : /guilds list
  5546. */
  5547. void Commands::Command_GuildsList(Client* client)
  5548. {
  5549. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  5550. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  5551. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  5552. if (guilds->size() == 0)
  5553. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  5554. else {
  5555. while (itr.Next()) {
  5556. Guild* guild = itr.second;
  5557. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  5558. }
  5559. }
  5560. }
  5561. /*
  5562. Function: Command_GuildsRemove()
  5563. Purpose : Removes a player from a guild
  5564. Params : guild name|guild id, player name
  5565. Dev : Scatman
  5566. Example : /guilds remove 1 Admin = removes Admin from guild 1
  5567. */
  5568. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  5569. {
  5570. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5571. {
  5572. Guild* guild = 0;
  5573. bool found = true;
  5574. if (sep->IsNumber(0))
  5575. {
  5576. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5577. if (!guild)
  5578. {
  5579. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5580. found = false;
  5581. }
  5582. }
  5583. else
  5584. {
  5585. guild = guild_list.GetGuild(sep->arg[0]);
  5586. if (!guild)
  5587. {
  5588. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5589. found = false;
  5590. }
  5591. }
  5592. if (found)
  5593. {
  5594. Client* to_client = 0;
  5595. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5596. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5597. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5598. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5599. if (to_client)
  5600. {
  5601. Player* to_player = to_client->GetPlayer();
  5602. if (to_player->GetGuild())
  5603. {
  5604. if (to_player->GetGuild() == guild)
  5605. {
  5606. guild->KickGuildMember(client, to_player->GetName());
  5607. }
  5608. else
  5609. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  5610. }
  5611. else
  5612. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  5613. }
  5614. else
  5615. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5616. }
  5617. }
  5618. else
  5619. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  5620. }
  5621. /*
  5622. Function: Command_InspectPlayer()
  5623. Purpose : Handle the Inspect functions
  5624. Params : Client to inspect
  5625. Dev : Scatman
  5626. Example : /inspect Scatman
  5627. */
  5628. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  5629. {
  5630. if (sep && sep->arg[0])
  5631. {
  5632. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  5633. if (inspect_client)
  5634. client->InspectPlayer(inspect_client->GetPlayer());
  5635. }
  5636. else
  5637. {
  5638. Spawn* target = client->GetPlayer()->GetTarget();
  5639. if (target && target->IsPlayer())
  5640. client->InspectPlayer((Player*)target);
  5641. }
  5642. }
  5643. /*
  5644. Function: Command_Inventory()
  5645. Purpose : Handle changes in player inventory
  5646. Params : <TBD>
  5647. Dev : All
  5648. Example : /inventory delete item_id
  5649. */
  5650. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  5651. {
  5652. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  5653. Player* player = client->GetPlayer();
  5654. if(sep && sep->arg[0][0])
  5655. {
  5656. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  5657. if(client->GetPlayer()->GetHP() == 0)
  5658. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  5659. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5660. {
  5661. int16 index = atoi(sep->arg[1]);
  5662. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5663. if(item)
  5664. {
  5665. if(item->GetItemScript() && lua_interface)
  5666. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  5667. int32 bag_id = item->details.inv_slot_id;
  5668. database.DeleteItem(client->GetCharacterID(), item, 0);
  5669. client->GetPlayer()->item_list.DestroyItem(index);
  5670. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  5671. client->QueuePacket(outapp);
  5672. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  5673. if (outapp)
  5674. client->QueuePacket(outapp);
  5675. }
  5676. }
  5677. 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))
  5678. {
  5679. int16 from_index = atoi(sep->arg[1]);
  5680. sint16 to_slot = atoi(sep->arg[2]);
  5681. sint32 bag_id = atol(sep->arg[3]);
  5682. int8 charges = atoi(sep->arg[4]);
  5683. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  5684. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  5685. {
  5686. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  5687. return;
  5688. }
  5689. sint32 old_inventory_id = 0;
  5690. if(item)
  5691. old_inventory_id = item->details.inv_slot_id;
  5692. //autobank
  5693. if (bag_id == -3 && to_slot == -1)
  5694. {
  5695. if (player->HasFreeBankSlot())
  5696. to_slot = player->FindFreeBankSlot();
  5697. else
  5698. {
  5699. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  5700. return;
  5701. }
  5702. }
  5703. //auto inventory
  5704. if (bag_id == 0 && to_slot == -1)
  5705. {
  5706. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5707. {
  5708. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  5709. return;
  5710. }
  5711. }
  5712. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  5713. client->QueuePacket(outapp);
  5714. //removed from bag send update
  5715. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  5716. {
  5717. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  5718. if(outapp)
  5719. client->QueuePacket(outapp);
  5720. }
  5721. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  5722. {
  5723. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  5724. if(outapp)
  5725. client->QueuePacket(outapp);
  5726. }
  5727. }
  5728. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  5729. {
  5730. if(client->GetPlayer()->EngagedInCombat())
  5731. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  5732. else
  5733. {
  5734. int16 index = atoi(sep->arg[1]);
  5735. int8 slot_id = 255;
  5736. if(sep->arg[2][0] && sep->IsNumber(2))
  5737. slot_id = atoi(sep->arg[2]);
  5738. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  5739. EQ2Packet* outapp = 0;
  5740. for(int32 i=0;i<packets.size();i++)
  5741. {
  5742. outapp = packets[i];
  5743. if(outapp)
  5744. client->QueuePacket(outapp);
  5745. }
  5746. client->GetPlayer()->ChangePrimaryWeapon();
  5747. client->GetPlayer()->ChangeSecondaryWeapon();
  5748. client->GetPlayer()->ChangeRangedWeapon();
  5749. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5750. client->QueuePacket(characterSheetPackets);
  5751. }
  5752. }
  5753. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5754. {
  5755. if (client->GetPlayer()->EngagedInCombat())
  5756. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5757. else {
  5758. int16 index = atoi(sep->arg[1]);
  5759. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5760. if (item) {
  5761. // client->GetPlayer()->item_list.DestroyItem(index);
  5762. if (item->item_sets.size() > 0) {
  5763. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5764. ItemSet* set = item->item_sets[i];
  5765. if (set->item_stack_size == 0)
  5766. set->item_stack_size += 1;
  5767. client->AddItem(set->item_id, set->item_stack_size);
  5768. }
  5769. }
  5770. }
  5771. client->RemoveItem(item, 1);
  5772. }
  5773. }
  5774. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5775. {
  5776. if(client->GetPlayer()->EngagedInCombat())
  5777. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5778. else
  5779. {
  5780. int16 index = atoi(sep->arg[1]);
  5781. sint32 bag_id = -999;
  5782. int8 to_slot = 255;
  5783. if(sep->arg[3][0])
  5784. {
  5785. if(sep->IsNumber(2))
  5786. bag_id = atol(sep->arg[2]);
  5787. if(sep->IsNumber(3))
  5788. to_slot = atoi(sep->arg[3]);
  5789. }
  5790. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  5791. EQ2Packet* outapp = 0;
  5792. for(int32 i=0;i<packets.size();i++)
  5793. {
  5794. outapp = packets[i];
  5795. if(outapp)
  5796. client->QueuePacket(outapp);
  5797. }
  5798. client->GetPlayer()->ChangePrimaryWeapon();
  5799. client->GetPlayer()->ChangeSecondaryWeapon();
  5800. client->GetPlayer()->ChangeRangedWeapon();
  5801. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5802. client->QueuePacket(characterSheetPackets);
  5803. }
  5804. }
  5805. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5806. {
  5807. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5808. int16 index1 = atoi(sep->arg[1]);
  5809. int16 index2 = atoi(sep->arg[2]);
  5810. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  5811. if(outapp)
  5812. client->QueuePacket(outapp);
  5813. else
  5814. {
  5815. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5816. return;
  5817. }
  5818. }
  5819. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5820. {
  5821. sint16 to_slot = atoi(sep->arg[1]);
  5822. sint32 bag_id = atoi(sep->arg[2]);
  5823. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5824. if (item) {
  5825. //auto inventory
  5826. if (bag_id == 0 && to_slot == -1)
  5827. {
  5828. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5829. {
  5830. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5831. return;
  5832. }
  5833. // Set the slot for the item
  5834. item->details.inv_slot_id = bag_id;
  5835. item->details.slot_id = to_slot;
  5836. // Flag the item so it gets saved in its new location
  5837. item->save_needed = true;
  5838. // Add the item to its new location
  5839. player->item_list.AddItem(item);
  5840. // Remove the item from the overflow list
  5841. player->item_list.RemoveOverflowItem(item);
  5842. // Send the inventory update packet
  5843. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5844. return;
  5845. }
  5846. else if (bag_id == -3 && to_slot == -1) {
  5847. // Auto Bank
  5848. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5849. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5850. return;
  5851. }
  5852. item->details.inv_slot_id = bag_id;
  5853. item->details.slot_id = to_slot;
  5854. item->save_needed = true;
  5855. player->item_list.AddItem(item);
  5856. player->item_list.RemoveOverflowItem(item);
  5857. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5858. }
  5859. else if (bag_id == -4) {
  5860. // Shared Bank
  5861. if (!player->item_list.SharedBankAddAllowed(item)) {
  5862. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5863. return;
  5864. }
  5865. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5866. if (tmp_item) {
  5867. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5868. return;
  5869. }
  5870. else {
  5871. item->details.inv_slot_id = bag_id;
  5872. item->details.slot_id = to_slot;
  5873. item->save_needed = true;
  5874. player->item_list.AddItem(item);
  5875. player->item_list.RemoveOverflowItem(item);
  5876. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5877. return;
  5878. }
  5879. }
  5880. else {
  5881. // Try to get an item from the given bag id and slot id
  5882. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5883. // Check to see if we got an item, if we do send an error,
  5884. // if we don't put the overflow item into this slot
  5885. if (tmp_item) {
  5886. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5887. }
  5888. else {
  5889. item->details.inv_slot_id = bag_id;
  5890. item->details.slot_id = to_slot;
  5891. item->save_needed = true;
  5892. player->item_list.AddItem(item);
  5893. player->item_list.RemoveOverflowItem(item);
  5894. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5895. return;
  5896. }
  5897. }
  5898. }
  5899. }
  5900. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5901. {
  5902. sint64 data = strtoull(sep->arg[1], NULL, 0);
  5903. int32 character_item_id = (int32) (data >> 32);
  5904. int32 item_id = (int32) (data & 0xffffffffL);
  5905. int8 sale_setting = atoi(sep->arg[2]);
  5906. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  5907. if(item)
  5908. {
  5909. item->no_sale = sale_setting;
  5910. item->save_needed = true;
  5911. client->SendSellMerchantList();
  5912. }
  5913. }
  5914. }
  5915. else
  5916. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5917. }
  5918. /*
  5919. Function: Command_IRC()
  5920. Purpose : Handle the IRC functions
  5921. Params : IRC Commands
  5922. Dev : Scatman
  5923. Example : /irc say #Channel Hello World!
  5924. */
  5925. void Commands::Command_IRC(Client* client, Seperator* sep)
  5926. {
  5927. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5928. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5929. return;
  5930. }
  5931. if (sep && sep->arg[0][0]) {
  5932. if (strcasecmp(sep->arg[0], "say") == 0) {
  5933. if (sep->arg[1][0] && sep->arg[2][0]) {
  5934. if (sep->IsNumber(sep->arg[1]))
  5935. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5936. else
  5937. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5938. }
  5939. else
  5940. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5941. }
  5942. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5943. if (sep->arg[1][0])
  5944. irc.JoinChannel(client, sep->arg[1]);
  5945. else
  5946. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5947. }
  5948. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5949. if (sep->arg[1][0])
  5950. irc.LeaveChannel(client, sep->arg[1]);
  5951. else
  5952. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5953. }
  5954. else if (strcasecmp(sep->arg[0], "list") == 0)
  5955. irc.ListChannels(client);
  5956. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5957. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5958. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5959. else
  5960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5961. }
  5962. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5963. irc.DisconnectFromServer(client);
  5964. else
  5965. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5966. }
  5967. else
  5968. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5969. }
  5970. /*
  5971. Function: Command_Languages()
  5972. Purpose : Show's languages the player knows
  5973. Params :
  5974. Dev : Zcoretri
  5975. Example :
  5976. */
  5977. void Commands::Command_Languages(Client* client, Seperator* sep)
  5978. {
  5979. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5980. list<Language*>::iterator itr;
  5981. Language* language;
  5982. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  5983. for(itr = languages->begin(); itr != languages->end(); itr++)
  5984. {
  5985. language = *itr;
  5986. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  5987. }
  5988. }
  5989. /*
  5990. Function: Command_SetLanguage()
  5991. Purpose : Handles language commands
  5992. Params : Language ID
  5993. Dev : Zcoretri
  5994. Example :
  5995. */
  5996. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5997. {
  5998. Player* player = client->GetPlayer();
  5999. if (sep && sep->arg[0])
  6000. {
  6001. if(!sep->IsNumber(0))
  6002. {
  6003. //String passed in
  6004. const char* value = sep->arg[0];
  6005. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6006. {
  6007. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6008. client->SendLanguagesUpdate(0);
  6009. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6010. }
  6011. else
  6012. {
  6013. if(player->HasLanguage(value))
  6014. {
  6015. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6016. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6017. client->SendLanguagesUpdate(language->GetID());
  6018. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6019. }
  6020. else
  6021. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6022. }
  6023. }
  6024. else
  6025. {
  6026. //Number passed in
  6027. int32 id = atoul(sep->arg[0]);
  6028. if(player->HasLanguage(id))
  6029. {
  6030. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6031. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6032. client->SendLanguagesUpdate(id);
  6033. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6034. }
  6035. else
  6036. {
  6037. Language* language = master_languages_list.GetLanguage(id);
  6038. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6039. }
  6040. }
  6041. }
  6042. else
  6043. {
  6044. //No value was passed in
  6045. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6046. if(id > 0)
  6047. {
  6048. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6049. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6050. }
  6051. else
  6052. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6053. }
  6054. }
  6055. /*
  6056. Function: Command_LastName()
  6057. Purpose : Sets player surname
  6058. Params : Name text
  6059. Dev : theFoof
  6060. Example :
  6061. */
  6062. void Commands::Command_LastName(Client* client, Seperator* sep)
  6063. {
  6064. if (!client)
  6065. return;
  6066. if (sep && sep->arg[0])
  6067. {
  6068. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6069. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6070. return;
  6071. }
  6072. client->RemovePendingLastName();
  6073. uchar* checkname = (uchar*)sep->arg[0];
  6074. bool valid_name = true;
  6075. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6076. if (!alpha_check(checkname[i])) {
  6077. valid_name = false;
  6078. break;
  6079. }
  6080. }
  6081. if (!valid_name) {
  6082. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6083. return;
  6084. }
  6085. string last_name = (string)sep->arg[0];
  6086. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6087. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6088. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6089. client->SetPendingLastName(last_name);
  6090. client->SendLastNameConfirmation();
  6091. }
  6092. else
  6093. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6094. }
  6095. }
  6096. /*
  6097. Function: Command_ConfirmLastName()
  6098. Purpose : Confirms setting of player surname
  6099. Params : Name text
  6100. Dev : theFoof
  6101. Example :
  6102. */
  6103. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6104. {
  6105. if (!client)
  6106. return;
  6107. string* name = client->GetPendingLastName();
  6108. if (name){
  6109. Player* player = client->GetPlayer();
  6110. player->SetLastName(name->c_str(), false);
  6111. client->SendTitleUpdate();
  6112. player->SetCharSheetChanged(true);
  6113. client->RemovePendingLastName();
  6114. }
  6115. }
  6116. /*
  6117. Function: Command_Location()
  6118. Purpose : Display's Help for /location commands
  6119. Params :
  6120. Dev : Scatman
  6121. Example : /location = show's help for command
  6122. */
  6123. void Commands::Command_Location(Client* client)
  6124. {
  6125. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6126. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6127. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6128. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6129. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6130. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6131. }
  6132. /*
  6133. Function: Command_LocationAdd()
  6134. Purpose : Add's a location to an existing location config
  6135. Params : location_id
  6136. Dev : Scatman
  6137. Example : /location add {location_id}
  6138. */
  6139. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6140. {
  6141. if (sep && sep->arg[0] && sep->IsNumber(0))
  6142. {
  6143. int32 location_id = atoul(sep->arg[0]);
  6144. float x = client->GetPlayer()->GetX();
  6145. float y = client->GetPlayer()->GetY();
  6146. float z = client->GetPlayer()->GetZ();
  6147. if (database.AddLocationPoint(location_id, x, y, z))
  6148. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6149. else
  6150. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6151. }
  6152. else
  6153. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6154. }
  6155. /*
  6156. Function: Command_LocationCreate()
  6157. Purpose : Creates a new location config
  6158. Params : location name, 0/1 for include_y (optional)
  6159. Dev : Scatman
  6160. Example : /location create Test 1 = creates a new location named Test with include_y True
  6161. */
  6162. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6163. {
  6164. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6165. {
  6166. const char* name = sep->arg[0];
  6167. bool include_y = false;
  6168. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6169. include_y = true;
  6170. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  6171. if (location_id > 0)
  6172. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6173. else
  6174. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6175. }
  6176. else
  6177. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6178. }
  6179. /*
  6180. Function: Command_LocationDelete()
  6181. Purpose : Delete's a location config and all it's location points
  6182. Params : location_id
  6183. Dev : Scatman
  6184. Example : /location delete {location_id}
  6185. */
  6186. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6187. {
  6188. if (sep && sep->arg[0] && sep->IsNumber(0))
  6189. {
  6190. int32 location_id = atoul(sep->arg[0]);
  6191. if (database.DeleteLocation(location_id))
  6192. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6193. else
  6194. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6195. }
  6196. else
  6197. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6198. }
  6199. /*
  6200. Function: Command_LocationList()
  6201. Purpose : Display's a list of location points
  6202. Params : location_id
  6203. Dev : Scatman
  6204. Example : /location list {location_id}
  6205. */
  6206. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6207. {
  6208. if (sep && sep->arg[0])
  6209. {
  6210. const char* option = sep->arg[0];
  6211. if (strncmp(option, "locations", strlen(option)) == 0)
  6212. database.ListLocations(client);
  6213. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  6214. {
  6215. int32 location_id = atoul(sep->arg[1]);
  6216. database.ListLocationPoints(client, location_id);
  6217. }
  6218. else
  6219. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6220. }
  6221. else
  6222. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6223. }
  6224. /*
  6225. Function: Command_LocationRemove()
  6226. Purpose : Removes a single location point from a location config
  6227. Params : location_point_id (gotten from /location list {id})
  6228. Dev : Scatman
  6229. Example : /location remove 1 = will remove location_point_id 1
  6230. */
  6231. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  6232. {
  6233. if (sep && sep->arg[0] && sep->IsNumber(0))
  6234. {
  6235. int32 location_point_id = atoul(sep->arg[0]);
  6236. if (database.DeleteLocationPoint(location_point_id))
  6237. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  6238. else
  6239. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  6240. }
  6241. else
  6242. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  6243. }
  6244. /*
  6245. Function: Command_Merchant()
  6246. Purpose : Handles Merchant commands
  6247. Params : list
  6248. Dev : Scatman
  6249. Example : /merchant list
  6250. */
  6251. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  6252. {
  6253. if( handler == COMMAND_MERCHANT )
  6254. {
  6255. // /merchant command by itself shows help (to be extended)
  6256. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6257. return;
  6258. }
  6259. else if( handler == COMMAND_MERCHANT_LIST )
  6260. {
  6261. // /merchant list command expects "description" param
  6262. if (sep && sep->arg[0])
  6263. {
  6264. const char* merchant_description = sep->argplus[0];
  6265. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  6266. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  6267. map<int32, MerchantInfo*>::iterator itr;
  6268. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  6269. {
  6270. string description = database.GetMerchantDescription(itr->first);
  6271. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  6272. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  6273. }
  6274. }
  6275. else // no description
  6276. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6277. }
  6278. }
  6279. /*
  6280. Function: Command_Modify()
  6281. Purpose : to replace our other "set" commands
  6282. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  6283. Dev : John Adams
  6284. Example : /modify spell set name "Aegolism III"
  6285. */
  6286. void Commands::Command_Modify(Client* client)
  6287. {
  6288. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  6289. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  6290. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  6291. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  6292. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  6293. }
  6294. /*
  6295. Function: Command_ModifySpawn()
  6296. Purpose : replace "spawn set" commands
  6297. Params : Action : the action to perform (or special handler)
  6298. : Field : the DB field to change
  6299. : Value : what to set the value to
  6300. : Target : what object to change (my target, or spawn_id)
  6301. Dev : John Adams
  6302. Example : /modify spawn set name "Lady Vox"
  6303. :
  6304. Note : Special Handlers, like "zoneto" for Signs
  6305. : /modify spawn zoneto
  6306. : Will set a sign's zone x/y/z to my current coords
  6307. */
  6308. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  6309. {
  6310. PrintSep(sep, "COMMAND_MODIFY");
  6311. // need at least 2 args for a valid command
  6312. if( sep && sep->arg[1] )
  6313. {
  6314. // JA: just a quick implementation because I need it :)
  6315. if (strcmp(sep->arg[0], "zoneto") == 0)
  6316. {
  6317. if( sep->IsNumber(1) )
  6318. {
  6319. int32 spawn_id = atoul(sep->arg[1]);
  6320. float x_coord = client->GetPlayer()->GetX();
  6321. float y_coord = client->GetPlayer()->GetY();
  6322. float z_coord = client->GetPlayer()->GetZ();
  6323. float h_coord = client->GetPlayer()->GetHeading();
  6324. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  6325. }
  6326. else
  6327. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  6328. }
  6329. }
  6330. else
  6331. Command_Modify(client);
  6332. }
  6333. /*
  6334. Function: Command_ModifyCharacter()
  6335. Purpose : to replace our other "set" commands
  6336. Params : Action : Add, Remove
  6337. : Field : copper, silver, gold, plat
  6338. : Value : min 1, max unlimited
  6339. : Target : Self, Player
  6340. Dev : Cynnar
  6341. Example : /modify character add gold 50
  6342. : /modify character remove silver 25
  6343. */
  6344. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  6345. {
  6346. PrintSep(sep, "COMMAND_MODIFY");
  6347. int64 value = 0;
  6348. Player* player = client->GetPlayer();
  6349. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  6350. player = (Player*)player->GetTarget();
  6351. // need at least 2 args for a valid command
  6352. if( sep && sep->arg[1] )
  6353. {
  6354. if (strcmp(sep->arg[0], "add") == 0)
  6355. {
  6356. if (strcmp(sep->arg[1], "copper") == 0)
  6357. {
  6358. value = atoi64(sep->arg[2]);
  6359. player->AddCoins(value);
  6360. if (client->GetPlayer() == player)
  6361. {
  6362. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  6363. }
  6364. else {
  6365. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  6366. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  6367. }
  6368. }
  6369. else if (strcmp(sep->arg[1], "silver") == 0)
  6370. {
  6371. value = atoi64(sep->arg[2]) * 100;
  6372. player->AddCoins(value);
  6373. if (client->GetPlayer() == player)
  6374. {
  6375. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  6376. }
  6377. else {
  6378. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  6379. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  6380. }
  6381. }
  6382. else if (strcmp(sep->arg[1], "gold") == 0)
  6383. {
  6384. value = atoi64(sep->arg[2]) * 10000;
  6385. player->AddCoins(value);
  6386. if (client->GetPlayer() == player)
  6387. {
  6388. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  6389. }
  6390. else {
  6391. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6392. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6393. }
  6394. }
  6395. else if (strcmp(sep->arg[1], "plat") == 0)
  6396. {
  6397. value = atoi64(sep->arg[2]) * 1000000;
  6398. player->AddCoins(value);
  6399. if (client->GetPlayer() == player)
  6400. {
  6401. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  6402. }
  6403. else {
  6404. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  6405. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  6406. }
  6407. }
  6408. else
  6409. {
  6410. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  6411. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  6412. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  6413. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  6414. }
  6415. }
  6416. else if (strcmp(sep->arg[0], "remove") == 0)
  6417. {
  6418. if (strcmp(sep->arg[1], "copper") == 0)
  6419. {
  6420. value = atoi64(sep->arg[2]);
  6421. player->RemoveCoins(value);
  6422. if (client->GetPlayer() == player)
  6423. {
  6424. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  6425. }
  6426. else {
  6427. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  6428. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  6429. }
  6430. }
  6431. else if (strcmp(sep->arg[1], "silver") == 0)
  6432. {
  6433. value = atoi64(sep->arg[2]) * 100;
  6434. player->RemoveCoins(value);
  6435. if (client->GetPlayer() == player)
  6436. {
  6437. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  6438. }
  6439. else {
  6440. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  6441. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  6442. }
  6443. }
  6444. else if (strcmp(sep->arg[1], "gold") == 0)
  6445. {
  6446. value = atoi64(sep->arg[2]) * 10000;
  6447. player->RemoveCoins(value);
  6448. if (client->GetPlayer() == player)
  6449. {
  6450. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  6451. }
  6452. else {
  6453. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  6454. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6455. }
  6456. }
  6457. else if (strcmp(sep->arg[1], "plat") == 0)
  6458. {
  6459. value = atoi64(sep->arg[2]) * 1000000;
  6460. player->RemoveCoins(value);
  6461. if (client->GetPlayer() == player)
  6462. {
  6463. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  6464. }
  6465. else {
  6466. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  6467. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  6468. }
  6469. }
  6470. else
  6471. {
  6472. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  6473. }
  6474. }
  6475. else if (strcmp(sep->arg[0], "set") == 0) {
  6476. if (strcmp(sep->arg[1], "tslevel") == 0) {
  6477. int8 level = atoi(sep->arg[2]);
  6478. if (level > 0 && level < 256) {
  6479. if (player) {
  6480. if (client->GetPlayer() == player)
  6481. client->ChangeTSLevel(player->GetTSLevel(), level);
  6482. else
  6483. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  6484. }
  6485. }
  6486. else
  6487. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  6488. }
  6489. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  6490. int8 tsclass = atoi(sep->arg[2]);
  6491. player->SetTradeskillClass(tsclass);
  6492. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  6493. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  6494. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  6495. player->SetCharSheetChanged(true);
  6496. }
  6497. }
  6498. }
  6499. else
  6500. {
  6501. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  6502. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  6503. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  6504. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  6505. }
  6506. }
  6507. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  6508. {
  6509. PrintSep(sep, "COMMAND_MODIFY");
  6510. // need at least 2 args for a valid command
  6511. if( sep && sep->arg[1] )
  6512. {
  6513. }
  6514. else
  6515. Command_Modify(client);
  6516. }
  6517. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  6518. {
  6519. PrintSep(sep, "COMMAND_MODIFY");
  6520. // need at least 2 args for a valid command
  6521. if( sep && sep->arg[1] )
  6522. {
  6523. }
  6524. else
  6525. Command_Modify(client);
  6526. }
  6527. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  6528. {
  6529. PrintSep(sep, "COMMAND_MODIFY");
  6530. // need at least 2 args for a valid command
  6531. if( sep && sep->arg[1] )
  6532. {
  6533. }
  6534. else
  6535. Command_Modify(client);
  6536. }
  6537. /*
  6538. Function: Command_ModifyQuest()
  6539. Purpose : to list players quest and completed quests
  6540. Params : Action : list, completed
  6541. : Target : Self, Player
  6542. Dev : Cynnar
  6543. Example : /modify quest list
  6544. : /modify quest completed
  6545. */
  6546. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  6547. {
  6548. PrintSep(sep, "COMMAND_MODIFY");
  6549. int64 value = 0;
  6550. Player* player = client->GetPlayer();
  6551. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  6552. player = (Player*)player->GetTarget();
  6553. // need at least 2 args for a valid command
  6554. if (sep && sep->arg[1])
  6555. {
  6556. if (strcmp(sep->arg[0], "list") == 0)
  6557. {
  6558. map<int32, Quest*>* quests = player->GetPlayerQuests();
  6559. map<int32, Quest*>::iterator itr;
  6560. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  6561. if (quests->size() == 0)
  6562. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  6563. else
  6564. {
  6565. for (itr = quests->begin(); itr != quests->end(); itr++)
  6566. {
  6567. Quest* quest = itr->second;
  6568. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6569. }
  6570. }
  6571. }
  6572. else if (strcmp(sep->arg[0], "completed") == 0)
  6573. {
  6574. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  6575. map<int32, Quest*>::iterator itr;
  6576. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  6577. if (quests->size() == 0)
  6578. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  6579. else
  6580. {
  6581. for (itr = quests->begin(); itr != quests->end(); itr++)
  6582. {
  6583. Quest* quest = itr->second;
  6584. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6585. }
  6586. }
  6587. }
  6588. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  6589. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  6590. else if (strcmp(sep->arg[0], "remove") == 0)
  6591. {
  6592. int32 quest_id = 0;
  6593. if (sep && sep->arg[1] && sep->IsNumber(1))
  6594. quest_id = atoul(sep->arg[1]);
  6595. if (quest_id > 0)
  6596. {
  6597. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  6598. {
  6599. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6600. if (quest)
  6601. if (client->GetPlayer() == player)
  6602. {
  6603. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  6604. }
  6605. else
  6606. {
  6607. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  6608. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  6609. }
  6610. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  6611. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  6612. }
  6613. client->RemovePlayerQuest(quest_id);
  6614. client->GetCurrentZone()->SendQuestUpdates(client);
  6615. }
  6616. }
  6617. else if (strcmp(sep->arg[0], "advance") == 0)
  6618. {
  6619. int32 quest_id = 0;
  6620. int32 step = 0;
  6621. if (sep && sep->arg[1] && sep->IsNumber(1))
  6622. {
  6623. quest_id = atoul(sep->arg[1]);
  6624. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6625. if (sep && sep->arg[2] && sep->IsNumber(1))
  6626. {
  6627. step = atoul(sep->arg[2]);
  6628. if (quest_id > 0 && step > 0)
  6629. {
  6630. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  6631. {
  6632. if (client)
  6633. {
  6634. client->AddPendingQuestUpdate(quest_id, step);
  6635. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  6636. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  6637. }
  6638. }
  6639. }
  6640. else
  6641. {
  6642. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  6643. }
  6644. }
  6645. else
  6646. {
  6647. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  6648. }
  6649. }
  6650. else
  6651. {
  6652. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  6653. }
  6654. }
  6655. else
  6656. {
  6657. Command_Modify(client);
  6658. }
  6659. }
  6660. else
  6661. {
  6662. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  6663. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  6664. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  6665. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  6666. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  6667. }
  6668. }
  6669. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  6670. {
  6671. PrintSep(sep, "COMMAND_MODIFY");
  6672. // need at least 2 args for a valid command
  6673. if( sep && sep->arg[1] )
  6674. {
  6675. if (strcmp(sep->arg[0], "add") == 0) {
  6676. const char* skill_name = sep->argplus[1];
  6677. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6678. if (skill) {
  6679. Player* player = 0;
  6680. Client* to_client = 0;
  6681. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6682. player = (Player*)client->GetPlayer()->GetTarget();
  6683. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6684. }
  6685. else {
  6686. player = client->GetPlayer();
  6687. to_client = client;
  6688. }
  6689. if (player)
  6690. {
  6691. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6692. {
  6693. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6694. if (to_client == client) {
  6695. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  6696. }
  6697. else {
  6698. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6699. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6700. }
  6701. }
  6702. else
  6703. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  6704. }
  6705. }
  6706. else
  6707. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6708. }
  6709. else if (strcmp(sep->arg[0], "remove") == 0) {
  6710. const char* skill_name = sep->argplus[1];
  6711. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6712. if (skill) {
  6713. Player* player = 0;
  6714. Client* to_client = 0;
  6715. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6716. player = (Player*)client->GetPlayer()->GetTarget();
  6717. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6718. }
  6719. else {
  6720. player = client->GetPlayer();
  6721. to_client = client;
  6722. }
  6723. if (player)
  6724. {
  6725. if (player->GetSkills()->HasSkill(skill->skill_id))
  6726. {
  6727. player->RemoveSkillFromDB(skill, true);
  6728. if (client == to_client) {
  6729. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  6730. }
  6731. else {
  6732. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6733. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6734. }
  6735. }
  6736. else {
  6737. if (client == to_client)
  6738. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  6739. else
  6740. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6741. }
  6742. }
  6743. }
  6744. else
  6745. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6746. }
  6747. else if (strcmp(sep->arg[0], "set") == 0) {
  6748. if (!sep->IsNumber(2)) {
  6749. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  6750. return;
  6751. }
  6752. const char* skill_name = sep->arg[1];
  6753. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6754. if (skill) {
  6755. int16 val = atoi(sep->arg[2]);
  6756. Player* player = 0;
  6757. Client* to_client = 0;
  6758. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6759. player = (Player*)client->GetPlayer()->GetTarget();
  6760. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6761. }
  6762. else {
  6763. player = client->GetPlayer();
  6764. to_client = client;
  6765. }
  6766. if (player)
  6767. {
  6768. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6769. player->GetSkills()->SetSkill(skill->skill_id, val);
  6770. if (client != to_client)
  6771. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6772. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6773. }
  6774. else {
  6775. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6776. }
  6777. }
  6778. }
  6779. else {
  6780. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6781. }
  6782. }
  6783. else {
  6784. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6785. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6786. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6787. }
  6788. }
  6789. else {
  6790. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6791. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6792. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6793. }
  6794. }
  6795. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6796. {
  6797. PrintSep(sep, "COMMAND_MODIFY");
  6798. // need at least 2 args for a valid command
  6799. if( sep && sep->arg[1] )
  6800. {
  6801. }
  6802. else
  6803. Command_Modify(client);
  6804. }
  6805. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6806. {
  6807. PrintSep(sep, "COMMAND_MODIFY");
  6808. // need at least 2 args for a valid command
  6809. if( sep && sep->arg[1] )
  6810. {
  6811. }
  6812. else
  6813. Command_Modify(client);
  6814. }
  6815. /*
  6816. Function: Command_MOTD()
  6817. Purpose : Displays server MOTD
  6818. Params :
  6819. Dev : LethalEncounter
  6820. Example : /motd
  6821. */
  6822. void Commands::Command_MOTD(Client* client)
  6823. {
  6824. if (client)
  6825. ClientPacketFunctions::SendMOTD(client);
  6826. }
  6827. /*
  6828. Function: Command_Pet()
  6829. Purpose : Handle Pet {Command} commands
  6830. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6831. Dev :
  6832. Example : /pet preserve_master
  6833. */
  6834. void Commands::Command_Pet(Client* client, Seperator* sep)
  6835. {
  6836. PrintSep(sep, "COMMAND_PET");
  6837. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6838. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6839. if (!sep || !sep->arg[0])
  6840. return; // should have sep->arg[0] filled
  6841. if (strcmp(sep->arg[0], "hide") == 0) {
  6842. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6843. Entity* pet = client->GetPlayer()->GetDeityPet();
  6844. if (pet) {
  6845. if (pet->IsPrivateSpawn())
  6846. client->GetPlayer()->HideDeityPet(false);
  6847. else
  6848. client->GetPlayer()->HideDeityPet(true);
  6849. }
  6850. pet = client->GetPlayer()->GetCosmeticPet();
  6851. if (pet) {
  6852. if (pet->IsPrivateSpawn())
  6853. client->GetPlayer()->HideCosmeticPet(false);
  6854. else
  6855. client->GetPlayer()->HideCosmeticPet(true);
  6856. }
  6857. return;
  6858. }
  6859. // below is for all combat pets
  6860. if (!client->GetPlayer()->HasPet()) {
  6861. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6862. return;
  6863. }
  6864. if (strcmp(sep->arg[0], "stay") == 0) {
  6865. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6866. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  6867. client->GetPlayer()->SetCharSheetChanged(true);
  6868. if (client->GetPlayer()->GetPet())
  6869. client->GetPlayer()->GetPet()->following = false;
  6870. if (client->GetPlayer()->GetCharmedPet())
  6871. client->GetPlayer()->GetCharmedPet()->following = false;
  6872. }
  6873. else if (strcmp(sep->arg[0], "follow") == 0) {
  6874. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6875. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  6876. client->GetPlayer()->SetCharSheetChanged(true);
  6877. }
  6878. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6879. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  6880. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6881. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  6882. }
  6883. else {
  6884. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6885. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  6886. }
  6887. client->GetPlayer()->SetCharSheetChanged(true);
  6888. }
  6889. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6890. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  6891. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6892. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  6893. }
  6894. else {
  6895. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6896. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  6897. }
  6898. client->GetPlayer()->SetCharSheetChanged(true);
  6899. }
  6900. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6901. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6902. if (client->GetPlayer()->GetPet())
  6903. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6904. if (client->GetPlayer()->GetCharmedPet())
  6905. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6906. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  6907. client->GetPlayer()->SetCharSheetChanged(true);
  6908. }
  6909. else if (strcmp(sep->arg[0], "attack") == 0) {
  6910. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6911. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6912. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6913. if (client->GetPlayer()->GetPet())
  6914. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6915. if (client->GetPlayer()->GetCharmedPet())
  6916. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6917. }
  6918. else
  6919. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6920. }
  6921. else
  6922. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6923. }
  6924. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6925. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6926. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6927. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6928. }
  6929. else
  6930. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6931. }
  6932. /*
  6933. Function: Command_PetName()
  6934. Purpose : Pet your name (???)
  6935. Params :
  6936. Dev :
  6937. Example :
  6938. */
  6939. void Commands::Command_PetName(Client* client, Seperator* sep)
  6940. {
  6941. PrintSep(sep, "COMMAND_PETNAME");
  6942. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6943. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6944. }
  6945. /*
  6946. Function: Command_NamePet()
  6947. Purpose : Name your pet
  6948. Params :
  6949. Dev :
  6950. Example :
  6951. */
  6952. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6953. {
  6954. PrintSep(sep, "COMMAND_NAME_PET");
  6955. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6956. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6957. }
  6958. /*
  6959. Function: Command_Rename()
  6960. Purpose : Renames existing pet
  6961. Params :
  6962. Dev :
  6963. Example :
  6964. */
  6965. void Commands::Command_Rename(Client* client, Seperator* sep)
  6966. {
  6967. PrintSep(sep, "COMMAND_RENAME");
  6968. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6969. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6970. }
  6971. /*
  6972. Function: Command_ConfirmRename()
  6973. Purpose : Confirms renaming your pet
  6974. Params :
  6975. Dev :
  6976. Example :
  6977. */
  6978. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6979. {
  6980. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6981. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6982. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6983. }
  6984. /*
  6985. Function: Command_PetOptions()
  6986. Purpose : Sets various pet options
  6987. Params :
  6988. Dev :
  6989. Example :
  6990. */
  6991. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6992. {
  6993. PrintSep(sep, "COMMAND_PETOPTIONS");
  6994. Player* player = client->GetPlayer();
  6995. Spawn* target = player->GetTarget();
  6996. if (!target)
  6997. return;
  6998. if (target == player->GetPet())
  6999. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7000. else if (target == player->GetCharmedPet())
  7001. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7002. else if (target == player->GetCosmeticPet())
  7003. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7004. else if (target == player->GetDeityPet())
  7005. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7006. }
  7007. /*
  7008. Function: Command_Random()
  7009. Purpose : Handles /random dice roll in-game
  7010. Params : 1-100
  7011. Dev : Scatman
  7012. Example : /randon 1 100
  7013. */
  7014. void Commands::Command_Random(Client* client, Seperator* sep)
  7015. {
  7016. char message[256] = {0};
  7017. if (sep)
  7018. {
  7019. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7020. 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])));
  7021. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7022. 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])));
  7023. else
  7024. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7025. }
  7026. else
  7027. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7028. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7029. }
  7030. /*
  7031. Function: Command_Randomize()
  7032. Purpose : Sets randomize (appearance) values for NPCs
  7033. Params : Attrib Name
  7034. Dev : Scatman
  7035. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7036. */
  7037. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7038. {
  7039. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7040. if (target)
  7041. {
  7042. if (target->IsNPC())
  7043. {
  7044. if (sep && sep->arg[0] && !sep->IsNumber(0))
  7045. {
  7046. const char* value = sep->arg[0];
  7047. if (strncasecmp(value, "show", strlen(value)) == 0)
  7048. {
  7049. client->DisplayRandomizeFeatures(target->GetRandomize());
  7050. }
  7051. else
  7052. {
  7053. if (sep->arg[1] && sep->IsNumber(1))
  7054. {
  7055. int8 option = atoi(sep->arg[1]);
  7056. if (option == 0 || option == 1)
  7057. {
  7058. int32 feature = 0;
  7059. char feature_text[32] = {0};
  7060. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7061. feature = RANDOMIZE_GENDER;
  7062. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7063. }
  7064. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7065. feature = RANDOMIZE_RACE;
  7066. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7067. }
  7068. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7069. feature = RANDOMIZE_MODEL_TYPE;
  7070. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7071. }
  7072. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7073. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7074. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7075. }
  7076. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7077. feature = RANDOMIZE_HAIR_TYPE;
  7078. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7079. }
  7080. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7081. feature = RANDOMIZE_WING_TYPE;
  7082. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7083. }
  7084. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7085. feature = RANDOMIZE_CHEEK_TYPE;
  7086. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7087. }
  7088. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7089. feature = RANDOMIZE_CHIN_TYPE;
  7090. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7091. }
  7092. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7093. feature = RANDOMIZE_EAR_TYPE;
  7094. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7095. }
  7096. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7097. feature = RANDOMIZE_EYE_BROW_TYPE;
  7098. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7099. }
  7100. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7101. feature = RANDOMIZE_EYE_TYPE;
  7102. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7103. }
  7104. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7105. feature = RANDOMIZE_LIP_TYPE;
  7106. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7107. }
  7108. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7109. feature = RANDOMIZE_NOSE_TYPE;
  7110. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7111. }
  7112. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7113. feature = RANDOMIZE_EYE_COLOR;
  7114. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7115. }
  7116. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7117. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7118. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7119. }
  7120. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7121. feature = RANDOMIZE_HAIR_COLOR1;
  7122. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7123. }
  7124. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7125. feature = RANDOMIZE_HAIR_COLOR2;
  7126. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7127. }
  7128. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7129. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7130. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7131. }
  7132. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7133. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7134. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7135. }
  7136. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7137. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7138. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7139. }
  7140. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7141. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7142. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7143. }
  7144. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7145. feature = RANDOMIZE_SKIN_COLOR;
  7146. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7147. }
  7148. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7149. feature = RANDOMIZE_WING_COLOR1;
  7150. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7151. }
  7152. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7153. feature = RANDOMIZE_WING_COLOR2;
  7154. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7155. }
  7156. else {
  7157. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7158. 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'.");
  7159. }
  7160. if (feature > 0) {
  7161. if (option == 1) {
  7162. if (target->GetRandomize() & feature)
  7163. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  7164. else {
  7165. target->AddRandomize(feature);
  7166. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  7167. database.UpdateRandomize(target->GetDatabaseID(), feature);
  7168. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  7169. }
  7170. }
  7171. else {
  7172. if (target->GetRandomize() & feature) {
  7173. target->AddRandomize(-feature);
  7174. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  7175. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  7176. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  7177. }
  7178. else
  7179. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  7180. }
  7181. }
  7182. }
  7183. else
  7184. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7185. }
  7186. else
  7187. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7188. }
  7189. }
  7190. else {
  7191. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  7192. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  7193. 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'.");
  7194. }
  7195. }
  7196. else
  7197. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  7198. }
  7199. else
  7200. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  7201. }
  7202. /*
  7203. Function: Command_ShowCloak()
  7204. Purpose : Character Settings combo box for Show Cloak
  7205. Params : true/false
  7206. Dev : John Adams
  7207. Example :
  7208. */
  7209. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  7210. {
  7211. Player* player = client->GetPlayer();
  7212. if (sep && sep->arg[0])
  7213. {
  7214. const char* value = sep->arg[0];
  7215. if (strncasecmp(value, "true", strlen(value)) == 0)
  7216. {
  7217. player->set_character_flag(CF_SHOW_CLOAK);
  7218. player->reset_character_flag(CF2_SHOW_RANGED);
  7219. }
  7220. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7221. player->reset_character_flag(CF_SHOW_CLOAK);
  7222. else
  7223. {
  7224. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7225. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7226. }
  7227. }
  7228. }
  7229. /*
  7230. Function: Command_ShowHelm()
  7231. Purpose : Character Settings combo box for Show Helm
  7232. Params : true/false
  7233. Dev : John Adams
  7234. Example :
  7235. */
  7236. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  7237. {
  7238. Player* player = client->GetPlayer();
  7239. if (sep && sep->arg[0])
  7240. {
  7241. const char* value = sep->arg[0];
  7242. if (strncasecmp(value, "true", strlen(value)) == 0)
  7243. {
  7244. player->reset_character_flag(CF_HIDE_HELM);
  7245. player->set_character_flag(CF_HIDE_HOOD);
  7246. }
  7247. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7248. player->set_character_flag(CF_HIDE_HELM);
  7249. else
  7250. {
  7251. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7252. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7253. }
  7254. }
  7255. }
  7256. /*
  7257. Function: Command_ShowHood()
  7258. Purpose : Character Settings combo box for Show Hood
  7259. Params : true/false
  7260. Dev : John Adams
  7261. Example :
  7262. */
  7263. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  7264. {
  7265. Player* player = client->GetPlayer();
  7266. if (sep && sep->arg[0])
  7267. {
  7268. const char* value = sep->arg[0];
  7269. if (strncasecmp(value, "true", strlen(value)) == 0)
  7270. {
  7271. player->reset_character_flag(CF_HIDE_HOOD);
  7272. player->set_character_flag(CF_HIDE_HELM);
  7273. }
  7274. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7275. player->set_character_flag(CF_HIDE_HOOD);
  7276. else
  7277. {
  7278. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7279. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7280. }
  7281. }
  7282. }
  7283. /*
  7284. Function: Command_ShowHoodHelm()
  7285. Purpose : Character Settings combo box for Show Helm or Hood
  7286. Params : true/false
  7287. Dev : John Adams
  7288. Example :
  7289. */
  7290. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  7291. {
  7292. Player* player = client->GetPlayer();
  7293. if (sep && sep->arg[0])
  7294. {
  7295. const char* value = sep->arg[0];
  7296. if (strncasecmp(value, "true", strlen(value)) == 0)
  7297. {
  7298. player->reset_character_flag(CF_HIDE_HOOD);
  7299. player->reset_character_flag(CF_HIDE_HELM);
  7300. }
  7301. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7302. {
  7303. // don't think we ever wind up in here...
  7304. player->set_character_flag(CF_HIDE_HOOD);
  7305. player->set_character_flag(CF_HIDE_HELM);
  7306. }
  7307. else
  7308. {
  7309. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7310. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7311. }
  7312. }
  7313. }
  7314. /*
  7315. Function: Command_ShowRanged()
  7316. Purpose : Character Settings combo box for Show Ranged weapon
  7317. Params : true/false
  7318. Dev : John Adams
  7319. Example :
  7320. */
  7321. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  7322. {
  7323. Player* player = client->GetPlayer();
  7324. if (sep && sep->arg[0])
  7325. {
  7326. const char* value = sep->arg[0];
  7327. if (strncasecmp(value, "true", strlen(value)) == 0)
  7328. {
  7329. player->set_character_flag(CF2_SHOW_RANGED);
  7330. player->reset_character_flag(CF_SHOW_CLOAK);
  7331. }
  7332. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7333. player->reset_character_flag(CF2_SHOW_RANGED);
  7334. else
  7335. {
  7336. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7337. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7338. }
  7339. }
  7340. }
  7341. /*
  7342. Function:
  7343. Purpose :
  7344. Params :
  7345. Dev :
  7346. Example :
  7347. */
  7348. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  7349. {
  7350. Player* player = 0;
  7351. Client* to_client = 0;
  7352. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  7353. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  7354. switch(handler)
  7355. {
  7356. case COMMAND_SKILL:
  7357. {
  7358. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  7359. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  7360. break;
  7361. }
  7362. case COMMAND_SKILL_ADD:
  7363. {
  7364. if (sep && sep->arg[0])
  7365. {
  7366. const char* skill_name = sep->argplus[0];
  7367. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7368. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  7369. {
  7370. player = to_client->GetPlayer();
  7371. if (player)
  7372. {
  7373. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7374. {
  7375. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7376. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7377. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7378. }
  7379. else
  7380. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  7381. }
  7382. }
  7383. else if (skill) // add skill to yourself
  7384. {
  7385. player = client->GetPlayer();
  7386. if (player)
  7387. {
  7388. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7389. {
  7390. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7391. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  7392. }
  7393. else
  7394. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  7395. }
  7396. }
  7397. else
  7398. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  7399. }
  7400. else
  7401. {
  7402. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  7403. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  7404. }
  7405. break;
  7406. }
  7407. case COMMAND_SKILL_REMOVE:
  7408. {
  7409. if (sep && sep->arg[0])
  7410. {
  7411. const char* skill_name = sep->argplus[0];
  7412. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7413. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  7414. {
  7415. player = to_client->GetPlayer();
  7416. if (player)
  7417. {
  7418. if (player->GetSkills()->HasSkill(skill->skill_id))
  7419. {
  7420. player->RemoveSkillFromDB(skill, true);
  7421. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7422. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7423. }
  7424. else
  7425. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7426. }
  7427. }
  7428. else if(skill) // remove skill from yourself
  7429. {
  7430. Player* player = client->GetPlayer();
  7431. if (player)
  7432. {
  7433. if (player->GetSkills()->HasSkill(skill->skill_id))
  7434. {
  7435. player->RemoveSkillFromDB(skill, true);
  7436. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  7437. }
  7438. else
  7439. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  7440. }
  7441. }
  7442. else
  7443. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  7444. }
  7445. else
  7446. {
  7447. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  7448. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  7449. }
  7450. break;
  7451. }
  7452. case COMMAND_SKILL_LIST:
  7453. {
  7454. if (sep && sep->arg[0])
  7455. {
  7456. const char* skill_name = sep->argplus[0];
  7457. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  7458. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  7459. map<int32, Skill*>::iterator itr;
  7460. if (skills && skills->size() > 0)
  7461. {
  7462. for (itr = skills->begin(); itr != skills->end(); itr++)
  7463. {
  7464. Skill* skill = itr->second;
  7465. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  7466. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  7467. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  7468. }
  7469. }
  7470. }
  7471. else
  7472. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  7473. break;
  7474. }
  7475. }
  7476. }
  7477. /*
  7478. Function: Command_SpawnTemplate()
  7479. Purpose : Create or Use defined Spawn Templates
  7480. Params : create, save, rempve, list
  7481. Dev : John Adams
  7482. Example : /spawn template create "Test"
  7483. */
  7484. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  7485. {
  7486. if (sep == NULL || sep->arg[0] == NULL)
  7487. {
  7488. 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.");
  7489. return;
  7490. }
  7491. // got params, continue
  7492. const char * template_cmd = sep->arg[0];
  7493. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  7494. {
  7495. if (!sep->IsSet(1))
  7496. {
  7497. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  7498. 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.");
  7499. return;
  7500. }
  7501. map<int32, string>* template_names = 0;
  7502. if (sep->IsNumber(1))
  7503. {
  7504. int32 location_id = 0;
  7505. location_id = atoi(sep->arg[1]);
  7506. template_names = database.GetSpawnTemplateListByID(location_id);
  7507. }
  7508. else
  7509. {
  7510. const char* name = 0;
  7511. name = sep->argplus[1];
  7512. template_names = database.GetSpawnTemplateListByName(name);
  7513. }
  7514. if(!template_names)
  7515. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  7516. else
  7517. {
  7518. map<int32, string>::iterator itr;
  7519. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  7520. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  7521. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  7522. safe_delete(template_names);
  7523. }
  7524. }
  7525. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  7526. {
  7527. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7528. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  7529. {
  7530. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  7531. {
  7532. // first, lookup to see if template name already exists
  7533. const char* name = 0;
  7534. name = sep->argplus[1];
  7535. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  7536. if(!template_names)
  7537. {
  7538. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  7539. if( new_template_id > 0 )
  7540. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  7541. else
  7542. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  7543. }
  7544. else
  7545. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  7546. }
  7547. else
  7548. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  7549. }
  7550. else
  7551. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  7552. }
  7553. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  7554. {
  7555. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  7556. {
  7557. int32 template_id = 0;
  7558. template_id = atoi(sep->arg[1]);
  7559. if (database.RemoveSpawnTemplate(template_id))
  7560. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  7561. else
  7562. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  7563. }
  7564. else
  7565. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  7566. }
  7567. // Renamed create to spawn
  7568. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  7569. {
  7570. if (sep && sep->arg[1][0])
  7571. {
  7572. int32 new_location = 0;
  7573. if (sep->IsNumber(1))
  7574. {
  7575. int32 template_id = 0;
  7576. template_id = atoi(sep->arg[1]);
  7577. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  7578. if( new_location > 0 )
  7579. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  7580. else
  7581. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  7582. }
  7583. else
  7584. {
  7585. const char* name = 0;
  7586. name = sep->argplus[1];
  7587. new_location = database.CreateSpawnFromTemplateByName(client, name);
  7588. if( new_location > 0 )
  7589. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  7590. else
  7591. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  7592. }
  7593. }
  7594. else
  7595. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  7596. }
  7597. else
  7598. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  7599. }
  7600. void Commands::Command_Speed(Client* client, Seperator* sep) {
  7601. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  7602. float new_speed = atof(sep->arg[0]);
  7603. if (new_speed > 0.0f)
  7604. {
  7605. client->GetPlayer()->SetSpeed(new_speed, true);
  7606. client->GetPlayer()->SetCharSheetChanged(true);
  7607. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  7608. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  7609. }
  7610. else
  7611. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  7612. }
  7613. else{
  7614. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  7615. }
  7616. }
  7617. /*
  7618. Function: Command_StationMarketPlace()
  7619. Purpose : just trying to eat the console spam for now
  7620. Params :
  7621. Dev : John
  7622. */
  7623. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  7624. {
  7625. PrintSep(sep, "COMMAND_SMP");
  7626. // This will reduce the spam from once every 10 sec to once every 30 sec,
  7627. // can't seem to reduce it any more get rid of it completely...
  7628. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  7629. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  7630. if (packet) {
  7631. packet->setDataByName("account_id", client->GetAccountID());
  7632. packet->setDataByName("character_id", client->GetCharacterID());
  7633. packet->setDataByName("unknown1", 1, 5);
  7634. packet->setDataByName("unknown1", 26, 6);
  7635. packet->setDataByName("unknown2", 0xFFFFFFFF);
  7636. packet->setDataByName("unknown3", 248, 1);
  7637. client->QueuePacket(packet->serialize());
  7638. }
  7639. safe_delete(packet);
  7640. }
  7641. }
  7642. /*
  7643. Function: Command_StopDrinking()
  7644. Purpose : Stops player from auto-consuming drink
  7645. Params :
  7646. Dev : Zcoretri
  7647. Example : /stopdrinking
  7648. */
  7649. void Commands::Command_StopDrinking(Client* client)
  7650. {
  7651. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  7652. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  7653. }
  7654. /*
  7655. Function: Command_StopEating()
  7656. Purpose : Stops player from auto-consuming food
  7657. Params :
  7658. Dev : Zcoretri
  7659. Example : /stopeating
  7660. */
  7661. void Commands::Command_StopEating(Client* client)
  7662. {
  7663. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  7664. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  7665. }
  7666. /*
  7667. Function: Command_Title()
  7668. Purpose : Help for /title command
  7669. Params : n/a
  7670. Dev : Zcoretri
  7671. Example : /title
  7672. */
  7673. void Commands::Command_Title(Client* client)
  7674. {
  7675. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  7676. }
  7677. /*
  7678. Function: Command_TitleList()
  7679. Purpose : List available titles for player
  7680. Params : n/a
  7681. Dev : Zcoretri
  7682. Example : /title list
  7683. */
  7684. void Commands::Command_TitleList(Client* client)
  7685. {
  7686. // must call release read lock before leaving function on GetPlayerTitles
  7687. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  7688. vector<Title*>::iterator itr;
  7689. Title* title;
  7690. sint32 i = 0;
  7691. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  7692. for(itr = titles->begin(); itr != titles->end(); itr++)
  7693. {
  7694. title = *itr;
  7695. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  7696. i++;
  7697. }
  7698. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  7699. }
  7700. /*
  7701. Function: Command_TitleSetPrefix()
  7702. Purpose : Set Prefix title for player
  7703. Params : Title ID
  7704. Dev : Zcoretri
  7705. Example : /title setprefix 1
  7706. */
  7707. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  7708. {
  7709. if (sep && sep->arg[0] && sep->IsNumber(0))
  7710. {
  7711. sint32 index = atoul(sep->arg[0]);
  7712. if(index > -1)
  7713. {
  7714. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  7715. if(!title)
  7716. {
  7717. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  7718. return;
  7719. }
  7720. else if(!title->GetPrefix())
  7721. {
  7722. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  7723. return;
  7724. }
  7725. }
  7726. else // make sure client doesn't pass some bogus negative index
  7727. index = -1;
  7728. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  7729. client->SendTitleUpdate();
  7730. }
  7731. }
  7732. /*
  7733. Function: Command_TitleSetSuffix()
  7734. Purpose : Set Suffix title for player
  7735. Params : Title ID
  7736. Dev : Zcoretri
  7737. Example : /title setsuffix 1
  7738. */
  7739. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  7740. {
  7741. if (sep && sep->arg[0] && sep->IsNumber(0))
  7742. {
  7743. sint32 index = atoul(sep->arg[0]);
  7744. if(index > -1)
  7745. {
  7746. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  7747. if(!title)
  7748. {
  7749. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  7750. return;
  7751. }
  7752. else if(title->GetPrefix())
  7753. {
  7754. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  7755. return;
  7756. }
  7757. }
  7758. else // make sure client doesn't pass some bogus negative index
  7759. index = -1;
  7760. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  7761. client->SendTitleUpdate();
  7762. }
  7763. }
  7764. /*
  7765. Function: Command_TitleFix()
  7766. Purpose : Fix title for player (???)
  7767. Params :
  7768. Dev : Zcoretri
  7769. Example :
  7770. */
  7771. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  7772. {
  7773. PrintSep(sep, "COMMAND_TITLE_FIX");
  7774. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  7775. }
  7776. /*
  7777. Function: Command_Toggle_Anonymous()
  7778. Purpose : Toggles player Anonymous
  7779. Params :
  7780. Dev : paulgh
  7781. Example : /anon
  7782. */
  7783. void Commands::Command_Toggle_Anonymous(Client* client)
  7784. {
  7785. Player* player = client->GetPlayer();
  7786. player->toggle_character_flag(CF_ANONYMOUS);
  7787. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  7788. if (player->get_character_flag(CF_ANONYMOUS))
  7789. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  7790. else
  7791. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  7792. }
  7793. /*
  7794. Function: Command_Toggle_AutoConsume()
  7795. Purpose : Toggles player food/drink auto consume
  7796. Params : unknown
  7797. Dev : paulgh
  7798. Example : /set_auto_consume
  7799. */
  7800. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7801. {
  7802. Player* player = client->GetPlayer();
  7803. if (sep && sep->arg[0])
  7804. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7805. if (sep && sep->arg[0] && sep->IsNumber(0))
  7806. {
  7807. int8 slot = atoi(sep->arg[0]);
  7808. int8 flag = atoi(sep->arg[1]);
  7809. if (client->GetVersion() <= 283) {
  7810. slot += 4;
  7811. }
  7812. else if (client->GetVersion() <= 546) {
  7813. slot += 2;
  7814. }
  7815. if (slot == EQ2_FOOD_SLOT)
  7816. {
  7817. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7818. player->SetCharSheetChanged(true);
  7819. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7820. if (flag == 1)
  7821. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  7822. else
  7823. {
  7824. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  7825. return;
  7826. }
  7827. }
  7828. else
  7829. {
  7830. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7831. player->SetCharSheetChanged(true);
  7832. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7833. if (flag == 1)
  7834. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  7835. else
  7836. {
  7837. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  7838. return;
  7839. }
  7840. }
  7841. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  7842. return;
  7843. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  7844. return;
  7845. Item* item = player->GetEquipmentList()->GetItem(slot);
  7846. if(item)
  7847. client->ConsumeFoodDrink(item, slot);
  7848. }
  7849. }
  7850. /*
  7851. Function: Command_Toggle_BonusXP()
  7852. Purpose : Toggles player Bonus XP
  7853. Params :
  7854. Dev : John Adams
  7855. Example : /disable_char_bonus_exp
  7856. */
  7857. void Commands::Command_Toggle_BonusXP(Client* client)
  7858. {
  7859. Player* player = client->GetPlayer();
  7860. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7861. player->SetCharSheetChanged(true);
  7862. }
  7863. /*
  7864. Function: Command_Toggle_CombatXP()
  7865. Purpose : Toggles player Adventure XP
  7866. Params :
  7867. Dev : John Adams
  7868. Example : /disable_combat_exp
  7869. */
  7870. void Commands::Command_Toggle_CombatXP(Client* client)
  7871. {
  7872. Player* player = client->GetPlayer();
  7873. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7874. player->SetCharSheetChanged(true);
  7875. }
  7876. /*
  7877. Function: Command_Toggle_GMHide()
  7878. Purpose : Toggles hiding player GM status
  7879. Params :
  7880. Dev : Scatman
  7881. Example : /gm_hide
  7882. */
  7883. void Commands::Command_Toggle_GMHide(Client* client)
  7884. {
  7885. Player* player = client->GetPlayer();
  7886. player->toggle_character_flag(CF_HIDE_STATUS);
  7887. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7888. }
  7889. /*
  7890. Function: Command_Toggle_GMVanish()
  7891. Purpose : Toggles hiding GM players from /who searches
  7892. Params :
  7893. Dev : Scatman
  7894. Example : /gm_vanish
  7895. */
  7896. void Commands::Command_Toggle_GMVanish(Client* client)
  7897. {
  7898. Player* player = client->GetPlayer();
  7899. player->toggle_character_flag(CF_GM_HIDDEN);
  7900. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7901. }
  7902. /*
  7903. Function: Command_Toggle_Illusions()
  7904. Purpose : Toggles player illusion form
  7905. Params : not sure sep is needed, testing
  7906. Dev : paulgh
  7907. Example : /hide_illusions
  7908. */
  7909. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7910. {
  7911. if (sep && sep->arg[0])
  7912. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7913. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7914. }
  7915. /*
  7916. Function: Command_Toggle_LFG()
  7917. Purpose : Toggles player LFG Flag
  7918. Params :
  7919. Dev : paulgh
  7920. Example : /lfg
  7921. */
  7922. void Commands::Command_Toggle_LFG(Client* client)
  7923. {
  7924. Player* player = client->GetPlayer();
  7925. player->toggle_character_flag(CF_LFG);
  7926. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7927. if (player->get_character_flag(CF_LFG))
  7928. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7929. else
  7930. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7931. }
  7932. /*
  7933. Function: Command_Toggle_LFW()
  7934. Purpose : Toggles player LFW Flag
  7935. Params :
  7936. Dev : paulgh
  7937. Example : /lfw
  7938. */
  7939. void Commands::Command_Toggle_LFW(Client* client)
  7940. {
  7941. Player* player = client->GetPlayer();
  7942. player->toggle_character_flag(CF_LFW);
  7943. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7944. if (player->get_character_flag(CF_LFW))
  7945. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7946. else
  7947. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7948. }
  7949. /*
  7950. Function: Command_Toggle_QuestXP()
  7951. Purpose : Toggles player Quest XP
  7952. Params :
  7953. Dev : John Adams
  7954. Example : /disable_quest_exp
  7955. */
  7956. void Commands::Command_Toggle_QuestXP(Client* client)
  7957. {
  7958. Player* player = client->GetPlayer();
  7959. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7960. player->SetCharSheetChanged(true);
  7961. }
  7962. /*
  7963. Function: Command_Toggle_Roleplaying()
  7964. Purpose : Toggles player Roleplaying flag
  7965. Params :
  7966. Dev : paulgh
  7967. Example : /role
  7968. */
  7969. void Commands::Command_Toggle_Roleplaying(Client* client)
  7970. {
  7971. Player* player = client->GetPlayer();
  7972. player->toggle_character_flag(CF_ROLEPLAYING);
  7973. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  7974. if (player->get_character_flag(CF_ROLEPLAYING))
  7975. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  7976. else
  7977. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  7978. }
  7979. void Commands::Command_Toggle_Duels(Client* client)
  7980. {
  7981. Player* player = client->GetPlayer();
  7982. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7983. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7984. }
  7985. void Commands::Command_Toggle_Trades(Client* client)
  7986. {
  7987. Player* player = client->GetPlayer();
  7988. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7989. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7990. }
  7991. void Commands::Command_Toggle_Guilds(Client* client)
  7992. {
  7993. Player* player = client->GetPlayer();
  7994. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7995. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7996. }
  7997. void Commands::Command_Toggle_Groups(Client* client)
  7998. {
  7999. Player* player = client->GetPlayer();
  8000. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8001. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8002. }
  8003. void Commands::Command_Toggle_Raids(Client* client)
  8004. {
  8005. Player* player = client->GetPlayer();
  8006. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8007. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8008. }
  8009. void Commands::Command_Toggle_LON(Client* client)
  8010. {
  8011. Player* player = client->GetPlayer();
  8012. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8013. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8014. }
  8015. void Commands::Command_Toggle_VoiceChat(Client* client)
  8016. {
  8017. Player* player = client->GetPlayer();
  8018. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8019. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8020. }
  8021. /*
  8022. Function: Command_TradeStart()
  8023. Purpose : Starts item/coin trade between players
  8024. Params :
  8025. Dev :
  8026. Example :
  8027. */
  8028. #include "../Trade.h"
  8029. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  8030. {
  8031. PrintSep(sep, "COMMAND_START_TRADE");
  8032. Entity* trader = client->GetPlayer();
  8033. Entity* trader2 = 0;
  8034. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8035. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  8036. if (spawn) {
  8037. if (spawn->IsEntity())
  8038. trader2 = (Entity*)spawn;
  8039. }
  8040. }
  8041. else if (client->GetPlayer()->GetTarget()) {
  8042. if (client->GetPlayer()->GetTarget()->IsEntity())
  8043. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  8044. }
  8045. // can only trade with player or bots
  8046. if (trader && trader2) {
  8047. if (trader == trader2) {
  8048. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  8049. }
  8050. else if (trader2->IsPlayer() || trader2->IsBot()) {
  8051. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  8052. if (trader->trade)
  8053. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  8054. else if (trader2->trade)
  8055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  8056. else {
  8057. Trade* trade = new Trade(trader, trader2);
  8058. trader->trade = trade;
  8059. trader2->trade = trade;
  8060. }
  8061. }
  8062. else {
  8063. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8064. }
  8065. }
  8066. else
  8067. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8068. }
  8069. /*
  8070. Function: Command_Track()
  8071. Purpose : Starts/Stops Tracking for a player
  8072. Params :
  8073. Dev : Scatman
  8074. Example : /track
  8075. */
  8076. void Commands::Command_Track(Client* client)
  8077. {
  8078. if (!client->GetPlayer()->GetIsTracking())
  8079. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8080. else
  8081. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8082. }
  8083. /*
  8084. Function: Command_TradeAccept()
  8085. Purpose : Accepts item/coin trade between players
  8086. Params :
  8087. Dev :
  8088. Example :
  8089. */
  8090. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8091. {
  8092. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8093. Trade* trade = client->GetPlayer()->trade;
  8094. if (trade) {
  8095. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8096. if (trade_complete)
  8097. safe_delete(trade);
  8098. }
  8099. else
  8100. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8101. }
  8102. /*
  8103. Function: Command_TradeReject()
  8104. Purpose : Rejects item/coin trade between players
  8105. Params :
  8106. Dev :
  8107. Example :
  8108. */
  8109. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8110. {
  8111. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8112. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  8113. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8114. }
  8115. /*
  8116. Function: Command_TradeCancel()
  8117. Purpose : Cancels item/coin trade between players
  8118. Params :
  8119. Dev :
  8120. Example :
  8121. */
  8122. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8123. {
  8124. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8125. Trade* trade = client->GetPlayer()->trade;
  8126. if (trade) {
  8127. trade->CancelTrade(client->GetPlayer());
  8128. safe_delete(trade);
  8129. }
  8130. else
  8131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8132. }
  8133. /*
  8134. Function: Command_TradeSetCoin()
  8135. Purpose : Sets coin trade between players
  8136. Params :
  8137. Dev :
  8138. Example :
  8139. */
  8140. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8141. {
  8142. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8143. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8144. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8145. }
  8146. /*
  8147. Function: Command_TradeAddCoin()
  8148. Purpose : Adds coin to trade between players
  8149. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8150. Dev :
  8151. Example :
  8152. */
  8153. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  8154. {
  8155. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  8156. Trade* trade = client->GetPlayer()->trade;
  8157. if (trade) {
  8158. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8159. int32 amount = atoi(sep->arg[0]);
  8160. int64 val = 0;
  8161. switch (handler) {
  8162. case COMMAND_ADD_TRADE_COPPER:
  8163. {
  8164. val = amount;
  8165. trade->AddCoinToTrade(client->GetPlayer(), val);
  8166. break;
  8167. }
  8168. case COMMAND_ADD_TRADE_SILVER:
  8169. {
  8170. val = amount * 100;
  8171. trade->AddCoinToTrade(client->GetPlayer(), val);
  8172. break;
  8173. }
  8174. case COMMAND_ADD_TRADE_GOLD:
  8175. {
  8176. val = amount * 10000;
  8177. trade->AddCoinToTrade(client->GetPlayer(), val);
  8178. break;
  8179. }
  8180. case COMMAND_ADD_TRADE_PLAT:
  8181. {
  8182. val = amount * 1000000;
  8183. trade->AddCoinToTrade(client->GetPlayer(), val);
  8184. break;
  8185. }
  8186. default:
  8187. {
  8188. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8189. break;
  8190. }
  8191. }
  8192. }
  8193. else
  8194. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  8195. }
  8196. else
  8197. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8198. }
  8199. /*
  8200. Function: Command_TradeRemoveCoin()
  8201. Purpose : Removes coin from trade between players
  8202. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8203. Dev :
  8204. Example :
  8205. */
  8206. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  8207. {
  8208. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  8209. Trade* trade = client->GetPlayer()->trade;
  8210. if (trade) {
  8211. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8212. int32 amount = atoi(sep->arg[0]);
  8213. int64 val = 0;
  8214. switch (handler) {
  8215. case COMMAND_REMOVE_TRADE_COPPER:
  8216. {
  8217. val = amount;
  8218. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8219. break;
  8220. }
  8221. case COMMAND_REMOVE_TRADE_SILVER:
  8222. {
  8223. val = amount * 100;
  8224. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8225. break;
  8226. }
  8227. case COMMAND_REMOVE_TRADE_GOLD:
  8228. {
  8229. val = amount * 10000;
  8230. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8231. break;
  8232. }
  8233. case COMMAND_REMOVE_TRADE_PLAT:
  8234. {
  8235. val = amount * 1000000;
  8236. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8237. break;
  8238. }
  8239. default:
  8240. {
  8241. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8242. break;
  8243. }
  8244. }
  8245. }
  8246. else
  8247. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  8248. }
  8249. else
  8250. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8251. }
  8252. /*
  8253. Function: Command_TradeAddItem()
  8254. Purpose : Adds item to trade between players
  8255. Params :
  8256. Dev :
  8257. Example :
  8258. */
  8259. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  8260. {
  8261. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  8262. /*
  8263. arg[0] = item index
  8264. arg[1] = slot
  8265. arg[2] = quantity
  8266. */
  8267. if (!client->GetPlayer()->trade) {
  8268. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  8269. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8270. return;
  8271. }
  8272. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  8273. Item* item = 0;
  8274. int32 index = atoi(sep->arg[0]);
  8275. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  8276. if (item) {
  8277. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  8278. if (result == 1)
  8279. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  8280. else if (result == 2)
  8281. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  8282. else if (result == 3)
  8283. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  8284. else if (result == 255)
  8285. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  8286. }
  8287. else {
  8288. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  8289. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  8290. }
  8291. }
  8292. else
  8293. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  8294. }
  8295. /*
  8296. Function: Command_TradeRemoveItem()
  8297. Purpose : Removes item from trade between players
  8298. Params :
  8299. Dev :
  8300. Example :
  8301. */
  8302. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  8303. {
  8304. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  8305. /*
  8306. arg[0] = trade window slot
  8307. */
  8308. Trade* trade = client->GetPlayer()->trade;
  8309. if (trade) {
  8310. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8311. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  8312. }
  8313. else
  8314. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  8315. }
  8316. else
  8317. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8318. }
  8319. void Commands::Command_TryOn(Client* client, Seperator* sep)
  8320. {
  8321. Item *item = 0;
  8322. sint32 crc;
  8323. if (sep) {
  8324. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  8325. if (client->GetVersion() < 1096) {
  8326. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  8327. {
  8328. item = master_item_list.GetItem(atoul(sep->arg[1]));
  8329. crc = atol(sep->arg[2]);
  8330. }
  8331. }
  8332. else {
  8333. // From the broker and links in chat
  8334. if (strcmp(sep->arg[0], "crc") == 0) {
  8335. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  8336. item = master_item_list.GetItem(atoul(sep->arg[2]));
  8337. crc = atol(sep->arg[3]);
  8338. }
  8339. }
  8340. // From inventory
  8341. if (strcmp(sep->arg[0], "dbid") == 0) {
  8342. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  8343. item = master_item_list.GetItem(atoul(sep->arg[2]));
  8344. crc = atol(sep->arg[4]);
  8345. }
  8346. }
  8347. }
  8348. if (item)
  8349. client->ShowDressingRoom(item, crc);
  8350. }
  8351. }
  8352. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  8353. const char *channel_name, *password = NULL;
  8354. if (sep == NULL || !sep->IsSet(0)) {
  8355. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  8356. return;
  8357. }
  8358. channel_name = sep->arg[0];
  8359. if (sep->IsSet(1))
  8360. password = sep->arg[1];
  8361. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  8362. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  8363. return;
  8364. }
  8365. if (chat.IsInChannel(client, channel_name)) {
  8366. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  8367. return;
  8368. }
  8369. if (chat.HasPassword(channel_name)) {
  8370. if (password == NULL) {
  8371. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  8372. return;
  8373. }
  8374. if (!chat.PasswordMatches(channel_name, password)) {
  8375. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  8376. return;
  8377. }
  8378. }
  8379. if (!chat.JoinChannel(client, channel_name))
  8380. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  8381. }
  8382. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  8383. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  8384. Command_JoinChannel(client, sep);
  8385. }
  8386. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  8387. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  8388. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  8389. PrintSep(sep, "tellchannel");
  8390. return;
  8391. }
  8392. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  8393. }
  8394. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  8395. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8396. if (sep->IsSet(0)) {
  8397. if (atoi(sep->arg[0]) == 1) {
  8398. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  8399. if (packet2) {
  8400. packet2->setDataByName("spell_type", 2);
  8401. packet2->setDataByName("spell_id", 8308);
  8402. packet2->setDataByName("spell_name", "Sprint");
  8403. packet2->setDataByName("add_silently", 0);
  8404. packet2->setDataByName("tier", 1);
  8405. packet2->setDataByName("blah1", 1);
  8406. packet2->setDataByName("blah2", 1);
  8407. EQ2Packet* outapp = packet2->serialize();
  8408. DumpPacket(outapp);
  8409. client->QueuePacket(outapp);
  8410. safe_delete(packet2);
  8411. }
  8412. }
  8413. else if (atoi(sep->arg[0]) == 2) {
  8414. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  8415. if (packet2) {
  8416. packet2->setDataByName("guild_name", "Test");
  8417. packet2->setDataByName("guild_motd", "Test MOTD");
  8418. packet2->setDataByName("guild_id", 1234);
  8419. packet2->setDataByName("guild_level", 1);
  8420. packet2->setDataByName("unknown", 2);
  8421. packet2->setDataByName("unknown2", 3);
  8422. packet2->setDataByName("exp_current", 1);
  8423. packet2->setDataByName("exp_to_next_level", 4);
  8424. EQ2Packet* outapp = packet2->serialize();
  8425. DumpPacket(outapp);
  8426. client->QueuePacket(outapp);
  8427. safe_delete(packet2);
  8428. }
  8429. }
  8430. else if (atoi(sep->arg[0]) == 3) {
  8431. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  8432. if (packet2) {
  8433. packet2->setDataByName("guild_id", 1234);
  8434. packet2->setDataByName("character_id", 1);
  8435. packet2->setDataByName("account_id", 2);
  8436. packet2->setDataByName("guild_level", 1);
  8437. packet2->setDataByName("name", "Test");
  8438. packet2->setDataByName("unknown2", 0);
  8439. packet2->setDataByName("unknown3", 1);
  8440. packet2->setDataByName("adventure_class", 6);
  8441. packet2->setDataByName("adventure_level", 7);
  8442. packet2->setDataByName("tradeskill_class", 4);
  8443. packet2->setDataByName("tradeskill_level", 5);
  8444. packet2->setDataByName("rank", 0);
  8445. packet2->setDataByName("member_flags", 2);
  8446. packet2->setDataByName("join_date", 1591112273);
  8447. packet2->setDataByName("guild_status", 2);
  8448. packet2->setDataByName("last_login", 1591132273);
  8449. packet2->setDataByName("recruiter_id", 1);
  8450. packet2->setDataByName("points", 2345);
  8451. packet2->setDataByName("note", "note");
  8452. packet2->setMediumStringByName("officer_note", "O note");
  8453. packet2->setMediumStringByName("zone", "Blah");
  8454. EQ2Packet* outapp = packet2->serialize();
  8455. DumpPacket(outapp);
  8456. client->QueuePacket(outapp);
  8457. safe_delete(packet2);
  8458. }
  8459. }
  8460. else if (atoi(sep->arg[0]) == 5) {
  8461. int16 offset = atoi(sep->arg[1]);
  8462. int32 value1 = atol(sep->arg[2]);
  8463. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  8464. client->QueuePacket(outapp);
  8465. }
  8466. else if (atoi(sep->arg[0]) == 6) {
  8467. Spawn* spawn = client->GetPlayer()->GetTarget();
  8468. if (!spawn)
  8469. spawn = client->GetPlayer();
  8470. else if (spawn->IsEntity())
  8471. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  8472. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  8473. }
  8474. else if (atoi(sep->arg[0]) == 7) {
  8475. int32 id = 0;
  8476. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  8477. if (spawn) {
  8478. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  8479. spawn->SetY(client->GetPlayer()->GetY(), false);
  8480. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  8481. float heading = client->GetPlayer()->GetHeading() + 180;
  8482. if (heading > 360)
  8483. heading -= 360;
  8484. spawn->SetLevel(5);
  8485. spawn->SetAdventureClass(4);
  8486. spawn->SetHeading(heading, false);
  8487. spawn->SetSpawnOrigX(spawn->GetX());
  8488. spawn->SetSpawnOrigY(spawn->GetY());
  8489. spawn->SetSpawnOrigZ(spawn->GetZ());
  8490. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  8491. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8492. spawn->appearance.targetable = 1;
  8493. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  8494. spawn->SetTotalHP(spawn->GetLevel() * 15);
  8495. spawn->SetHP(spawn->GetTotalHP());
  8496. }
  8497. if (spawn->GetTotalPower() == 0) {
  8498. spawn->SetTotalPower(spawn->GetLevel() * 15);
  8499. spawn->SetPower(spawn->GetTotalPower());
  8500. }
  8501. int16 offset = atoi(sep->arg[1]);
  8502. int32 value1 = atol(sep->arg[2]);
  8503. sprintf(spawn->appearance.name, "Offset %i", offset);
  8504. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  8505. DumpPacket(ret);
  8506. client->QueuePacket(ret);
  8507. }
  8508. }
  8509. else if (atoi(sep->arg[0]) == 8) {
  8510. int32 id = atoi(sep->arg[1]);
  8511. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  8512. if (spawn) {
  8513. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  8514. spawn->SetY(client->GetPlayer()->GetY(), false);
  8515. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  8516. float heading = client->GetPlayer()->GetHeading() + 180;
  8517. if (heading > 360)
  8518. heading -= 360;
  8519. spawn->SetLevel(5);
  8520. spawn->SetAdventureClass(4);
  8521. spawn->SetHeading(heading, false);
  8522. spawn->SetSpawnOrigX(spawn->GetX());
  8523. spawn->SetSpawnOrigY(spawn->GetY());
  8524. spawn->SetSpawnOrigZ(spawn->GetZ());
  8525. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  8526. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8527. spawn->appearance.targetable = 1;
  8528. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  8529. spawn->SetTotalHP(spawn->GetLevel() * 15);
  8530. spawn->SetHP(spawn->GetTotalHP());
  8531. }
  8532. if (spawn->GetTotalPower() == 0) {
  8533. spawn->SetTotalPower(spawn->GetLevel() * 15);
  8534. spawn->SetPower(spawn->GetTotalPower());
  8535. }
  8536. int16 offset = atoi(sep->arg[2]);
  8537. int16 offset2 = atoi(sep->arg[3]);
  8538. int32 value1 = atol(sep->arg[4]);
  8539. int16 offset3 = 0;
  8540. int16 offset4 = 0;
  8541. int32 value2 = 0;
  8542. if (sep->IsSet(7)) {
  8543. offset3 = atoi(sep->arg[5]);
  8544. offset4 = atoi(sep->arg[6]);
  8545. value2 = atol(sep->arg[7]);
  8546. }
  8547. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  8548. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  8549. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  8550. DumpPacket(ret);
  8551. client->QueuePacket(ret);
  8552. }
  8553. }
  8554. else if (atoi(sep->arg[0]) == 9) {
  8555. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  8556. if (packet2) {
  8557. packet2->setArrayLengthByName("location_count", 1);
  8558. packet2->setArrayDataByName("location_ida", 1234);
  8559. packet2->setArrayDataByName("unknown2a", 3);
  8560. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  8561. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  8562. packet2->setArrayDataByName("distance", 134);
  8563. EQ2Packet* app = packet2->serialize();
  8564. if (sep->IsSet(2)) {
  8565. int8 offset = atoi(sep->arg[1]);
  8566. uchar* ptr2 = app->pBuffer;
  8567. ptr2 += offset;
  8568. if (sep->IsNumber(2)) {
  8569. int32 value1 = atol(sep->arg[2]);
  8570. if (value1 > 0xFFFF)
  8571. memcpy(ptr2, (uchar*)&value1, 4);
  8572. else if (value1 > 0xFF)
  8573. memcpy(ptr2, (uchar*)&value1, 2);
  8574. else
  8575. memcpy(ptr2, (uchar*)&value1, 1);
  8576. }
  8577. else {
  8578. int8 len = strlen(sep->arg[2]);
  8579. memcpy(ptr2, (uchar*)&len, 1);
  8580. ptr2 += 1;
  8581. memcpy(ptr2, sep->arg[2], len);
  8582. }
  8583. }
  8584. DumpPacket(app);
  8585. client->QueuePacket(app);
  8586. safe_delete(packet2);
  8587. }
  8588. }
  8589. else if (atoi(sep->arg[0]) == 10) {
  8590. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  8591. if (packet2) {
  8592. packet2->setArrayLengthByName("num_quests", 1);
  8593. packet2->setArrayDataByName("active", 1);
  8594. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  8595. packet2->setArrayDataByName("quest_type", "Hallmark");
  8596. packet2->setArrayDataByName("quest_zone", "Hallmark");
  8597. packet2->setArrayDataByName("journal_updated", 1);
  8598. packet2->setArrayDataByName("quest_id", 524);
  8599. packet2->setArrayDataByName("day", 19);
  8600. packet2->setArrayDataByName("month", 6);
  8601. packet2->setArrayDataByName("year", 20);
  8602. packet2->setArrayDataByName("level", 2);
  8603. packet2->setArrayDataByName("encounter_level", 4);
  8604. packet2->setArrayDataByName("difficulty", 3);
  8605. packet2->setArrayDataByName("visible", 1);
  8606. packet2->setDataByName("visible_quest_id", 524);
  8607. packet2->setDataByName("player_crc", 2900677088);
  8608. packet2->setDataByName("player_name", "LethalEncounter");
  8609. EQ2Packet* app = packet2->serialize();
  8610. if (sep->IsSet(2)) {
  8611. int8 offset = atoi(sep->arg[1]);
  8612. uchar* ptr2 = app->pBuffer;
  8613. ptr2 += offset;
  8614. if (sep->IsNumber(2)) {
  8615. int32 value1 = atol(sep->arg[2]);
  8616. if (value1 > 0xFFFF)
  8617. memcpy(ptr2, (uchar*)&value1, 4);
  8618. else if (value1 > 0xFF)
  8619. memcpy(ptr2, (uchar*)&value1, 2);
  8620. else
  8621. memcpy(ptr2, (uchar*)&value1, 1);
  8622. }
  8623. else {
  8624. int8 len = strlen(sep->arg[2]);
  8625. memcpy(ptr2, (uchar*)&len, 1);
  8626. ptr2 += 1;
  8627. memcpy(ptr2, sep->arg[2], len);
  8628. }
  8629. }
  8630. DumpPacket(app);
  8631. client->QueuePacket(app);
  8632. safe_delete(packet2);
  8633. }
  8634. }
  8635. else if (atoi(sep->arg[0]) == 11) {
  8636. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8637. if (packet2) {
  8638. packet2->setDataByName("quest_id", 524);
  8639. packet2->setDataByName("player_crc", 2900677088);
  8640. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  8641. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  8642. packet2->setDataByName("type", "Hallmark");
  8643. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8644. packet2->setDataByName("day", 19);
  8645. packet2->setDataByName("month", 6);
  8646. packet2->setDataByName("year", 20);
  8647. packet2->setDataByName("level", 1);
  8648. packet2->setDataByName("encounter_level", 1);
  8649. packet2->setDataByName("difficulty", 1);
  8650. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8651. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8652. //packet2->setDataByName("timer_duration", 300);
  8653. //packet2->setDataByName("timer_running", 1);
  8654. packet2->setArrayLengthByName("task_groups_completed", 9);
  8655. packet2->setArrayLengthByName("num_task_groups", 10);
  8656. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  8657. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  8658. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  8659. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  8660. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  8661. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  8662. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  8663. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  8664. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  8665. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  8666. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  8667. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8668. packet2->setSubArrayLengthByName("num_updates", 1);
  8669. packet2->setSubArrayDataByName("update_currentval", 0);
  8670. packet2->setSubArrayDataByName("update_maxval", 1);
  8671. packet2->setSubArrayDataByName("icon", 11);
  8672. */
  8673. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8674. packet2->setDataByName("journal_updated", 1);
  8675. packet2->setDataByName("bullets", 1);
  8676. EQ2Packet* app = packet2->serialize();
  8677. if (sep->IsSet(2)) {
  8678. int16 offset = atoi(sep->arg[1]);
  8679. uchar* ptr2 = app->pBuffer;
  8680. ptr2 += offset;
  8681. if (sep->IsNumber(2)) {
  8682. int32 value1 = atol(sep->arg[2]);
  8683. if (value1 > 0xFFFF)
  8684. memcpy(ptr2, (uchar*)&value1, 4);
  8685. else if (value1 > 0xFF)
  8686. memcpy(ptr2, (uchar*)&value1, 2);
  8687. else
  8688. memcpy(ptr2, (uchar*)&value1, 1);
  8689. }
  8690. else {
  8691. int16 len = strlen(sep->arg[2]);
  8692. memcpy(ptr2, (uchar*)&len, 2);
  8693. ptr2 += 2;
  8694. memcpy(ptr2, sep->arg[2], len);
  8695. }
  8696. }
  8697. DumpPacket(app);
  8698. client->QueuePacket(app);
  8699. safe_delete(packet2);
  8700. }
  8701. }
  8702. else if (atoi(sep->arg[0]) == 12) {
  8703. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8704. if (packet2) {
  8705. packet2->setDataByName("quest_id", 524);
  8706. packet2->setDataByName("player_crc", 2900677088);
  8707. packet2->setDataByName("name", "Archetype Selection");
  8708. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  8709. packet2->setDataByName("type", "Hallmark");
  8710. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8711. packet2->setDataByName("day", 19);
  8712. packet2->setDataByName("month", 6);
  8713. packet2->setDataByName("year", 20);
  8714. packet2->setDataByName("level", 2);
  8715. packet2->setDataByName("encounter_level", 4);
  8716. packet2->setDataByName("difficulty", 3);
  8717. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8718. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8719. packet2->setDataByName("timer_duration", 300);
  8720. packet2->setDataByName("timer_running", 1);
  8721. packet2->setArrayLengthByName("task_groups_completed", 0);
  8722. packet2->setArrayLengthByName("num_task_groups", 1);
  8723. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8724. packet2->setSubArrayLengthByName("num_tasks", 1);
  8725. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8726. packet2->setSubArrayLengthByName("num_updates", 1);
  8727. packet2->setSubArrayDataByName("update_currentval", 0);
  8728. packet2->setSubArrayDataByName("update_maxval", 1);
  8729. packet2->setSubArrayDataByName("icon", 11);
  8730. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8731. packet2->setDataByName("journal_updated", 1);
  8732. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8733. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8734. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  8735. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8736. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8737. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8738. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  8739. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  8740. Item* item = master_item_list.GetItem(152755);
  8741. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8742. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8743. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  8744. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  8745. packet2->setSubstructDataByName("item", "icon", 0xe7);
  8746. packet2->setSubstructDataByName("item", "tier", 4);
  8747. packet2->setSubstructDataByName("item", "flags", 0x60);
  8748. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  8749. packet2->setSubstructDataByName("item", "stat_type", 1);
  8750. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  8751. packet2->setSubstructDataByName("item", "value", 3);
  8752. packet2->setSubstructDataByName("item", "condition", 100);
  8753. packet2->setSubstructDataByName("item", "weight", 1);
  8754. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  8755. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  8756. packet2->setSubstructDataByName("item", "skill_min", 1);
  8757. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  8758. packet2->setSubstructDataByName("item", "adventure_class", 1);
  8759. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  8760. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  8761. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  8762. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  8763. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  8764. packet2->setSubstructDataByName("item", "level", 0x1e);
  8765. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  8766. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  8767. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  8768. //packet2->PrintPacket();
  8769. EQ2Packet* app = packet2->serialize();
  8770. if (sep->IsSet(2)) {
  8771. int16 offset = atoi(sep->arg[1]);
  8772. uchar* ptr2 = app->pBuffer;
  8773. ptr2 += offset;
  8774. if (sep->IsNumber(2)) {
  8775. int32 value1 = atol(sep->arg[2]);
  8776. if (value1 > 0xFFFF)
  8777. memcpy(ptr2, (uchar*)&value1, 4);
  8778. else if (value1 > 0xFF)
  8779. memcpy(ptr2, (uchar*)&value1, 2);
  8780. else
  8781. memcpy(ptr2, (uchar*)&value1, 1);
  8782. }
  8783. else {
  8784. int16 len = strlen(sep->arg[2]);
  8785. memcpy(ptr2, (uchar*)&len, 2);
  8786. ptr2 += 2;
  8787. memcpy(ptr2, sep->arg[2], len);
  8788. }
  8789. }
  8790. DumpPacket(app);
  8791. client->QueuePacket(app);
  8792. safe_delete(packet2);
  8793. }
  8794. }
  8795. else if (atoi(sep->arg[0]) == 13) {
  8796. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  8797. if (packet2 && sep->IsSet(7)) {
  8798. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  8799. char blah[128];
  8800. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  8801. packet2->setDataByName("text", blah);
  8802. packet2->setDataByName("message_type", sep->arg[3]);
  8803. packet2->setDataByName("size", atof(sep->arg[4]));
  8804. packet2->setDataByName("red", atoi(sep->arg[5]));
  8805. packet2->setDataByName("green", atoi(sep->arg[6]));
  8806. packet2->setDataByName("blue", atoi(sep->arg[7]));
  8807. EQ2Packet* app = packet2->serialize();
  8808. DumpPacket(app);
  8809. client->QueuePacket(app);
  8810. safe_delete(packet2);
  8811. }
  8812. }
  8813. else if (atoi(sep->arg[0]) == 14) {
  8814. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  8815. if (packet2 && sep->IsSet(3)) {
  8816. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  8817. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  8818. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  8819. 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.");
  8820. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  8821. packet2->setArrayLengthByName("num_goals", 1);
  8822. //packet2->setArrayDataByName("goal_text", )
  8823. packet2->setSubArrayLengthByName("num_tasks", 1);
  8824. packet2->setSubArrayDataByName("task_text", "continue");
  8825. packet2->setDataByName("complete_sound", "click");
  8826. packet2->setDataByName("signal", "introduction");
  8827. packet2->setDataByName("voice_key1", 0xcda65173);
  8828. packet2->setDataByName("voice_key2", 0x984bfc6d);
  8829. EQ2Packet* app = packet2->serialize();
  8830. DumpPacket(app);
  8831. client->QueuePacket(app);
  8832. safe_delete(packet2);
  8833. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  8834. packet2->setDataByName("window", "MainHUD.StartMenu");
  8835. packet2->setDataByName("show", 1);
  8836. app = packet2->serialize();
  8837. DumpPacket(app);
  8838. client->QueuePacket(app);
  8839. safe_delete(packet2);
  8840. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  8841. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  8842. packet2->setDataByName("flash_seconds", 10);
  8843. app = packet2->serialize();
  8844. DumpPacket(app);
  8845. client->QueuePacket(app);
  8846. safe_delete(packet2);
  8847. }
  8848. }
  8849. else if (atoi(sep->arg[0]) == 15) {
  8850. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8851. if (packet2) {
  8852. packet2->setArrayLengthByName("loot_count", 1);
  8853. packet2->setArrayDataByName("name", "Test");
  8854. packet2->setArrayDataByName("item_id", 1234);
  8855. packet2->setArrayDataByName("count", 1);
  8856. packet2->setArrayDataByName("icon", 258);
  8857. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  8858. Spawn* spawn = client->GetPlayer()->GetTarget();
  8859. if (spawn)
  8860. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8861. packet2->setDataByName("unknown3", 1);
  8862. packet2->setDataByName("unknown4", 1);
  8863. packet2->setDataByName("unknown5", 60);
  8864. EQ2Packet* app = packet2->serialize();
  8865. DumpPacket(app);
  8866. client->QueuePacket(app);
  8867. safe_delete(packet2);
  8868. }
  8869. }
  8870. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  8871. char blah[32];
  8872. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  8873. client->SimpleMessage(atoi(sep->arg[1]), blah);
  8874. }
  8875. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  8876. if (sep->IsSet(2)) {
  8877. int16 offset = atoi(sep->arg[1]);
  8878. if (sep->IsNumber(2)) {
  8879. int32 value1 = atol(sep->arg[2]);
  8880. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  8881. cout << "Sent" << endl;
  8882. }
  8883. }
  8884. }
  8885. else if (atoi(sep->arg[0]) == 18) {
  8886. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  8887. if (packet2) {
  8888. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8889. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8890. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8891. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8892. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8893. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  8894. Item* item = new Item(master_item_list.GetItem(36212));
  8895. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8896. item->stack_count = 20;
  8897. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8898. safe_delete(item);
  8899. item = new Item(master_item_list.GetItem(36685));
  8900. item->stack_count = 20;
  8901. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8902. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  8903. safe_delete(item);
  8904. item = master_item_list.GetItem(1414);
  8905. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8906. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  8907. item = master_item_list.GetItem(75057);
  8908. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8909. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  8910. EQ2Packet* app = packet2->serialize();
  8911. if (sep->IsSet(2)) {
  8912. int16 offset = atoi(sep->arg[1]);
  8913. uchar* ptr2 = app->pBuffer;
  8914. ptr2 += offset;
  8915. if (sep->IsNumber(2)) {
  8916. int32 value1 = atol(sep->arg[2]);
  8917. if (value1 > 0xFFFF)
  8918. memcpy(ptr2, (uchar*)&value1, 4);
  8919. else if (value1 > 0xFF)
  8920. memcpy(ptr2, (uchar*)&value1, 2);
  8921. else
  8922. memcpy(ptr2, (uchar*)&value1, 1);
  8923. }
  8924. else {
  8925. int16 len = strlen(sep->arg[2]);
  8926. memcpy(ptr2, (uchar*)&len, 2);
  8927. ptr2 += 2;
  8928. memcpy(ptr2, sep->arg[2], len);
  8929. }
  8930. }
  8931. DumpPacket(app);
  8932. client->QueuePacket(app);
  8933. safe_delete(packet2);
  8934. }
  8935. }
  8936. else if (atoi(sep->arg[0]) == 19) {
  8937. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8938. Spawn* spawn = client->GetPlayer()->GetTarget();
  8939. if (packet2 && spawn) {
  8940. Item* item = master_item_list.GetItem(130053);
  8941. packet2->setArrayLengthByName("loot_count", 1);
  8942. packet2->setArrayDataByName("loot_id", item->details.item_id);
  8943. packet2->setArrayDataByName("unknown2", 1);
  8944. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  8945. packet2->setDataByName("display", 1);
  8946. packet2->setDataByName("unknown2b", 1);
  8947. packet2->setDataByName("unknown3", 0x3c);
  8948. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8949. packet2->PrintPacket();
  8950. EQ2Packet* app = packet2->serialize();
  8951. if (sep->IsSet(2)) {
  8952. int16 offset = atoi(sep->arg[1]);
  8953. int16 offset2 = 0;
  8954. int32 value1 = 0;
  8955. if (sep->IsSet(3)) {
  8956. offset2 = atoi(sep->arg[2]);
  8957. value1 = atol(sep->arg[3]);
  8958. }
  8959. else
  8960. value1 = atol(sep->arg[2]);
  8961. int16 offset3 = 0;
  8962. int16 offset4 = 0;
  8963. int32 value2 = 0;
  8964. if (sep->IsSet(6)) {
  8965. offset3 = atoi(sep->arg[4]);
  8966. offset4 = atoi(sep->arg[5]);
  8967. value2 = atol(sep->arg[6]);
  8968. }
  8969. offset--;
  8970. if (offset2 > 0 && offset2 >= offset) {
  8971. offset2--;
  8972. uchar* ptr2 = app->pBuffer;
  8973. ptr2 += offset;
  8974. for (int i = offset; i <= offset2; i++) {
  8975. if (value1 > 0xFFFF) {
  8976. memcpy(ptr2, (uchar*)&value1, 4);
  8977. i += 3;
  8978. ptr2 += 3;
  8979. }
  8980. else if (value1 > 0xFF) {
  8981. memcpy(ptr2, (uchar*)&value1, 2);
  8982. i++;
  8983. ptr2++;
  8984. }
  8985. else
  8986. memcpy(ptr2, (uchar*)&value1, 1);
  8987. ptr2++;
  8988. }
  8989. }
  8990. if (offset4 > 0 && offset4 >= offset3) {
  8991. offset3--;
  8992. offset4--;
  8993. uchar* ptr2 = app->pBuffer;
  8994. ptr2 += offset3;
  8995. for (int i = offset3; i <= offset4; i++) {
  8996. if (value2 > 0xFFFF) {
  8997. memcpy(ptr2, (uchar*)&value2, 4);
  8998. i += 3;
  8999. ptr2 += 3;
  9000. }
  9001. else if (value2 > 0xFF) {
  9002. memcpy(ptr2, (uchar*)&value2, 2);
  9003. i++;
  9004. ptr2++;
  9005. }
  9006. else
  9007. memcpy(ptr2, (uchar*)&value2, 1);
  9008. ptr2++;
  9009. }
  9010. }
  9011. }
  9012. DumpPacket(app);
  9013. client->QueuePacket(app);
  9014. safe_delete(packet2);
  9015. }
  9016. }
  9017. else if (atoi(sep->arg[0]) == 21) {
  9018. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9019. if (packet2) {
  9020. packet2->setDataByName("unknown0", 255);
  9021. packet2->setDataByName("reward", "New Quest");
  9022. packet2->setDataByName("title", "Title");
  9023. packet2->setDataByName("description", "description");
  9024. packet2->setDataByName("quest_difficulty", 3);
  9025. packet2->setDataByName("unknown1", 5);
  9026. packet2->setDataByName("level", 3);
  9027. packet2->setDataByName("coin", 150);
  9028. packet2->setDataByName("status_points", 5);
  9029. packet2->setDataByName("exp_bonus", 10);
  9030. packet2->setArrayLengthByName("num_rewards", 1);
  9031. Item* item = new Item(master_item_list.GetItem(36212));
  9032. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9033. item->stack_count = 20;
  9034. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9035. safe_delete(item);
  9036. char accept[35] = { 0 };
  9037. char decline[35] = { 0 };
  9038. sprintf(accept, "q_accept_pending_quest %u", 0);
  9039. sprintf(decline, "q_deny_pending_quest %u", 0);
  9040. packet2->setDataByName("accept_command", accept);
  9041. packet2->setDataByName("decline_command", decline);
  9042. EQ2Packet* app = packet2->serialize();
  9043. if (sep->IsSet(2)) {
  9044. int16 offset = atoi(sep->arg[1]);
  9045. uchar* ptr2 = app->pBuffer;
  9046. ptr2 += offset;
  9047. if (sep->IsNumber(2)) {
  9048. int32 value1 = atol(sep->arg[2]);
  9049. if (value1 > 0xFFFF)
  9050. memcpy(ptr2, (uchar*)&value1, 4);
  9051. else if (value1 > 0xFF)
  9052. memcpy(ptr2, (uchar*)&value1, 2);
  9053. else
  9054. memcpy(ptr2, (uchar*)&value1, 1);
  9055. }
  9056. DumpPacket(app);
  9057. client->QueuePacket(app);
  9058. safe_delete(packet2);
  9059. }
  9060. }
  9061. }
  9062. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9063. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9064. if (packet2) {
  9065. packet2->setDataByName("unknown0", 255);
  9066. packet2->setDataByName("reward", "New Quest");
  9067. packet2->setDataByName("title", "Title");
  9068. packet2->setDataByName("description", "description");
  9069. packet2->setDataByName("quest_difficulty", 3);
  9070. packet2->setDataByName("unknown1", 5);
  9071. packet2->setDataByName("level", 3);
  9072. packet2->setDataByName("coin", 150);
  9073. packet2->setDataByName("status_points", 5);
  9074. packet2->setDataByName("exp_bonus", 10);
  9075. packet2->setArrayLengthByName("num_rewards", 1);
  9076. Item* item = new Item(master_item_list.GetItem(36212));
  9077. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9078. item->stack_count = 20;
  9079. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9080. safe_delete(item);
  9081. char accept[35] = { 0 };
  9082. char decline[35] = { 0 };
  9083. sprintf(accept, "q_accept_pending_quest %u", 0);
  9084. sprintf(decline, "q_deny_pending_quest %u", 0);
  9085. packet2->setDataByName("accept_command", accept);
  9086. packet2->setDataByName("decline_command", decline);
  9087. EQ2Packet* app = packet2->serialize();
  9088. if (sep->IsSet(2)) {
  9089. int16 offset = atoi(sep->arg[1]);
  9090. uchar* ptr2 = app->pBuffer;
  9091. ptr2 += offset;
  9092. if (sep->IsNumber(2)) {
  9093. int32 value1 = atol(sep->arg[2]);
  9094. if (value1 > 0xFFFF)
  9095. memcpy(ptr2, (uchar*)&value1, 4);
  9096. else if (value1 > 0xFF)
  9097. memcpy(ptr2, (uchar*)&value1, 2);
  9098. else
  9099. memcpy(ptr2, (uchar*)&value1, 1);
  9100. }
  9101. else {
  9102. int8 len = strlen(sep->arg[2]);
  9103. memcpy(ptr2, (uchar*)&len, 1);
  9104. ptr2 += 1;
  9105. memcpy(ptr2, sep->arg[2], len);
  9106. }
  9107. }
  9108. DumpPacket(app);
  9109. client->QueuePacket(app);
  9110. safe_delete(packet2);
  9111. }
  9112. }
  9113. else if (atoi(sep->arg[0]) == 23) {
  9114. if (client->GetPlayer()->GetTarget()) {
  9115. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9116. if (packet2) {
  9117. Spawn* target = client->GetPlayer()->GetTarget();
  9118. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9119. Item* item = new Item(master_item_list.GetItem(12565));
  9120. int8 i = 0;
  9121. packet2->setArrayLengthByName("num_items", 1);
  9122. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9123. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9124. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9125. packet2->setArrayDataByName("icon", item->details.icon, i);
  9126. int8 tmp_level = 0;
  9127. if (item->generic_info.adventure_default_level > 0)
  9128. tmp_level = item->generic_info.adventure_default_level;
  9129. else
  9130. tmp_level = item->generic_info.tradeskill_default_level;
  9131. packet2->setArrayDataByName("level", tmp_level, i);
  9132. packet2->setArrayDataByName("tier", item->details.tier, i);
  9133. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9134. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9135. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9136. item_difficulty = ARROW_COLOR_WHITE;
  9137. item_difficulty -= 6;
  9138. if (item_difficulty < 0)
  9139. item_difficulty *= -1;
  9140. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9141. packet2->setArrayDataByName("quantity", 2, i);
  9142. packet2->setArrayDataByName("unknown5", 255, i);
  9143. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9144. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9145. packet2->setDataByName("type", 2);
  9146. EQ2Packet* app = packet2->serialize();
  9147. if (sep->IsSet(2)) {
  9148. int16 offset = atoi(sep->arg[1]);
  9149. uchar* ptr2 = app->pBuffer;
  9150. ptr2 += offset;
  9151. if (sep->IsNumber(2)) {
  9152. int32 value1 = atol(sep->arg[2]);
  9153. if (value1 > 0xFFFF)
  9154. memcpy(ptr2, (uchar*)&value1, 4);
  9155. else if (value1 > 0xFF)
  9156. memcpy(ptr2, (uchar*)&value1, 2);
  9157. else
  9158. memcpy(ptr2, (uchar*)&value1, 1);
  9159. }
  9160. else {
  9161. int8 len = strlen(sep->arg[2]);
  9162. memcpy(ptr2, (uchar*)&len, 1);
  9163. ptr2 += 1;
  9164. memcpy(ptr2, sep->arg[2], len);
  9165. }
  9166. }
  9167. DumpPacket(app);
  9168. client->QueuePacket(app);
  9169. safe_delete(packet2);
  9170. }
  9171. }
  9172. }
  9173. else if (atoi(sep->arg[0]) == 24) {
  9174. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  9175. if (packet2) {
  9176. if (sep->IsSet(2)) {
  9177. packet2->setDataByName("event_name", sep->arg[1]);
  9178. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  9179. EQ2Packet* app = packet2->serialize();
  9180. DumpPacket(app);
  9181. client->QueuePacket(app);
  9182. safe_delete(packet2);
  9183. }
  9184. }
  9185. }
  9186. else if (atoi(sep->arg[0]) == 25) {
  9187. if (sep->IsSet(1)) {
  9188. Widget* new_spawn = new Widget();
  9189. int32 id = atoul(sep->arg[1]);
  9190. new_spawn->SetWidgetID(id);
  9191. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9192. client->QueuePacket(ret);
  9193. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  9194. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  9195. if (packet2) {
  9196. packet2->setDataByName("spawn_index", index);
  9197. packet2->setDataByName("delete", 1);
  9198. EQ2Packet* app = packet2->serialize();
  9199. client->QueuePacket(app);
  9200. safe_delete(packet2);
  9201. }
  9202. }
  9203. }
  9204. else if (atoi(sep->arg[0]) == 26) {
  9205. if (sep->IsSet(4)) {
  9206. Widget* new_spawn = new Widget();
  9207. int32 id = atoul(sep->arg[1]);
  9208. new_spawn->SetWidgetID(id);
  9209. float x = atof(sep->arg[2]);
  9210. float y = atof(sep->arg[3]);
  9211. float z = atof(sep->arg[4]);
  9212. new_spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9213. new_spawn->SetWidgetX(x);
  9214. new_spawn->SetWidgetY(y);
  9215. new_spawn->SetWidgetZ(z);
  9216. new_spawn->SetX(x);
  9217. new_spawn->SetY(y);
  9218. new_spawn->SetZ(z);
  9219. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9220. client->QueuePacket(ret);
  9221. }
  9222. }
  9223. else if (atoi(sep->arg[0]) == 27) {
  9224. Spawn* target = client->GetPlayer()->GetTarget();
  9225. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  9226. if (packet2 && target && sep->IsSet(2)) {
  9227. packet2->setSubstructDataByName("header", "defender", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9228. packet2->setSubstructDataByName("header", "defender_proxy", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9229. packet2->setSubstructDataByName("header", "attacker", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  9230. packet2->setArrayLengthByName("num_dmg", 1);
  9231. packet2->setArrayDataByName("damage_type", atoi(sep->arg[1]));
  9232. packet2->setArrayDataByName("damage", atoi(sep->arg[2]));
  9233. packet2->setDataByName("spell", 1);
  9234. packet2->setDataByName("spell_name", "Testing");
  9235. EQ2Packet* app = packet2->serialize();
  9236. if (sep->IsSet(4)) {
  9237. int16 offset = atoi(sep->arg[3]);
  9238. uchar* ptr2 = app->pBuffer;
  9239. ptr2 += offset;
  9240. if (sep->IsNumber(4)) {
  9241. int32 value1 = atol(sep->arg[4]);
  9242. if (value1 > 0xFFFF)
  9243. memcpy(ptr2, (uchar*)&value1, 4);
  9244. else if (value1 > 0xFF)
  9245. memcpy(ptr2, (uchar*)&value1, 2);
  9246. else
  9247. memcpy(ptr2, (uchar*)&value1, 1);
  9248. }
  9249. else {
  9250. int8 len = strlen(sep->arg[4]);
  9251. memcpy(ptr2, (uchar*)&len, 1);
  9252. ptr2 += 1;
  9253. memcpy(ptr2, sep->arg[4], len);
  9254. }
  9255. }
  9256. if (sep->IsSet(6)) {
  9257. int16 offset = atoi(sep->arg[5]);
  9258. uchar* ptr2 = app->pBuffer;
  9259. ptr2 += offset;
  9260. if (sep->IsNumber(6)) {
  9261. int32 value1 = atol(sep->arg[6]);
  9262. if (value1 > 0xFFFF)
  9263. memcpy(ptr2, (uchar*)&value1, 4);
  9264. else if (value1 > 0xFF)
  9265. memcpy(ptr2, (uchar*)&value1, 2);
  9266. else
  9267. memcpy(ptr2, (uchar*)&value1, 1);
  9268. }
  9269. else {
  9270. int8 len = strlen(sep->arg[6]);
  9271. memcpy(ptr2, (uchar*)&len, 1);
  9272. ptr2 += 1;
  9273. memcpy(ptr2, sep->arg[6], len);
  9274. }
  9275. }
  9276. DumpPacket(app);
  9277. client->QueuePacket(app);
  9278. safe_delete(packet2);
  9279. }
  9280. }
  9281. }
  9282. else {
  9283. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  9284. if (packet2) {
  9285. packet2->setSubstructDataByName("info_header", "show_name", 1);
  9286. packet2->setSubstructDataByName("info_header", "unknown", 7);
  9287. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  9288. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  9289. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  9290. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  9291. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  9292. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  9293. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  9294. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  9295. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  9296. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  9297. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  9298. packet2->setSubstructDataByName("info_header", "packettype", 3);
  9299. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  9300. packet2->setSubstructDataByName("spell_info", "level", 19);
  9301. packet2->setSubstructDataByName("spell_info", "tier", 1);
  9302. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  9303. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  9304. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  9305. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  9306. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  9307. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  9308. packet2->setSubstructDataByName("spell_info", "recast", 280);
  9309. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  9310. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  9311. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  9312. packet2->setSubstructDataByName("spell_info", "quality", 3);
  9313. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  9314. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  9315. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  9316. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  9317. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  9318. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  9319. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  9320. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  9321. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  9322. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  9323. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  9324. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  9325. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  9326. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  9327. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  9328. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  9329. packet2->setArrayDataByName("reagent", "Alcohol");
  9330. packet2->setArrayDataByName("consumed", "123");
  9331. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  9332. packet2->setSubstructDataByName("spell_info", "id", 8308);
  9333. packet2->setSubstructDataByName("spell_info", "icon", 303);
  9334. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  9335. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  9336. packet2->setSubstructDataByName("spell_info", "type", 2);
  9337. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  9338. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  9339. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  9340. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  9341. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  9342. EQ2Packet* outapp = packet2->serialize();
  9343. DumpPacket(outapp);
  9344. client->QueuePacket(outapp);
  9345. safe_delete(packet2);
  9346. }
  9347. }
  9348. return;
  9349. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  9350. if (!p) return;
  9351. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9352. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  9353. //}
  9354. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9355. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  9356. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  9357. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  9358. if (packet) {
  9359. client->QueuePacket(packet->serialize());
  9360. safe_delete(packet);
  9361. }
  9362. }*/
  9363. /*if (client->GetCurrentZone()->Grid != nullptr) {
  9364. int32 numFaces = 0;
  9365. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  9366. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  9367. map<int32, vector<Face*> >::iterator itr;
  9368. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  9369. numFaces += (*itr).second.size();
  9370. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  9371. }*/
  9372. //uchar blah[] = {
  9373. // 1208 - OP_EQUpdateStoreCmd
  9374. // /*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
  9375. // /*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
  9376. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  9377. // /*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
  9378. /*};
  9379. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9380. int8 val = 0;
  9381. int16 pos = 0;
  9382. int idx = 0;
  9383. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  9384. pos = atoi(sep2->arg[idx]);
  9385. val = atoi(sep2->arg[idx+1]);
  9386. memset(blah+pos, val, 1);
  9387. idx+=2;
  9388. }
  9389. DumpPacket(blah, sizeof(blah));
  9390. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  9391. if (client->GetPlayer()->GetTarget()) {
  9392. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  9393. if (packet) {
  9394. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  9395. packet->setDataByName("size", 0);
  9396. packet->setDataByName("unknown2", 0);
  9397. EQ2Packet* app = packet->serialize();
  9398. client->QueuePacket(app);
  9399. safe_delete(packet);
  9400. }
  9401. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  9402. if (set_pov) {
  9403. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  9404. EQ2Packet* app_pov = set_pov->serialize();
  9405. client->QueuePacket(app_pov);
  9406. safe_delete(set_pov);
  9407. }
  9408. }
  9409. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9410. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  9411. if (packet) {
  9412. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  9413. packet->setDataByName("Type", atoi(sep2->arg[0]));
  9414. else
  9415. packet->setDataByName("Type", 2);
  9416. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  9417. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  9418. else
  9419. packet->setDataByName("race_id", 0);
  9420. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  9421. packet->setDataByName("gender", atoi(sep2->arg[2]));
  9422. else
  9423. packet->setDataByName("gender", 2);
  9424. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  9425. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  9426. else
  9427. packet->setDataByName("unknown", 0, 0);
  9428. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  9429. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  9430. else
  9431. packet->setDataByName("unknown", 0, 1);
  9432. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  9433. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  9434. else
  9435. packet->setDataByName("unknown", 0, 2);
  9436. client->QueuePacket(packet->serialize());
  9437. }
  9438. safe_delete(packet);
  9439. safe_delete(sep2);
  9440. }
  9441. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  9442. const char *channel_name;
  9443. if (sep == NULL || !sep->IsSet(0)) {
  9444. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  9445. PrintSep(sep);
  9446. return;
  9447. }
  9448. channel_name = sep->arg[0];
  9449. if (!chat.IsInChannel(client, channel_name))
  9450. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  9451. else if (!chat.LeaveChannel(client, channel_name))
  9452. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  9453. }
  9454. /*
  9455. Function:
  9456. Purpose :
  9457. Params :
  9458. Dev :
  9459. Example :
  9460. */
  9461. void Commands::Command_WeaponStats(Client* client)
  9462. {
  9463. Player* player = client->GetPlayer();
  9464. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  9465. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  9466. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  9467. client->SimpleMessage(0, "Primary:");
  9468. if (primary) {
  9469. client->Message(0, "Name: %s", primary->name.c_str());
  9470. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  9471. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  9472. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  9473. client->Message(0, "Proc Percent: %d%%", 0);
  9474. client->Message(0, "Procs Per Minute: %d", 0);
  9475. }
  9476. else {
  9477. client->SimpleMessage(0, "Name: fist");
  9478. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  9479. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  9480. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  9481. client->Message(0, "Proc Percent: %d%%", 0);
  9482. client->Message(0, "Procs Per Minute: %d", 0);
  9483. }
  9484. client->SimpleMessage(0, " ");
  9485. client->SimpleMessage(0, " ");
  9486. if (secondary) {
  9487. client->SimpleMessage(0, "Secondary:");
  9488. client->Message(0, "Name: %s", secondary->name.c_str());
  9489. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  9490. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  9491. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  9492. client->Message(0, "Proc Percent: %d%%", 0);
  9493. client->Message(0, "Procs Per Minute: %d", 0);
  9494. client->SimpleMessage(0, " ");
  9495. client->SimpleMessage(0, " ");
  9496. }
  9497. client->SimpleMessage(0, "Ranged:");
  9498. if (ranged) {
  9499. client->Message(0, "Name: %s", ranged->name.c_str());
  9500. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  9501. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  9502. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  9503. client->Message(0, "Proc Percent: %d%%", 0);
  9504. client->Message(0, "Procs Per Minute: %d", 0);
  9505. }
  9506. else
  9507. client->SimpleMessage(0, "None");
  9508. }
  9509. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  9510. const char *channel_name;
  9511. if (sep == NULL || !sep->IsSet(0)) {
  9512. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  9513. return;
  9514. }
  9515. channel_name = sep->arg[0];
  9516. if (!chat.ChannelExists(channel_name))
  9517. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  9518. else
  9519. chat.SendChannelUserList(client, channel_name);
  9520. }
  9521. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  9522. {
  9523. ZoneServer* zone = 0;
  9524. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  9525. if (zone_id > 0)
  9526. {
  9527. zone = zone_list.Get(zone_id, false);
  9528. if (zone)
  9529. {
  9530. zone->SetSafeX(client->GetPlayer()->GetX());
  9531. zone->SetSafeY(client->GetPlayer()->GetY());
  9532. zone->SetSafeZ(client->GetPlayer()->GetZ());
  9533. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  9534. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  9535. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  9536. else
  9537. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  9538. }
  9539. }
  9540. }
  9541. /*
  9542. Function:
  9543. Purpose :
  9544. Params :
  9545. Dev :
  9546. Example :
  9547. */
  9548. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  9549. {
  9550. ZoneInfo* zone_info = new ZoneInfo;
  9551. if (sep && sep->arg[0])
  9552. {
  9553. if (sep->IsNumber(0))
  9554. zone_info->id = atoi(sep->arg[0]);
  9555. else
  9556. zone_info->id = database.GetZoneID(sep->arg[0]);
  9557. if (zone_info->id > 0)
  9558. {
  9559. database.LoadZoneInfo(zone_info);
  9560. 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);
  9561. 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);
  9562. 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);
  9563. 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);
  9564. 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);
  9565. 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);
  9566. 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);
  9567. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  9568. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  9569. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  9570. }
  9571. else
  9572. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  9573. }
  9574. else
  9575. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  9576. safe_delete(zone_info);
  9577. }
  9578. /*
  9579. Function:
  9580. Purpose :
  9581. Params :
  9582. Dev :
  9583. Example :
  9584. */
  9585. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  9586. {
  9587. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  9588. {
  9589. ZoneServer* zone = 0;
  9590. int32 zone_id = 0;
  9591. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  9592. {
  9593. zone_id = atoi(sep->arg[0]);
  9594. zone = zone_list.Get(atoi(sep->arg[0]), false);
  9595. }
  9596. else
  9597. {
  9598. zone_id = database.GetZoneID(sep->arg[0]);
  9599. if (zone_id > 0)
  9600. zone = zone_list.Get(sep->arg[0], false);
  9601. }
  9602. if (zone_id > 0)
  9603. {
  9604. if (zone_set_values.count(string(sep->arg[1])) > 0)
  9605. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  9606. else
  9607. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  9608. }
  9609. else
  9610. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  9611. }
  9612. else
  9613. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  9614. }
  9615. void Commands::Command_Rain(Client* client, Seperator* sep) {
  9616. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  9617. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  9618. return;
  9619. }
  9620. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  9621. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  9622. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  9623. }
  9624. void Commands::Command_Wind(Client* client, Seperator* sep) {
  9625. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  9626. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  9627. return;
  9628. }
  9629. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  9630. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  9631. }
  9632. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  9633. Spawn* spawn = client->GetPlayer()->GetTarget();
  9634. if(spawn) {
  9635. client->SetMerchantTransaction(spawn);
  9636. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  9637. client->SendHailCommand(spawn);
  9638. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  9639. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  9640. client->SendBuyMerchantList(sell);
  9641. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  9642. client->SendSellMerchantList(sell);
  9643. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  9644. client->SendBuyBackList(sell);
  9645. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9646. if (packet) {
  9647. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  9648. packet->setDataByName("type", 16);
  9649. EQ2Packet* outapp = packet->serialize();
  9650. if (outapp)
  9651. client->QueuePacket(outapp);
  9652. safe_delete(packet);
  9653. }
  9654. }
  9655. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  9656. client->SendRepairList();
  9657. }
  9658. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  9659. }
  9660. void Commands::Command_Weather(Client* client, Seperator* sep)
  9661. {
  9662. //PrintSep(sep, "Weather");
  9663. if( sep && sep->arg[0] )
  9664. {
  9665. ZoneServer* zsZone = client->GetCurrentZone();
  9666. const char* value = sep->arg[0];
  9667. // process single-param commands first
  9668. if( strncasecmp(value, "details", strlen(value)) == 0 )
  9669. {
  9670. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  9671. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  9672. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  9673. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  9674. }
  9675. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  9676. {
  9677. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9678. zsZone->ProcessWeather();
  9679. }
  9680. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  9681. {
  9682. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  9683. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  9684. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  9685. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  9686. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  9687. zsZone->SetWeatherPattern(1);
  9688. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  9689. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  9690. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  9691. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9692. zsZone->ProcessWeather();
  9693. }
  9694. // process commands with params
  9695. if( sep->arg[1] )
  9696. {
  9697. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  9698. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  9699. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  9700. zsZone->SetWeatherType(atoi(sep->arg[1]));
  9701. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  9702. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  9703. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  9704. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  9705. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  9706. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  9707. }
  9708. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  9709. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  9710. zsZone->SetRain(zsZone->GetCurrentWeather());
  9711. }
  9712. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  9713. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  9714. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  9715. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  9716. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9717. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  9718. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9719. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  9720. }
  9721. }
  9722. else
  9723. {
  9724. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  9725. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  9726. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  9727. return;
  9728. }
  9729. }
  9730. void Commands::Command_Select(Client* client, Seperator* sep) {
  9731. if (sep && sep->arg[1]) {
  9732. Spawn* spawn = client->GetPlayer()->GetTarget();
  9733. if (spawn && strlen(sep->arg[1]) > 0)
  9734. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  9735. }
  9736. }
  9737. /*
  9738. Function: Command_ConsumeFood()
  9739. Purpose : Consume Food/Drink and apply mods
  9740. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  9741. Dev : Zcoretri
  9742. Example : /consume_food 22
  9743. */
  9744. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  9745. if (sep && sep->arg[0] && sep->IsNumber(0))
  9746. {
  9747. Player* player = client->GetPlayer();
  9748. int8 slot = atoi(sep->arg[0]);
  9749. Item* item = player->GetEquipmentList()->GetItem(slot);
  9750. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  9751. {
  9752. client->Message(CHANNEL_NARRATIVE, "If you ate anymore you would explode!");
  9753. return;
  9754. }
  9755. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  9756. {
  9757. client->Message(CHANNEL_NARRATIVE, "If you drank anymore you would explode!");
  9758. return;
  9759. }
  9760. client->ConsumeFoodDrink(item, slot);
  9761. }
  9762. }
  9763. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  9764. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9765. if (atoi(sep->arg[0]) == 1) {
  9766. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  9767. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  9768. client->GetPlayer()->SetCharSheetChanged(true);
  9769. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  9770. }
  9771. else {
  9772. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  9773. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  9774. client->GetPlayer()->SetCharSheetChanged(true);
  9775. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  9776. }
  9777. }
  9778. else
  9779. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  9780. }
  9781. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  9782. {
  9783. if(sep)
  9784. {
  9785. string data;
  9786. if(sep->arg[0]){
  9787. data = string(sep->arg[0]);
  9788. }
  9789. for(int i=1;i<sep->GetMaxArgNum();i++){
  9790. if(sep->arg[i])
  9791. data.append(" ").append(sep->arg[i]);
  9792. }
  9793. const char* target_name = 0;
  9794. int32 spawn_id = 0;
  9795. if(client->GetPlayer()->GetTarget())
  9796. {
  9797. target_name = client->GetPlayer()->GetTarget()->GetName();
  9798. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9799. }
  9800. else
  9801. target_name = "N/A";
  9802. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  9803. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  9804. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  9805. else
  9806. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  9807. }
  9808. }
  9809. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  9810. PrintSep(sep, "Command_Attune_Inv");
  9811. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9812. // Get the item index from the first parameter
  9813. int16 index = atoi(sep->arg[0]);
  9814. // Check to see if this is a valid item index for the player, if not exit out of the function
  9815. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  9816. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  9817. return;
  9818. }
  9819. // Get the item
  9820. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  9821. if(item) {
  9822. // Valid item lets check to make sure this item is attunable, if not return out
  9823. if (!item->CheckFlag(ATTUNEABLE)) {
  9824. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  9825. return;
  9826. }
  9827. // Remove the attunable flag
  9828. item->generic_info.item_flags -= ATTUNEABLE;
  9829. // Set the attuned flag
  9830. item->generic_info.item_flags += ATTUNED;
  9831. // Flag this item for saving
  9832. item->save_needed = true;
  9833. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  9834. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  9835. EQ2Packet* outapp = 0;
  9836. for (int32 i=0;i<packets.size();i++) {
  9837. outapp = packets[i];
  9838. if(outapp)
  9839. client->QueuePacket(outapp);
  9840. }
  9841. }
  9842. }
  9843. }
  9844. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  9845. PrintSep(sep, "Command_Reset_Zone_Timer");
  9846. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9847. int32 db_id = atoul(sep->arg[0]);
  9848. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  9849. if (data) {
  9850. // TODO: add a check to timers to ensure it can be reset
  9851. // Delete the character from the instance
  9852. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  9853. data->instance_id = 0;
  9854. // Update the success time and set to 0 so the player can enter it again
  9855. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  9856. data->last_success_timestamp = 0;
  9857. }
  9858. }*/
  9859. }
  9860. void Commands::Command_Player(Client* client, Seperator* sep) {
  9861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  9862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  9863. }
  9864. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  9865. // /player coins add 10
  9866. // /player coins add plat 10
  9867. Player* player = client->GetPlayer();
  9868. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  9869. player = (Player*)player->GetTarget();
  9870. if (sep && sep->arg[0] && sep->arg[1]) {
  9871. const char* action = sep->arg[0];
  9872. int64 value = 0;
  9873. if (strncasecmp(action, "add", strlen(action)) == 0) {
  9874. if (sep->IsNumber(1)) {
  9875. value = atoi64(sep->arg[1]);
  9876. player->AddCoins(value);
  9877. if (client->GetPlayer() == player)
  9878. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9879. else {
  9880. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9881. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9882. }
  9883. return;
  9884. }
  9885. else if (sep->arg[2] && sep->IsNumber(2)) {
  9886. const char* type = sep->arg[1];
  9887. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  9888. value = atoi64(sep->arg[2]);
  9889. }
  9890. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  9891. value = atoi64(sep->arg[2]) * 100;
  9892. }
  9893. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  9894. value = atoi64(sep->arg[2]) * 10000;
  9895. }
  9896. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  9897. value = atoi64(sep->arg[2]) * 1000000;
  9898. }
  9899. player->AddCoins(value);
  9900. if (client->GetPlayer() == player)
  9901. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9902. else {
  9903. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9904. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9905. }
  9906. return;
  9907. }
  9908. }
  9909. }
  9910. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  9911. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  9912. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  9913. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  9914. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  9915. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  9916. }
  9917. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  9918. PrintSep(sep, "ACHIEVEMENT_ADD");
  9919. if (sep && sep->IsSet(0)) {
  9920. int32 spell_id = atoul(sep->arg[1]);
  9921. int8 spell_tier = 0;
  9922. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9923. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9924. // addspellbookentry here
  9925. if (spell_tier >= data->maxRank) {
  9926. return;
  9927. }
  9928. if (!spell_tier) {
  9929. spell_tier = 1;
  9930. }
  9931. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9932. {
  9933. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9934. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9935. client->GetPlayer()->UnlockSpell(spell);
  9936. client->SendSpellUpdate(spell);
  9937. }
  9938. else
  9939. {
  9940. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  9941. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9942. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9943. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9944. client->GetPlayer()->UnlockSpell(spell);
  9945. client->SendSpellUpdate(spell);
  9946. }
  9947. // cast spell here
  9948. if (!spell_tier)
  9949. spell_tier = 1;
  9950. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9951. if (spell) {
  9952. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9953. }
  9954. }
  9955. else {
  9956. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9957. }
  9958. master_aa_list.DisplayAA(client, 0, 0);
  9959. }
  9960. void Commands::Command_Editor(Client* client, Seperator* sep) {
  9961. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  9962. if (packet) {
  9963. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  9964. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  9965. char command[255];
  9966. url = "browser " + url;
  9967. int32 spawn_id = 0;
  9968. int32 zone_id = 0;
  9969. string type;
  9970. if (client->GetCurrentZone())
  9971. zone_id = client->GetCurrentZone()->GetZoneID();
  9972. if (client->GetPlayer()->GetTarget()) {
  9973. Spawn* target = client->GetPlayer()->GetTarget();
  9974. if (target->IsWidget())
  9975. type = "widgets";
  9976. else if (target->IsSign())
  9977. type = "signs";
  9978. else if (target->IsObject())
  9979. type = "objects";
  9980. else if (target->IsNPC())
  9981. type = "npcs";
  9982. else if (target->IsGroundSpawn())
  9983. type = "ground";
  9984. else
  9985. type = "spawn";
  9986. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9987. }
  9988. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  9989. packet->setDataByName("accept_command", command);
  9990. }
  9991. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  9992. char command[255];
  9993. url = "browser " + url;
  9994. if (client->GetPlayer()->GetTarget())
  9995. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  9996. packet->setDataByName("accept_command", command);
  9997. }
  9998. else {
  9999. string command = "browser " + url;
  10000. packet->setDataByName("accept_command", command.c_str());
  10001. }
  10002. packet->setDataByName("text", "Open the web editor?");
  10003. packet->setDataByName("accept_text", "Open");
  10004. packet->setDataByName("cancel_text", "Cancel");
  10005. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  10006. packet->setDataByName("unknown2", 50);
  10007. packet->setDataByName("unknown4", 1);
  10008. client->QueuePacket(packet->serialize());
  10009. safe_delete(packet);
  10010. }
  10011. }
  10012. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  10013. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10014. return;
  10015. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10016. if(client->GetCurrentRez()->active)
  10017. client->AcceptResurrection();
  10018. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10019. }
  10020. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  10021. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10022. return;
  10023. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10024. if(client->GetCurrentRez()->active)
  10025. client->GetCurrentRez()->should_delete = true;
  10026. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10027. }
  10028. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  10029. PrintSep(sep, "Switch_AA_Profile");
  10030. if (sep && sep->IsSet(0)) {
  10031. string type = sep->arg[0];
  10032. int8 newtemplate = atoul(sep->arg[1]);
  10033. master_aa_list.DisplayAA(client, newtemplate, 1);
  10034. }
  10035. }
  10036. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  10037. PrintSep(sep, "Get_AA_Xml");
  10038. if (sep && sep->IsSet(0)) {
  10039. string tabnum = sep->arg[0];
  10040. string spellid = sep->arg[1];
  10041. }
  10042. }
  10043. void Commands::Add_AA(Client* client, Seperator* sep) {
  10044. PrintSep(sep, "Add_AA");
  10045. if (sep && sep->IsSet(0)) {
  10046. int32 spell_id = atoul(sep->arg[1]);
  10047. int8 spell_tier = 0;
  10048. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10049. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10050. // addspellbookentry here
  10051. if(!data) {
  10052. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  10053. return;
  10054. }
  10055. if (spell_tier >= data->maxRank) {
  10056. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  10057. return;
  10058. }
  10059. if (!spell_tier) {
  10060. spell_tier = 1;
  10061. }
  10062. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10063. {
  10064. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10065. if(spell)
  10066. {
  10067. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10068. client->GetPlayer()->UnlockSpell(spell);
  10069. client->SendSpellUpdate(spell);
  10070. }
  10071. }
  10072. else
  10073. {
  10074. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10075. if(spell)
  10076. {
  10077. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10078. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10079. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10080. client->GetPlayer()->UnlockSpell(spell);
  10081. client->SendSpellUpdate(spell);
  10082. }
  10083. }
  10084. // cast spell here
  10085. if (!spell_tier)
  10086. spell_tier = 1;
  10087. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10088. if (spell) {
  10089. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10090. }
  10091. }
  10092. else {
  10093. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10094. }
  10095. master_aa_list.DisplayAA(client, 0, 0);
  10096. }
  10097. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  10098. PrintSep(sep, "Commit_AA_Profile");
  10099. if (sep && sep->IsSet(0)) {
  10100. }
  10101. }
  10102. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  10103. PrintSep(sep, "Begin_AA_Profile");
  10104. if (sep && sep->IsSet(0)) {
  10105. master_aa_list.DisplayAA(client, 100, 2);
  10106. }
  10107. }
  10108. void Commands::Back_AA(Client* client, Seperator* sep) {
  10109. if (sep && sep->IsSet(0)) {
  10110. PrintSep(sep, "Back_AA");
  10111. }
  10112. }
  10113. void Commands::Remove_AA(Client* client, Seperator* sep) {
  10114. if (sep && sep->IsSet(0)) {
  10115. PrintSep(sep, "Remove_AA");
  10116. }
  10117. }
  10118. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  10119. MasterAAList master_aa_list;
  10120. PrintSep(sep, "Cancel_AA_Profile");
  10121. master_aa_list.DisplayAA(client, 0, 0);
  10122. }
  10123. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  10124. if (sep && sep->IsSet(0)) {
  10125. PrintSep(sep, "Save_AA_Profile");
  10126. }
  10127. }
  10128. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  10129. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  10130. if (!sep->IsNumber(0)) return;
  10131. int32 request_id = atoul(sep->arg[0]);
  10132. if (!sep->IsNumber(1)) return;
  10133. sint32 item_id = atoi(sep->arg[1]);
  10134. if (client->IsCurrentTransmuteID(request_id)) {
  10135. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  10136. }
  10137. else if (client->IsCurrentTransmuteID(item_id)) {
  10138. if (!sep->IsSet(2)) return;
  10139. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  10140. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  10141. }
  10142. }
  10143. }
  10144. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  10145. if(sep)
  10146. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  10147. }
  10148. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  10149. if(sep && sep->arg[0][0] && sep->arg[1][0])
  10150. {
  10151. char* name = sep->arg[0];
  10152. char* zoneName = sep->arg[1];
  10153. char query[256];
  10154. 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);
  10155. if (database.RunQuery(query, strnlen(query, 256)))
  10156. {
  10157. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  10158. }
  10159. else
  10160. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  10161. }
  10162. }