Commands.cpp 443 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include <boost/algorithm/string/predicate.hpp>
  18. #include <boost/algorithm/string.hpp>
  19. #include "Commands.h"
  20. #include "../ClientPacketFunctions.h"
  21. #include "../../common/version.h"
  22. #include "../../common/seperator.h"
  23. #include "../../common/servertalk.h"
  24. #include "../WorldDatabase.h"
  25. #include "../World.h"
  26. #include "../../common/ConfigReader.h"
  27. #include "../VisualStates.h"
  28. #include "../../common/debug.h"
  29. #include "../LuaInterface.h"
  30. #include "../Quests.h"
  31. #include "../client.h"
  32. #include "../NPC.h"
  33. #include "../Guilds/Guild.h"
  34. #include "../SpellProcess.h"
  35. #include "../Tradeskills/Tradeskills.h"
  36. #include "../../common/Log.h"
  37. #include "../../common/MiscFunctions.h"
  38. #include "../Languages.h"
  39. #include "../Traits/Traits.h"
  40. #include "../Chat/Chat.h"
  41. #include "../Rules/Rules.h"
  42. #include "../AltAdvancement/AltAdvancement.h"
  43. #include "../RaceTypes/RaceTypes.h"
  44. #include "../classes.h"
  45. #include "../Transmute.h"
  46. #include "../Bots/Bot.h"
  47. extern WorldDatabase database;
  48. extern MasterSpellList master_spell_list;
  49. extern MasterTraitList master_trait_list;
  50. extern MasterRecipeList master_recipe_list;
  51. extern MasterRecipeBookList master_recipebook_list;
  52. extern World world;
  53. extern ClientList client_list;
  54. extern ConfigReader configReader;
  55. extern VisualStates visual_states;
  56. extern ZoneList zone_list;
  57. extern LuaInterface* lua_interface;
  58. extern MasterQuestList master_quest_list;
  59. extern MasterCollectionList master_collection_list;
  60. extern MasterSkillList master_skill_list;
  61. extern MasterFactionList master_faction_list;
  62. extern GuildList guild_list;
  63. extern MasterLanguagesList master_languages_list;
  64. extern Chat chat;
  65. extern RuleManager rule_manager;
  66. extern MasterAAList master_aa_list;
  67. extern MasterRaceTypeList race_types_list;
  68. extern Classes classes;
  69. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  70. #if defined(__GNUC__)
  71. #define stricmp strcasecmp
  72. #define strnicmp strncasecmp
  73. #endif
  74. EQ2Packet* RemoteCommands::serialize(){
  75. buffer.clear();
  76. vector<EQ2_RemoteCommandString>::iterator command_list;
  77. buffer.append((char*)&num_commands, sizeof(int16));
  78. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  79. AddDataCommand(&(*command_list));
  80. }
  81. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  82. return app;
  83. }
  84. Commands::Commands(){
  85. remote_commands = new RemoteCommands();
  86. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  87. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  88. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  89. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  90. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  91. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  92. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  93. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  94. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  95. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  96. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  97. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  98. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  99. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  100. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  101. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  102. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  103. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  104. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  105. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  106. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  107. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  108. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  109. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  110. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  111. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  112. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  113. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  114. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  115. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  116. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  117. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  118. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  119. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  120. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  121. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  122. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  123. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  124. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  125. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  126. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  127. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  128. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  129. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  130. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  131. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  132. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  133. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  134. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  135. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  136. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  137. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  138. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  139. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  140. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  141. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  142. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  143. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  144. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  145. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  146. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  147. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  148. spawn_set_values["skin_color"] = SPAWN_SET_SKIN_COLOR;
  149. spawn_set_values["aaxp_rewards"] = SPAWN_SET_AAXP_REWARDS;
  150. spawn_set_values["hair_color1"] = SPAWN_SET_HAIR_COLOR1;
  151. spawn_set_values["hair_color2"] = SPAWN_SET_HAIR_COLOR2;
  152. spawn_set_values["hair_type_color"] = SPAWN_SET_HAIR_TYPE_COLOR;
  153. spawn_set_values["hair_face_color"] = SPAWN_SET_HAIR_FACE_COLOR;
  154. spawn_set_values["hair_type_highlight_color"] = SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR;
  155. spawn_set_values["face_hairlight_color"] = SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR;
  156. spawn_set_values["hair_highlight"] = SPAWN_SET_HAIR_HIGHLIGHT;
  157. spawn_set_values["model_color"] = SPAWN_SET_MODEL_COLOR;
  158. spawn_set_values["eye_color"] = SPAWN_SET_EYE_COLOR;
  159. spawn_set_values["soga_skin_color"] = SPAWN_SET_SOGA_SKIN_COLOR;
  160. spawn_set_values["soga_hair_color1"] = SPAWN_SET_SOGA_HAIR_COLOR1;
  161. spawn_set_values["soga_hair_color2"] = SPAWN_SET_SOGA_HAIR_COLOR2;
  162. spawn_set_values["soga_hair_type_color"] = SPAWN_SET_SOGA_HAIR_TYPE_COLOR;
  163. spawn_set_values["soga_hair_face_color"] = SPAWN_SET_SOGA_HAIR_FACE_COLOR;
  164. spawn_set_values["soga_hair_type_highlight_color"] = SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR;
  165. spawn_set_values["soga_face_hairlight_color"] = SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR;
  166. spawn_set_values["soga_hair_highlight"] = SPAWN_SET_SOGA_HAIR_HIGHLIGHT;
  167. spawn_set_values["soga_model_color"] = SPAWN_SET_SOGA_MODEL_COLOR;
  168. spawn_set_values["soga_eye_color"] = SPAWN_SET_SOGA_EYE_COLOR;
  169. spawn_set_values["cheek_type"] = SPAWN_SET_CHEEK_TYPE;
  170. spawn_set_values["chin_type"] = SPAWN_SET_CHIN_TYPE;
  171. spawn_set_values["ear_type"] = SPAWN_SET_EAR_TYPE;
  172. spawn_set_values["eye_brow_type"] = SPAWN_SET_EYE_BROW_TYPE;
  173. spawn_set_values["eye_type"] = SPAWN_SET_EYE_TYPE;
  174. spawn_set_values["lip_type"] = SPAWN_SET_LIP_TYPE;
  175. spawn_set_values["nose_type"] = SPAWN_SET_NOSE_TYPE;
  176. spawn_set_values["body_size"] = SPAWN_SET_BODY_SIZE;
  177. spawn_set_values["body_age"] = SPAWN_SET_BODY_AGE;
  178. spawn_set_values["soga_cheek_type"] = SPAWN_SET_SOGA_CHEEK_TYPE;
  179. spawn_set_values["soga_chin_type"] = SPAWN_SET_SOGA_CHIN_TYPE;
  180. spawn_set_values["soga_ear_type"] = SPAWN_SET_SOGA_EAR_TYPE;
  181. spawn_set_values["soga_eye_brow_type"] = SPAWN_SET_SOGA_EYE_BROW_TYPE;
  182. spawn_set_values["soga_eye_type"] = SPAWN_SET_SOGA_EYE_TYPE;
  183. spawn_set_values["soga_lip_type"] = SPAWN_SET_SOGA_LIP_TYPE;
  184. spawn_set_values["soga_nose_type"] = SPAWN_SET_SOGA_NOSE_TYPE;
  185. spawn_set_values["soga_body_size"] = SPAWN_SET_SOGA_BODY_SIZE;
  186. spawn_set_values["soga_body_age"] = SPAWN_SET_SOGA_BODY_AGE;
  187. spawn_set_values["attack_type"] = SPAWN_SET_ATTACK_TYPE;
  188. spawn_set_values["race_type"] = SPAWN_SET_RACE_TYPE;
  189. spawn_set_values["loot_tier"] = SPAWN_SET_LOOT_TIER;
  190. spawn_set_values["loot_drop_type"] = SPAWN_SET_LOOT_DROP_TYPE;
  191. spawn_set_values["scared_strong_players"] = SPAWN_SET_SCARED_STRONG_PLAYERS;
  192. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  193. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  194. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  195. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  196. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  197. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  198. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  199. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  200. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  201. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  202. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  203. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  204. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  205. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  206. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  207. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  208. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  209. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  210. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  211. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  212. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  213. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  214. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  215. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  216. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  217. }
  218. Commands::~Commands() {
  219. safe_delete(remote_commands);
  220. }
  221. int32 Commands::GetSpawnSetType(string val){
  222. if(spawn_set_values.count(val) > 0)
  223. return spawn_set_values[val];
  224. return 0xFFFFFFFF;
  225. }
  226. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value, int8 index){
  227. if(!target)
  228. return false;
  229. int32 val = 0;
  230. try{
  231. if(type != SPAWN_SET_VALUE_NAME &&
  232. !(type >= SPAWN_SET_VALUE_SPAWN_SCRIPT && type <= SPAWN_SET_VALUE_SUB_TITLE) && !(type >= SPAWN_SET_VALUE_PREFIX && type <= SPAWN_SET_VALUE_EXPANSION_FLAG || type == SPAWN_SET_VALUE_HOLIDAY_FLAG))
  233. {
  234. switch(type)
  235. {
  236. case SPAWN_SET_SKIN_COLOR:
  237. case SPAWN_SET_HAIR_COLOR1:
  238. case SPAWN_SET_HAIR_COLOR2:
  239. case SPAWN_SET_HAIR_TYPE_COLOR:
  240. case SPAWN_SET_HAIR_FACE_COLOR:
  241. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  242. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  243. case SPAWN_SET_HAIR_HIGHLIGHT:
  244. case SPAWN_SET_EYE_COLOR:
  245. case SPAWN_SET_SOGA_SKIN_COLOR:
  246. case SPAWN_SET_SOGA_HAIR_COLOR1:
  247. case SPAWN_SET_SOGA_HAIR_COLOR2:
  248. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  249. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  250. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  251. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  252. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  253. case SPAWN_SET_SOGA_EYE_COLOR:
  254. case SPAWN_SET_RACE_TYPE:
  255. // ignore these are colors can't pass as a integer value
  256. break;
  257. default:
  258. val = atoul(value);
  259. }
  260. }
  261. }
  262. catch(...){
  263. if(client)
  264. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  265. return false;
  266. }
  267. if(temporary){
  268. char tmp[128] = {0};
  269. switch(type){
  270. case SPAWN_SET_VALUE_NAME:{
  271. sprintf(tmp, "%s", target->GetName());
  272. target->SetName(value);
  273. if(target->GetZone())
  274. target->GetZone()->SendUpdateTitles(target);
  275. break;
  276. }
  277. case SPAWN_SET_VALUE_X_OFFSET:
  278. {
  279. sprintf(tmp, "%f", target->GetXOffset());
  280. target->SetXOffset(float(val));
  281. break;
  282. }
  283. case SPAWN_SET_VALUE_Y_OFFSET:
  284. {
  285. sprintf(tmp, "%f", target->GetYOffset());
  286. target->SetYOffset(float(val));
  287. break;
  288. }
  289. case SPAWN_SET_VALUE_Z_OFFSET:
  290. {
  291. sprintf(tmp, "%f", target->GetZOffset());
  292. target->SetZOffset(float(val));
  293. break;
  294. }
  295. case SPAWN_SET_VALUE_EXPIRE: {
  296. sprintf(tmp, "%u", target->GetExpireTime());
  297. target->SetExpireTime(val);
  298. break;
  299. }
  300. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  301. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  302. target->SetExpireOffsetTime(val);
  303. break;
  304. }
  305. case SPAWN_SET_VALUE_SUB_TITLE: {
  306. sprintf(tmp, "%s", target->GetSubTitle());
  307. target->SetSubTitle(value);
  308. if(target->GetZone())
  309. target->GetZone()->SendUpdateTitles(target);
  310. break;
  311. }
  312. case SPAWN_SET_VALUE_LEVEL:{
  313. sprintf(tmp, "%i", target->GetLevel());
  314. target->SetLevel(val, send_update);
  315. break;
  316. }
  317. case SPAWN_SET_VALUE_DIFFICULTY:{
  318. sprintf(tmp, "%i", target->GetDifficulty());
  319. target->SetDifficulty(val, send_update);
  320. break;
  321. }
  322. case SPAWN_SET_VALUE_MODEL_TYPE:{
  323. sprintf(tmp, "%i", target->GetModelType());
  324. target->SetModelType(val, send_update);
  325. break;
  326. }
  327. case SPAWN_SET_VALUE_CLASS:{
  328. sprintf(tmp, "%i", target->GetAdventureClass());
  329. target->SetAdventureClass(val, send_update);
  330. break;
  331. }
  332. case SPAWN_SET_VALUE_GENDER:{
  333. sprintf(tmp, "%i", target->GetGender());
  334. target->SetGender(val, send_update);
  335. break;
  336. }
  337. case SPAWN_SET_VALUE_SHOW_NAME:{
  338. sprintf(tmp, "%i", target->GetShowName());
  339. target->SetShowName(val, send_update);
  340. break;
  341. }
  342. case SPAWN_SET_VALUE_ATTACKABLE:{
  343. sprintf(tmp, "%i", target->GetAttackable());
  344. target->SetAttackable(val, send_update);
  345. break;
  346. }
  347. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  348. sprintf(tmp, "%i", target->GetShowLevel());
  349. target->SetShowLevel(val, send_update);
  350. break;
  351. }
  352. case SPAWN_SET_VALUE_TARGETABLE:{
  353. sprintf(tmp, "%i", target->GetTargetable());
  354. target->SetTargetable(val, send_update);
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  358. sprintf(tmp, "%i", target->GetShowCommandIcon());
  359. target->SetShowCommandIcon(val, send_update);
  360. break;
  361. }
  362. case SPAWN_SET_VALUE_HAND_ICON:{
  363. sprintf(tmp, "%i", target->GetShowHandIcon());
  364. target->SetShowHandIcon(val, send_update);
  365. break;
  366. }
  367. case SPAWN_SET_VALUE_HAIR_TYPE:{
  368. if(target->IsEntity()){
  369. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  370. ((Entity*)target)->SetHairType(val, send_update);
  371. }
  372. break;
  373. }
  374. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  375. if(target->IsEntity()){
  376. sprintf(tmp, "%i", ((Entity*)target)->GetFacialHairType());
  377. ((Entity*)target)->SetFacialHairType(val, send_update);
  378. }
  379. break;
  380. }
  381. case SPAWN_SET_VALUE_WING_TYPE:{
  382. if(target->IsEntity()){
  383. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  384. ((Entity*)target)->SetWingType(val, send_update);
  385. }
  386. break;
  387. }
  388. case SPAWN_SET_VALUE_CHEST_TYPE:{
  389. if(target->IsEntity()){
  390. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  391. ((Entity*)target)->SetChestType(val, send_update);
  392. }
  393. break;
  394. }
  395. case SPAWN_SET_VALUE_LEGS_TYPE:{
  396. if(target->IsEntity()){
  397. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  398. ((Entity*)target)->SetLegsType(val, send_update);
  399. }
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  403. if(target->IsEntity()){
  404. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  405. ((Entity*)target)->SetSogaHairType(val, send_update);
  406. }
  407. break;
  408. }
  409. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  410. if(target->IsEntity()){
  411. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  412. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  413. }
  414. break;
  415. }
  416. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  417. sprintf(tmp, "%i", target->GetSogaModelType());
  418. target->SetSogaModelType(val, send_update);
  419. break;
  420. }
  421. case SPAWN_SET_VALUE_SIZE:{
  422. sprintf(tmp, "%i", target->GetSize());
  423. target->SetSize(val, send_update);
  424. break;
  425. }
  426. case SPAWN_SET_VALUE_HP:{
  427. sprintf(tmp, "%i", target->GetHP());
  428. target->SetHP(val, send_update);
  429. break;
  430. }
  431. case SPAWN_SET_VALUE_POWER:{
  432. sprintf(tmp, "%i", target->GetPower());
  433. target->SetPower(val, send_update);
  434. break;
  435. }
  436. case SPAWN_SET_VALUE_HEROIC:{
  437. sprintf(tmp, "%i", target->GetHeroic());
  438. target->SetHeroic(val, send_update);
  439. break;
  440. }
  441. case SPAWN_SET_VALUE_RESPAWN:{
  442. sprintf(tmp, "%u", target->GetRespawnTime());
  443. target->SetRespawnTime(val);
  444. break;
  445. }
  446. case SPAWN_SET_VALUE_X:{
  447. sprintf(tmp, "%f", target->GetX());
  448. target->SetX(atof(value), send_update);
  449. break;
  450. }
  451. case SPAWN_SET_VALUE_Y:{
  452. sprintf(tmp, "%f", target->GetY());
  453. target->SetY(atof(value), send_update);
  454. break;
  455. }
  456. case SPAWN_SET_VALUE_Z:{
  457. sprintf(tmp, "%f", target->GetZ());
  458. target->SetZ(atof(value), send_update);
  459. break;
  460. }
  461. case SPAWN_SET_VALUE_HEADING:{
  462. sprintf(tmp, "%f", target->GetHeading());
  463. target->SetHeading(atof(value) + 360, send_update);
  464. break;
  465. }
  466. case SPAWN_SET_VALUE_VISUAL_STATE:{
  467. sprintf(tmp, "%i", target->GetVisualState());
  468. target->SetVisualState(val, send_update);
  469. break;
  470. }
  471. case SPAWN_SET_VALUE_ACTION_STATE:{
  472. sprintf(tmp, "%i", target->GetActionState());
  473. target->SetActionState(val, send_update);
  474. break;
  475. }
  476. case SPAWN_SET_VALUE_MOOD_STATE:{
  477. sprintf(tmp, "%i", target->GetMoodState());
  478. target->SetMoodState(val, send_update);
  479. break;
  480. }
  481. case SPAWN_SET_VALUE_INITIAL_STATE:{
  482. sprintf(tmp, "%i", target->GetInitialState());
  483. target->SetInitialState(val, send_update);
  484. break;
  485. }
  486. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  487. sprintf(tmp, "%i", target->GetActivityStatus());
  488. target->SetActivityStatus(val, send_update);
  489. break;
  490. }
  491. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  492. sprintf(tmp, "%i", target->GetCollisionRadius());
  493. target->SetCollisionRadius(val, send_update);
  494. break;
  495. }
  496. case SPAWN_SET_VALUE_DEVICE_ID: {
  497. if (target->IsObject()) {
  498. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  499. ((Object*)target)->SetDeviceID(val);
  500. }
  501. break;
  502. }
  503. case SPAWN_SET_VALUE_PITCH: {
  504. sprintf(tmp, "%f", target->GetPitch());
  505. target->SetPitch(atof(value), send_update);
  506. break;
  507. }
  508. case SPAWN_SET_VALUE_ROLL: {
  509. sprintf(tmp, "%f", target->GetRoll());
  510. target->SetRoll(atof(value), send_update);
  511. break;
  512. }
  513. case SPAWN_SET_VALUE_HIDE_HOOD: {
  514. sprintf(tmp, "%i", target->appearance.hide_hood);
  515. target->SetHideHood(val);
  516. break;
  517. }
  518. case SPAWN_SET_VALUE_EMOTE_STATE: {
  519. sprintf(tmp, "%i", target->appearance.emote_state);
  520. target->SetEmoteState(val);
  521. break;
  522. }
  523. case SPAWN_SET_VALUE_ICON: {
  524. sprintf(tmp, "%i", target->GetIconValue());
  525. target->SetIcon(val);
  526. break;
  527. }
  528. case SPAWN_SET_VALUE_PREFIX: {
  529. sprintf(tmp, "%s", target->GetPrefixTitle());
  530. target->SetPrefixTitle(value);
  531. if(target->GetZone())
  532. target->GetZone()->SendUpdateTitles(target);
  533. break;
  534. }
  535. case SPAWN_SET_VALUE_SUFFIX: {
  536. sprintf(tmp, "%s", target->GetSuffixTitle());
  537. target->SetSuffixTitle(value);
  538. if(target->GetZone())
  539. target->GetZone()->SendUpdateTitles(target);
  540. break;
  541. }
  542. case SPAWN_SET_VALUE_LASTNAME: {
  543. sprintf(tmp, "%s", target->GetLastName());
  544. target->SetLastName(value);
  545. if(target->GetZone())
  546. target->GetZone()->SendUpdateTitles(target);
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  550. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  551. // nothing to do must reload spawns
  552. break;
  553. }
  554. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  555. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  556. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  557. break;
  558. }
  559. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  560. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  561. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  562. break;
  563. }
  564. case SPAWN_SET_VALUE_FACTION:{
  565. sprintf(tmp, "%i", target->faction_id);
  566. ZoneServer* zone = target->GetZone();
  567. if (!zone && client)
  568. zone = client->GetCurrentZone();
  569. target->faction_id = atoul(value);
  570. if(zone)
  571. {
  572. zone->RemoveDeadEnemyList(target);
  573. if(target->IsNPC())
  574. zone->AddEnemyList((NPC*)target);
  575. }
  576. break;
  577. }
  578. case SPAWN_SET_SKIN_COLOR:
  579. case SPAWN_SET_HAIR_COLOR1:
  580. case SPAWN_SET_HAIR_COLOR2:
  581. case SPAWN_SET_HAIR_TYPE_COLOR:
  582. case SPAWN_SET_HAIR_FACE_COLOR:
  583. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  584. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  585. case SPAWN_SET_HAIR_HIGHLIGHT:
  586. case SPAWN_SET_MODEL_COLOR:
  587. case SPAWN_SET_EYE_COLOR:
  588. case SPAWN_SET_SOGA_SKIN_COLOR:
  589. case SPAWN_SET_SOGA_HAIR_COLOR1:
  590. case SPAWN_SET_SOGA_HAIR_COLOR2:
  591. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  592. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  593. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  594. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  595. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  596. case SPAWN_SET_SOGA_MODEL_COLOR:
  597. case SPAWN_SET_SOGA_EYE_COLOR:
  598. {
  599. if (target->IsEntity())
  600. {
  601. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  602. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  603. {
  604. EQ2_Color clr;
  605. clr.red = atoul(skinsep->arg[0]);
  606. clr.green = atoul(skinsep->arg[1]);
  607. clr.blue = atoul(skinsep->arg[2]);
  608. switch(type)
  609. {
  610. case SPAWN_SET_SKIN_COLOR:
  611. ((Entity*)target)->SetSkinColor(clr);
  612. break;
  613. case SPAWN_SET_HAIR_COLOR1:
  614. ((Entity*)target)->SetHairColor1(clr);
  615. break;
  616. case SPAWN_SET_HAIR_COLOR2:
  617. ((Entity*)target)->SetHairColor2(clr);
  618. break;
  619. case SPAWN_SET_HAIR_TYPE_COLOR:
  620. ((Entity*)target)->SetHairColor(clr);
  621. break;
  622. case SPAWN_SET_HAIR_FACE_COLOR:
  623. ((Entity*)target)->SetFacialHairColor(clr);
  624. break;
  625. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  626. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  627. break;
  628. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  629. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  630. break;
  631. case SPAWN_SET_HAIR_HIGHLIGHT:
  632. ((Entity*)target)->SetHairHighlightColor(clr);
  633. break;
  634. case SPAWN_SET_MODEL_COLOR:
  635. ((Entity*)target)->SetModelColor(clr);
  636. break;
  637. case SPAWN_SET_EYE_COLOR:
  638. ((Entity*)target)->SetEyeColor(clr);
  639. break;
  640. case SPAWN_SET_SOGA_SKIN_COLOR:
  641. ((Entity*)target)->SetSogaSkinColor(clr);
  642. break;
  643. case SPAWN_SET_SOGA_HAIR_COLOR1:
  644. ((Entity*)target)->SetSogaHairColor1(clr);
  645. break;
  646. case SPAWN_SET_SOGA_HAIR_COLOR2:
  647. ((Entity*)target)->SetSogaHairColor2(clr);
  648. break;
  649. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  650. ((Entity*)target)->SetSogaHairColor(clr);
  651. break;
  652. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  653. ((Entity*)target)->SetSogaFacialHairColor(clr);
  654. break;
  655. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  656. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  657. break;
  658. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  659. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  660. break;
  661. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  662. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  663. break;
  664. case SPAWN_SET_SOGA_MODEL_COLOR:
  665. ((Entity*)target)->SetSogaModelColor(clr);
  666. break;
  667. case SPAWN_SET_SOGA_EYE_COLOR:
  668. ((Entity*)target)->SetSogaEyeColor(clr);
  669. break;
  670. }
  671. }
  672. safe_delete(skinsep);
  673. }
  674. break;
  675. }
  676. case SPAWN_SET_AAXP_REWARDS: {
  677. target->SetAAXPRewards(atoul(value));
  678. break;
  679. }
  680. case SPAWN_SET_CHEEK_TYPE:{
  681. if(target->IsEntity() && index < 3){
  682. sprintf(tmp, "%i", ((Entity*)target)->features.cheek_type[index]);
  683. sint8 new_value = atoi(value);
  684. ((Entity*)target)->features.cheek_type[index] = new_value;
  685. ((Entity*)target)->info_changed = true;
  686. }
  687. break;
  688. }
  689. case SPAWN_SET_CHIN_TYPE:{
  690. if(target->IsEntity() && index < 3){
  691. sprintf(tmp, "%i", ((Entity*)target)->features.chin_type[index]);
  692. sint8 new_value = atoi(value);
  693. ((Entity*)target)->features.chin_type[index] = new_value;
  694. ((Entity*)target)->info_changed = true;
  695. }
  696. break;
  697. }
  698. case SPAWN_SET_EAR_TYPE:{
  699. if(target->IsEntity() && index < 3){
  700. sprintf(tmp, "%i", ((Entity*)target)->features.ear_type[index]);
  701. sint8 new_value = atoi(value);
  702. ((Entity*)target)->features.ear_type[index] = new_value;
  703. ((Entity*)target)->info_changed = true;
  704. }
  705. break;
  706. }
  707. case SPAWN_SET_EYE_BROW_TYPE:{
  708. if(target->IsEntity() && index < 3){
  709. sprintf(tmp, "%i", ((Entity*)target)->features.eye_brow_type[index]);
  710. sint8 new_value = atoi(value);
  711. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  712. ((Entity*)target)->info_changed = true;
  713. }
  714. break;
  715. }
  716. case SPAWN_SET_EYE_TYPE:{
  717. if(target->IsEntity() && index < 3){
  718. sprintf(tmp, "%i", ((Entity*)target)->features.eye_type[index]);
  719. sint8 new_value = atoi(value);
  720. ((Entity*)target)->features.eye_type[index] = new_value;
  721. ((Entity*)target)->info_changed = true;
  722. }
  723. break;
  724. }
  725. case SPAWN_SET_LIP_TYPE:{
  726. if(target->IsEntity() && index < 3){
  727. sprintf(tmp, "%i", ((Entity*)target)->features.lip_type[index]);
  728. sint8 new_value = atoi(value);
  729. ((Entity*)target)->features.lip_type[index] = new_value;
  730. ((Entity*)target)->info_changed = true;
  731. }
  732. break;
  733. }
  734. case SPAWN_SET_NOSE_TYPE:{
  735. if(target->IsEntity() && index < 3){
  736. sprintf(tmp, "%i", ((Entity*)target)->features.nose_type[index]);
  737. sint8 new_value = atoi(value);
  738. ((Entity*)target)->features.nose_type[index] = new_value;
  739. ((Entity*)target)->info_changed = true;
  740. }
  741. break;
  742. }
  743. case SPAWN_SET_BODY_SIZE:{
  744. if(target->IsEntity()){
  745. sprintf(tmp, "%i", ((Entity*)target)->features.body_size);
  746. int8 new_value = atoul(value);
  747. ((Entity*)target)->features.body_size = new_value;
  748. ((Entity*)target)->info_changed = true;
  749. }
  750. break;
  751. }
  752. case SPAWN_SET_BODY_AGE:{
  753. if(target->IsEntity()){
  754. sprintf(tmp, "%i", ((Entity*)target)->features.body_age);
  755. int8 new_value = atoul(value);
  756. ((Entity*)target)->features.body_age = new_value;
  757. ((Entity*)target)->info_changed = true;
  758. }
  759. break;
  760. }
  761. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  762. if(target->IsEntity() && index < 3){
  763. sprintf(tmp, "%i", ((Entity*)target)->features.soga_cheek_type[index]);
  764. sint8 new_value = atoi(value);
  765. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  766. ((Entity*)target)->info_changed = true;
  767. }
  768. break;
  769. }
  770. case SPAWN_SET_SOGA_CHIN_TYPE:{
  771. if(target->IsEntity() && index < 3){
  772. sprintf(tmp, "%i", ((Entity*)target)->features.soga_chin_type[index]);
  773. sint8 new_value = atoi(value);
  774. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  775. ((Entity*)target)->info_changed = true;
  776. }
  777. break;
  778. }
  779. case SPAWN_SET_SOGA_EAR_TYPE:{
  780. if(target->IsEntity() && index < 3){
  781. sprintf(tmp, "%i", ((Entity*)target)->features.soga_ear_type[index]);
  782. sint8 new_value = atoi(value);
  783. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  784. ((Entity*)target)->info_changed = true;
  785. }
  786. break;
  787. }
  788. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  789. if(target->IsEntity() && index < 3){
  790. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_brow_type[index]);
  791. sint8 new_value = atoi(value);
  792. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  793. ((Entity*)target)->info_changed = true;
  794. }
  795. break;
  796. }
  797. case SPAWN_SET_SOGA_EYE_TYPE:{
  798. if(target->IsEntity() && index < 3){
  799. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_type[index]);
  800. sint8 new_value = atoi(value);
  801. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  802. ((Entity*)target)->info_changed = true;
  803. }
  804. break;
  805. }
  806. case SPAWN_SET_SOGA_LIP_TYPE:{
  807. if(target->IsEntity() && index < 3){
  808. sprintf(tmp, "%i", ((Entity*)target)->features.soga_lip_type[index]);
  809. sint8 new_value = atoi(value);
  810. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  811. ((Entity*)target)->info_changed = true;
  812. }
  813. break;
  814. }
  815. case SPAWN_SET_SOGA_BODY_SIZE:{
  816. if(target->IsEntity()){
  817. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_size);
  818. int8 new_value = atoul(value);
  819. ((Entity*)target)->features.soga_body_size = new_value;
  820. ((Entity*)target)->info_changed = true;
  821. }
  822. break;
  823. }
  824. case SPAWN_SET_SOGA_BODY_AGE:{
  825. if(target->IsEntity()){
  826. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_age);
  827. int8 new_value = atoul(value);
  828. ((Entity*)target)->features.soga_body_age = new_value;
  829. ((Entity*)target)->info_changed = true;
  830. }
  831. break;
  832. }
  833. case SPAWN_SET_ATTACK_TYPE:{
  834. if(target->IsEntity()){
  835. sprintf(tmp, "%u", ((Entity*)target)->GetInfoStruct()->get_attack_type());
  836. int8 new_value = atoul(value);
  837. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  838. }
  839. break;
  840. }
  841. case SPAWN_SET_RACE_TYPE:{
  842. if(target->GetModelType() > 0){
  843. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  844. if (tmpsep->IsNumber(0))
  845. {
  846. int16 race_type = atoul(value);
  847. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  848. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  849. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  850. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  851. if(client) {
  852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Race type added to memory, however not saved to database.");
  853. }
  854. }
  855. else {
  856. client->SimpleMessage(CHANNEL_COLOR_RED, "Model type already on the race_types_list, use spawn set database to override and update database.");
  857. }
  858. }
  859. safe_delete(tmpsep);
  860. }
  861. break;
  862. }
  863. case SPAWN_SET_LOOT_TIER:{
  864. if(target->IsEntity()){
  865. sprintf(tmp, "%u", target->GetLootTier());
  866. int32 new_value = atoul(value);
  867. target->SetLootTier(new_value);
  868. }
  869. break;
  870. }
  871. case SPAWN_SET_LOOT_DROP_TYPE:{
  872. if(target->IsEntity()){
  873. sprintf(tmp, "%u", target->GetLootDropType());
  874. int32 new_value = atoul(value);
  875. target->SetLootDropType(new_value);
  876. }
  877. break;
  878. }
  879. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  880. if(target->IsNPC()){
  881. sprintf(tmp, "%u", target->IsScaredByStrongPlayers());
  882. int32 new_value = atoul(value);
  883. target->SetScaredByStrongPlayers(new_value);
  884. }
  885. break;
  886. }
  887. if(temp_value)
  888. *temp_value = string(tmp);
  889. }
  890. }
  891. else{
  892. /**** NOT TEMPORARY ELSE STATEMENT ****/
  893. /**** MUST RE-DEFINE WHAT IS ALREADY IN THE IF TEMPORARY BLOCK HERE ****/
  894. switch(type){
  895. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  896. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  897. break;
  898. }
  899. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  900. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  901. break;
  902. }
  903. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  904. if (target->GetDatabaseID() > 0)
  905. {
  906. char query[256];
  907. snprintf(query, 256, "update spawn set expansion_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  908. if (database.RunQuery(query, strnlen(query, 256)))
  909. {
  910. if(client)
  911. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  912. }
  913. }
  914. break;
  915. }
  916. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  917. if (target->GetDatabaseID() > 0)
  918. {
  919. char query[256];
  920. snprintf(query, 256, "update spawn set holiday_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  921. if (database.RunQuery(query, strnlen(query, 256)))
  922. {
  923. if(client)
  924. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  925. }
  926. }
  927. break;
  928. }
  929. case SPAWN_SET_AAXP_REWARDS: {
  930. if (target->GetDatabaseID() > 0)
  931. {
  932. char query[256];
  933. snprintf(query, 256, "update spawn set aaxp_rewards=%u where id=%u", atoul(value), target->GetDatabaseID());
  934. if (database.RunQuery(query, strnlen(query, 256)))
  935. {
  936. if(client)
  937. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  938. }
  939. }
  940. break;
  941. }
  942. case SPAWN_SET_VALUE_NAME:{
  943. target->SetName(value);
  944. if(target->GetZone())
  945. target->GetZone()->SendUpdateTitles(target);
  946. break;
  947. }
  948. case SPAWN_SET_VALUE_SUB_TITLE: {
  949. target->SetSubTitle(value);
  950. if(target->GetZone())
  951. target->GetZone()->SendUpdateTitles(target);
  952. break;
  953. }
  954. case SPAWN_SET_VALUE_X_OFFSET:
  955. {
  956. target->SetXOffset(atof(value));
  957. break;
  958. }
  959. case SPAWN_SET_VALUE_Y_OFFSET:
  960. {
  961. target->SetYOffset(atof(value));
  962. break;
  963. }
  964. case SPAWN_SET_VALUE_Z_OFFSET:
  965. {
  966. target->SetZOffset(atof(value));
  967. break;
  968. }
  969. case SPAWN_SET_VALUE_EXPIRE: {
  970. target->SetExpireTime(val);
  971. break;
  972. }
  973. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  974. target->SetExpireOffsetTime(val);
  975. break;
  976. }
  977. case SPAWN_SET_VALUE_LEVEL:{
  978. target->SetLevel(val, send_update);
  979. break;
  980. }
  981. case SPAWN_SET_VALUE_DIFFICULTY:{
  982. target->SetDifficulty(val, send_update);
  983. break;
  984. }
  985. case SPAWN_SET_VALUE_MODEL_TYPE:{
  986. target->SetModelType(val, send_update);
  987. break;
  988. }
  989. case SPAWN_SET_VALUE_CLASS:{
  990. target->SetAdventureClass(val, send_update);
  991. break;
  992. }
  993. case SPAWN_SET_VALUE_GENDER:{
  994. target->SetGender(val, send_update);
  995. break;
  996. }
  997. case SPAWN_SET_VALUE_SHOW_NAME:{
  998. target->SetShowName(val, send_update);
  999. break;
  1000. }
  1001. case SPAWN_SET_VALUE_ATTACKABLE:{
  1002. target->SetAttackable(val, send_update);
  1003. break;
  1004. }
  1005. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  1006. target->SetShowLevel(val, send_update);
  1007. break;
  1008. }
  1009. case SPAWN_SET_VALUE_TARGETABLE:{
  1010. target->SetTargetable(val, send_update);
  1011. break;
  1012. }
  1013. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  1014. target->SetShowCommandIcon(val, send_update);
  1015. break;
  1016. }
  1017. case SPAWN_SET_VALUE_HAND_ICON:{
  1018. target->SetShowHandIcon(val, send_update);
  1019. break;
  1020. }
  1021. case SPAWN_SET_VALUE_HAIR_TYPE:{
  1022. if(target->IsEntity())
  1023. ((Entity*)target)->SetHairType(val, send_update);
  1024. break;
  1025. }
  1026. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  1027. if(target->IsEntity())
  1028. ((Entity*)target)->SetFacialHairType(val, send_update);
  1029. break;
  1030. }
  1031. case SPAWN_SET_VALUE_WING_TYPE:{
  1032. if(target->IsEntity())
  1033. ((Entity*)target)->SetWingType(val, send_update);
  1034. break;
  1035. }
  1036. case SPAWN_SET_VALUE_CHEST_TYPE:{
  1037. if(target->IsEntity())
  1038. ((Entity*)target)->SetChestType(val, send_update);
  1039. break;
  1040. }
  1041. case SPAWN_SET_VALUE_LEGS_TYPE:{
  1042. if(target->IsEntity())
  1043. ((Entity*)target)->SetLegsType(val, send_update);
  1044. break;
  1045. }
  1046. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  1047. if(target->IsEntity())
  1048. ((Entity*)target)->SetSogaHairType(val, send_update);
  1049. break;
  1050. }
  1051. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  1052. if(target->IsEntity())
  1053. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  1054. break;
  1055. }
  1056. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  1057. target->SetSogaModelType(val, send_update);
  1058. break;
  1059. }
  1060. case SPAWN_SET_VALUE_SIZE:{
  1061. target->SetSize(val, send_update);
  1062. break;
  1063. }
  1064. case SPAWN_SET_VALUE_HP:{
  1065. target->SetHP(val, send_update);
  1066. break;
  1067. }
  1068. case SPAWN_SET_VALUE_POWER:{
  1069. target->SetPower(val, send_update);
  1070. break;
  1071. }
  1072. case SPAWN_SET_VALUE_HEROIC:{
  1073. target->SetHeroic(val, send_update);
  1074. break;
  1075. }
  1076. case SPAWN_SET_VALUE_RESPAWN:{
  1077. target->SetRespawnTime(val);
  1078. break;
  1079. }
  1080. case SPAWN_SET_VALUE_X:{
  1081. target->SetX(atof(value), send_update);
  1082. target->SetSpawnOrigX(target->GetX());
  1083. break;
  1084. }
  1085. case SPAWN_SET_VALUE_Y:{
  1086. target->SetY(atof(value), send_update);
  1087. target->SetSpawnOrigY(target->GetY());
  1088. break;
  1089. }
  1090. case SPAWN_SET_VALUE_Z:{
  1091. target->SetZ(atof(value), send_update);
  1092. target->SetSpawnOrigZ(target->GetZ());
  1093. break;
  1094. }
  1095. case SPAWN_SET_VALUE_HEADING:{
  1096. target->SetHeading(atof(value), send_update);
  1097. target->SetSpawnOrigHeading(target->GetHeading());
  1098. break;
  1099. }
  1100. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  1101. ZoneServer* zone = target->GetZone();
  1102. if (!zone && client)
  1103. zone = client->GetCurrentZone();
  1104. if(zone && zone->GetEntityCommandList(val))
  1105. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  1106. target->primary_command_list_id = val;
  1107. break;
  1108. }
  1109. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  1110. ZoneServer* zone = target->GetZone();
  1111. if (!zone && client)
  1112. zone = client->GetCurrentZone();
  1113. if (zone && zone->GetEntityCommandList(val))
  1114. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  1115. target->secondary_command_list_id = val;
  1116. break;
  1117. }
  1118. case SPAWN_SET_VALUE_VISUAL_STATE:{
  1119. target->SetVisualState(val, send_update);
  1120. break;
  1121. }
  1122. case SPAWN_SET_VALUE_ACTION_STATE:{
  1123. target->SetActionState(val, send_update);
  1124. break;
  1125. }
  1126. case SPAWN_SET_VALUE_MOOD_STATE:{
  1127. target->SetMoodState(val, send_update);
  1128. break;
  1129. }
  1130. case SPAWN_SET_VALUE_INITIAL_STATE:{
  1131. target->SetInitialState(val, send_update);
  1132. break;
  1133. }
  1134. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  1135. target->SetActivityStatus(val, send_update);
  1136. break;
  1137. }
  1138. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  1139. target->SetCollisionRadius(val, send_update);
  1140. break;
  1141. }
  1142. case SPAWN_SET_VALUE_FACTION:{
  1143. ZoneServer* zone = target->GetZone();
  1144. if (!zone && client)
  1145. zone = client->GetCurrentZone();
  1146. target->faction_id = val;
  1147. if(zone)
  1148. {
  1149. zone->RemoveDeadEnemyList(target);
  1150. if(target->IsNPC())
  1151. zone->AddEnemyList((NPC*)target);
  1152. }
  1153. break;
  1154. }
  1155. case SPAWN_SET_VALUE_DEVICE_ID:{
  1156. if (target->IsObject())
  1157. ((Object*)target)->SetDeviceID(val);
  1158. break;
  1159. }
  1160. case SPAWN_SET_VALUE_PITCH: {
  1161. target->SetPitch(atof(value), send_update);
  1162. target->SetSpawnOrigPitch(atof(value));
  1163. break;
  1164. }
  1165. case SPAWN_SET_VALUE_ROLL: {
  1166. target->SetRoll(atof(value), send_update);
  1167. target->SetSpawnOrigRoll(atof(value));
  1168. break;
  1169. }
  1170. case SPAWN_SET_VALUE_HIDE_HOOD: {
  1171. target->SetHideHood(val);
  1172. break;
  1173. }
  1174. case SPAWN_SET_VALUE_EMOTE_STATE: {
  1175. target->SetEmoteState(val);
  1176. break;
  1177. }
  1178. case SPAWN_SET_VALUE_ICON: {
  1179. target->SetIcon(val);
  1180. break;
  1181. }
  1182. case SPAWN_SET_VALUE_PREFIX: {
  1183. target->SetPrefixTitle(value);
  1184. if(target->GetZone())
  1185. target->GetZone()->SendUpdateTitles(target);
  1186. break;
  1187. }
  1188. case SPAWN_SET_VALUE_SUFFIX: {
  1189. target->SetSuffixTitle(value);
  1190. if(target->GetZone())
  1191. target->GetZone()->SendUpdateTitles(target);
  1192. break;
  1193. }
  1194. case SPAWN_SET_VALUE_LASTNAME: {
  1195. target->SetLastName(value);
  1196. if(target->GetZone())
  1197. target->GetZone()->SendUpdateTitles(target);
  1198. break;
  1199. }
  1200. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  1201. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1202. if(client){
  1203. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1204. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  1205. }
  1206. return false;
  1207. }
  1208. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  1209. return false;
  1210. else{
  1211. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  1212. target->SetSpawnScript(value);
  1213. }
  1214. break;
  1215. }
  1216. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  1217. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1218. if(client){
  1219. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1220. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  1221. }
  1222. return false;
  1223. }
  1224. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  1225. return false;
  1226. else{
  1227. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  1228. target->SetSpawnScript(value);
  1229. }
  1230. break;
  1231. }
  1232. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  1233. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1234. if(client){
  1235. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1236. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  1237. }
  1238. return false;
  1239. }
  1240. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  1241. return false;
  1242. else
  1243. target->SetSpawnScript(value);
  1244. break;
  1245. }
  1246. case SPAWN_SET_SKIN_COLOR:
  1247. case SPAWN_SET_HAIR_COLOR1:
  1248. case SPAWN_SET_HAIR_COLOR2:
  1249. case SPAWN_SET_HAIR_TYPE_COLOR:
  1250. case SPAWN_SET_HAIR_FACE_COLOR:
  1251. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1252. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1253. case SPAWN_SET_HAIR_HIGHLIGHT:
  1254. case SPAWN_SET_MODEL_COLOR:
  1255. case SPAWN_SET_EYE_COLOR:
  1256. case SPAWN_SET_SOGA_SKIN_COLOR:
  1257. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1258. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1259. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1260. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1261. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1262. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1263. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1264. case SPAWN_SET_SOGA_MODEL_COLOR:
  1265. case SPAWN_SET_SOGA_EYE_COLOR: {
  1266. if (target->IsNPC())
  1267. {
  1268. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  1269. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  1270. {
  1271. EQ2_Color clr;
  1272. clr.red = atoul(skinsep->arg[0]);
  1273. clr.green = atoul(skinsep->arg[1]);
  1274. clr.blue = atoul(skinsep->arg[2]);
  1275. Query replaceSkinQuery;
  1276. string fieldName("");
  1277. switch(type)
  1278. {
  1279. case SPAWN_SET_SKIN_COLOR:
  1280. ((Entity*)target)->SetSkinColor(clr);
  1281. fieldName.append("skin_color");
  1282. break;
  1283. case SPAWN_SET_HAIR_COLOR1:
  1284. ((Entity*)target)->SetHairColor1(clr);
  1285. fieldName.append("hair_color1");
  1286. break;
  1287. case SPAWN_SET_HAIR_COLOR2:
  1288. ((Entity*)target)->SetHairColor2(clr);
  1289. fieldName.append("hair_color2");
  1290. break;
  1291. case SPAWN_SET_HAIR_TYPE_COLOR:
  1292. ((Entity*)target)->SetHairColor(clr);
  1293. fieldName.append("hair_type_color");
  1294. break;
  1295. case SPAWN_SET_HAIR_FACE_COLOR:
  1296. ((Entity*)target)->SetFacialHairColor(clr);
  1297. fieldName.append("hair_face_color");
  1298. break;
  1299. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1300. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  1301. fieldName.append("hair_type_highlight_color");
  1302. break;
  1303. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1304. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  1305. fieldName.append("hair_face_highlight_color");
  1306. break;
  1307. case SPAWN_SET_HAIR_HIGHLIGHT:
  1308. ((Entity*)target)->SetHairHighlightColor(clr);
  1309. fieldName.append("hair_highlight");
  1310. break;
  1311. case SPAWN_SET_MODEL_COLOR:
  1312. ((Entity*)target)->SetModelColor(clr);
  1313. fieldName.append("model_color");
  1314. break;
  1315. case SPAWN_SET_EYE_COLOR:
  1316. ((Entity*)target)->SetEyeColor(clr);
  1317. fieldName.append("eye_color");
  1318. break;
  1319. case SPAWN_SET_SOGA_SKIN_COLOR:
  1320. ((Entity*)target)->SetSogaSkinColor(clr);
  1321. fieldName.append("soga_skin_color");
  1322. break;
  1323. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1324. ((Entity*)target)->SetSogaHairColor1(clr);
  1325. fieldName.append("soga_hair_color1");
  1326. break;
  1327. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1328. ((Entity*)target)->SetSogaHairColor2(clr);
  1329. fieldName.append("soga_hair_color2");
  1330. break;
  1331. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1332. ((Entity*)target)->SetSogaHairColor(clr);
  1333. fieldName.append("soga_hair_type_color");
  1334. break;
  1335. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1336. ((Entity*)target)->SetSogaFacialHairColor(clr);
  1337. fieldName.append("soga_hair_face_color");
  1338. break;
  1339. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1340. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  1341. fieldName.append("soga_hair_type_highlight_color");
  1342. break;
  1343. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1344. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  1345. fieldName.append("soga_hair_face_highlight_color");
  1346. break;
  1347. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1348. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  1349. fieldName.append("soga_hair_highlight");
  1350. break;
  1351. case SPAWN_SET_SOGA_MODEL_COLOR:
  1352. ((Entity*)target)->SetSogaModelColor(clr);
  1353. fieldName.append("soga_model_color");
  1354. break;
  1355. case SPAWN_SET_SOGA_EYE_COLOR:
  1356. ((Entity*)target)->SetSogaEyeColor(clr);
  1357. fieldName.append("soga_eye_color");
  1358. break;
  1359. }
  1360. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1361. replaceSkinQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into npc_appearance set spawn_id=%u, type='%s', red=%u, green=%u, blue=%u", target->GetDatabaseID(), fieldName.c_str(), clr.red, clr.green, clr.blue);
  1362. }
  1363. safe_delete(skinsep);
  1364. }
  1365. break;
  1366. }
  1367. case SPAWN_SET_CHEEK_TYPE:{
  1368. if(target->IsEntity() && index < 3){
  1369. sint8 new_value = atoi(value);
  1370. ((Entity*)target)->features.cheek_type[index] = new_value;
  1371. UpdateDatabaseAppearance(client, target, "cheek_type", ((Entity*)target)->features.cheek_type[0], ((Entity*)target)->features.cheek_type[1], ((Entity*)target)->features.cheek_type[2]);
  1372. }
  1373. break;
  1374. }
  1375. case SPAWN_SET_CHIN_TYPE:{
  1376. if(target->IsEntity() && index < 3){
  1377. sint8 new_value = atoi(value);
  1378. ((Entity*)target)->features.chin_type[index] = new_value;
  1379. UpdateDatabaseAppearance(client, target, "chin_type", ((Entity*)target)->features.chin_type[0], ((Entity*)target)->features.chin_type[1], ((Entity*)target)->features.chin_type[2]);
  1380. }
  1381. break;
  1382. }
  1383. case SPAWN_SET_EAR_TYPE:{
  1384. if(target->IsEntity() && index < 3){
  1385. sint8 new_value = atoi(value);
  1386. ((Entity*)target)->features.ear_type[index] = new_value;
  1387. UpdateDatabaseAppearance(client, target, "ear_type", ((Entity*)target)->features.ear_type[0], ((Entity*)target)->features.ear_type[1], ((Entity*)target)->features.ear_type[2]);
  1388. }
  1389. break;
  1390. }
  1391. case SPAWN_SET_EYE_BROW_TYPE:{
  1392. if(target->IsEntity() && index < 3){
  1393. sint8 new_value = atoi(value);
  1394. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  1395. UpdateDatabaseAppearance(client, target, "eye_brow_type", ((Entity*)target)->features.eye_brow_type[0], ((Entity*)target)->features.eye_brow_type[1], ((Entity*)target)->features.eye_brow_type[2]);
  1396. }
  1397. break;
  1398. }
  1399. case SPAWN_SET_EYE_TYPE:{
  1400. if(target->IsEntity() && index < 3){
  1401. sint8 new_value = atoi(value);
  1402. ((Entity*)target)->features.eye_type[index] = new_value;
  1403. UpdateDatabaseAppearance(client, target, "eye_type", ((Entity*)target)->features.eye_type[0], ((Entity*)target)->features.eye_type[1], ((Entity*)target)->features.eye_type[2]);
  1404. }
  1405. break;
  1406. }
  1407. case SPAWN_SET_LIP_TYPE:{
  1408. if(target->IsEntity() && index < 3){
  1409. sint8 new_value = atoi(value);
  1410. ((Entity*)target)->features.lip_type[index] = new_value;
  1411. UpdateDatabaseAppearance(client, target, "lip_type", ((Entity*)target)->features.lip_type[0], ((Entity*)target)->features.lip_type[1], ((Entity*)target)->features.lip_type[2]);
  1412. }
  1413. break;
  1414. }
  1415. case SPAWN_SET_NOSE_TYPE:{
  1416. if(target->IsEntity() && index < 3){
  1417. sint8 new_value = atoi(value);
  1418. ((Entity*)target)->features.nose_type[index] = new_value;
  1419. UpdateDatabaseAppearance(client, target, "nose_type", ((Entity*)target)->features.nose_type[0], ((Entity*)target)->features.nose_type[1], ((Entity*)target)->features.nose_type[2]);
  1420. }
  1421. break;
  1422. }
  1423. case SPAWN_SET_BODY_SIZE:{
  1424. if(target->IsEntity()){
  1425. int8 new_value = atoul(value);
  1426. ((Entity*)target)->features.body_size = new_value;
  1427. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1428. }
  1429. break;
  1430. }
  1431. case SPAWN_SET_BODY_AGE:{
  1432. if(target->IsEntity()){
  1433. int8 new_value = atoul(value);
  1434. ((Entity*)target)->features.body_age = new_value;
  1435. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1436. }
  1437. break;
  1438. }
  1439. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  1440. if(target->IsEntity() && index < 3){
  1441. sint8 new_value = atoi(value);
  1442. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  1443. UpdateDatabaseAppearance(client, target, "soga_cheek_type", ((Entity*)target)->features.soga_cheek_type[0], ((Entity*)target)->features.soga_cheek_type[1], ((Entity*)target)->features.soga_cheek_type[2]);
  1444. }
  1445. break;
  1446. }
  1447. case SPAWN_SET_SOGA_CHIN_TYPE:{
  1448. if(target->IsEntity() && index < 3){
  1449. sint8 new_value = atoi(value);
  1450. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  1451. UpdateDatabaseAppearance(client, target, "soga_chin_type", ((Entity*)target)->features.soga_chin_type[0], ((Entity*)target)->features.soga_chin_type[1], ((Entity*)target)->features.soga_chin_type[2]);
  1452. }
  1453. break;
  1454. }
  1455. case SPAWN_SET_SOGA_EAR_TYPE:{
  1456. if(target->IsEntity() && index < 3){
  1457. sint8 new_value = atoi(value);
  1458. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  1459. UpdateDatabaseAppearance(client, target, "soga_ear_type", ((Entity*)target)->features.soga_ear_type[0], ((Entity*)target)->features.soga_ear_type[1], ((Entity*)target)->features.soga_ear_type[2]);
  1460. }
  1461. break;
  1462. }
  1463. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  1464. if(target->IsEntity() && index < 3){
  1465. sint8 new_value = atoi(value);
  1466. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  1467. UpdateDatabaseAppearance(client, target, "soga_eye_brow_type", ((Entity*)target)->features.soga_eye_brow_type[0], ((Entity*)target)->features.soga_eye_brow_type[1], ((Entity*)target)->features.soga_eye_brow_type[2]);
  1468. }
  1469. break;
  1470. }
  1471. case SPAWN_SET_SOGA_EYE_TYPE:{
  1472. if(target->IsEntity() && index < 3){
  1473. sint8 new_value = atoi(value);
  1474. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  1475. UpdateDatabaseAppearance(client, target, "soga_eye_type", ((Entity*)target)->features.soga_eye_type[0], ((Entity*)target)->features.soga_eye_type[1], ((Entity*)target)->features.soga_eye_type[2]);
  1476. }
  1477. break;
  1478. }
  1479. case SPAWN_SET_SOGA_LIP_TYPE:{
  1480. if(target->IsEntity() && index < 3){
  1481. sint8 new_value = atoi(value);
  1482. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  1483. UpdateDatabaseAppearance(client, target, "soga_lip_type", ((Entity*)target)->features.soga_lip_type[0], ((Entity*)target)->features.soga_lip_type[1], ((Entity*)target)->features.soga_lip_type[2]);
  1484. }
  1485. break;
  1486. }
  1487. case SPAWN_SET_SOGA_NOSE_TYPE:{
  1488. if(target->IsEntity() && index < 3){
  1489. sint8 new_value = atoi(value);
  1490. ((Entity*)target)->features.soga_nose_type[index] = new_value;
  1491. UpdateDatabaseAppearance(client, target, "soga_nose_type", ((Entity*)target)->features.soga_nose_type[0], ((Entity*)target)->features.soga_nose_type[1], ((Entity*)target)->features.soga_nose_type[2]);
  1492. }
  1493. break;
  1494. }
  1495. case SPAWN_SET_SOGA_BODY_SIZE:{
  1496. if(target->IsEntity()){
  1497. int8 new_value = atoul(value);
  1498. ((Entity*)target)->features.body_size = new_value;
  1499. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1500. }
  1501. break;
  1502. }
  1503. case SPAWN_SET_SOGA_BODY_AGE:{
  1504. if(target->IsEntity()){
  1505. int8 new_value = atoul(value);
  1506. ((Entity*)target)->features.body_age = new_value;
  1507. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1508. }
  1509. break;
  1510. }
  1511. case SPAWN_SET_ATTACK_TYPE:{
  1512. if(target->IsEntity()){
  1513. int8 new_value = atoul(value);
  1514. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  1515. if(target->IsNPC()) {
  1516. if(target->GetDatabaseID()) {
  1517. Query spawnNPCQuery;
  1518. spawnNPCQuery.AddQueryAsync(0, &database, Q_INSERT, "update spawn_npcs set attack_type=%u where id=%u", new_value, target->GetDatabaseID());
  1519. } else if(client) {
  1520. client->Message(CHANNEL_COLOR_RED, "Invalid spawn to update the database (NPC only) or no database id for the NPC present.");
  1521. }
  1522. }
  1523. }
  1524. break;
  1525. }
  1526. case SPAWN_SET_RACE_TYPE:{
  1527. if(target->GetModelType() > 0){
  1528. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  1529. if (tmpsep->IsNumber(0))
  1530. {
  1531. Query typequery;
  1532. int16 race_type = atoul(value);
  1533. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  1534. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  1535. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  1536. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  1537. client->Message(CHANNEL_COLOR_YELLOW, "Model Type %u Race type %u inserted into memory + replaced into database, Model Type: %u set to Race Type: %u, Category: %s, SubCategory: %s, Model Name: %s.", race_type, target->GetModelType(), race_type, category, subcategory, model_name);
  1538. typequery.AddQueryAsync(0, &database, Q_INSERT, "insert into race_types (model_type, race_id, category, subcategory, model_name) values(%u, %u, '%s', '%s', '%s')", target->GetModelType(), race_type, category, subcategory, model_name);
  1539. }
  1540. else {
  1541. client->Message(CHANNEL_COLOR_RED, "Model Type: %u Race type %u overrided in memory + replaced into database, Model Type: %u set to Race Type: %u, Category: %s, SubCategory: %s, Model Name: %s.", race_type, target->GetModelType(), race_type, category, subcategory, model_name);
  1542. race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name, true);
  1543. typequery.AddQueryAsync(0, &database, Q_INSERT, "update race_types set race_id=%u, category='%s', subcategory='%s', model_name='%s' where model_type=%u", race_type, category, subcategory, model_name, target->GetModelType());
  1544. }
  1545. }
  1546. safe_delete(tmpsep);
  1547. }
  1548. break;
  1549. }
  1550. case SPAWN_SET_LOOT_TIER:{
  1551. int32 new_value = atoul(value);
  1552. target->SetLootTier(new_value);
  1553. if (target->GetDatabaseID() > 0)
  1554. {
  1555. char query[256];
  1556. snprintf(query, 256, "update spawn set loot_tier=%u where id=%u", atoul(value), target->GetDatabaseID());
  1557. if (database.RunQuery(query, strnlen(query, 256)))
  1558. {
  1559. if(client)
  1560. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1561. }
  1562. }
  1563. break;
  1564. }
  1565. case SPAWN_SET_LOOT_DROP_TYPE:{
  1566. int32 new_value = atoul(value);
  1567. target->SetLootDropType(new_value);
  1568. if (target->GetDatabaseID() > 0)
  1569. {
  1570. char query[256];
  1571. snprintf(query, 256, "update spawn set loot_drop_type=%u where id=%u", atoul(value), target->GetDatabaseID());
  1572. if (database.RunQuery(query, strnlen(query, 256)))
  1573. {
  1574. if(client)
  1575. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1576. }
  1577. }
  1578. break;
  1579. }
  1580. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  1581. int32 new_value = atoul(value);
  1582. target->SetScaredByStrongPlayers(new_value);
  1583. if (target->GetDatabaseID() > 0)
  1584. {
  1585. char query[256];
  1586. snprintf(query, 256, "update spawn_npcs set scared_by_strong_players=%u where id=%u", atoul(value), target->GetDatabaseID());
  1587. if (database.RunQuery(query, strnlen(query, 256)))
  1588. {
  1589. if(client)
  1590. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1591. }
  1592. }
  1593. break;
  1594. }
  1595. }
  1596. }
  1597. return true;
  1598. }
  1599. void Commands::UpdateDatabaseAppearance(Client* client, Spawn* target, string fieldName, sint8 r, sint8 g, sint8 b)
  1600. {
  1601. Query replaceQuery;
  1602. if(target->IsBot())
  1603. {
  1604. Bot* bot = (Bot*)target;
  1605. if(bot->BotID)
  1606. database.SaveBotFloats(bot->BotID, fieldName.c_str(), r, g, b);
  1607. }
  1608. else if(target->IsPlayer())
  1609. {
  1610. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from char_colors where char_id=%u and type='%s'", ((Player*)target)->GetCharacterID(), fieldName.c_str());
  1611. replaceQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into char_colors set char_id=%u, type='%s', red=%i, green=%i, blue=%i", ((Player*)target)->GetCharacterID(), fieldName.c_str(), r, g, b);
  1612. }
  1613. else
  1614. {
  1615. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1616. replaceQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into npc_appearance set spawn_id=%u, type='%s', red=%i, green=%i, blue=%i", target->GetDatabaseID(), fieldName.c_str(), r, g, b);
  1617. }
  1618. ((Entity*)target)->changed = true;
  1619. ((Entity*)target)->info_changed = true;
  1620. if(target->GetZone())
  1621. target->GetZone()->AddChangedSpawn(target);
  1622. }
  1623. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  1624. the database fields always and also update the zone in memory if it's running. */
  1625. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  1626. if (client && zone_id > 0 && type > 0 && value) {
  1627. sint32 int_value = 0;
  1628. float float_value = 0;
  1629. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  1630. try {
  1631. float_value = atof(value);
  1632. }
  1633. catch (...) {
  1634. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  1635. return false;
  1636. }
  1637. }
  1638. else if (type != ZONE_SET_VALUE_NAME && type != ZONE_SET_VALUE_FILE && type != ZONE_SET_VALUE_DESCRIPTION && type != ZONE_SET_VALUE_ZONE_TYPE && type != ZONE_SET_VALUE_LUA_SCRIPT && type != ZONE_SET_VALUE_ZONE_MOTD) {
  1639. try {
  1640. int_value = atoi(value);
  1641. }
  1642. catch (...) {
  1643. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  1644. return false;
  1645. }
  1646. }
  1647. switch (type) {
  1648. case ZONE_SET_VALUE_EXPANSION_ID: {
  1649. break;
  1650. }
  1651. case ZONE_SET_VALUE_NAME: {
  1652. if (zone)
  1653. zone->SetZoneName(const_cast<char*>(value));
  1654. database.SaveZoneInfo(zone_id, "name", value);
  1655. break;
  1656. }
  1657. case ZONE_SET_VALUE_FILE: {
  1658. if (zone)
  1659. zone->SetZoneFile(const_cast<char*>(value));
  1660. database.SaveZoneInfo(zone_id, "file", value);
  1661. break;
  1662. }
  1663. case ZONE_SET_VALUE_DESCRIPTION: {
  1664. if (zone)
  1665. zone->SetZoneDescription(const_cast<char*>(value));
  1666. database.SaveZoneInfo(zone_id, "description", value);
  1667. break;
  1668. }
  1669. case ZONE_SET_VALUE_SAFE_X: {
  1670. if (zone)
  1671. zone->SetSafeX(float_value);
  1672. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  1673. break;
  1674. }
  1675. case ZONE_SET_VALUE_SAFE_Y: {
  1676. if (zone)
  1677. zone->SetSafeY(float_value);
  1678. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  1679. break;
  1680. }
  1681. case ZONE_SET_VALUE_SAFE_Z: {
  1682. if (zone)
  1683. zone->SetSafeZ(float_value);
  1684. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  1685. break;
  1686. }
  1687. case ZONE_SET_VALUE_UNDERWORLD: {
  1688. if (zone)
  1689. zone->SetUnderWorld(float_value);
  1690. database.SaveZoneInfo(zone_id, "underworld", float_value);
  1691. break;
  1692. }
  1693. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  1694. break;
  1695. }
  1696. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  1697. break;
  1698. }
  1699. case ZONE_SET_VALUE_ZONE_TYPE: {
  1700. break;
  1701. }
  1702. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  1703. if (zone)
  1704. zone->SetAlwaysLoaded(int_value == 1);
  1705. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  1706. break;
  1707. }
  1708. case ZONE_SET_VALUE_CITY_ZONE: {
  1709. if (zone)
  1710. zone->SetCityZone(int_value == 1);
  1711. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  1712. break;
  1713. }
  1714. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  1715. if (zone)
  1716. zone->SetWeatherAllowed(int_value == 1);
  1717. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  1718. break;
  1719. }
  1720. case ZONE_SET_VALUE_MIN_STATUS: {
  1721. if (zone)
  1722. zone->SetMinimumStatus(int_value);
  1723. database.SaveZoneInfo(zone_id, "min_status", int_value);
  1724. break;
  1725. }
  1726. case ZONE_SET_VALUE_MIN_LEVEL: {
  1727. if (zone)
  1728. zone->SetMinimumLevel(int_value);
  1729. database.SaveZoneInfo(zone_id, "min_level", int_value);
  1730. break;
  1731. }
  1732. case ZONE_SET_VALUE_MAX_LEVEL: {
  1733. if (zone)
  1734. zone->SetMaximumLevel(int_value);
  1735. database.SaveZoneInfo(zone_id, "max_level", int_value);
  1736. break;
  1737. }
  1738. case ZONE_SET_VALUE_START_ZONE: {
  1739. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  1740. break;
  1741. }
  1742. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  1743. if (zone)
  1744. zone->SetInstanceType(int_value);
  1745. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  1746. break;
  1747. }
  1748. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  1749. if (zone)
  1750. zone->SetDefaultReenterTime(int_value);
  1751. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  1752. break;
  1753. }
  1754. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  1755. if (zone)
  1756. zone->SetDefaultResetTime(int_value);
  1757. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  1758. break;
  1759. }
  1760. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1761. if (zone)
  1762. zone->SetDefaultLockoutTime(int_value);
  1763. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1764. break;
  1765. }
  1766. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1767. if (zone)
  1768. zone->SetForceGroupZoneOption(int_value);
  1769. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1770. break;
  1771. }
  1772. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1773. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1774. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1775. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1776. return false;
  1777. }
  1778. else {
  1779. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1780. database.SaveZoneInfo(zone_id, "lua_script", value);
  1781. }
  1782. break;
  1783. }
  1784. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1785. if (zone)
  1786. zone->SetShutdownTimer(int_value);
  1787. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1788. break;
  1789. }
  1790. case ZONE_SET_VALUE_ZONE_MOTD: {
  1791. if (zone)
  1792. zone->SetZoneMOTD(string(value));
  1793. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1794. break;
  1795. }
  1796. default: {
  1797. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1798. return false;
  1799. }
  1800. }
  1801. }
  1802. else {
  1803. if (client)
  1804. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1805. return false;
  1806. }
  1807. return true;
  1808. }
  1809. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1810. if (index >= remote_commands->commands.size()) {
  1811. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1812. return;
  1813. }
  1814. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1815. EQ2_RemoteCommandString* parent_command = 0;
  1816. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1817. Seperator* sep = 0;
  1818. if (command_parms->size > 0) {
  1819. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1820. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1821. parent_command = command;
  1822. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1823. safe_delete(sep);
  1824. if (command_parms->data.length() > (command->command.data.length() + 1))
  1825. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1826. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1827. }
  1828. else
  1829. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1830. }
  1831. int ndx = 0;
  1832. if (command->required_status > client->GetAdminStatus())
  1833. {
  1834. LogWrite(COMMAND__ERROR, 0, "Command", "Player '%s' (%u) needs status %i to use command: %s", client->GetPlayer()->GetName(), client->GetAccountID(), command->required_status, command->command.data.c_str());
  1835. safe_delete(sep);
  1836. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1837. return;
  1838. }
  1839. Player* player = client->GetPlayer();
  1840. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1841. switch (command->handler) {
  1842. case COMMAND_RELOAD: {
  1843. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1845. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1846. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1848. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells npc");
  1850. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload voiceovers");
  1863. break;
  1864. }
  1865. case COMMAND_RELOADSTRUCTS: {
  1866. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1867. world.SetReloadingSubsystem("Structs");
  1868. configReader.ReloadStructs();
  1869. world.RemoveReloadingSubSystem("Structs");
  1870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1871. break;
  1872. }
  1873. case COMMAND_RELOAD_QUESTS: {
  1874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1875. world.SetReloadingSubsystem("Quests");
  1876. master_quest_list.Reload();
  1877. client_list.ReloadQuests();
  1878. zone_list.ReloadClientQuests();
  1879. world.RemoveReloadingSubSystem("Quests");
  1880. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1881. break;
  1882. }
  1883. case COMMAND_RELOAD_SPAWNS: {
  1884. client->GetCurrentZone()->ReloadSpawns();
  1885. break;
  1886. }
  1887. case COMMAND_RELOAD_SPELLS: {
  1888. if (sep && sep->arg[0] && strcmp(sep->arg[0], "npc") == 0) {
  1889. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading NPC Spells Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1890. world.PurgeNPCSpells();
  1891. database.LoadNPCSpells();
  1892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1893. }
  1894. else {
  1895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells & NPC Spell Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1896. world.SetReloadingSubsystem("Spells");
  1897. zone_list.DeleteSpellProcess();
  1898. master_spell_list.Reload();
  1899. if (lua_interface)
  1900. lua_interface->ReloadSpells();
  1901. zone_list.LoadSpellProcess();
  1902. world.RemoveReloadingSubSystem("Spells");
  1903. world.PurgeNPCSpells();
  1904. database.LoadNPCSpells();
  1905. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1906. }
  1907. break;
  1908. }
  1909. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1910. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1911. world.SetReloadingSubsystem("GroundSpawns");
  1912. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1913. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1914. world.RemoveReloadingSubSystem("GroundSpawns");
  1915. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1916. break;
  1917. }
  1918. case COMMAND_RELOAD_ZONESCRIPTS: {
  1919. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1920. world.SetReloadingSubsystem("ZoneScripts");
  1921. world.ResetZoneScripts();
  1922. database.LoadZoneScriptData();
  1923. if (lua_interface)
  1924. lua_interface->DestroyZoneScripts();
  1925. world.RemoveReloadingSubSystem("ZoneScripts");
  1926. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1927. break;
  1928. }
  1929. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1930. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1931. world.SetReloadingSubsystem("EntityCommands");
  1932. client->GetCurrentZone()->ClearEntityCommands();
  1933. database.LoadEntityCommands(client->GetCurrentZone());
  1934. world.RemoveReloadingSubSystem("EntityCommands");
  1935. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1936. break;
  1937. }
  1938. case COMMAND_RELOAD_FACTIONS: {
  1939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1940. world.SetReloadingSubsystem("Factions");
  1941. master_faction_list.Clear();
  1942. database.LoadFactionList();
  1943. world.RemoveReloadingSubSystem("Factions");
  1944. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1945. break;
  1946. }
  1947. case COMMAND_RELOAD_MAIL: {
  1948. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1949. zone_list.ReloadMail();
  1950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1951. break;
  1952. }
  1953. case COMMAND_RELOAD_GUILDS: {
  1954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1955. world.ReloadGuilds();
  1956. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1957. break;
  1958. }
  1959. case COMMAND_RELOAD_LOCATIONS: {
  1960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1961. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1962. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1963. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1964. break;
  1965. }
  1966. case COMMAND_RELOAD_RULES: {
  1967. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1968. database.LoadRuleSets(true);
  1969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1970. break;
  1971. }
  1972. case COMMAND_RELOAD_TRANSPORTERS: {
  1973. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1974. database.LoadTransporters(client->GetCurrentZone());
  1975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1976. break;
  1977. }
  1978. case COMMAND_RELOAD_STARTABILITIES: {
  1979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1980. world.PurgeStartingLists();
  1981. world.LoadStartingLists();
  1982. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1983. break;
  1984. }
  1985. case COMMAND_RELOAD_VOICEOVERS: {
  1986. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Voiceovers...");
  1987. world.PurgeVoiceOvers();
  1988. world.LoadVoiceOvers();
  1989. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1990. break;
  1991. }
  1992. case COMMAND_READ: {
  1993. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1994. if (strcmp(sep->arg[0], "read") == 0) {
  1995. int32 item_index = atol(sep->arg[1]);
  1996. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1997. if (item) {
  1998. Spawn* spawn = cmdTarget;
  1999. client->SendShowBook(client->GetPlayer(), item->name, item->book_language, item->book_pages);
  2000. break;
  2001. }
  2002. }
  2003. }
  2004. break;
  2005. }
  2006. case COMMAND_USEABILITY:{
  2007. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  2008. if (!client->GetPlayer()->Alive()) {
  2009. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  2010. }
  2011. else {
  2012. int32 spell_id = atoul(sep->arg[0]);
  2013. int8 spell_tier = 0;
  2014. if (sep->arg[1][0] && sep->IsNumber(1))
  2015. spell_tier = atoi(sep->arg[1]);
  2016. else
  2017. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  2018. if (!spell_tier)
  2019. spell_tier = 1;
  2020. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  2021. if (spell) {
  2022. if (strncmp(spell->GetName(), "Gathering", 9) == 0 || strncmp(spell->GetName(), "Mining", 6) == 0 || strncmp(spell->GetName(), "Trapping", 8) == 0 || strncmp(spell->GetName(), "Foresting", 9) == 0 || strncmp(spell->GetName(), "Fishing", 7) == 0 || strncmp(spell->GetName(), "Collecting", 10) == 0)
  2023. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  2024. else
  2025. {
  2026. if (cmdTarget)
  2027. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  2028. else
  2029. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  2030. }
  2031. }
  2032. }
  2033. }
  2034. else if (cmdTarget && cmdTarget->IsWidget())
  2035. {
  2036. Widget* widget = (Widget*)cmdTarget;
  2037. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  2038. }
  2039. else
  2040. {
  2041. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  2042. }
  2043. break;
  2044. }
  2045. case COMMAND_INFO:{
  2046. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  2047. if(strcmp(sep->arg[0], "inventory") == 0){
  2048. int32 item_index = atol(sep->arg[1]);
  2049. LogWrite(COMMAND__DEBUG, 5, "Command", "/info inventory item original index %u", item_index);
  2050. if(client->GetVersion() <= 546) {
  2051. if(item_index <= 255) {
  2052. item_index = 255 - item_index;
  2053. }
  2054. else {
  2055. if(item_index == 256) { // first "new" item to inventory is assigned index 256 by client
  2056. item_index = client->GetPlayer()->item_list.GetFirstNewItem();
  2057. }
  2058. else {
  2059. // otherwise the slot has to be mapped out depending on the amount of new items + index sent in
  2060. item_index = client->GetPlayer()->item_list.GetNewItemByIndex((int16)item_index - 255);
  2061. }
  2062. }
  2063. }
  2064. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  2065. if(item){
  2066. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  2067. break;
  2068. EQ2Packet* app = 0;
  2069. if(client->GetVersion() <= 546) {
  2070. app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2071. }
  2072. else {
  2073. app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  2074. }
  2075. //DumpPacket(app);
  2076. client->QueuePacket(app);
  2077. if(item->GetItemScript() && lua_interface)
  2078. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2079. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  2080. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  2081. if(quest && client->GetPlayer()->HasQuestBeenCompleted(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->HasActiveQuest(item->generic_info.offers_quest_id) == 0)
  2082. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  2083. }
  2084. }
  2085. else
  2086. LogWrite(COMMAND__ERROR, 0, "Command", "/info inventory: Unknown Index: %u", item_index);
  2087. }
  2088. else if(strcmp(sep->arg[0], "equipment") == 0){
  2089. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2090. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  2091. if(item){
  2092. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2093. client->QueuePacket(app);
  2094. if(item->GetItemScript() && lua_interface)
  2095. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2096. }
  2097. else
  2098. LogWrite(COMMAND__ERROR, 0, "Command", "/info equipment: Unknown Index: %u", item_index);
  2099. }
  2100. else if(strcmp(sep->arg[0], "appearance") == 0){
  2101. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2102. Item* item = client->GetPlayer()->GetAppearanceEquipmentList()->GetItem(item_index);
  2103. if(item){
  2104. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2105. client->QueuePacket(app);
  2106. if(item->GetItemScript() && lua_interface)
  2107. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2108. }
  2109. else
  2110. LogWrite(COMMAND__ERROR, 0, "Command", "/info appearance: Unknown Index: %u", item_index);
  2111. }
  2112. 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){
  2113. int32 item_id = atoul(sep->arg[1]);
  2114. Item* item = master_item_list.GetItem(item_id);
  2115. if(item){
  2116. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2117. client->QueuePacket(app);
  2118. }
  2119. else
  2120. LogWrite(COMMAND__ERROR, 0, "Command", "/info item|merchant|store|buyback|consignment: Unknown Item ID: %u", item_id);
  2121. }
  2122. else if (strcmp(sep->arg[0], "spell") == 0) {
  2123. sint32 spell_id = atol(sep->arg[1]);
  2124. int8 tier = atoi(sep->arg[3]);
  2125. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  2126. if (outapp)
  2127. client->QueuePacket(outapp);
  2128. else
  2129. LogWrite(COMMAND__ERROR, 0, "Command", "/info spell: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2130. }
  2131. else if (strcmp(sep->arg[0], "achievement") == 0) {
  2132. sint32 spell_id = atol(sep->arg[2]);
  2133. int8 group = atoi(sep->arg[1]);
  2134. AltAdvanceData* data = 0;
  2135. SpellBookEntry* spellentry = 0;
  2136. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2137. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  2138. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  2139. if (outapp)
  2140. client->QueuePacket(outapp);
  2141. else
  2142. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  2143. }
  2144. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  2145. sint32 spell_id = atol(sep->arg[1]);
  2146. int32 tier = atoi(sep->arg[2]);
  2147. if (tier > 255) {
  2148. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  2149. if (ent)
  2150. tier = ent->tier;
  2151. }
  2152. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  2153. if (outapp)
  2154. client->QueuePacket(outapp);
  2155. else
  2156. LogWrite(COMMAND__ERROR, 0, "Command", "/info spellbook: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2157. }
  2158. else if (strcmp(sep->arg[0], "recipe") == 0) {
  2159. sint32 recipe_id = atol(sep->arg[1]);
  2160. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  2161. if(outapp)
  2162. client->QueuePacket(outapp);
  2163. else
  2164. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe: Unknown Recipe ID: %u", recipe_id);
  2165. }
  2166. else if (strcmp(sep->arg[0], "recipe_product") == 0) {
  2167. sint32 recipe_id = atol(sep->arg[1]);
  2168. PlayerRecipeList* prl = client->GetPlayer()->GetRecipeList();
  2169. Recipe* recipe = nullptr;
  2170. if ((recipe = prl->GetRecipe(recipe_id)) && recipe->GetProductID()) {
  2171. RecipeProducts* rp = recipe->products[1];
  2172. if (recipe->GetProductID() > 0) {
  2173. Item* item = master_item_list.GetItem(recipe->GetProductID());
  2174. if(item){
  2175. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2176. client->QueuePacket(app);
  2177. }
  2178. else
  2179. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: Unknown Item ID: %u", recipe->GetProductID());
  2180. }
  2181. else {
  2182. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: recipe->GetProductID() has value 0 for recipe id %u.", recipe_id);
  2183. }
  2184. }
  2185. else {
  2186. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: with recipe id %u not found (recipe missing or no product in stage 1 assigned).", recipe_id);
  2187. }
  2188. }
  2189. else if (strcmp(sep->arg[0], "maintained") ==0) {
  2190. int32 slot = atol(sep->arg[1]);
  2191. int32 spell_id = atol(sep->arg[2]);
  2192. LogWrite(COMMAND__DEBUG, 5, "Command", "/info maintained: Spell ID - Slot: %u unknown: %u", slot, spell_id);
  2193. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2194. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  2195. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  2196. if(outapp)
  2197. client->QueuePacket(outapp);
  2198. else
  2199. LogWrite(COMMAND__ERROR, 0, "Command", "/info maintained: Unknown Spell ID: %u", spell_id);
  2200. }
  2201. else if (strcmp(sep->arg[0], "effect") == 0) {
  2202. int32 spell_id = atol(sep->arg[1]);
  2203. LogWrite(COMMAND__DEBUG, 5, "Command", "/info effect: Spell ID: %u", spell_id);
  2204. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2205. int8 type = 0;
  2206. if (client->GetVersion() <= 546)
  2207. type = 1;
  2208. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  2209. if (outapp){
  2210. client->QueuePacket(outapp);
  2211. }
  2212. else
  2213. LogWrite(COMMAND__ERROR, 0, "Command", "/info effect: Unknown Spell ID: %u", spell_id);
  2214. }
  2215. }
  2216. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  2217. Item* item = player->item_list.GetOverflowItem();
  2218. if(item) {
  2219. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2220. client->QueuePacket(app);
  2221. }
  2222. else
  2223. LogWrite(COMMAND__ERROR, 0,"Command", "/info overflow: Unable to retrieve an overflow item.");
  2224. }
  2225. else
  2226. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  2227. break;
  2228. }
  2229. case COMMAND_USE_EQUIPPED_ITEM:{
  2230. if (sep && sep->arg[0] && sep->IsNumber(0)){
  2231. int32 slot_id = atoul(sep->arg[0]);
  2232. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  2233. if (item && item->generic_info.usable && item->GetItemScript()) {
  2234. if(!item->CheckFlag2(INDESTRUCTABLE) && item->generic_info.condition == 0) {
  2235. client->SimpleMessage(CHANNEL_COLOR_RED, "This item is broken and must be repaired at a mender before it can be used");
  2236. }
  2237. else if (item->CheckFlag(EVIL_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_EVIL) {
  2238. client->Message(0, "%s requires an evil race.", item->name.c_str());
  2239. }
  2240. else if (item->CheckFlag(GOOD_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_GOOD) {
  2241. client->Message(0, "%s requires a good race.", item->name.c_str());
  2242. }
  2243. else {
  2244. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player, player->GetTarget());
  2245. }
  2246. }
  2247. }
  2248. break;
  2249. }
  2250. case COMMAND_USE_ITEM: {
  2251. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2252. int32 item_index = atoul(sep->arg[0]);
  2253. Item* item = player->item_list.GetItemFromIndex(item_index);
  2254. client->UseItem(item, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer());
  2255. }
  2256. break;
  2257. }
  2258. case COMMAND_SCRIBE_SCROLL_ITEM: {
  2259. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2260. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  2261. if (item) {
  2262. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  2263. if(item->generic_info.item_type == 6) {
  2264. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  2265. int8 old_slot = 0;
  2266. if (spell) {
  2267. if(!spell->ScribeAllowed(client->GetPlayer())) {
  2268. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not meet one of the requirements to scribe, due to class or level.");
  2269. break;
  2270. }
  2271. int16 tier_up = player->GetTierUp(spell->GetSpellTier());
  2272. if (rule_manager.GetGlobalRule(R_Spells, RequirePreviousTierScribe)->GetInt8() && !player->HasSpell(spell->GetSpellID(), tier_up, false, true))
  2273. client->SimpleMessage(CHANNEL_COLOR_RED, "You have not scribed the required previous version of this ability.");
  2274. else if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  2275. old_slot = player->GetSpellSlot(spell->GetSpellID());
  2276. player->RemoveSpellBookEntry(spell->GetSpellID());
  2277. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  2278. player->UnlockSpell(spell);
  2279. client->SendSpellUpdate(spell);
  2280. database.DeleteItem(client->GetCharacterID(), item, 0);
  2281. player->item_list.RemoveItem(item, true);
  2282. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  2283. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  2284. // force purge client cache and display updated spell for hover over
  2285. EQ2Packet* app = spell->SerializeSpell(client, false, false);
  2286. client->QueuePacket(app);
  2287. }
  2288. }
  2289. else
  2290. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  2291. }
  2292. else if(item->generic_info.item_type == 7){
  2293. if(item->recipebook_info) {
  2294. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->recipebook_info->recipe_id, player->GetName());
  2295. client->AddRecipeBookToPlayer(item->recipebook_info->recipe_id, item);
  2296. }
  2297. else {
  2298. client->Message(CHANNEL_NARRATIVE, "Recipe book is unavailable! Report to admin recipe id %u could not be retrieved.", item->recipebook_info ? item->recipebook_info->recipe_id : 0);
  2299. LogWrite(COMMAND__ERROR, 0, "Command", "Recipe Book %u could not be retrieved for item %s.", item->recipebook_info ? item->recipebook_info->recipe_id : 0, item->name.c_str());
  2300. }
  2301. }
  2302. else {
  2303. LogWrite(COMMAND__ERROR, 0, "Command", "Recipe Book Info is not set for item %s.", item->name.c_str());
  2304. }
  2305. }
  2306. else
  2307. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  2308. }
  2309. break;
  2310. }
  2311. case COMMAND_SUMMONITEM: {
  2312. if (sep && sep->IsNumber(0)) {
  2313. int32 item_id = atol(sep->arg[0]);
  2314. int32 quantity = 1;
  2315. if (sep->arg[1] && sep->IsNumber(1))
  2316. quantity = atoi(sep->arg[1]);
  2317. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  2318. client->AddItemToBank(item_id,quantity);
  2319. }
  2320. else {
  2321. client->AddItem(item_id, quantity);
  2322. }
  2323. }
  2324. else {
  2325. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  2326. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  2327. }
  2328. break;
  2329. }
  2330. case COMMAND_COLLECTION_ADDITEM: {
  2331. // takes 2 params: collection_id, slot
  2332. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2333. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  2334. if (item)
  2335. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  2336. else
  2337. 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]));
  2338. }
  2339. else
  2340. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  2341. break;
  2342. }
  2343. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  2344. // takes 1 param: slot
  2345. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  2346. int i = 0;
  2347. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  2348. printf("\t%u: %s\n", i, sep->arg[i]);
  2349. i++;
  2350. }
  2351. break;
  2352. }
  2353. case COMMAND_WAYPOINT: {
  2354. bool success = false;
  2355. client->ClearWaypoint();
  2356. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  2357. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  2358. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2359. }
  2360. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  2361. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  2362. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2363. }
  2364. else {
  2365. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  2366. }
  2367. break;
  2368. }
  2369. case COMMAND_WHO:{
  2370. const char* who = 0;
  2371. if(sep && sep->arg[0]){
  2372. //cout << "Who query: \n";
  2373. who = sep->argplus[0];
  2374. //cout << who << endl;
  2375. }
  2376. zone_list.ProcessWhoQuery(who, client);
  2377. break;
  2378. }
  2379. case COMMAND_SELECT_JUNCTION:{
  2380. // transporters (bells birds) use OP_SelectZoneTeleporterDestinatio / ProcessTeleportLocation(app)
  2381. // this is only used for revive it seems
  2382. int32 choice = 0;
  2383. if(sep && sep->arg[0] && sep->IsNumber(0))
  2384. choice = atoul(sep->arg[0]);
  2385. if(!client->GetPlayer()->Alive()){ //dead and this is a revive request
  2386. client->HandlePlayerRevive(choice);
  2387. }
  2388. break;
  2389. }
  2390. case COMMAND_SPAWN_MOVE: {
  2391. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  2392. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  2393. if (packet) {
  2394. float unknown2_3 = 0;
  2395. int8 placement_mode = 0;
  2396. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  2397. if (sep && sep->arg[0][0]) {
  2398. if (strcmp(sep->arg[0], "wall") == 0) {
  2399. placement_mode = 2;
  2400. unknown2_3 = 150;
  2401. }
  2402. else if (strcmp(sep->arg[0], "ceiling") == 0)
  2403. placement_mode = 1;
  2404. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  2405. {
  2406. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  2407. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  2408. }
  2409. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  2410. {
  2411. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  2412. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  2413. }
  2414. else if (strcmp(sep->arg[0], "myloc") == 0)
  2415. {
  2416. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  2417. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  2418. safe_delete(packet);
  2419. break;
  2420. }
  2421. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  2422. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  2423. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  2424. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  2425. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  2426. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  2427. safe_delete(packet);
  2428. break;
  2429. }
  2430. }
  2431. packet->setDataByName("placement_mode", placement_mode);
  2432. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  2433. packet->setDataByName("model_type", cmdTarget->GetModelType());
  2434. packet->setDataByName("unknown", 1); //size
  2435. packet->setDataByName("unknown2", 1); //size 2
  2436. packet->setDataByName("unknown2", .5, 1); //size 3
  2437. packet->setDataByName("unknown2", 3, 2);
  2438. packet->setDataByName("unknown2", unknown2_3, 3);
  2439. packet->setDataByName("max_distance", 500);
  2440. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  2441. client->QueuePacket(packet->serialize());
  2442. safe_delete(packet);
  2443. }
  2444. }
  2445. else {
  2446. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  2447. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  2448. }
  2449. break;
  2450. }
  2451. case COMMAND_HAIL:{
  2452. Spawn* spawn = cmdTarget;
  2453. if(spawn && spawn->GetTargetable())
  2454. {
  2455. char tmp[75] = {0};
  2456. sprintf(tmp, "Hail, %s", spawn->GetName());
  2457. bool show_bubble = true;
  2458. if (spawn->IsNPC())
  2459. show_bubble = false;
  2460. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble, client->GetPlayer()->GetCurrentLanguage());
  2461. if(spawn->IsPlayer() == false && spawn->Alive() && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetGlobalRule(R_Spawn, HailDistance)->GetInt32()){
  2462. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  2463. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  2464. else
  2465. {
  2466. bool pauseRunback = false;
  2467. // prime runback as the heading or anything can be altered when hailing succeeds
  2468. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  2469. {
  2470. ((NPC*)spawn)->StartRunback();
  2471. pauseRunback = true;
  2472. }
  2473. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  2474. spawn->PauseMovement(rule_manager.GetGlobalRule(R_Spawn, HailMovementPause)->GetInt32());
  2475. else if(spawn->IsNPC() && pauseRunback)
  2476. ((NPC*)spawn)->ClearRunback();
  2477. }
  2478. }
  2479. }
  2480. else {
  2481. string tmp = "Hail";
  2482. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2483. }
  2484. break;
  2485. }
  2486. case COMMAND_SAY:{
  2487. if (sep && sep->arg[0][0]) {
  2488. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2489. if (cmdTarget && !(cmdTarget->IsPlayer()))
  2490. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  2491. }
  2492. else
  2493. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  2494. break;
  2495. }
  2496. case COMMAND_TELL:{
  2497. if(sep && sep->arg[0] && sep->argplus[1]){
  2498. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1], 0, client->GetPlayer()->GetCurrentLanguage()))
  2499. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  2500. }else
  2501. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  2502. break;
  2503. }
  2504. case COMMAND_SHOUT:{
  2505. if(sep && sep->arg[0][0])
  2506. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2507. else
  2508. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  2509. break;
  2510. }
  2511. case COMMAND_AUCTION:{
  2512. if(sep && sep->arg[0][0])
  2513. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2514. else
  2515. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  2516. break;
  2517. }
  2518. case COMMAND_OOC:{
  2519. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2520. if(sep && sep->arg[0][0])
  2521. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0], 0, client->GetPlayer()->GetCurrentLanguage());
  2522. else
  2523. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2524. break;
  2525. }
  2526. case COMMAND_EMOTE:{
  2527. if(sep && sep->arg[0][0])
  2528. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2529. else
  2530. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2531. break;
  2532. }
  2533. case COMMAND_RACE:{
  2534. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2535. if(sep->arg[1][0] && sep->IsNumber(1)){
  2536. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2537. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2538. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2539. client->GetPlayer()->SetCharSheetChanged(true);
  2540. }
  2541. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2542. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2543. //client->QueuePacket(outapp);
  2544. }
  2545. else{
  2546. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2547. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2548. }
  2549. break;
  2550. }
  2551. case COMMAND_BANK_DEPOSIT:{
  2552. if(client->GetBanker() && sep && sep->arg[0]){
  2553. int64 amount = 0;
  2554. string deposit = string(sep->arg[0]);
  2555. amount = atoi64(deposit.c_str());
  2556. client->BankDeposit(amount);
  2557. }
  2558. break;
  2559. }
  2560. case COMMAND_BANK_WITHDRAWAL:{
  2561. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2562. int64 amount = 0;
  2563. string deposit = string(sep->arg[0]);
  2564. amount = atoi64(deposit.c_str());
  2565. client->BankWithdrawal(amount);
  2566. }
  2567. break;
  2568. }
  2569. case COMMAND_BANK_CANCEL:{
  2570. Spawn* banker = cmdTarget;
  2571. client->Bank(banker, true);
  2572. break;
  2573. }
  2574. case COMMAND_BANK:{
  2575. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2576. Spawn* banker = cmdTarget;
  2577. client->Bank(banker);
  2578. break;
  2579. }
  2580. case COMMAND_GUILD_BANK:{
  2581. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2582. //Spawn* banker = client->GetPlayer()->GetTarget();
  2583. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2584. break;
  2585. }
  2586. case COMMAND_START_MAIL: {
  2587. client->SetMailTransaction(cmdTarget);
  2588. client->SendMailList();
  2589. break;
  2590. }
  2591. case COMMAND_CANCEL_MAIL: {
  2592. client->SetMailTransaction(0);
  2593. break;
  2594. }
  2595. case COMMAND_GET_MAIL_MESSAGE: {
  2596. if (sep && sep->arg[0] && sep->IsNumber(0))
  2597. client->DisplayMailMessage(atoul(sep->arg[0]));
  2598. break;
  2599. }
  2600. case COMMAND_ADD_MAIL_PLAT: {
  2601. if (sep && sep->arg[0] && sep->IsNumber(0))
  2602. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2603. break;
  2604. }
  2605. case COMMAND_ADD_MAIL_GOLD: {
  2606. if (sep && sep->arg[0] && sep->IsNumber(0))
  2607. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2608. break;
  2609. }
  2610. case COMMAND_ADD_MAIL_SILVER: {
  2611. if (sep && sep->arg[0] && sep->IsNumber(0))
  2612. client->AddMailCoin(0, atoul(sep->arg[0]));
  2613. break;
  2614. }
  2615. case COMMAND_ADD_MAIL_COPPER: {
  2616. if (sep && sep->arg[0] && sep->IsNumber(0))
  2617. client->AddMailCoin(atoul(sep->arg[0]));
  2618. break;
  2619. }
  2620. case COMMAND_SET_MAIL_ITEM: {
  2621. if(sep && sep->IsNumber(0) && sep->IsNumber(1))
  2622. {
  2623. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2624. if(item)
  2625. {
  2626. int16 quantity = atoul(sep->arg[1]);
  2627. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2628. {
  2629. return;
  2630. }
  2631. if(item->IsBag())
  2632. {
  2633. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2634. if(bag_items && bag_items->size() > 0)
  2635. {
  2636. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2637. safe_delete(bag_items);
  2638. return;
  2639. }
  2640. safe_delete(bag_items);
  2641. }
  2642. Item* itemtoadd = item;
  2643. if(quantity > 0)
  2644. {
  2645. if(quantity > item->details.count)
  2646. return;
  2647. Item* tmpItem = new Item(item);
  2648. tmpItem->details.count = quantity;
  2649. itemtoadd = tmpItem;
  2650. }
  2651. if(client->AddMailItem(itemtoadd))
  2652. {
  2653. client->RemoveItem(item, quantity, true);
  2654. }
  2655. }
  2656. }
  2657. break;
  2658. }
  2659. case COMMAND_REMOVE_MAIL_PLAT: {
  2660. if (sep && sep->arg[0] && sep->IsNumber(0))
  2661. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2662. break;
  2663. }
  2664. case COMMAND_REMOVE_MAIL_GOLD: {
  2665. if (sep && sep->arg[0] && sep->IsNumber(0))
  2666. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2667. break;
  2668. }
  2669. case COMMAND_REMOVE_MAIL_SILVER: {
  2670. if (sep && sep->arg[0] && sep->IsNumber(0))
  2671. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2672. break;
  2673. }
  2674. case COMMAND_REMOVE_MAIL_COPPER: {
  2675. if (sep && sep->arg[0] && sep->IsNumber(0))
  2676. client->RemoveMailCoin(atoul(sep->arg[0]));
  2677. break;
  2678. }
  2679. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2680. if (sep && sep->arg[0] && sep->IsNumber(0))
  2681. client->TakeMailAttachments(atoul(sep->arg[0]));
  2682. break;
  2683. }
  2684. case COMMAND_CANCEL_SEND_MAIL: {
  2685. client->ResetSendMail();
  2686. break;
  2687. }
  2688. case COMMAND_DELETE_MAIL_MESSAGE: {
  2689. if (sep && sep->arg[0] && sep->IsNumber(0))
  2690. client->DeleteMail(atoul(sep->arg[0]), true);
  2691. break;
  2692. }
  2693. case COMMAND_REPORT_SPAM: {
  2694. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2695. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2696. break;
  2697. }
  2698. case COMMAND_KILL:{
  2699. Spawn* dead = 0;
  2700. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2701. dead=client->GetPlayer();
  2702. client->GetPlayer()->SetHP(0);
  2703. client->GetPlayer()->KillSpawn(dead);
  2704. }else{
  2705. dead= cmdTarget;
  2706. if(dead && dead->IsPlayer() == false){
  2707. if(dead->IsNPC() && ((NPC*)dead)->Brain()) {
  2708. client->GetPlayer()->CheckEncounterState((Entity*)dead);
  2709. ((NPC*)dead)->Brain()->AddToEncounter(client->GetPlayer());
  2710. ((NPC*)dead)->AddTargetToEncounter(client->GetPlayer());
  2711. ((NPC*)dead)->Brain()->AddHate(client->GetPlayer(), 1);
  2712. }
  2713. dead->SetHP(0);
  2714. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2715. client->GetCurrentZone()->RemoveSpawn(dead, true, true, true, true, true);
  2716. else
  2717. client->GetPlayer()->KillSpawn(dead);
  2718. }else{
  2719. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2720. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2721. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2722. }
  2723. }
  2724. break;
  2725. }
  2726. case COMMAND_LEVEL:{
  2727. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2728. int16 new_level = atoi(sep->arg[ndx]);
  2729. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2730. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2731. else {
  2732. if (new_level < 1)
  2733. new_level = 1;
  2734. if (new_level > 255)
  2735. new_level = 255;
  2736. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2737. }
  2738. }else
  2739. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2740. break;
  2741. }
  2742. case COMMAND_SIT: {
  2743. if(client->GetPlayer()->GetHP() > 0){
  2744. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2745. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2746. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2747. }
  2748. break;
  2749. }
  2750. case COMMAND_STAND: {
  2751. if(client->GetPlayer()->GetHP() > 0){
  2752. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2753. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2754. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2755. }
  2756. break;
  2757. }
  2758. case COMMAND_CLASS:{
  2759. if(sep && sep->arg[ndx][0]){
  2760. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2761. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2762. }else
  2763. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2764. break;
  2765. }
  2766. case COMMAND_FLYMODE:{
  2767. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2768. PrintSep(sep, "COMMAND_FLYMODE");
  2769. int8 val = atoul(sep->arg[0]);
  2770. ClientPacketFunctions::SendFlyMode(client, val);
  2771. }
  2772. else{
  2773. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode [1|2] 1 = fly, 2 = no clip");
  2774. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2775. }
  2776. break;
  2777. }
  2778. case COMMAND_LOOT_LIST:{
  2779. Spawn* spawn = cmdTarget;
  2780. if(spawn && spawn->IsEntity()){
  2781. if (sep && sep->arg[0]) {
  2782. if (!spawn->GetDatabaseID())
  2783. {
  2784. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "NOTE: Spawn has no database id to assign to loottables.");
  2785. }
  2786. if (!spawn->IsNPC())
  2787. {
  2788. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2789. break;
  2790. }
  2791. bool reloadLoot = false;
  2792. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2793. {
  2794. int32 loottable_id = atoul(sep->arg[1]);
  2795. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2796. {
  2797. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2798. reloadLoot = true;
  2799. }
  2800. else
  2801. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2802. }
  2803. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2804. {
  2805. int32 loottable_id = atoul(sep->arg[1]);
  2806. if (loottable_id > 0)
  2807. {
  2808. database.AddLootTableToSpawn(spawn, loottable_id);
  2809. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2810. reloadLoot = true;
  2811. }
  2812. else
  2813. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2814. }
  2815. else if (!stricmp(sep->arg[0], "clearall"))
  2816. {
  2817. if (database.RemoveSpawnLootTable(spawn, 0))
  2818. {
  2819. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2820. reloadLoot = true;
  2821. }
  2822. else
  2823. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2824. }
  2825. else if (!stricmp(sep->arg[0], "details"))
  2826. {
  2827. spawn->LockLoot();
  2828. client->SimpleMessage(CHANNEL_COMMANDS, "Loot Window List:");
  2829. if (spawn->GetLootWindowList()->size() > 0) {
  2830. std::map<int32, bool>::iterator itr;
  2831. for (itr = spawn->GetLootWindowList()->begin(); itr != spawn->GetLootWindowList()->end(); itr++) {
  2832. Spawn* looter = client->GetPlayer()->GetZone()->GetSpawnByID(itr->first);
  2833. if (looter) {
  2834. client->Message(CHANNEL_COLOR_YELLOW, "Looter: %s IsLootWindowOpen: %s, HasCompletedLootWindow: %s.", looter->GetName(), itr->second ? "NO" : "YES", spawn->HasSpawnLootWindowCompleted(itr->first) ? "YES" : "NO");
  2835. }
  2836. }
  2837. }
  2838. spawn->UnlockLoot();
  2839. }
  2840. else
  2841. {
  2842. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2843. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2845. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2846. break;
  2847. }
  2848. if (reloadLoot)
  2849. {
  2850. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2851. if (spawn->IsNPC())
  2852. {
  2853. Entity* ent = (Entity*)spawn;
  2854. ent->SetLootCoins(0);
  2855. ent->ClearLoot();
  2856. spawn->GetZone()->AddLoot((NPC*)spawn);
  2857. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2858. }
  2859. }
  2860. break; // nothing further this is the end of these sub commands
  2861. }
  2862. else
  2863. {
  2864. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()), spawn);
  2865. if (loot_list.size() > 0) {
  2866. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2867. vector<int32>::iterator list_itr;
  2868. LootTable* table = 0;
  2869. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2870. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2871. if (table)
  2872. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2873. }
  2874. }
  2875. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2876. vector<Item*>* items = spawn->GetLootItems();
  2877. if (items) {
  2878. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2879. vector<Item*>::iterator itr;
  2880. Item* item = 0;
  2881. for (itr = items->begin(); itr != items->end(); itr++) {
  2882. item = *itr;
  2883. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2884. }
  2885. }
  2886. else
  2887. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2888. }
  2889. }
  2890. break;
  2891. }
  2892. case COMMAND_LOOT_SETCOIN:{
  2893. Spawn* spawn = cmdTarget;
  2894. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2895. spawn->SetLootCoins(atoul(sep->arg[0]));
  2896. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2897. }
  2898. else
  2899. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2900. break;
  2901. }
  2902. case COMMAND_LOOT_ADDITEM:{
  2903. Spawn* spawn = cmdTarget;
  2904. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2905. int16 charges = 1;
  2906. if(sep->arg[1] && sep->IsNumber(1))
  2907. charges = atoi(sep->arg[1]);
  2908. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2909. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2910. }
  2911. else
  2912. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2913. break;
  2914. }
  2915. case COMMAND_LOOT_REMOVEITEM:{
  2916. Spawn* spawn = cmdTarget;
  2917. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2918. Item* item = spawn->LootItem(atoul(sep->arg[0]));
  2919. lua_interface->SetLuaUserDataStale(item);
  2920. safe_delete(item);
  2921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2922. }
  2923. else
  2924. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2925. break;
  2926. }
  2927. case COMMAND_LOOT_CORPSE:
  2928. case COMMAND_DISARM:
  2929. case COMMAND_LOOT:{
  2930. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2931. {
  2932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2933. break;
  2934. }
  2935. if(cmdTarget && cmdTarget->IsEntity()){
  2936. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2937. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2938. client->OpenChest(cmdTarget, true);
  2939. else
  2940. client->LootSpawnRequest(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2941. if (!(cmdTarget)->HasLoot()){
  2942. if (((Entity*)cmdTarget)->IsNPC())
  2943. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2944. }
  2945. }
  2946. else
  2947. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2948. }
  2949. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2951. break;
  2952. }
  2953. case COMMAND_RELOADSPAWNSCRIPTS:{
  2954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2955. if (lua_interface)
  2956. lua_interface->SetLuaSystemReloading(true);
  2957. world.ResetSpawnScripts();
  2958. database.LoadSpawnScriptData();
  2959. if(lua_interface) {
  2960. lua_interface->DestroySpawnScripts();
  2961. lua_interface->SetLuaSystemReloading(false);
  2962. }
  2963. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2964. break;
  2965. }
  2966. case COMMAND_RELOADREGIONSCRIPTS:{
  2967. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2968. if(lua_interface) {
  2969. lua_interface->DestroyRegionScripts();
  2970. }
  2971. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2972. break;
  2973. }
  2974. case COMMAND_RELOADLUASYSTEM:{
  2975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2976. world.SetReloadingSubsystem("LuaSystem");
  2977. if(lua_interface) {
  2978. lua_interface->SetLuaSystemReloading(true);
  2979. }
  2980. zone_list.DeleteSpellProcess();
  2981. master_spell_list.Reload();
  2982. if (lua_interface)
  2983. lua_interface->ReloadSpells();
  2984. zone_list.LoadSpellProcess();
  2985. if(lua_interface){
  2986. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2987. map<Client*, int32>::iterator itr;
  2988. for(itr = debug_clients.begin(); itr != debug_clients.end(); itr++){
  2989. if(lua_interface)
  2990. lua_interface->UpdateDebugClients(itr->first);
  2991. }
  2992. }
  2993. world.ResetSpawnScripts();
  2994. database.LoadSpawnScriptData();
  2995. world.ResetZoneScripts();
  2996. database.LoadZoneScriptData();
  2997. if(lua_interface) {
  2998. lua_interface->DestroySpawnScripts();
  2999. lua_interface->DestroyRegionScripts();
  3000. lua_interface->DestroyQuests();
  3001. lua_interface->DestroyItemScripts();
  3002. lua_interface->DestroyZoneScripts();
  3003. }
  3004. int32 quest_count = database.LoadQuests();
  3005. int32 spell_count = 0;
  3006. if(lua_interface) {
  3007. spell_count = database.LoadSpellScriptData();
  3008. lua_interface->SetLuaSystemReloading(false);
  3009. }
  3010. world.RemoveReloadingSubSystem("LuaSystem");
  3011. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  3012. break;
  3013. }
  3014. case COMMAND_DECLINE_QUEST:{
  3015. int32 quest_id = 0;
  3016. if(sep && sep->arg[0] && sep->IsNumber(0))
  3017. quest_id = atoul(sep->arg[0]);
  3018. if(quest_id > 0){
  3019. client->RemovePendingQuest(quest_id);
  3020. }
  3021. break;
  3022. }
  3023. case COMMAND_DELETE_QUEST:{
  3024. int32 quest_id = 0;
  3025. if(sep && sep->arg[0] && sep->IsNumber(0))
  3026. quest_id = atoul(sep->arg[0]);
  3027. if(quest_id > 0){
  3028. client->GetPlayer()->MPlayerQuests.readlock(__FUNCTION__, __LINE__);
  3029. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  3030. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  3031. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3032. if (quest && quest->CanDeleteQuest()) {
  3033. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  3034. client->RemovePlayerQuest(quest_id);
  3035. client->GetCurrentZone()->SendQuestUpdates(client);
  3036. }
  3037. }
  3038. else {
  3039. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3040. }
  3041. }
  3042. break;
  3043. }
  3044. case COMMAND_ACCEPT_QUEST:{
  3045. int32 quest_id = 0;
  3046. if(sep && sep->arg[0] && sep->IsNumber(0))
  3047. quest_id = atoul(sep->arg[0]);
  3048. if(quest_id > 0){
  3049. client->AcceptQuest(quest_id);
  3050. }
  3051. break;
  3052. }
  3053. case COMMAND_NAME:{
  3054. if(sep && sep->arg[ndx][0]){
  3055. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  3056. client->GetPlayer()->SetCharSheetChanged(true);
  3057. }else
  3058. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  3059. break;
  3060. }
  3061. case COMMAND_GROUP: {
  3062. if(sep && sep->arg[0])
  3063. printf("Group: %s\n",sep->argplus[0]);
  3064. break;
  3065. }
  3066. case COMMAND_GROUPSAY:{
  3067. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3068. if(sep && sep->arg[0] && gmi)
  3069. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), client->GetPlayer()->GetCurrentLanguage(), sep->argplus[0]);
  3070. break;
  3071. }
  3072. case COMMAND_GROUPINVITE: {
  3073. Entity* target = 0;
  3074. Client* target_client = 0;
  3075. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3076. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  3077. return;
  3078. }
  3079. // name provided with command so it has to be a player, npc not supported here
  3080. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  3081. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  3082. if (target_client) {
  3083. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  3084. target = 0;
  3085. else
  3086. target = target_client->GetPlayer();
  3087. }
  3088. }
  3089. // if name was not provided use the players target, npc or player supported here
  3090. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  3091. target = (Entity*)client->GetPlayer()->GetTarget();
  3092. if (target->IsPlayer()) {
  3093. target_client = ((Player*)target)->GetClient();
  3094. }
  3095. }
  3096. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  3097. if (result == 0) {
  3098. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  3099. if (target_client) {
  3100. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  3101. if (packet) {
  3102. packet->setDataByName("type", 1);
  3103. packet->setDataByName("name", client->GetPlayer()->GetName());
  3104. packet->setDataByName("unknown2", 1);
  3105. target_client->QueuePacket(packet->serialize());
  3106. safe_delete(packet);
  3107. }
  3108. }
  3109. }
  3110. else if (result == 1)
  3111. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  3112. else if (result == 2)
  3113. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  3114. else if (result == 3)
  3115. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  3116. else if (result == 4)
  3117. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  3118. else if (result == 5)
  3119. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  3120. else if (result == 6)
  3121. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  3122. else
  3123. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  3124. break;
  3125. }
  3126. case COMMAND_GROUPDISBAND: {
  3127. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3128. if (gmi) { // TODO: Leader check
  3129. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  3130. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  3131. }
  3132. break;
  3133. }
  3134. case COMMAND_GROUP_LEAVE: {
  3135. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3136. if (gmi) {
  3137. int32 group_id = gmi->group_id;
  3138. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  3139. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  3140. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  3141. }
  3142. else {
  3143. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  3144. }
  3145. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  3146. }
  3147. break;
  3148. }
  3149. case COMMAND_FRIEND_ADD:{
  3150. string name = "";
  3151. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3152. name = database.GetPlayerName(sep->arg[0]);
  3153. else if(cmdTarget && cmdTarget->IsPlayer())
  3154. name = string(cmdTarget->GetName());
  3155. if(name.length() > 0){
  3156. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3157. if(client->GetPlayer()->IsIgnored(name.c_str())){
  3158. client->GetPlayer()->RemoveIgnore(name.c_str());
  3159. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3160. client->SendChatRelationship(3, name.c_str());
  3161. }
  3162. client->GetPlayer()->AddFriend(name.c_str(), true);
  3163. client->SendChatRelationship(0, name.c_str());
  3164. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  3165. if(zone_list.GetClientByCharName(name))
  3166. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  3167. }
  3168. else
  3169. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  3170. }
  3171. else
  3172. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3173. break;
  3174. }
  3175. case COMMAND_FRIEND_REMOVE:{
  3176. string name = "";
  3177. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3178. name = database.GetPlayerName(sep->arg[0]);
  3179. else if(cmdTarget && cmdTarget->IsPlayer())
  3180. name = string(cmdTarget->GetName());
  3181. if(name.length() > 0){
  3182. client->GetPlayer()->RemoveFriend(name.c_str());
  3183. client->SendChatRelationship(1, name.c_str());
  3184. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3185. }
  3186. else
  3187. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3188. break;
  3189. }
  3190. case COMMAND_FRIENDS:{
  3191. break;
  3192. }
  3193. case COMMAND_IGNORE_ADD:{
  3194. string name = "";
  3195. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3196. name = database.GetPlayerName(sep->arg[0]);
  3197. else if(cmdTarget && cmdTarget->IsPlayer())
  3198. name = string(cmdTarget->GetName());
  3199. if(name.length() > 0){
  3200. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3201. if(client->GetPlayer()->IsFriend(name.c_str())){
  3202. client->GetPlayer()->RemoveFriend(name.c_str());
  3203. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3204. client->SendChatRelationship(1, name.c_str());
  3205. }
  3206. client->GetPlayer()->AddIgnore(name.c_str(), true);
  3207. client->SendChatRelationship(2, name.c_str());
  3208. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  3209. }
  3210. else
  3211. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  3212. }
  3213. else
  3214. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3215. break;
  3216. }
  3217. case COMMAND_IGNORE_REMOVE:{
  3218. string name = "";
  3219. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3220. name = database.GetPlayerName(sep->arg[0]);
  3221. else if(cmdTarget && cmdTarget->IsPlayer())
  3222. name = string(cmdTarget->GetName());
  3223. if(name.length() > 0){
  3224. client->GetPlayer()->RemoveIgnore(name.c_str());
  3225. client->SendChatRelationship(3, name.c_str());
  3226. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3227. }
  3228. break;
  3229. }
  3230. case COMMAND_IGNORES:{
  3231. break;
  3232. }
  3233. case COMMAND_GROUP_KICK:{
  3234. Entity* kicked = 0;
  3235. Client* kicked_client = 0;
  3236. int32 group_id = 0;
  3237. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  3238. return;
  3239. if (sep && sep->arg[0]) {
  3240. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  3241. if (kicked_client)
  3242. kicked = kicked_client->GetPlayer();
  3243. }
  3244. else if (cmdTarget && cmdTarget->IsEntity()) {
  3245. kicked = (Entity*)cmdTarget;
  3246. }
  3247. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  3248. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  3249. if (kicked)
  3250. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  3251. if(send_kicked_message)
  3252. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  3253. else
  3254. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  3255. if (kicked_client)
  3256. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  3257. break;
  3258. }
  3259. case COMMAND_GROUP_MAKE_LEADER:{
  3260. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3261. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  3262. return;
  3263. }
  3264. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  3265. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  3266. if (new_leader && new_leader->GetPlayer()->GetGroupMemberInfo() && new_leader->GetPlayer()->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3267. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  3268. if(world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer())) {
  3269. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", new_leader->GetPlayer()->GetName());
  3270. }
  3271. }
  3272. }
  3273. else
  3274. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  3275. }
  3276. else if (cmdTarget && cmdTarget->IsPlayer() && ((Player*)cmdTarget)->GetGroupMemberInfo() && ((Player*)cmdTarget)->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3277. if(client->GetPlayer()->IsGroupMember((Player*)cmdTarget) && world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget)) {
  3278. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", cmdTarget->GetName());
  3279. }
  3280. }
  3281. else
  3282. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  3283. break;
  3284. }
  3285. case COMMAND_GROUP_ACCEPT_INVITE: {
  3286. if((sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) || (!sep && client->GetVersion() <= 546)) {
  3287. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  3288. if (result == 0)
  3289. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  3290. else if (result == 1)
  3291. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  3292. else if (result == 2)
  3293. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  3294. else
  3295. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  3296. }
  3297. break;
  3298. }
  3299. case COMMAND_GROUP_DECLINE_INVITE: {
  3300. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  3301. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  3302. }
  3303. break;
  3304. }
  3305. case COMMAND_SUMMON:{
  3306. char* search_name = 0;
  3307. if(sep && sep->arg[0][0])
  3308. search_name = sep->arg[0];
  3309. if(!search_name && !cmdTarget){
  3310. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  3311. 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.");
  3312. }
  3313. else{
  3314. if(!client->Summon(search_name))
  3315. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3316. }
  3317. break;
  3318. }
  3319. case COMMAND_GOTO:{
  3320. const char* search_name = 0;
  3321. if(sep && sep->arg[0][0])
  3322. search_name = sep->argplus[0];
  3323. if(!search_name && !cmdTarget){
  3324. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  3325. 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.");
  3326. }
  3327. else{
  3328. if(!client->GotoSpawn(search_name))
  3329. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3330. }
  3331. break;
  3332. }
  3333. case COMMAND_MOVE:{
  3334. bool success = false;
  3335. try{
  3336. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  3337. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  3338. if(app){
  3339. client->QueuePacket(app);
  3340. success = true;
  3341. }
  3342. }
  3343. }
  3344. catch(...){}
  3345. if(!success){
  3346. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  3347. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  3348. }
  3349. break;
  3350. }
  3351. case COMMAND_SETTIME:{
  3352. if(sep && sep->arg[0]){
  3353. world.MWorldTime.writelock(__FUNCTION__, __LINE__);
  3354. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  3355. if(sep->arg[1] && sep->IsNumber(1))
  3356. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  3357. if(sep->arg[2] && sep->IsNumber(2))
  3358. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  3359. if(sep->arg[3] && sep->IsNumber(3))
  3360. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  3361. world.MWorldTime.releasewritelock(__FUNCTION__, __LINE__);
  3362. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  3363. }
  3364. else{
  3365. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  3366. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  3367. }
  3368. break;
  3369. }
  3370. case COMMAND_VERSION:{
  3371. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  3372. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  3373. break;
  3374. }
  3375. case COMMAND_ZONE:{
  3376. int32 instanceID = 0;
  3377. string zone;
  3378. int32 zone_id = 0;
  3379. bool listSearch = false;
  3380. bool isInstance = false;
  3381. ZoneServer* zsZone = 0;
  3382. if(sep && sep->arg[0][0])
  3383. {
  3384. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  3385. listSearch = true;
  3386. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  3387. {
  3388. zone_list.SendZoneList(client);
  3389. break;
  3390. }
  3391. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  3392. {
  3393. if(sep->IsNumber(1))
  3394. instanceID = atol(sep->arg[1]);
  3395. }
  3396. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  3397. {
  3398. PrintSep(sep, "ZONE LOCK");
  3399. if(sep->IsNumber(1))
  3400. zsZone = zone_list.Get(atoul(sep->arg[1]), false, false, false);
  3401. else
  3402. zsZone = zone_list.Get(sep->arg[1], false, false, false);
  3403. if( zsZone )
  3404. {
  3405. zsZone->SetZoneLockState(true);
  3406. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3407. }
  3408. else
  3409. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  3410. break;
  3411. }
  3412. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  3413. {
  3414. PrintSep(sep, "ZONE UNLOCK");
  3415. if(sep->IsNumber(1))
  3416. zsZone = zone_list.Get(atoul(sep->arg[1]), false, false, false);
  3417. else
  3418. zsZone = zone_list.Get(sep->arg[1], false, false, false);
  3419. if( zsZone )
  3420. {
  3421. zsZone->SetZoneLockState(false);
  3422. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3423. }
  3424. else
  3425. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  3426. break;
  3427. }
  3428. else
  3429. {
  3430. if(sep->IsNumber(0))
  3431. {
  3432. zone_id = atoul(sep->arg[0]);
  3433. string zonename = database.GetZoneName(zone_id);
  3434. if(zonename.length() > 0)
  3435. zone = zonename;
  3436. }
  3437. else
  3438. zone = sep->arg[0];
  3439. }
  3440. if(instanceID > 0)
  3441. {
  3442. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  3443. if(zsInstance != NULL)
  3444. {
  3445. instanceID = zsInstance->GetInstanceID();
  3446. zone = zsInstance->GetZoneName();
  3447. zone_id = zsInstance->GetZoneID();
  3448. isInstance = true;
  3449. }
  3450. }
  3451. }
  3452. if(!listSearch)
  3453. {
  3454. if(zone.length() == 0)
  3455. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  3456. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  3457. zone_id != client->GetCurrentZone()->GetZoneID())
  3458. {
  3459. const char* zonestr = zone.c_str();
  3460. if(database.VerifyZone(zonestr))
  3461. {
  3462. if(client->CheckZoneAccess(zonestr))
  3463. {
  3464. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  3465. if(isInstance)
  3466. client->Zone(instanceID,true,true,false);
  3467. else
  3468. client->Zone(zonestr);
  3469. }
  3470. }
  3471. else
  3472. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  3473. }
  3474. else
  3475. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  3476. }
  3477. else
  3478. {
  3479. const char* name = 0;
  3480. if(sep && sep->arg[1][0])
  3481. {
  3482. map<int32, string>* zone_names;
  3483. name = sep->argplus[1];
  3484. sint16 status = client->GetAdminStatus();
  3485. if( status > 0 )
  3486. {
  3487. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  3488. zone_names = database.GetZoneList(name, true);
  3489. }
  3490. else
  3491. zone_names = database.GetZoneList(name);
  3492. if(!zone_names)
  3493. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  3494. else
  3495. {
  3496. map<int32, string>::iterator itr;
  3497. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  3498. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  3499. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  3500. safe_delete(zone_names);
  3501. }
  3502. }
  3503. else
  3504. {
  3505. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  3506. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  3507. }
  3508. }
  3509. break;
  3510. }
  3511. case COMMAND_USE: {
  3512. Spawn* target = cmdTarget;
  3513. if (target && target->IsWidget())
  3514. ((Widget*)target)->HandleUse(client, "use");
  3515. break;
  3516. }
  3517. case COMMAND_OPEN: {
  3518. Spawn* target = cmdTarget;
  3519. if (target && target->IsWidget())
  3520. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  3521. break;
  3522. }
  3523. case COMMAND_CASTSPELL: {
  3524. if (sep && sep->arg[0] && sep->IsNumber(0))
  3525. {
  3526. int8 tier = 1;
  3527. if (sep->arg[1] && sep->IsNumber(1))
  3528. tier = atoul(sep->arg[1]);
  3529. int8 self = 1;
  3530. if (sep->arg[1] && sep->IsNumber(2))
  3531. {
  3532. self = atoul(sep->arg[2]);
  3533. if(self != 1 && !cmdTarget->IsEntity())
  3534. {
  3535. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  3536. self = 1;
  3537. }
  3538. }
  3539. int32 spellid = atoul(sep->arg[0]);
  3540. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  3541. if (spell)
  3542. {
  3543. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3544. SpellProcess* spellProcess = 0;
  3545. // Get the current zones spell process
  3546. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3547. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3548. }
  3549. else
  3550. {
  3551. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3552. }
  3553. }
  3554. else if (sep && sep->arg[0])
  3555. {
  3556. database.FindSpell(client, (char*)sep->argplus[0]);
  3557. }
  3558. else
  3559. {
  3560. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3561. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3562. }
  3563. break;
  3564. }
  3565. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3566. if (sep && (client->GetVersion() <= 546 && sep->GetArgNumber() == 3) || sep->GetArgNumber() == 4)
  3567. {
  3568. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3569. // cannot sort the ability book in this client it is greyed out
  3570. if (client->GetVersion() <= 546 && book == SPELL_BOOK_TYPE_ABILITY)
  3571. break;
  3572. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3573. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3574. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3575. int32 maxlvlonly = 0;
  3576. if(client->GetVersion() > 546 && sep->arg[4][0]) {
  3577. maxlvlonly = atoul(sep->arg[4]); // checkbox for newer clients
  3578. }
  3579. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3580. ClientPacketFunctions::SendSkillSlotMappings(client);
  3581. }
  3582. else
  3583. {
  3584. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3585. }
  3586. break;
  3587. }
  3588. case COMMAND_MOVE_ITEM:
  3589. {
  3590. int32 id = 0;
  3591. if (sep && sep->IsNumber(0))
  3592. id = atoul(sep->arg[0]);
  3593. Spawn* spawn = 0;
  3594. if (id == 0)
  3595. {
  3596. spawn = cmdTarget;
  3597. }
  3598. else
  3599. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3600. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3601. break;
  3602. client->SendMoveObjectMode(spawn, 0);
  3603. break;
  3604. }
  3605. case COMMAND_PICKUP:
  3606. {
  3607. int32 id = 0;
  3608. if (sep && sep->IsNumber(0))
  3609. id = atoul(sep->arg[0]);
  3610. Spawn* spawn = 0;
  3611. if (id == 0)
  3612. {
  3613. spawn = cmdTarget;
  3614. }
  3615. else
  3616. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3617. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3618. break;
  3619. if(client->AddItem(spawn->GetPickupItemID(), 1)) {
  3620. Query query;
  3621. 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());
  3622. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3623. client->GetCurrentZone()->RemoveSpawn(spawn, true, true, true, true, true);
  3624. }
  3625. // we had a UI Window displayed, update the house items
  3626. if ( id > 0 )
  3627. client->GetCurrentZone()->SendHouseItems(client);
  3628. }
  3629. break;
  3630. }
  3631. case COMMAND_HOUSE_DEPOSIT:
  3632. {
  3633. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3634. // arg0 = spawn_id for DoF, could also be house_id for newer clients
  3635. // arg1 = coin (in copper)
  3636. // arg2 = status? (not implemented yet)
  3637. PlayerHouse* ph = nullptr;
  3638. int32 spawn_id = 0;
  3639. if(sep && sep->arg[0]) {
  3640. spawn_id = atoul(sep->arg[0]);
  3641. ph = world.GetPlayerHouse(client, spawn_id, client->GetVersion() > 546 ? spawn_id : 0, nullptr);
  3642. }
  3643. if(!ph) {
  3644. ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3645. }
  3646. if (ph && sep && sep->IsNumber(1))
  3647. {
  3648. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3649. int32 outValStatus = 0;
  3650. if(sep->IsNumber(2))
  3651. {
  3652. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3653. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3654. outValStatus = 0; // cheat check
  3655. }
  3656. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3657. {
  3658. if(outValStatus)
  3659. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3660. char query[256];
  3661. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3662. if (itr != ph->depositsMap.end())
  3663. {
  3664. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %llu, last_amount = %llu, status = status + %u, last_status = %u where house_id = %u and instance_id = %u and name='%s'", Timer::GetUnixTimeStamp(), outValCoin, outValCoin, outValStatus, outValStatus, ph->house_id, ph->instance_id, client->GetPlayer()->GetName());
  3665. }
  3666. else
  3667. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %llu, status = %u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outValCoin, outValStatus);
  3668. if (database.RunQuery(query, strnlen(query, 256)))
  3669. {
  3670. ph->escrow_coins += outValCoin;
  3671. ph->escrow_status += outValStatus;
  3672. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3673. database.LoadDeposits(ph);
  3674. client->PlaySound("coin_cha_ching");
  3675. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3676. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 546 ? spawn_id : client->GetPlayer()->GetID());
  3677. }
  3678. else
  3679. {
  3680. if(outValCoin)
  3681. client->GetPlayer()->AddCoins(outValCoin);
  3682. if(outValStatus)
  3683. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3684. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3685. }
  3686. }
  3687. }
  3688. break;
  3689. }
  3690. case COMMAND_HOUSE:
  3691. {
  3692. int32 spawn_id = 0;
  3693. if (sep && sep->IsNumber(0))
  3694. {
  3695. PlayerHouse* ph = nullptr;
  3696. if(!ph && sep && sep->arg[0]) {
  3697. spawn_id = atoul(sep->arg[0]);
  3698. ph = world.GetPlayerHouse(client, spawn_id, spawn_id, nullptr);
  3699. }
  3700. HouseZone* hz = 0;
  3701. if (ph)
  3702. hz = world.GetHouseZone(ph->house_id);
  3703. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3704. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 546 ? spawn_id : client->GetPlayer()->GetID());
  3705. }
  3706. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3707. {
  3708. // inside a house or something? Send the access window
  3709. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3710. HouseZone* hz = 0;
  3711. if ( ph )
  3712. hz = world.GetHouseZone(ph->house_id);
  3713. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 546 ? spawn_id : client->GetPlayer()->GetID());
  3714. client->GetCurrentZone()->SendHouseItems(client);
  3715. }
  3716. break;
  3717. }
  3718. case COMMAND_HOUSE_UI:
  3719. {
  3720. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3721. {
  3722. int32 unique_id = atoi(sep->arg[0]);
  3723. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3724. HouseZone* hz = 0;
  3725. if ( ph )
  3726. hz = world.GetHouseZone(ph->house_id);
  3727. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3728. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3729. }
  3730. break;
  3731. }
  3732. case COMMAND_PLACE_HOUSE_ITEM: {
  3733. if (sep && sep->IsNumber(0))
  3734. {
  3735. int32 uniqueid = atoi(sep->arg[0]);
  3736. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3737. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3738. if (item && item->IsHouseItem())
  3739. {
  3740. if (!client->HasOwnerOrEditAccess())
  3741. {
  3742. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3743. break;
  3744. }
  3745. else if (!item->generic_info.appearance_id)
  3746. {
  3747. 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);
  3748. break;
  3749. }
  3750. else if(item->CheckFlag2(HOUSE_LORE) && client->GetCurrentZone()->HouseItemSpawnExists(item->details.item_id)) {
  3751. client->Message(CHANNEL_COLOR_RED, "Item %s is house lore and you cannot place another.", item->name.c_str());
  3752. break;
  3753. }
  3754. if (client->GetTempPlacementSpawn())
  3755. {
  3756. Spawn* tmp = client->GetTempPlacementSpawn();
  3757. client->GetCurrentZone()->RemoveSpawn(tmp, true, true, true, true, true);
  3758. client->SetTempPlacementSpawn(nullptr);
  3759. }
  3760. Object* obj = new Object();
  3761. Spawn* spawn = (Spawn*)obj;
  3762. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3763. strcpy(spawn->appearance.name, "temp");
  3764. spawn->SetX(client->GetPlayer()->GetX());
  3765. spawn->SetY(client->GetPlayer()->GetY());
  3766. spawn->SetZ(client->GetPlayer()->GetZ());
  3767. spawn->appearance.pos.collision_radius = 32;
  3768. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3769. spawn->SetSpawnOrigX(spawn->GetX());
  3770. spawn->SetSpawnOrigY(spawn->GetY());
  3771. spawn->SetSpawnOrigZ(spawn->GetZ());
  3772. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3773. spawn->appearance.targetable = 1;
  3774. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3775. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3776. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3777. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3778. spawn->SetZone(client->GetCurrentZone());
  3779. client->SetTempPlacementSpawn(spawn);
  3780. client->SetPlacementUniqueItemID(uniqueid);
  3781. client->GetCurrentZone()->AddSpawn(spawn);
  3782. }
  3783. }
  3784. break;
  3785. }
  3786. case COMMAND_GM:
  3787. {
  3788. if (sep && sep->arg[0] && sep->arg[1])
  3789. {
  3790. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3791. if (strcmp(sep->arg[0], "vision") == 0)
  3792. {
  3793. client->GetPlayer()->SetGMVision(onOff);
  3794. #if defined(__GNUC__)
  3795. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3796. #else
  3797. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3798. #endif
  3799. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3800. if (onOff)
  3801. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3802. else
  3803. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3804. }
  3805. else if (strcmp(sep->arg[0], "tag") == 0)
  3806. {
  3807. int32 value = 0;
  3808. int16 tag_icon = 0;
  3809. // groundspawn has special exception -1 argument so it needs to be handled here
  3810. if(sep->arg[2] && sep->arg[3] && ((tag_icon = atoul(sep->arg[3])) > 0) || (strncasecmp(sep->arg[1], "groundspawn", 11) == 0)) {
  3811. value = atoul(sep->arg[2]);
  3812. if(strncasecmp(sep->arg[1], "faction", 7) == 0){
  3813. if(!value) {
  3814. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid faction id.");
  3815. break;
  3816. }
  3817. if(!tag_icon) {
  3818. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3819. break;
  3820. }
  3821. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_FACTION, value, "", tag_icon);
  3822. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3823. client->Message(CHANNEL_COLOR_RED, "Adding faction id %u with tag icon %u.", value, tag_icon);
  3824. }
  3825. else if(strncasecmp(sep->arg[1], "spawngroup", 10) == 0){
  3826. if(value>0) {
  3827. value = 1;
  3828. }
  3829. if(!tag_icon) {
  3830. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3831. break;
  3832. }
  3833. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_SPAWNGROUP, value, "", tag_icon);
  3834. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3835. client->Message(CHANNEL_COLOR_RED, "Adding spawn group tag \"%s\" with tag icon %u.", (value == 1) ? "on" : "off", tag_icon);
  3836. }
  3837. else if(strncasecmp(sep->arg[1], "race", 4 == 0)){
  3838. if(!value) {
  3839. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid race id.");
  3840. break;
  3841. }
  3842. if(!tag_icon) {
  3843. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3844. break;
  3845. }
  3846. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_RACE, value, "", tag_icon);
  3847. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3848. client->Message(CHANNEL_COLOR_RED, "Adding race id %u with tag icon %u.", value, tag_icon);
  3849. }
  3850. else if(strncasecmp(sep->arg[1], "groundspawn", 11) == 0){
  3851. // one less argument value field not tag_icon for this one
  3852. if(!value) {
  3853. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3854. break;
  3855. }
  3856. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_GROUNDSPAWN, 1, "", value);
  3857. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3858. client->Message(CHANNEL_COLOR_RED, "Adding groundspawns with tag icon %u.", value);
  3859. }
  3860. }
  3861. else {
  3862. if(strncasecmp(sep->arg[1], "clear", 5) == 0){
  3863. client->GetPlayer()->ClearGMVisualFilters();
  3864. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Tags Cleared!");
  3865. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3866. }
  3867. else {
  3868. client->SimpleMessage(CHANNEL_COLOR_RED, "GM Tagging Missing Arguments:");
  3869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag [type] [value] [visual_icon_display]");
  3870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag clear - Clears all GM visual tags");
  3871. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Type Options:");
  3872. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: faction, value: faction id of spawn(s)");
  3873. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: spawngroup, value: 1 to show grouped, 0 to show not grouped");
  3874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: race, value: race id (either against base race or race id in spawn details)");
  3875. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: groundspawn, value: (not used)");
  3876. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Icon Options:");
  3877. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3878. "1 = skull, 2 = shield half dark blue / half light blue, 3 = purple? star, 4 = yellow sword, 5 = red X, 6 = green flame");
  3879. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3880. "7 = Number \"1\", 8 = Number \"2\", 9 = Number \"3\", 10 = Number \"4\", 11 = Number \"5\", 12 = Number \"6\"");
  3881. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3882. "25 = shield, 26 = green plus, 27 = crossed swords, 28 = bow with arrow in it, 29 = light blue lightning bolt");
  3883. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3884. "30 = bard instrument (hard to see), 31 = writ with shield, 32 = writ with green +, 33 = writ with crossed sword");
  3885. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3886. "34 = writ with bow, 35 = writ with light blue lightning bolt, 36 = same as 30, 37 = party with crossed sword, shield and lightning bolt");
  3887. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3888. "38 = shaking hands green background, 39 = shaking hands dark green background, unlocked keylock");
  3889. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3890. "40 = red aura icon with black shadow of person and big red aura, 41 = green aura icon with black shadow of person big green aura");
  3891. }
  3892. }
  3893. }
  3894. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3895. {
  3896. client->SetRegionDebug(onOff);
  3897. #if defined(__GNUC__)
  3898. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3899. #else
  3900. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3901. #endif
  3902. if (onOff)
  3903. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  3904. else
  3905. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  3906. }
  3907. else if (strcmp(sep->arg[0], "sight") == 0)
  3908. {
  3909. if(onOff && cmdTarget) {
  3910. client->SetPlayerPOVGhost(cmdTarget);
  3911. }
  3912. else
  3913. client->SetPlayerPOVGhost(nullptr);
  3914. }
  3915. else if (strcmp(sep->arg[0], "controleffects") == 0)
  3916. {
  3917. if(cmdTarget && cmdTarget->IsEntity()) {
  3918. ((Entity*)cmdTarget)->SendControlEffectDetailsToClient(client);
  3919. }
  3920. else {
  3921. client->GetPlayer()->SendControlEffectDetailsToClient(client);
  3922. }
  3923. }
  3924. else if (strcmp(sep->arg[0], "luadebug") == 0)
  3925. {
  3926. client->SetLuaDebugClient(onOff);
  3927. #if defined(__GNUC__)
  3928. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3929. #else
  3930. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  3931. #endif
  3932. if (onOff)
  3933. {
  3934. if (lua_interface)
  3935. lua_interface->UpdateDebugClients(client);
  3936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3937. }
  3938. else
  3939. {
  3940. if (lua_interface)
  3941. lua_interface->RemoveDebugClients(client);
  3942. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3943. }
  3944. }
  3945. }
  3946. break;
  3947. }
  3948. case COMMAND_ATTACK:
  3949. case COMMAND_AUTO_ATTACK:{
  3950. Command_AutoAttack(client, sep);
  3951. break;
  3952. }
  3953. case COMMAND_DEPOP:{
  3954. bool allow_respawns = false;
  3955. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3956. if(atoi(sep->arg[0]) == 1)
  3957. allow_respawns = true;
  3958. }
  3959. client->GetCurrentZone()->Depop(allow_respawns);
  3960. break;
  3961. }
  3962. case COMMAND_REPOP:{
  3963. client->GetCurrentZone()->Depop(false, true);
  3964. break;
  3965. }
  3966. case COMMAND_BUYBACK:{
  3967. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3968. // 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
  3969. int64 id = atoi64(sep->arg[0]);
  3970. // get the first int32, the item id
  3971. //int32 item_id = (int32)id;
  3972. // get the second int32, the unique id
  3973. int32 unique_id = (int32)(id>>32);
  3974. int8 quantity = atoi(sep->arg[1]);
  3975. if(quantity == 255)
  3976. quantity = 1;
  3977. client->BuyBack(unique_id, quantity);
  3978. }
  3979. break;
  3980. }
  3981. case COMMAND_MERCHANT_BUY:{
  3982. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3983. int32 item_id = atoul(sep->arg[0]);
  3984. int8 quantity = atoi(sep->arg[1]);
  3985. client->BuyItem(item_id, quantity);
  3986. }
  3987. else
  3988. Command_SendMerchantWindow(client, sep);
  3989. break;
  3990. }
  3991. case COMMAND_MERCHANT_SELL:{
  3992. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3993. // 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
  3994. int64 id = atoi64(sep->arg[0]);
  3995. // get the first int32, the item id
  3996. int32 item_id = (int32)id;
  3997. // get the second int32, the unique id
  3998. int32 unique_id = (int32)(id>>32);
  3999. int8 quantity = atoi(sep->arg[1]);
  4000. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  4001. client->SellItem(item_id, quantity, unique_id);
  4002. }
  4003. break;
  4004. }
  4005. case COMMAND_MENDER_REPAIR: {
  4006. if (sep && sep->arg[0] && sep->IsNumber(0))
  4007. client->RepairItem(atoul(sep->arg[0]));
  4008. break;
  4009. }
  4010. case COMMAND_MENDER_REPAIR_ALL: {
  4011. client->RepairAllItems();
  4012. break;
  4013. }
  4014. case COMMAND_CANCEL_MERCHANT:{
  4015. client->SetMerchantTransaction(0);
  4016. break;
  4017. }
  4018. case COMMAND_START_MERCHANT:{
  4019. break;
  4020. }
  4021. case COMMAND_INVULNERABLE:{
  4022. sint8 val = -1;
  4023. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4024. val = atoi(sep->arg[0]);
  4025. //devn00b: Fix for linux builds
  4026. #if defined(__GNUC__)
  4027. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  4028. #else
  4029. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4030. #endif
  4031. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4032. client->GetPlayer()->SetInvulnerable(val==1);
  4033. if(client->GetPlayer()->GetInvulnerable())
  4034. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  4035. else
  4036. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  4037. }
  4038. if(val == -1)
  4039. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  4040. break;
  4041. }
  4042. case COMMAND_REPAIR: {
  4043. Spawn* spawn = cmdTarget;
  4044. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  4045. client->SendHailCommand(spawn);
  4046. client->SetMerchantTransaction(spawn);
  4047. client->SendRepairList();
  4048. }
  4049. break;
  4050. }
  4051. case COMMAND_LOTTO: {
  4052. Spawn* spawn = cmdTarget;
  4053. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  4054. client->SetMerchantTransaction(spawn);
  4055. client->ShowLottoWindow();
  4056. }
  4057. break;
  4058. }
  4059. case COMMAND_ACCEPT_REWARD:{
  4060. int32 unknown = 0;
  4061. int32 selectable_item_id = 0;
  4062. //Quest *quest = 0;
  4063. /* no idea what the first argument is for (faction maybe?)
  4064. if the reward has a selectable item reward, it's sent as the second argument
  4065. if neither of these are included in the reward, there is no sep
  4066. 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
  4067. only 1 quest or collection reward may be displayed at a time */
  4068. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  4069. unknown = atoul(sep->arg[0]);
  4070. selectable_item_id = atoul(sep->arg[1]);
  4071. }
  4072. /* this logic here may seem unexpected, but the quest queue response for GetPendingQuestAcceptance is only populated if it is the current reward displayed to the client based on a quest
  4073. ** Otherwise it will likely be a DoF client scenario (pending item rewards, selectable item rewards) which is specifying an item id
  4074. ** lastly it will be a collection which also supplies an item id and you can only have one pending collection turn in at a time (they queue against Client::HandInCollections
  4075. */
  4076. int32 item_id = 0;
  4077. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  4078. item_id = atoul(sep->arg[0]);
  4079. bool collectedItems = client->GetPlayer()->AcceptQuestReward(item_id, selectable_item_id);
  4080. if (collectedItems) {
  4081. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4082. if (outapp)
  4083. client->QueuePacket(outapp);
  4084. }
  4085. else
  4086. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  4087. break;
  4088. }
  4089. case COMMAND_BUY_FROM_BROKER:{
  4090. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4091. int32 item_id = atoul(sep->arg[0]);
  4092. int16 quantity = atoul(sep->arg[1]);
  4093. Item* item = master_item_list.GetItem(item_id);
  4094. if(item && item->generic_info.max_charges > 1)
  4095. quantity = item->generic_info.max_charges;
  4096. client->AddItem(item_id, quantity, AddItemType::BUY_FROM_BROKER);
  4097. }
  4098. break;
  4099. }
  4100. case COMMAND_SEARCH_STORES_PAGE:{
  4101. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4102. int32 page = atoul(sep->arg[0]);
  4103. client->SearchStore(page);
  4104. }
  4105. break;
  4106. }
  4107. case COMMAND_SEARCH_STORES:{
  4108. if(sep && sep->arg[0][0]){
  4109. const char* values = sep->argplus[0];
  4110. if(values){
  4111. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  4112. map<string, string> str_values = TranslateBrokerRequest(values);
  4113. vector<Item*>* items = master_item_list.GetItems(str_values, client);
  4114. if(items){
  4115. client->SetItemSearch(items);
  4116. client->SearchStore(0);
  4117. }
  4118. }
  4119. }
  4120. break;
  4121. }
  4122. case COMMAND_LUADEBUG:{
  4123. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  4124. client->SetLuaDebugClient(true);
  4125. if(lua_interface)
  4126. lua_interface->UpdateDebugClients(client);
  4127. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4128. }
  4129. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  4130. client->SetLuaDebugClient(false);
  4131. if(lua_interface)
  4132. lua_interface->RemoveDebugClients(client);
  4133. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4134. }
  4135. else{
  4136. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  4137. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  4138. }
  4139. break;
  4140. }
  4141. case COMMAND_SPAWN_GROUP:
  4142. {
  4143. Spawn* target = cmdTarget;
  4144. if(target && target->IsPlayer() == false)
  4145. {
  4146. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  4147. {
  4148. if(target->GetSpawnLocationPlacementID() > 0)
  4149. {
  4150. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  4151. {
  4152. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  4153. if(id > 0)
  4154. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  4155. else
  4156. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  4157. target->SetSpawnGroupID(id);
  4158. target->AddSpawnToGroup(target);
  4159. }
  4160. else
  4161. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  4162. }
  4163. else
  4164. 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.");
  4165. }
  4166. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  4167. {
  4168. if(sep->arg[1] && sep->IsNumber(1))
  4169. {
  4170. int32 group_id = atoul(sep->arg[1]);
  4171. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  4172. if(leader)
  4173. {
  4174. leader->AddSpawnToGroup(target);
  4175. target->SetSpawnGroupID(group_id);
  4176. if(database.SpawnGroupAddSpawn(target, group_id))
  4177. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  4178. else
  4179. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  4180. }
  4181. else
  4182. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  4183. }
  4184. else
  4185. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  4186. }
  4187. else if(target->GetSpawnGroupID() == 0)
  4188. {
  4189. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  4190. }
  4191. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  4192. {
  4193. int32 group_id = target->GetSpawnGroupID();
  4194. target->RemoveSpawnFromGroup();
  4195. if(database.SpawnGroupRemoveSpawn(target, group_id))
  4196. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  4197. else
  4198. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  4199. }
  4200. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  4201. {
  4202. int32 group_id = target->GetSpawnGroupID();
  4203. if(sep->arg[1] && sep->IsNumber(1))
  4204. {
  4205. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  4206. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  4207. else
  4208. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  4209. }
  4210. else
  4211. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  4212. }
  4213. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  4214. {
  4215. int32 group_id = target->GetSpawnGroupID();
  4216. if(sep->arg[1] && sep->IsNumber(1))
  4217. {
  4218. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  4219. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  4220. else
  4221. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  4222. }
  4223. else
  4224. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  4225. }
  4226. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  4227. {
  4228. if(sep->arg[1] && sep->IsNumber(1))
  4229. {
  4230. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  4231. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  4232. else
  4233. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  4234. }
  4235. else
  4236. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  4237. }
  4238. else
  4239. {
  4240. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  4241. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  4242. }
  4243. }
  4244. else
  4245. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  4246. break;
  4247. }
  4248. case COMMAND_SPAWN_COMBINE:{
  4249. Spawn* spawn = cmdTarget;
  4250. float radius = 0;
  4251. bool failed = true;
  4252. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  4253. failed = false;
  4254. if(spawn->GetSpawnGroupID() > 0){
  4255. 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.");
  4256. }
  4257. else if(sep->IsNumber(0)){
  4258. radius = atof(sep->arg[0]);
  4259. client->CombineSpawns(radius, spawn);
  4260. }
  4261. else{
  4262. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  4263. client->AddCombineSpawn(spawn);
  4264. }
  4265. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  4266. client->RemoveCombineSpawn(spawn);
  4267. }
  4268. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  4269. const char* name = 0;
  4270. if(sep->arg[1] && sep->arg[1][0])
  4271. name = sep->argplus[1];
  4272. client->SaveCombineSpawns(name);
  4273. }
  4274. else
  4275. failed = true;
  4276. }
  4277. }
  4278. if(failed){
  4279. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  4280. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  4281. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  4282. }
  4283. break;
  4284. }
  4285. case COMMAND_SPAWN_CREATE:{
  4286. Spawn* spawn = 0;
  4287. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4288. spawn = new Object();
  4289. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4290. }
  4291. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4292. spawn = new GroundSpawn();
  4293. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4294. }
  4295. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4296. spawn = new Sign();
  4297. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4298. }
  4299. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4300. spawn = new NPC();
  4301. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4302. spawn->appearance.pos.collision_radius = 32;
  4303. spawn->secondary_command_list_id = 0;
  4304. spawn->primary_command_list_id = 0;
  4305. spawn->appearance.display_name = 1;
  4306. spawn->appearance.show_level = 1;
  4307. spawn->appearance.attackable = 1;
  4308. }
  4309. else{
  4310. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  4311. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  4312. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  4313. break;
  4314. }
  4315. spawn->SetID(Spawn::NextID());
  4316. spawn->SetX(client->GetPlayer()->GetX());
  4317. spawn->SetY(client->GetPlayer()->GetY());
  4318. spawn->SetZ(client->GetPlayer()->GetZ());
  4319. spawn->SetHeading(client->GetPlayer()->GetHeading());
  4320. spawn->SetSpawnOrigX(spawn->GetX());
  4321. spawn->SetSpawnOrigY(spawn->GetY());
  4322. spawn->SetSpawnOrigZ(spawn->GetZ());
  4323. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4324. if(spawn->IsSign())
  4325. {
  4326. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  4327. ((Sign*)spawn)->SetSignDistance(20.0f);
  4328. ((Sign*)spawn)->SetIncludeLocation(1);
  4329. ((Sign*)spawn)->SetIncludeHeading(1);
  4330. ((Sign*)spawn)->SetInitialState(1);
  4331. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  4332. ((Sign*)spawn)->SetActivityStatus(64);
  4333. spawn->appearance.race = 0;
  4334. spawn->SetLevel(0);
  4335. spawn->SetHP(0);
  4336. spawn->SetTotalHP(0);
  4337. spawn->SetPower(0);
  4338. spawn->SetTotalPower(0);
  4339. spawn->SetDifficulty(0);
  4340. spawn->SetTargetable(0);
  4341. spawn->SetSogaModelType(0);
  4342. spawn->SetCollisionRadius(19);
  4343. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  4344. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  4345. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  4346. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4347. spawn->appearance.model_type = atoul(sep->arg[1]);
  4348. }
  4349. else
  4350. {
  4351. spawn->appearance.targetable = 1;
  4352. spawn->appearance.race = 255;
  4353. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4354. spawn->SetModelType(atoi(sep->arg[1]));
  4355. spawn->SetAdventureClass(atoi(sep->arg[2]));
  4356. spawn->SetLevel(atoi(sep->arg[3]));
  4357. spawn->SetName(sep->arg[4]);
  4358. if(sep->arg[5][0] && sep->IsNumber(5))
  4359. spawn->SetDifficulty(atoi(sep->arg[5]));
  4360. if(sep->arg[6][0] && sep->IsNumber(6))
  4361. spawn->size = atoi(sep->arg[6]);
  4362. if(spawn->GetTotalHP() == 0){
  4363. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  4364. spawn->SetHP(25*spawn->GetLevel() + 1);
  4365. }
  4366. if(spawn->GetTotalPower() == 0){
  4367. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  4368. spawn->SetPower(25*spawn->GetLevel() + 1);
  4369. }
  4370. }
  4371. client->GetCurrentZone()->AddSpawn(spawn);
  4372. break;
  4373. }
  4374. case COMMAND_SPAWN_EQUIPMENT:{
  4375. Spawn* spawn = cmdTarget;
  4376. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  4377. int8 slot = atoi(sep->arg[0]);
  4378. int16 type = atoi(sep->arg[1]);
  4379. int8 red = 0;
  4380. int8 green = 0;
  4381. int8 blue = 0;
  4382. int8 h_red = 0;
  4383. int8 h_green = 0;
  4384. int8 h_blue = 0;
  4385. if(sep->arg[2])
  4386. red = atoi(sep->arg[2]);
  4387. if(sep->arg[3])
  4388. green = atoi(sep->arg[3]);
  4389. if(sep->arg[4])
  4390. blue = atoi(sep->arg[4]);
  4391. if(sep->arg[5])
  4392. h_red = atoi(sep->arg[5]);
  4393. if(sep->arg[6])
  4394. h_green = atoi(sep->arg[6]);
  4395. if(sep->arg[7])
  4396. h_blue = atoi(sep->arg[7]);
  4397. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  4398. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  4399. }
  4400. else{
  4401. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  4402. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  4403. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  4404. }
  4405. break;
  4406. }
  4407. case COMMAND_SPAWN_DETAILS: {
  4408. Spawn* spawn = cmdTarget;
  4409. if (sep && sep->arg[0][0]) {
  4410. if (cmdTarget)
  4411. {
  4412. if (ToLower(string(sep->arg[0])) == "los")
  4413. {
  4414. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  4415. if (hasLOS)
  4416. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  4417. else
  4418. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  4419. break;
  4420. }
  4421. else if (ToLower(string(sep->arg[0])) == "bestz")
  4422. {
  4423. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  4424. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  4425. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  4426. break;
  4427. }
  4428. else if (ToLower(string(sep->arg[0])) == "inwater")
  4429. {
  4430. if (cmdTarget->GetRegionMap() == nullptr)
  4431. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  4432. else
  4433. {
  4434. bool inWater = cmdTarget->InWater();
  4435. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  4436. }
  4437. break;
  4438. }
  4439. else if (ToLower(string(sep->arg[0])) == "inlava")
  4440. {
  4441. if (cmdTarget->GetRegionMap() == nullptr)
  4442. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4443. else
  4444. {
  4445. bool inLava = cmdTarget->InLava();
  4446. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  4447. }
  4448. break;
  4449. }
  4450. else if (ToLower(string(sep->arg[0])) == "regions")
  4451. {
  4452. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  4453. if (cmdTarget->GetRegionMap() == nullptr)
  4454. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4455. else
  4456. {
  4457. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  4458. }
  4459. break;
  4460. }
  4461. else if (ToLower(string(sep->arg[0])) == "behind")
  4462. {
  4463. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  4464. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  4465. break;
  4466. }
  4467. else if (ToLower(string(sep->arg[0])) == "infront")
  4468. {
  4469. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  4470. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  4471. break;
  4472. }
  4473. else if (ToLower(string(sep->arg[0])) == "flank")
  4474. {
  4475. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  4476. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  4477. break;
  4478. }
  4479. else if (ToLower(string(sep->arg[0])) == "aggro")
  4480. {
  4481. if(cmdTarget->IsNPC() && ((NPC*)cmdTarget)->Brain()) {
  4482. ((NPC*)cmdTarget)->Brain()->SendEncounterList(client);
  4483. ((NPC*)cmdTarget)->Brain()->SendHateList(client);
  4484. }
  4485. else {
  4486. client->SimpleMessage(CHANNEL_COLOR_RED, "/spawn details aggro is for NPCs only!");
  4487. }
  4488. break;
  4489. }
  4490. else if (ToLower(string(sep->arg[0])) == "angle")
  4491. {
  4492. float spawnAngle = client->GetPlayer()->GetFaceTarget(cmdTarget->GetX(), cmdTarget->GetZ());
  4493. client->Message(CHANNEL_COLOR_YELLOW, "Angle %f between player %s and target %s", spawnAngle, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget()->GetName() : client->GetPlayer()->GetName(), client->GetPlayer()->GetName());
  4494. break;
  4495. }
  4496. }
  4497. if (sep->IsNumber(0))
  4498. {
  4499. float radius = atof(sep->arg[0]);
  4500. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  4501. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  4502. break;
  4503. }
  4504. }
  4505. if (spawn) {
  4506. const char* type = "NPC";
  4507. if (spawn->IsObject())
  4508. type = "Object";
  4509. else if (spawn->IsSign())
  4510. type = "Sign";
  4511. else if (spawn->IsWidget())
  4512. type = "Widget";
  4513. else if (spawn->IsGroundSpawn())
  4514. type = "GroundSpawn";
  4515. int16 race_type = race_types_list.GetRaceType(spawn->GetModelType());
  4516. int16 race_base_type = race_types_list.GetRaceBaseType(spawn->GetModelType());
  4517. char* category = race_types_list.GetRaceTypeCategory(spawn->GetModelType());
  4518. char* subcategory = race_types_list.GetRaceTypeSubCategory(spawn->GetModelType());
  4519. char* modelname = race_types_list.GetRaceTypeModelName(spawn->GetModelType());
  4520. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  4521. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  4522. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  4523. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  4524. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  4525. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  4526. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u / %u, Power: %u / %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetTotalHP(), spawn->GetPower(), spawn->GetTotalPower());
  4527. 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());
  4528. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetDifficulty(), spawn->GetHeroic());
  4529. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  4530. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  4531. if (spawn->IsEntity()) {
  4532. 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());
  4533. 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());
  4534. }
  4535. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i, Race Type: %u, Race Base Type: %u, Race Category: %s (subcategory: %s), Model Name: %s.", spawn->GetModelType(), spawn->GetSogaModelType(), race_type, race_base_type, category, subcategory, modelname);
  4536. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  4537. 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());
  4538. 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);
  4539. if (spawn->IsNPC())
  4540. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  4541. if (spawn->IsNPC()){
  4542. client->Message(CHANNEL_COLOR_YELLOW, "Heat Resist/Base: %u/%u",((NPC*)spawn)->GetHeatResistance(), ((NPC*)spawn)->GetHeatResistanceBase());
  4543. client->Message(CHANNEL_COLOR_YELLOW, "Cold Resist/Base: %u/%u",((NPC*)spawn)->GetColdResistance(), ((NPC*)spawn)->GetColdResistanceBase());
  4544. client->Message(CHANNEL_COLOR_YELLOW, "Magic Resist/Base: %u/%u",((NPC*)spawn)->GetMagicResistance(), ((NPC*)spawn)->GetMagicResistanceBase());
  4545. client->Message(CHANNEL_COLOR_YELLOW, "Mental Resist/Base: %u/%u",((NPC*)spawn)->GetMentalResistance(), ((NPC*)spawn)->GetMentalResistanceBase());
  4546. client->Message(CHANNEL_COLOR_YELLOW, "Divine Resist/Base: %u/%u",((NPC*)spawn)->GetDivineResistance(), ((NPC*)spawn)->GetDivineResistanceBase());
  4547. client->Message(CHANNEL_COLOR_YELLOW, "Disease Resist/Base: %u/%u",((NPC*)spawn)->GetDiseaseResistance(), ((NPC*)spawn)->GetDiseaseResistanceBase());
  4548. client->Message(CHANNEL_COLOR_YELLOW, "Poison Resist/Base: %u/%u",((NPC*)spawn)->GetPoisonResistance(), ((NPC*)spawn)->GetPoisonResistanceBase());
  4549. }
  4550. string details;
  4551. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  4552. details += "Type: " + string(type) + "\n";
  4553. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  4554. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  4555. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  4556. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  4557. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  4558. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  4559. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  4560. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  4561. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  4562. details += "HP: " + to_string(spawn->GetHP()) + " / " + to_string(spawn->GetTotalHP()) + "(" + to_string(spawn->GetIntHPRatio()) + "%)\n";
  4563. details += "Power: " + to_string(spawn->GetPower()) + + " / " + to_string(spawn->GetTotalPower()) + "\n";
  4564. details += "Difficulty: " + to_string(spawn->GetDifficulty()) + "\n";
  4565. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  4566. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  4567. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  4568. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  4569. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  4570. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  4571. char x[16];
  4572. sprintf(x, "%.2f", spawn->GetX());
  4573. char y[16];
  4574. sprintf(y, "%.2f", spawn->GetY());
  4575. char z[16];
  4576. sprintf(z, "%.2f", spawn->GetZ());
  4577. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  4578. string details2;
  4579. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  4580. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  4581. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  4582. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  4583. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  4584. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  4585. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  4586. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  4587. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  4588. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  4589. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  4590. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  4591. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  4592. details2 += "Race Type: " + to_string(race_type) + "\n";
  4593. details2 += "Race Base Type: " + to_string(race_base_type) + "\n";
  4594. details2 += "Race Category (Sub Category): " + std::string(category) + " (" + std::string(subcategory) + ")\n";
  4595. details2 += "Model Name: " + std::string(modelname) + "\n";
  4596. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  4597. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  4598. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  4599. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  4600. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  4601. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  4602. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  4603. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  4604. string details3;
  4605. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  4606. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  4607. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  4608. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  4609. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  4610. if(spawn->IsSign()) {
  4611. details3 += "Sign Language: " + to_string(((Sign*)spawn)->GetLanguage()) + "\n";
  4612. }
  4613. if(spawn->IsEntity())
  4614. {
  4615. Entity* ent = (Entity*)spawn;
  4616. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  4617. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  4618. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  4619. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  4620. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  4621. }
  4622. string details4;
  4623. if (spawn->IsEntity()) {
  4624. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  4625. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4626. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4627. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4628. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4629. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4630. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4631. if (spawn->IsNPC()) {
  4632. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4633. }
  4634. }
  4635. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4636. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4637. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4638. client->SendShowBook(client->GetPlayer(), title, 0, 4, details, details2, details3, details4);
  4639. }
  4640. else {
  4641. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4642. 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.");
  4643. }
  4644. break;
  4645. }
  4646. case COMMAND_SPAWN_TARGET:{
  4647. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4648. int32 spawn_id = atoul(sep->arg[0]);
  4649. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4650. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4651. }
  4652. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4653. float distance = atof(sep->arg[1]);
  4654. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4655. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4656. }
  4657. else{
  4658. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4659. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4660. }
  4661. break;
  4662. }
  4663. case COMMAND_SPAWN_SET:
  4664. {
  4665. Spawn* spawn = cmdTarget;
  4666. sint16 set_type = -1;
  4667. string type_str;
  4668. if (spawn)
  4669. {
  4670. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4671. 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)
  4672. {
  4673. // set the type, which will be 0 if location or list or invalid
  4674. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4675. }
  4676. if(set_type > 0)
  4677. {
  4678. // check if spawn set is NOT a char update, or not location, or isn't a number
  4679. 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)
  4680. {
  4681. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4682. }
  4683. else
  4684. {
  4685. string name = string(spawn->GetName());
  4686. bool customSetSpawn = false;
  4687. if(set_type >= SPAWN_SET_CHEEK_TYPE && set_type <= SPAWN_SET_SOGA_NOSE_TYPE)
  4688. {
  4689. int8 index = sep->IsNumber(2) ? atoul(sep->arg[2]) : 0;
  4690. // override the standard setspawncommand, we pass arguments different!
  4691. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1], true, false, nullptr, index))
  4692. customSetSpawn = true;
  4693. }
  4694. if(customSetSpawn || SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4695. {
  4696. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4697. {
  4698. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4699. }
  4700. else if (set_type == SPAWN_SET_VALUE_NAME)
  4701. {
  4702. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4703. }
  4704. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4705. {
  4706. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4707. }
  4708. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4709. {
  4710. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4711. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s' (DBID: %u)", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str(), spawn->GetDatabaseID());
  4712. }
  4713. else
  4714. {
  4715. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s' (DBID: %u)", sep->arg[0], sep->arg[1], name.c_str(), spawn->GetDatabaseID());
  4716. }
  4717. switch (set_type)
  4718. {
  4719. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4720. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4721. case SPAWN_SET_VALUE_FACTION:
  4722. case SPAWN_SET_AAXP_REWARDS:
  4723. case SPAWN_SET_CHEEK_TYPE:
  4724. case SPAWN_SET_CHIN_TYPE:
  4725. case SPAWN_SET_EAR_TYPE:
  4726. case SPAWN_SET_EYE_BROW_TYPE:
  4727. case SPAWN_SET_EYE_TYPE:
  4728. case SPAWN_SET_LIP_TYPE:
  4729. case SPAWN_SET_NOSE_TYPE:
  4730. case SPAWN_SET_BODY_SIZE:
  4731. case SPAWN_SET_BODY_AGE:
  4732. case SPAWN_SET_SOGA_CHEEK_TYPE:
  4733. case SPAWN_SET_SOGA_CHIN_TYPE:
  4734. case SPAWN_SET_SOGA_EAR_TYPE:
  4735. case SPAWN_SET_SOGA_EYE_BROW_TYPE:
  4736. case SPAWN_SET_SOGA_EYE_TYPE:
  4737. case SPAWN_SET_SOGA_LIP_TYPE:
  4738. case SPAWN_SET_SOGA_NOSE_TYPE:
  4739. case SPAWN_SET_SOGA_BODY_SIZE:
  4740. case SPAWN_SET_SOGA_BODY_AGE:
  4741. case SPAWN_SET_ATTACK_TYPE:
  4742. case SPAWN_SET_RACE_TYPE:
  4743. case SPAWN_SET_LOOT_TIER:
  4744. case SPAWN_SET_LOOT_DROP_TYPE:
  4745. case SPAWN_SET_SCARED_STRONG_PLAYERS:
  4746. {
  4747. // not applicable already ran db command
  4748. break;
  4749. }
  4750. default:
  4751. {
  4752. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4753. break;
  4754. }
  4755. }
  4756. 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))
  4757. {
  4758. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4759. {
  4760. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4761. }
  4762. else if(spawn->GetSpawnLocationID() > 0)
  4763. {
  4764. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4765. }
  4766. }
  4767. else
  4768. {
  4769. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4770. {
  4771. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4772. }
  4773. else if(spawn->GetDatabaseID() > 0)
  4774. {
  4775. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4776. }
  4777. }
  4778. }
  4779. }
  4780. }
  4781. else if(set_type == 0)
  4782. {
  4783. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4784. map<string, int8>::iterator itr;
  4785. int i=0;
  4786. string list;
  4787. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4788. {
  4789. if(i==10)
  4790. {
  4791. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4792. i = 0;
  4793. }
  4794. if(i>0)
  4795. {
  4796. list.append(", ").append(itr->first);
  4797. }
  4798. else
  4799. {
  4800. list = itr->first;
  4801. }
  4802. }
  4803. if(list.length() > 0)
  4804. {
  4805. // if 1 or more, display in client.
  4806. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4807. }
  4808. }
  4809. else
  4810. {
  4811. // syntax fail
  4812. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4813. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4814. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4815. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4816. }
  4817. }
  4818. break;
  4819. }
  4820. case COMMAND_SPAWN_REMOVE:{
  4821. Spawn* spawn = cmdTarget;
  4822. if(spawn && !spawn->IsPlayer()){
  4823. if(spawn->GetSpawnLocationID() > 0){
  4824. string name = string(spawn->GetName());
  4825. int32 dbid = spawn->GetDatabaseID();
  4826. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4827. client->GetCurrentZone()->RemoveSpawn(spawn, true, false, true, true, true);
  4828. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone for spawn '%s' (DBID: %u)", name.c_str(), dbid);
  4829. }
  4830. else
  4831. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4832. }
  4833. else
  4834. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4835. }
  4836. else{
  4837. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4838. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4839. }
  4840. break;
  4841. }
  4842. case COMMAND_SPAWN_LIST:{
  4843. if(sep && sep->arg[0][0]){
  4844. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4845. vector<string>::iterator itr;
  4846. if(results){
  4847. for(itr=results->begin();itr!=results->end();itr++){
  4848. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4849. }
  4850. safe_delete(results);
  4851. }
  4852. else
  4853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4854. }
  4855. else{
  4856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4859. }
  4860. break;
  4861. }
  4862. case COMMAND_SPAWN_ADD:{
  4863. Spawn* spawn = cmdTarget;
  4864. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  4865. if(spawn->GetSpawnLocationID() > 0){
  4866. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4867. break;
  4868. }
  4869. if(spawn->GetDatabaseID() == 0){
  4870. if(database.SaveSpawnInfo(spawn)) {
  4871. char spawn_type[32];
  4872. memset(spawn_type, 0, sizeof(spawn_type));
  4873. if (spawn->IsNPC())
  4874. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4875. else if (spawn->IsObject())
  4876. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4877. else if (spawn->IsSign())
  4878. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4879. else if (spawn->IsGroundSpawn())
  4880. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4881. else
  4882. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4883. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4884. }
  4885. else
  4886. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4887. }
  4888. int32 spawn_group_id = 0;
  4889. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4890. spawn_group_id = database.GetNextSpawnLocation();
  4891. else
  4892. spawn_group_id = atol(sep->arg[0]);
  4893. int8 percent = 100;
  4894. if(sep->arg[2] && sep->IsNumber(2))
  4895. percent = atoi(sep->arg[2]);
  4896. spawn->SetSpawnLocationID(spawn_group_id);
  4897. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4898. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4899. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4900. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4901. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4902. else
  4903. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  4904. }
  4905. else{
  4906. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  4907. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  4908. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  4909. }
  4910. break;
  4911. }
  4912. case COMMAND_SPAWN:{
  4913. int32 id = 0;
  4914. Spawn* spawn = 0;
  4915. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4916. id = atol(sep->arg[0]);
  4917. spawn = client->GetCurrentZone()->GetSpawn(id);
  4918. }
  4919. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  4920. id = 0;
  4921. if(!id || !spawn){
  4922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  4923. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  4924. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  4925. safe_delete(sep);
  4926. return;
  4927. }
  4928. if(sep && sep->arg[1][0]){
  4929. float x = atof(sep->arg[1]);
  4930. spawn->appearance.pos.X = x;
  4931. }
  4932. else
  4933. spawn->SetX(client->GetPlayer()->GetX(), false);
  4934. if(sep && sep->arg[2][0]){
  4935. float y = atof(sep->arg[2]);
  4936. spawn->appearance.pos.Y = y;
  4937. }
  4938. else
  4939. spawn->SetY(client->GetPlayer()->GetY(), false);
  4940. if(sep && sep->arg[3][0]){
  4941. float z = atof(sep->arg[3]);
  4942. spawn->appearance.pos.Z = z;
  4943. }
  4944. else
  4945. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  4946. if(sep && sep->arg[4][0]){
  4947. float heading = atof(sep->arg[4]);
  4948. spawn->SetHeading(heading);
  4949. }
  4950. else
  4951. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  4952. spawn->SetSpawnOrigX(spawn->GetX());
  4953. spawn->SetSpawnOrigY(spawn->GetY());
  4954. spawn->SetSpawnOrigZ(spawn->GetZ());
  4955. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4956. if(sep && sep->arg[5][0])
  4957. spawn->SetLocation(atoul(sep->arg[5]));
  4958. else
  4959. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4960. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  4961. spawn->SetTotalHP(spawn->GetLevel() * 15);
  4962. spawn->SetHP(spawn->GetTotalHP());
  4963. }
  4964. if(spawn->GetTotalPower() == 0){
  4965. spawn->SetTotalPower(spawn->GetLevel() * 15);
  4966. spawn->SetPower(spawn->GetTotalPower());
  4967. }
  4968. const char* script = world.GetSpawnScript(id);
  4969. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  4970. spawn->SetSpawnScript(string(script));
  4971. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  4972. client->GetCurrentZone()->AddSpawn(spawn);
  4973. if(spawn->IsNPC())
  4974. spawn->GetZone()->AddLoot((NPC*)spawn);
  4975. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  4976. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  4977. break;
  4978. }
  4979. case COMMAND_ADMINFLAG:
  4980. {
  4981. if(sep && sep->arg[0]){
  4982. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  4983. sint16 new_status = atoi(sep->arg[1]);
  4984. if(tmp_status == -10)
  4985. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  4986. else if(tmp_status >= client->GetAdminStatus())
  4987. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  4988. else if (new_status > client->GetAdminStatus())
  4989. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  4990. else{
  4991. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  4992. if (!client2)
  4993. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  4994. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  4995. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  4996. if (client2) {
  4997. client2->SetAdminStatus(new_status);
  4998. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  4999. }
  5000. }
  5001. else
  5002. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  5003. }
  5004. }else{
  5005. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  5006. if(status != client->GetAdminStatus())
  5007. {
  5008. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  5009. client->SetAdminStatus(status);
  5010. }
  5011. else
  5012. {
  5013. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  5014. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  5015. client->Message(CHANNEL_COLOR_YELLOW," Admin User: %i", status);
  5016. }
  5017. }
  5018. break;
  5019. }
  5020. case COMMAND_CANNEDEMOTE:{
  5021. client->GetCurrentZone()->HandleEmote(client->GetPlayer(), command_parms->data);
  5022. break;
  5023. }
  5024. case COMMAND_BROADCAST: {
  5025. if (sep && sep->arg[0])
  5026. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  5027. else
  5028. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  5029. break;
  5030. }
  5031. case COMMAND_ANNOUNCE: {
  5032. if (sep && sep->arg[0])
  5033. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  5034. else
  5035. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  5036. break;
  5037. }
  5038. case COMMAND_RELOAD_ITEMS:{
  5039. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  5040. int32 item_id = (sep && sep->arg[0]) ? atoul(sep->arg[0]) : 0;
  5041. if(item_id > 0) {
  5042. client->Message(CHANNEL_COLOR_YELLOW, "Reloading item %u based on /reload items [item_id].", item_id);
  5043. }
  5044. else {
  5045. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  5046. }
  5047. database.ReloadItemList(item_id);
  5048. if(!item_id) {
  5049. database.LoadMerchantInformation(); // we skip if there is only a reload of single item not all items
  5050. }
  5051. if(item_id > 0) {
  5052. client->Message(CHANNEL_COLOR_YELLOW, "Reloaded item %u.", item_id);
  5053. }
  5054. else {
  5055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  5056. }
  5057. break;
  5058. }
  5059. case COMMAND_ENABLE_ABILITY_QUE:{
  5060. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  5061. if(app)
  5062. client->QueuePacket(app);
  5063. break;
  5064. }
  5065. case COMMAND_ITEMSEARCH:
  5066. case COMMAND_FROMBROKER:{
  5067. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  5068. if (packet) {
  5069. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  5070. //packet->setDataByName("unknown", 1);
  5071. packet->setDataByName("unknown2", 5, 0);
  5072. packet->setDataByName("unknown2", 20, 1);
  5073. packet->setDataByName("unknown2", 58, 3);
  5074. packet->setDataByName("unknown2", 40, 4);
  5075. client->QueuePacket(packet->serialize());
  5076. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  5077. if (packet2) {
  5078. packet2->setDataByName("char_id", client->GetCharacterID());
  5079. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  5080. safe_delete(packet2);
  5081. }
  5082. safe_delete(packet);
  5083. }
  5084. break;
  5085. }
  5086. case COMMAND_ANIMTEST:{
  5087. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  5088. if(command_packet){
  5089. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  5090. if (cmdTarget)
  5091. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  5092. command_packet->setDataByName ( "spawn_id" , id);
  5093. int animID = 1;
  5094. if(sep && sep->arg[0] && sep->IsNumber(0))
  5095. animID = atoi(sep->arg[0]);
  5096. VisualState* vs = NULL;
  5097. if(animID == 0)
  5098. {
  5099. vs = visual_states.FindVisualState(sep->arg[0]);
  5100. }
  5101. char msg[128];
  5102. sprintf(msg,"Animation Test ID: %i",animID);
  5103. command_packet->setMediumStringByName ( "emote_msg" , msg );
  5104. if(vs != NULL)
  5105. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  5106. else
  5107. command_packet->setDataByName ( "anim_type", animID );
  5108. command_packet->setDataByName ( "unknown0", 0 );
  5109. EQ2Packet* outapp = command_packet->serialize();
  5110. client->QueuePacket(outapp);
  5111. safe_delete(command_packet);
  5112. }
  5113. break;
  5114. }
  5115. case COMMAND_KICK:
  5116. {
  5117. if( sep == 0 || sep->arg[0] == 0)
  5118. {
  5119. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  5120. }
  5121. else
  5122. {
  5123. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  5124. if ( kickClient == client )
  5125. {
  5126. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  5127. break;
  5128. }
  5129. else if(kickClient != NULL)
  5130. {
  5131. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5132. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  5133. {
  5134. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5135. break;
  5136. }
  5137. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  5138. kickClient->Disconnect();
  5139. }
  5140. else
  5141. {
  5142. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5143. }
  5144. }
  5145. break;
  5146. }
  5147. case COMMAND_LOCK:
  5148. {
  5149. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  5150. int worldLocked = atoi(sep->arg[0]);
  5151. net.world_locked = worldLocked;
  5152. if ( worldLocked )
  5153. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  5154. else
  5155. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  5156. }
  5157. else
  5158. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  5159. break;
  5160. }
  5161. case COMMAND_BAN:{
  5162. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  5163. {
  5164. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  5165. }
  5166. else
  5167. {
  5168. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  5169. if ( kickClient == client )
  5170. {
  5171. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  5172. break;
  5173. }
  5174. else if(kickClient != NULL)
  5175. {
  5176. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5177. if ( maxStatus > client->GetAdminStatus( ) ||
  5178. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  5179. {
  5180. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5181. break;
  5182. }
  5183. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  5184. int perm = atol(sep->arg[1]);
  5185. if ( perm == 1 )
  5186. database.UpdateAdminStatus(sep->arg[0],-2);
  5187. else
  5188. database.UpdateAdminStatus(sep->arg[0],-1);
  5189. kickClient->Disconnect();
  5190. }
  5191. else
  5192. {
  5193. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5194. }
  5195. }
  5196. break;
  5197. }
  5198. case COMMAND_SET_COMBAT_VOICE:{
  5199. int32 value = 0;
  5200. if(sep && sep->arg[0] && sep->IsNumber(0))
  5201. value = atoi(sep->arg[0]);
  5202. client->GetPlayer()->SetCombatVoice(value);
  5203. break;
  5204. }
  5205. case COMMAND_SET_EMOTE_VOICE:{
  5206. int32 value = 0;
  5207. if(sep && sep->arg[0] && sep->IsNumber(0))
  5208. value = atoi(sep->arg[0]);
  5209. client->GetPlayer()->SetEmoteVoice(value);
  5210. break;
  5211. }
  5212. case COMMAND_GIVEITEM:{
  5213. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  5214. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  5215. if ( itemToClient == NULL )
  5216. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  5217. else
  5218. {
  5219. int32 item_id = atol(sep->arg[1]);
  5220. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  5221. itemToClient->AddItem(item_id);
  5222. }
  5223. }
  5224. else
  5225. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  5226. break;
  5227. }
  5228. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  5229. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  5230. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  5231. case COMMAND_SKILL :
  5232. case COMMAND_SKILL_ADD :
  5233. case COMMAND_SKILL_REMOVE :
  5234. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  5235. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  5236. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  5237. case COMMAND_ENTITYCOMMAND :
  5238. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  5239. case COMMAND_MERCHANT :
  5240. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  5241. case COMMAND_APPEARANCE :
  5242. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  5243. case COMMAND_TRACK : { Command_Track(client); break; }
  5244. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  5245. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  5246. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  5247. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  5248. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  5249. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  5250. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  5251. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  5252. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  5253. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  5254. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  5255. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  5256. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  5257. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  5258. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  5259. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  5260. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  5261. case COMMAND_LOCATION : { Command_Location(client); break; }
  5262. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  5263. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  5264. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  5265. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  5266. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  5267. case COMMAND_GRID : { Command_Grid(client, sep); break; }
  5268. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  5269. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  5270. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  5271. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  5272. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  5273. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  5274. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  5275. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  5276. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  5277. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  5278. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  5279. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  5280. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  5281. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  5282. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  5283. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  5284. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  5285. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  5286. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  5287. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  5288. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  5289. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  5290. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  5291. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  5292. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  5293. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  5294. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  5295. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  5296. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  5297. case COMMAND_MOTD : { Command_MOTD(client); break; }
  5298. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  5299. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  5300. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  5301. case COMMAND_TITLE : { Command_Title(client); break; }
  5302. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  5303. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  5304. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  5305. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  5306. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  5307. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  5308. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  5309. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  5310. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  5311. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  5312. case COMMAND_PET : { Command_Pet(client, sep); break; }
  5313. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  5314. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  5315. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  5316. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  5317. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  5318. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  5319. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  5320. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  5321. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  5322. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  5323. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  5324. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  5325. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  5326. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  5327. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  5328. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  5329. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  5330. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  5331. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  5332. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  5333. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  5334. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  5335. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  5336. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  5337. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  5338. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  5339. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  5340. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  5341. //devn00b
  5342. case COMMAND_MOOD : { Command_Mood(client, sep); break;}
  5343. case COMMAND_MODIFY : { Command_Modify(client); break; }
  5344. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  5345. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  5346. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  5347. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  5348. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  5349. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  5350. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  5351. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  5352. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  5353. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  5354. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  5355. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  5356. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  5357. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  5358. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  5359. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  5360. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  5361. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  5362. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  5363. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  5364. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  5365. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5366. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  5367. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  5368. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  5369. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  5370. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  5371. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  5372. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  5373. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  5374. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  5375. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  5376. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  5377. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  5378. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  5379. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  5380. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  5381. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  5382. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  5383. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  5384. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  5385. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  5386. case ADD_AA : { Add_AA(client, sep); break; }
  5387. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  5388. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  5389. case BACK_AA : { Back_AA(client, sep); break; }
  5390. case REMOVE_AA : { Remove_AA(client, sep); break; }
  5391. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  5392. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  5393. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  5394. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  5395. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  5396. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  5397. case COMMAND_CRAFTITEM: {
  5398. Item* item = 0;
  5399. if (sep && sep->IsNumber(0)) {
  5400. int32 item_id = atol(sep->arg[0]);
  5401. int32 quantity = 1;
  5402. if (sep->arg[1] && sep->IsNumber(1))
  5403. quantity = atoi(sep->arg[1]);
  5404. item = new Item(master_item_list.GetItem(item_id));
  5405. if (!item) {
  5406. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  5407. }
  5408. else {
  5409. item->details.count = quantity;
  5410. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  5411. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  5412. bool itemDeleted = false;
  5413. client->AddItem(item, &itemDeleted);
  5414. //Check for crafting quest updates
  5415. int8 update_amt = 0;
  5416. if (!itemDeleted && item->stack_count > 1)
  5417. update_amt = 1;
  5418. else
  5419. update_amt = quantity;
  5420. if(!itemDeleted)
  5421. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  5422. }
  5423. }
  5424. else {
  5425. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  5426. }
  5427. break;
  5428. }
  5429. case COMMAND_UNMENTOR:
  5430. case COMMAND_MENTOR: {
  5431. client->GetPlayer()->MentorTarget();
  5432. break;
  5433. }
  5434. case COMMAND_CANCEL_EFFECT: { Command_CancelEffect(client, sep); break; }
  5435. case COMMAND_CUREPLAYER: { Command_CurePlayer(client, sep); break; }
  5436. case COMMAND_SHARE_QUEST: { Command_ShareQuest(client, sep); break; }
  5437. case COMMAND_YELL: { Command_Yell(client, sep); break; }
  5438. case COMMAND_SETAUTOLOOTMODE: { Command_SetAutoLootMode(client, sep); break; }
  5439. case COMMAND_ASSIST: { Command_Assist(client, sep); break; }
  5440. default:
  5441. {
  5442. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  5443. break;
  5444. }
  5445. }
  5446. safe_delete(sep);
  5447. }
  5448. /******************** New COMMAND Handler Functions ********************/
  5449. /*
  5450. Started breaking apart the huge switch() for commands into sepErate
  5451. functions so it is easier to locate the blocks of code by command
  5452. -- JA 2012.03.03
  5453. */
  5454. // sample function header
  5455. /*
  5456. Function:
  5457. Purpose :
  5458. Params :
  5459. Dev :
  5460. Example :
  5461. */
  5462. //void Commands::Command()
  5463. //{
  5464. //}
  5465. /*
  5466. Function: Command_AcceptAdvancement()
  5467. Purpose : Player accepts a new advancement option
  5468. Params : Spell ID
  5469. Dev : Jabantiz
  5470. */
  5471. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  5472. {
  5473. Player *player = client->GetPlayer();
  5474. if (sep && sep->IsSet(0)) {
  5475. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  5476. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  5477. if (!player->HasSpell(trait->spellID, 0, true))
  5478. {
  5479. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5480. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5481. }
  5482. else
  5483. {
  5484. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5485. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  5486. player->RemoveSpellBookEntry(spell->GetSpellID());
  5487. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5488. player->UnlockSpell(spell);
  5489. client->SendSpellUpdate(spell);
  5490. }
  5491. // Spell book update
  5492. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  5493. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  5494. }
  5495. }
  5496. /*
  5497. Function:
  5498. Purpose :
  5499. Params :
  5500. Dev :
  5501. Example :
  5502. */
  5503. void Commands::Command_AFK(Client* client, Seperator* sep)
  5504. {
  5505. Player* player = client->GetPlayer();
  5506. player->toggle_character_flag(CF_AFK);
  5507. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  5508. if (player->get_character_flag(CF_AFK))
  5509. {
  5510. if (sep && sep->argplus[0])
  5511. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  5512. else
  5513. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  5514. string message = string(player->GetName()) + " is going afk.";
  5515. Spawn* target = player->GetTarget();
  5516. if (target && target != player)
  5517. {
  5518. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  5519. player->GetGender() == 1 ? message += "he" : message += "she";
  5520. message += " is going afk.";
  5521. }
  5522. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  5523. }
  5524. }
  5525. /*
  5526. Function: Command_Appearance()
  5527. Purpose : Handles /appearance commands
  5528. Params : list
  5529. Dev : Scatman
  5530. Example : /appearance list
  5531. */
  5532. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  5533. {
  5534. if( handler == COMMAND_APPEARANCE )
  5535. {
  5536. // /appearance command by itself shows help (to be extended)
  5537. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5538. return;
  5539. }
  5540. else if( handler == COMMAND_APPEARANCE_LIST )
  5541. {
  5542. // /appearance list command expects "name" param
  5543. if (sep && sep->arg[0])
  5544. {
  5545. const char* appearance_name = sep->argplus[0];
  5546. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  5547. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  5548. if (appearances)
  5549. {
  5550. vector<int16>::iterator itr;
  5551. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  5552. {
  5553. int16 id = *itr;
  5554. string name = database.GetAppearanceName(id);
  5555. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  5556. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  5557. }
  5558. safe_delete(appearances);
  5559. }
  5560. }
  5561. else // no param
  5562. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5563. }
  5564. }
  5565. /*
  5566. Function: Command_Claim()
  5567. Purpose : Summon veteran rewards
  5568. Params : nothing = show claim window, any number claims that item.
  5569. Dev : devn00b
  5570. Example : /claim 0 (claims the 1st item added to the list claim[0])
  5571. */
  5572. void Commands::Command_Claim(Client* client, Seperator* sep)
  5573. {
  5574. //if we were passed a claim id
  5575. if (sep && sep->argplus[0] && sep->IsNumber(0))
  5576. {
  5577. int32 char_id = client->GetCharacterID();
  5578. int8 my_claim_id = atoi(sep->argplus[0]);
  5579. vector<ClaimItems> claim = database.LoadCharacterClaimItems(char_id);
  5580. Item* item = master_item_list.GetItem(claim[my_claim_id].item_id);
  5581. database.ClaimItem(char_id, item->details.item_id, client);
  5582. return;
  5583. }
  5584. else {
  5585. //if no arg just send the window.
  5586. client->ShowClaimWindow();
  5587. return;
  5588. }
  5589. return;
  5590. }
  5591. /*
  5592. Function: Command_ClearAllQueued()
  5593. Purpose :
  5594. Params :
  5595. Dev :
  5596. Example :
  5597. */
  5598. void Commands::Command_ClearAllQueued(Client* client)
  5599. {
  5600. ZoneServer* zone = client->GetPlayer()->GetZone();
  5601. if (zone && zone->GetSpellProcess())
  5602. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  5603. }
  5604. /*
  5605. Function: Command_CancelMaintained()
  5606. Purpose : Cancels maintained spells
  5607. Params : Maintained Spell Index
  5608. Dev : Zcoretri
  5609. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  5610. */
  5611. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  5612. {
  5613. if (sep && sep->arg[0] && sep->IsNumber(0))
  5614. {
  5615. int32 spell_index = atoul(sep->arg[0]);
  5616. if(spell_index > 29)
  5617. return;
  5618. client->GetPlayer()->MMaintainedSpells.readlock(__FUNCTION__, __LINE__);
  5619. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  5620. client->GetPlayer()->MMaintainedSpells.releasereadlock(__FUNCTION__, __LINE__);
  5621. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled", false))
  5622. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  5623. }
  5624. }
  5625. /*
  5626. Function: Command_Create()
  5627. Purpose : Handler for starting Tradeskilling table
  5628. Params :
  5629. Dev : Zcoretri
  5630. Example :
  5631. */
  5632. void Commands::Command_Create(Client* client, Seperator* sep)
  5633. {
  5634. PrintSep(sep, "COMMAND_CREATE");
  5635. client->ShowRecipeBook();
  5636. }
  5637. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  5638. {
  5639. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  5640. if (sep && sep->arg[0] && sep->IsNumber(0))
  5641. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  5642. }
  5643. /*
  5644. Function: Command_Distance()
  5645. Purpose : Displays distance from targeted spawn
  5646. Params :
  5647. Dev : Scatman
  5648. Example : /distance
  5649. */
  5650. void Commands::Command_Distance(Client* client)
  5651. {
  5652. Spawn* target = client->GetPlayer()->GetTarget();
  5653. if (target)
  5654. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  5655. else
  5656. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  5657. }
  5658. /*
  5659. Function: Command_Duel()
  5660. Purpose : Handle the /duel commands - not yet implemented
  5661. Params : unknown
  5662. Dev :
  5663. Example :
  5664. */
  5665. void Commands::Command_Duel(Client* client, Seperator* sep)
  5666. {
  5667. PrintSep(sep, "COMMAND_DUEL");
  5668. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  5669. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5670. }
  5671. /*
  5672. Function: Command_DuelBet()
  5673. Purpose : Handle the /duel commands - not yet implemented
  5674. Params : unknown
  5675. Dev :
  5676. Example :
  5677. */
  5678. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  5679. {
  5680. PrintSep(sep, "COMMAND_DUELBET");
  5681. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  5682. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5683. }
  5684. /*
  5685. Function: Command_DuelAccept()
  5686. Purpose : Handle the /duel commands - not yet implemented
  5687. Params : unknown
  5688. Dev :
  5689. Example :
  5690. */
  5691. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5692. {
  5693. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5694. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5695. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5696. }
  5697. /*
  5698. Function: Command_DuelDecline()
  5699. Purpose : Handle the /duel commands - not yet implemented
  5700. Params : unknown
  5701. Dev :
  5702. Example :
  5703. */
  5704. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5705. {
  5706. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5707. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5708. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5709. }
  5710. /*
  5711. Function: Command_DuelSurrender()
  5712. Purpose : Handle the /duel commands - not yet implemented
  5713. Params : unknown
  5714. Dev :
  5715. Example :
  5716. */
  5717. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5718. {
  5719. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5720. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5721. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5722. // JA, just messin around ;)
  5723. char surrender[64];
  5724. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5725. zone_list.HandleGlobalAnnouncement(surrender);
  5726. }
  5727. /*
  5728. Function: Command_DuelToggle()
  5729. Purpose : Handle the /duel commands - not yet implemented
  5730. Params : unknown
  5731. Dev :
  5732. Example :
  5733. */
  5734. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5735. {
  5736. PrintSep(sep, "COMMAND_DUEL");
  5737. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5738. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5739. }
  5740. /*
  5741. Function:
  5742. Purpose :
  5743. Params :
  5744. Dev :
  5745. Example :
  5746. */
  5747. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5748. {
  5749. if( handler == COMMAND_ENTITYCOMMAND )
  5750. {
  5751. // /entitycommand command by itself shows help (to be extended)
  5752. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5753. return;
  5754. }
  5755. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5756. {
  5757. // /entitycommand list command expects "name" param
  5758. if (sep && sep->arg[0])
  5759. {
  5760. const char* entity_command_name = sep->argplus[0];
  5761. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5762. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5763. map<int32, vector<EntityCommand*>*>::iterator itr;
  5764. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5765. {
  5766. vector<EntityCommand*>* entity_command_list = itr->second;
  5767. vector<EntityCommand*>::iterator itr2;
  5768. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5769. {
  5770. EntityCommand* entity_command = *itr2;
  5771. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5772. 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);
  5773. }
  5774. }
  5775. }
  5776. else // no command name
  5777. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5778. }
  5779. }
  5780. /*
  5781. Function: Command_Follow()
  5782. Purpose : Handle the /follow command - not yet implemented
  5783. Params :
  5784. Dev :
  5785. Example :
  5786. */
  5787. void Commands::Command_Follow(Client* client, Seperator* sep)
  5788. {
  5789. PrintSep(sep, "COMMAND_FOLLOW");
  5790. // flag to toggle if the players target is in the players group
  5791. bool targetInGroup = false;
  5792. // get a pointer to the players group
  5793. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5794. // If the player has a group and has a target
  5795. if (gmi && client->GetPlayer()->GetTarget()) {
  5796. deque<GroupMemberInfo*>::iterator itr;
  5797. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5798. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5799. if (group)
  5800. {
  5801. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5802. deque<GroupMemberInfo*>* members = group->GetMembers();
  5803. // Loop through the group members
  5804. for (itr = members->begin(); itr != members->end(); itr++) {
  5805. // If a group member matches a target
  5806. if ((*itr)->member && (*itr)->member == client->GetPlayer()->GetTarget()) {
  5807. // toggle the flag and break the loop
  5808. targetInGroup = true;
  5809. break;
  5810. }
  5811. }
  5812. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5813. }
  5814. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5815. }
  5816. if (targetInGroup) {
  5817. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5818. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5819. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5820. client->GetPlayer()->info_changed = true;
  5821. client->GetPlayer()->changed = true;
  5822. }
  5823. else
  5824. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5825. }
  5826. /*
  5827. Function: Command_StopFollow()
  5828. Purpose : Handle the /stop_follow command - not yet implemented
  5829. Params :
  5830. Dev :
  5831. Example :
  5832. */
  5833. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5834. {
  5835. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5836. if (client->GetPlayer()->GetFollowTarget()) {
  5837. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5838. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5839. client->GetPlayer()->SetFollowTarget(0);
  5840. client->GetPlayer()->info_changed = true;
  5841. client->GetPlayer()->changed = true;
  5842. }
  5843. }
  5844. /*
  5845. Function: Command_Grid()
  5846. Purpose : Show player's current Grid ID
  5847. Params :
  5848. Dev : Scatman
  5849. Example : /grid
  5850. */
  5851. void Commands::Command_Grid(Client* client, Seperator* sep)
  5852. {
  5853. if (client->GetPlayer()->GetMap() != nullptr) {
  5854. if(sep && sep->arg[0][0] && strncasecmp("spawns", sep->arg[0], 6) == 0) {
  5855. int32 grid = client->GetPlayer()->GetLocation();
  5856. if(sep->IsNumber(1))
  5857. grid = atoul(sep->arg[1]);
  5858. client->GetCurrentZone()->SendClientSpawnListInGrid(client, grid);
  5859. }
  5860. else {
  5861. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->GetLocation());
  5862. auto loc = glm::vec3(client->GetPlayer()->GetX(), client->GetPlayer()->GetZ(), client->GetPlayer()->GetY());
  5863. uint32 GridID = 0;
  5864. uint32 WidgetID = 0;
  5865. float new_z = client->GetPlayer()->FindBestZ(loc, nullptr, &GridID, &WidgetID);
  5866. float minY = client->GetPlayer()->GetMap()->GetMinY();
  5867. float maxY = client->GetPlayer()->GetMap()->GetMaxY();
  5868. float minZ = client->GetPlayer()->GetMap()->GetMinZ();
  5869. float maxZ = client->GetPlayer()->GetMap()->GetMaxZ();
  5870. int32 grid_spawn_count = client->GetPlayer()->GetZone()->GetSpawnCountInGrid(GridID);
  5871. client->Message(CHANNEL_COLOR_YELLOW, "Grid result is %u, at EQ2 Y coordinate %f. Spawns on grid: %u. Min/Max Y %f/%f Z %f/%f. Widget ID: %u", GridID, new_z, grid_spawn_count, minY, maxY, minZ, maxZ, WidgetID);
  5872. }
  5873. }
  5874. }
  5875. /*
  5876. Function: Command_Guild()
  5877. Purpose : Handler for all UI-related guild commands
  5878. Dev : Scatman
  5879. */
  5880. void Commands::Command_Guild(Client* client, Seperator* sep)
  5881. {
  5882. Guild* guild = client->GetPlayer()->GetGuild();
  5883. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  5884. {
  5885. const char* command = sep->arg[0];
  5886. int32 length = strlen(command);
  5887. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  5888. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  5889. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  5890. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5891. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5892. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5893. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5894. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  5895. guild->KickGuildMember(client, sep->arg[1]);
  5896. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  5897. guild->DemoteGuildMember(client, sep->arg[1]);
  5898. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  5899. guild->PromoteGuildMember(client, sep->arg[1]);
  5900. else if (strncmp(command, "points", length) == 0 && guild)
  5901. {
  5902. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  5903. {
  5904. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5905. {
  5906. float points = atof(sep->arg[2]);
  5907. const char* option = sep->arg[3];
  5908. const char* comment = sep->argplus[4];
  5909. if (strncmp(option, "all", strlen(option)) == 0)
  5910. guild->AddPointsToAll(client, points, comment);
  5911. else if (strncmp(option, "online", strlen(option)) == 0)
  5912. guild->AddPointsToAllOnline(client, points, comment);
  5913. else if (strncmp(option, "group", strlen(option)) == 0)
  5914. guild->AddPointsToGroup(client, points, comment);
  5915. else if (strncmp(option, "raid", strlen(option)) == 0)
  5916. guild->AddPointsToRaid(client, points, comment);
  5917. else
  5918. guild->AddPointsToGuildMember(client, points, option, comment);
  5919. }
  5920. }
  5921. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  5922. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  5923. else
  5924. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  5925. }
  5926. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  5927. guild->SetMOTD(sep->argplus[1]);
  5928. else if (strncmp(command, "recruiting", length) == 0 && guild)
  5929. {
  5930. if (sep->arg[1])
  5931. {
  5932. const char* option = sep->arg[1];
  5933. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  5934. guild->SetRecruitingShortDesc(sep->argplus[2]);
  5935. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  5936. guild->SetRecruitingFullDesc(sep->argplus[2]);
  5937. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5938. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5939. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5940. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  5941. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5942. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  5943. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  5944. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  5945. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  5946. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5947. else
  5948. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5949. }
  5950. else
  5951. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5952. }
  5953. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  5954. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5955. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  5956. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5957. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5958. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5959. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  5960. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  5961. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5962. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5963. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  5964. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  5965. else if (strncmp(command, "invite", length) == 0 && guild)
  5966. {
  5967. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5968. guild->InvitePlayer(client, sep->arg[1]);
  5969. else
  5970. {
  5971. Spawn* target = client->GetPlayer()->GetTarget();
  5972. if (target)
  5973. {
  5974. if (target->IsPlayer())
  5975. guild->InvitePlayer(client, target->GetName());
  5976. else
  5977. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  5978. }
  5979. }
  5980. }
  5981. else if (strncmp(command, "accept", length) == 0)
  5982. {
  5983. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5984. if (pgi && pgi->guild && pgi->invited_by)
  5985. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  5986. client->SetPendingGuildInvite(0);
  5987. }
  5988. else if (strncmp(command, "decline", length) == 0)
  5989. {
  5990. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5991. if (pgi && pgi->guild && pgi->invited_by && pgi->invited_by->IsPlayer())
  5992. {
  5993. Client* client_inviter = ((Player*)pgi->invited_by)->GetClient();
  5994. if (client_inviter) {
  5995. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  5996. }
  5997. }
  5998. client->SetPendingGuildInvite(0);
  5999. }
  6000. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  6001. {
  6002. const char* guild_name = sep->argplus[1];
  6003. if (!guild_list.GetGuild(guild_name))
  6004. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6005. else
  6006. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  6007. }
  6008. else if (strncmp(command, "search", length) == 0)
  6009. client->ShowGuildSearchWindow();
  6010. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6011. {
  6012. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6013. if (to_guild)
  6014. to_guild->SendGuildRecruitingDetails(client);
  6015. }
  6016. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6017. {
  6018. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6019. if (to_guild)
  6020. to_guild->SendGuildRecruitingImages(client);
  6021. }
  6022. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  6023. {
  6024. if (sep->arg[1])
  6025. {
  6026. const char* option = sep->arg[1];
  6027. if (strncmp(option, "toggle", strlen(option)) == 0)
  6028. guild->ToggleGuildRecruiterAdventureClass(client);
  6029. }
  6030. else
  6031. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  6032. }
  6033. else if (strncmp(command, "display_heraldry", length) == 0)
  6034. {
  6035. // JA: not sure this is right...
  6036. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  6037. client->GetPlayer()->SetCharSheetChanged(true);
  6038. }
  6039. else
  6040. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  6041. }
  6042. }
  6043. /*
  6044. Function: Command_GuildCreate()
  6045. Purpose : Display's in-game Guild Creation window
  6046. Dev : Scatman
  6047. */
  6048. void Commands::Command_CreateGuild(Client* client)
  6049. {
  6050. client->SendGuildCreateWindow();
  6051. }
  6052. /*
  6053. Function: Command_SetGuildOfficerNote()
  6054. Purpose :
  6055. Dev : Scatman
  6056. */
  6057. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  6058. {
  6059. if (sep && sep->arg[0] && sep->arg[1])
  6060. {
  6061. Guild* guild = client->GetPlayer()->GetGuild();
  6062. if (guild)
  6063. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  6064. }
  6065. }
  6066. /*
  6067. Function: Command_SetGuildMemberNote()
  6068. Purpose :
  6069. Dev : Scatman
  6070. */
  6071. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  6072. {
  6073. if (sep && sep->arg[0] && sep->arg[1])
  6074. {
  6075. Guild* guild = client->GetPlayer()->GetGuild();
  6076. if (guild)
  6077. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  6078. }
  6079. }
  6080. /*
  6081. Function: Command_GuildSay()
  6082. Purpose :
  6083. Dev : Scatman
  6084. */
  6085. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  6086. {
  6087. Guild* guild = client->GetPlayer()->GetGuild();
  6088. if (guild)
  6089. {
  6090. if (sep && sep->arg[0])
  6091. guild->HandleGuildSay(client, sep->argplus[0]);
  6092. }
  6093. else
  6094. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6095. }
  6096. /*
  6097. Function: Command_OfficerSay()
  6098. Purpose :
  6099. Dev : Scatman
  6100. */
  6101. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  6102. {
  6103. Guild* guild = client->GetPlayer()->GetGuild();
  6104. if (guild)
  6105. {
  6106. if (sep && sep->arg[0])
  6107. guild->HandleOfficerSay(client, sep->argplus[0]);
  6108. }
  6109. else
  6110. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6111. }
  6112. /*
  6113. Function: Command_Guilds()
  6114. Purpose : Shows help for /guild command
  6115. Params :
  6116. Dev : Scatman
  6117. Example :
  6118. */
  6119. void Commands::Command_Guilds(Client* client)
  6120. {
  6121. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  6122. }
  6123. /*
  6124. Function: Command_GuildsAdd()
  6125. Purpose : Add's players to a guild
  6126. Params : guild_name|guild_id, player name
  6127. Dev : Scatman
  6128. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  6129. */
  6130. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  6131. {
  6132. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6133. {
  6134. Guild* guild = 0;
  6135. bool found = true;
  6136. if (sep->IsNumber(0))
  6137. {
  6138. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6139. if (!guild)
  6140. {
  6141. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6142. found = false;
  6143. }
  6144. }
  6145. else
  6146. {
  6147. guild = guild_list.GetGuild(sep->arg[0]);
  6148. if (!guild)
  6149. {
  6150. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6151. found = false;
  6152. }
  6153. }
  6154. if (found)
  6155. {
  6156. Client* to_client = 0;
  6157. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6158. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6159. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6160. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6161. if (to_client)
  6162. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  6163. else
  6164. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6165. }
  6166. }
  6167. else
  6168. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  6169. }
  6170. /*
  6171. Function: Command_GuildsCreate()
  6172. Purpose : Creates a guild
  6173. Params : guild_name, player_name (optional)
  6174. Dev : Scatman
  6175. Example : /guilds create [guild name] (player name)
  6176. */
  6177. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  6178. {
  6179. if (sep && sep->arg[0])
  6180. {
  6181. const char* guild_name = sep->arg[0];
  6182. if (!guild_list.GetGuild(guild_name))
  6183. {
  6184. bool ret = false;
  6185. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6186. {
  6187. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6188. if (to_client)
  6189. {
  6190. world.CreateGuild(guild_name, to_client);
  6191. ret = true;
  6192. }
  6193. else
  6194. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  6195. }
  6196. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6197. {
  6198. Client* to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6199. if (to_client)
  6200. {
  6201. world.CreateGuild(guild_name, to_client);
  6202. ret = true;
  6203. }
  6204. }
  6205. else
  6206. {
  6207. world.CreateGuild(guild_name);
  6208. ret = true;
  6209. }
  6210. if (ret)
  6211. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  6212. else
  6213. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  6214. }
  6215. else
  6216. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  6217. }
  6218. else
  6219. 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.");
  6220. }
  6221. /*
  6222. Function: Command_GuildsDelete()
  6223. Purpose : Delete's a guild
  6224. Params : guild name
  6225. Dev : Scatman
  6226. Example : /guilds delete Test
  6227. */
  6228. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  6229. {
  6230. if (sep && sep->arg[0])
  6231. {
  6232. Guild* guild = 0;
  6233. bool found = true;
  6234. if (sep->IsNumber(0))
  6235. {
  6236. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6237. if (!guild)
  6238. {
  6239. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6240. found = false;
  6241. }
  6242. }
  6243. else
  6244. {
  6245. guild = guild_list.GetGuild(sep->arg[0]);
  6246. if (!guild)
  6247. {
  6248. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6249. found = false;
  6250. }
  6251. }
  6252. if (found)
  6253. {
  6254. guild->RemoveAllGuildMembers();
  6255. database.DeleteGuild(guild);
  6256. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  6257. guild_list.RemoveGuild(guild, true);
  6258. }
  6259. }
  6260. else
  6261. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  6262. }
  6263. /*
  6264. Function: Command_GuildsList()
  6265. Purpose : Lists current guilds on server
  6266. Params :
  6267. Dev : Scatman
  6268. Example : /guilds list
  6269. */
  6270. void Commands::Command_GuildsList(Client* client)
  6271. {
  6272. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  6273. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  6274. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  6275. if (guilds->size() == 0)
  6276. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  6277. else {
  6278. while (itr.Next()) {
  6279. Guild* guild = itr.second;
  6280. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  6281. }
  6282. }
  6283. }
  6284. /*
  6285. Function: Command_GuildsRemove()
  6286. Purpose : Removes a player from a guild
  6287. Params : guild name|guild id, player name
  6288. Dev : Scatman
  6289. Example : /guilds remove 1 Admin = removes Admin from guild 1
  6290. */
  6291. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  6292. {
  6293. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6294. {
  6295. Guild* guild = 0;
  6296. bool found = true;
  6297. if (sep->IsNumber(0))
  6298. {
  6299. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6300. if (!guild)
  6301. {
  6302. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6303. found = false;
  6304. }
  6305. }
  6306. else
  6307. {
  6308. guild = guild_list.GetGuild(sep->arg[0]);
  6309. if (!guild)
  6310. {
  6311. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6312. found = false;
  6313. }
  6314. }
  6315. if (found)
  6316. {
  6317. Client* to_client = 0;
  6318. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6319. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6320. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6321. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6322. if (to_client)
  6323. {
  6324. Player* to_player = to_client->GetPlayer();
  6325. if (to_player->GetGuild())
  6326. {
  6327. if (to_player->GetGuild() == guild)
  6328. {
  6329. guild->KickGuildMember(client, to_player->GetName());
  6330. }
  6331. else
  6332. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  6333. }
  6334. else
  6335. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  6336. }
  6337. else
  6338. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6339. }
  6340. }
  6341. else
  6342. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  6343. }
  6344. /*
  6345. Function: Command_InspectPlayer()
  6346. Purpose : Handle the Inspect functions
  6347. Params : Client to inspect
  6348. Dev : Scatman
  6349. Example : /inspect Scatman
  6350. */
  6351. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  6352. {
  6353. if (sep && sep->arg[0])
  6354. {
  6355. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  6356. if (inspect_client)
  6357. client->InspectPlayer(inspect_client->GetPlayer());
  6358. }
  6359. else
  6360. {
  6361. Spawn* target = client->GetPlayer()->GetTarget();
  6362. if (target && target->IsPlayer())
  6363. client->InspectPlayer((Player*)target);
  6364. }
  6365. }
  6366. /*
  6367. Function: Command_Inventory()
  6368. Purpose : Handle changes in player inventory
  6369. Params : <TBD>
  6370. Dev : All
  6371. Example : /inventory delete item_id
  6372. */
  6373. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  6374. {
  6375. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  6376. Player* player = client->GetPlayer();
  6377. if(sep && sep->arg[0][0])
  6378. {
  6379. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  6380. if(!client->GetPlayer()->Alive())
  6381. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  6382. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6383. {
  6384. int16 index = atoi(sep->arg[1]);
  6385. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6386. if(item)
  6387. {
  6388. if(item->details.item_locked) {
  6389. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item in use.");
  6390. return;
  6391. }
  6392. else if(item->CheckFlag(NO_DESTROY)) {
  6393. client->SimpleMessage(CHANNEL_COLOR_RED, "You can't destroy this item.");
  6394. return;
  6395. }
  6396. if(item->GetItemScript() && lua_interface)
  6397. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  6398. //reobtain item make sure it wasn't removed
  6399. item = player->item_list.GetItemFromIndex(index);
  6400. int32 bag_id = 0;
  6401. if(item){
  6402. bag_id = item->details.inv_slot_id;
  6403. database.DeleteItem(client->GetCharacterID(), item, 0);
  6404. }
  6405. client->GetPlayer()->item_list.DestroyItem(index);
  6406. client->GetPlayer()->UpdateInventory(bag_id);
  6407. client->GetPlayer()->CalculateApplyWeight();
  6408. }
  6409. }
  6410. else if(sep->arg[4][0] && strncasecmp("move", sep->arg[0], 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3) && sep->IsNumber(4))
  6411. {
  6412. int16 from_index = atoi(sep->arg[1]);
  6413. sint16 to_slot = atoi(sep->arg[2]); // don't convert slot since this is inventory not equipment
  6414. sint32 bag_id = atol(sep->arg[3]);
  6415. int8 charges = atoi(sep->arg[4]);
  6416. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  6417. if(!item) {
  6418. client->SimpleMessage(CHANNEL_COLOR_RED, "You have no item.");
  6419. return;
  6420. }
  6421. if(to_slot == item->details.slot_id && (bag_id < 0 || bag_id == item->details.inv_slot_id)) {
  6422. return;
  6423. }
  6424. if(item->details.item_locked)
  6425. {
  6426. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot move the item in use.");
  6427. return;
  6428. }
  6429. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  6430. {
  6431. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  6432. return;
  6433. }
  6434. sint32 old_inventory_id = 0;
  6435. if(item)
  6436. old_inventory_id = item->details.inv_slot_id;
  6437. //autobank
  6438. if (bag_id == -3 && to_slot == -1)
  6439. {
  6440. if (player->HasFreeBankSlot())
  6441. to_slot = player->FindFreeBankSlot();
  6442. else
  6443. {
  6444. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  6445. return;
  6446. }
  6447. }
  6448. //auto inventory
  6449. if (bag_id == 0 && to_slot == -1)
  6450. {
  6451. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6452. {
  6453. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  6454. return;
  6455. }
  6456. }
  6457. bool item_deleted = false;
  6458. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, &item_deleted, client->GetVersion());
  6459. client->QueuePacket(outapp);
  6460. if(item_deleted)
  6461. item = nullptr;
  6462. //removed from bag send update
  6463. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  6464. {
  6465. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  6466. if(outapp)
  6467. client->QueuePacket(outapp);
  6468. }
  6469. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  6470. {
  6471. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  6472. if(outapp)
  6473. client->QueuePacket(outapp);
  6474. }
  6475. }
  6476. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  6477. {
  6478. if(client->GetPlayer()->EngagedInCombat())
  6479. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  6480. else
  6481. {
  6482. int16 index = atoi(sep->arg[1]);
  6483. int8 slot_id = 255;
  6484. int8 unk3 = 0;
  6485. int8 appearance_equip = 0;
  6486. if(sep->arg[2][0] && sep->IsNumber(2))
  6487. slot_id = player->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6488. if(sep->arg[3][0] && sep->IsNumber(3))
  6489. unk3 = atoul(sep->arg[3]);
  6490. if(sep->arg[4][0] && sep->IsNumber(4))
  6491. appearance_equip = atoul(sep->arg[4]);
  6492. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  6493. EQ2Packet* outapp = 0;
  6494. for(int32 i=0;i<packets.size();i++)
  6495. {
  6496. outapp = packets[i];
  6497. if(outapp)
  6498. client->QueuePacket(outapp);
  6499. }
  6500. client->GetPlayer()->UpdateWeapons();
  6501. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6502. client->QueuePacket(characterSheetPackets);
  6503. }
  6504. }
  6505. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6506. {
  6507. if (client->GetPlayer()->EngagedInCombat())
  6508. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  6509. else {
  6510. int16 index = atoi(sep->arg[1]);
  6511. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6512. if (item) {
  6513. if(item->details.item_locked)
  6514. {
  6515. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot unpack the item in use.");
  6516. return;
  6517. }
  6518. // client->GetPlayer()->item_list.DestroyItem(index);
  6519. if (item->item_sets.size() > 0) {
  6520. for (int32 i = 0; i < item->item_sets.size(); i++) {
  6521. ItemSet* set = item->item_sets[i];
  6522. if (set->item_stack_size == 0)
  6523. set->item_stack_size += 1;
  6524. client->AddItem(set->item_id, set->item_stack_size);
  6525. }
  6526. }
  6527. }
  6528. client->RemoveItem(item, 1);
  6529. }
  6530. }
  6531. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  6532. {
  6533. if(client->GetPlayer()->EngagedInCombat())
  6534. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  6535. else
  6536. {
  6537. int16 index = player->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6538. sint32 bag_id = -999;
  6539. int8 to_slot = 255;
  6540. if(sep->arg[3][0])
  6541. {
  6542. if(sep->IsNumber(2))
  6543. bag_id = atol(sep->arg[2]);
  6544. if(sep->IsNumber(3))
  6545. to_slot = atoi(sep->arg[3]);
  6546. }
  6547. sint8 unk4 = 0;
  6548. int8 appearance_equip = 0;
  6549. if(sep->arg[4][0] && sep->IsNumber(4))
  6550. unk4 = atoi(sep->arg[4]);
  6551. if(sep->arg[5][0] && sep->IsNumber(5))
  6552. appearance_equip = atoul(sep->arg[5]);
  6553. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  6554. EQ2Packet* outapp = 0;
  6555. for(int32 i=0;i<packets.size();i++)
  6556. {
  6557. outapp = packets[i];
  6558. if(outapp)
  6559. client->QueuePacket(outapp);
  6560. }
  6561. client->UnequipItem(index, bag_id, to_slot, appearance_equip);
  6562. }
  6563. }
  6564. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6565. {
  6566. if(client->GetPlayer()->EngagedInCombat()) {
  6567. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not swap items while in combat.");
  6568. }
  6569. else {
  6570. int16 index1 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6571. int16 index2 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6572. int8 type = 0;
  6573. if(sep->IsNumber(3))
  6574. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  6575. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  6576. if(outapp)
  6577. client->QueuePacket(outapp);
  6578. else
  6579. {
  6580. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  6581. return;
  6582. }
  6583. }
  6584. }
  6585. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6586. {
  6587. sint16 to_slot = atoi(sep->arg[1]);
  6588. sint32 bag_id = atoi(sep->arg[2]);
  6589. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  6590. if (item) {
  6591. //auto inventory
  6592. if (bag_id == 0 && to_slot == -1)
  6593. {
  6594. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6595. {
  6596. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  6597. return;
  6598. }
  6599. // Set the slot for the item
  6600. item->details.inv_slot_id = bag_id;
  6601. item->details.slot_id = to_slot;
  6602. // Flag the item so it gets saved in its new location
  6603. item->save_needed = true;
  6604. // Add the item to its new location
  6605. if(player->item_list.AddItem(item)) {
  6606. // Remove the item from the overflow list
  6607. player->item_list.RemoveOverflowItem(item);
  6608. }
  6609. // Send the inventory update packet
  6610. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6611. return;
  6612. }
  6613. else if (bag_id == -3 && to_slot == -1) {
  6614. // Auto Bank
  6615. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  6616. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  6617. return;
  6618. }
  6619. item->details.inv_slot_id = bag_id;
  6620. item->details.slot_id = to_slot;
  6621. item->save_needed = true;
  6622. if(player->item_list.AddItem(item)) {
  6623. player->item_list.RemoveOverflowItem(item);
  6624. }
  6625. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6626. }
  6627. else if (bag_id == -4) {
  6628. // Shared Bank
  6629. if (!player->item_list.SharedBankAddAllowed(item)) {
  6630. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  6631. return;
  6632. }
  6633. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  6634. if (tmp_item) {
  6635. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6636. return;
  6637. }
  6638. else {
  6639. item->details.inv_slot_id = bag_id;
  6640. item->details.slot_id = to_slot;
  6641. item->save_needed = true;
  6642. if(player->item_list.AddItem(item)) {
  6643. player->item_list.RemoveOverflowItem(item);
  6644. }
  6645. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6646. return;
  6647. }
  6648. }
  6649. else {
  6650. // Try to get an item from the given bag id and slot id
  6651. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  6652. // Check to see if we got an item, if we do send an error,
  6653. // if we don't put the overflow item into this slot
  6654. if (tmp_item) {
  6655. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6656. }
  6657. else {
  6658. item->details.inv_slot_id = bag_id;
  6659. item->details.slot_id = to_slot;
  6660. item->save_needed = true;
  6661. if(player->item_list.AddItem(item)) {
  6662. player->item_list.RemoveOverflowItem(item);
  6663. }
  6664. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6665. return;
  6666. }
  6667. }
  6668. }
  6669. }
  6670. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6671. {
  6672. sint64 data = strtoull(sep->arg[1], NULL, 0);
  6673. int32 character_item_id = (int32) (data >> 32);
  6674. int32 item_id = (int32) (data & 0xffffffffL);
  6675. int8 sale_setting = atoi(sep->arg[2]);
  6676. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  6677. if(item)
  6678. {
  6679. item->no_sale = sale_setting;
  6680. item->save_needed = true;
  6681. client->SendSellMerchantList();
  6682. }
  6683. }
  6684. }
  6685. else
  6686. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  6687. }
  6688. /*
  6689. Function: Command_Languages()
  6690. Purpose : Show's languages the player knows
  6691. Params :
  6692. Dev : Zcoretri
  6693. Example :
  6694. */
  6695. void Commands::Command_Languages(Client* client, Seperator* sep)
  6696. {
  6697. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6698. list<Language*>::iterator itr;
  6699. Language* language;
  6700. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6701. for(itr = languages->begin(); itr != languages->end(); itr++)
  6702. {
  6703. language = *itr;
  6704. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6705. }
  6706. }
  6707. /*
  6708. Function: Command_SetLanguage()
  6709. Purpose : Handles language commands
  6710. Params : Language ID
  6711. Dev : Zcoretri
  6712. Example :
  6713. */
  6714. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6715. {
  6716. Player* player = client->GetPlayer();
  6717. if (sep && sep->arg[0])
  6718. {
  6719. if(!sep->IsNumber(0))
  6720. {
  6721. //String passed in
  6722. const char* value = sep->arg[0];
  6723. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6724. {
  6725. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6726. client->SendLanguagesUpdate(0);
  6727. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6728. }
  6729. else
  6730. {
  6731. if(player->HasLanguage(value))
  6732. {
  6733. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6734. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6735. client->SendLanguagesUpdate(language->GetID());
  6736. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6737. }
  6738. else
  6739. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6740. }
  6741. }
  6742. else
  6743. {
  6744. //Number passed in
  6745. int32 id = atoul(sep->arg[0]);
  6746. if(player->HasLanguage(id))
  6747. {
  6748. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6749. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6750. client->SendLanguagesUpdate(id);
  6751. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6752. }
  6753. else
  6754. {
  6755. Language* language = master_languages_list.GetLanguage(id);
  6756. if(language)
  6757. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6758. }
  6759. }
  6760. }
  6761. else
  6762. {
  6763. //No value was passed in
  6764. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6765. if(id > 0)
  6766. {
  6767. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6768. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6769. }
  6770. else
  6771. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6772. }
  6773. }
  6774. /*
  6775. Function: Command_LastName()
  6776. Purpose : Sets player surname
  6777. Params : Name text
  6778. Dev : theFoof
  6779. Example :
  6780. */
  6781. void Commands::Command_LastName(Client* client, Seperator* sep)
  6782. {
  6783. if (!client)
  6784. return;
  6785. if (sep && sep->arg[0])
  6786. {
  6787. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6788. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6789. return;
  6790. }
  6791. client->RemovePendingLastName();
  6792. uchar* checkname = (uchar*)sep->arg[0];
  6793. bool valid_name = true;
  6794. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6795. if (!alpha_check(checkname[i])) {
  6796. valid_name = false;
  6797. break;
  6798. }
  6799. }
  6800. if (!valid_name) {
  6801. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6802. return;
  6803. }
  6804. string last_name = (string)sep->arg[0];
  6805. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6806. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6807. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6808. client->SetPendingLastName(last_name);
  6809. client->SendLastNameConfirmation();
  6810. }
  6811. else
  6812. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6813. }
  6814. }
  6815. /*
  6816. Function: Command_ConfirmLastName()
  6817. Purpose : Confirms setting of player surname
  6818. Params : Name text
  6819. Dev : theFoof
  6820. Example :
  6821. */
  6822. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6823. {
  6824. if (!client)
  6825. return;
  6826. string* name = client->GetPendingLastName();
  6827. if (name){
  6828. Player* player = client->GetPlayer();
  6829. player->SetLastName(name->c_str(), false);
  6830. client->SendTitleUpdate();
  6831. player->SetCharSheetChanged(true);
  6832. client->RemovePendingLastName();
  6833. }
  6834. }
  6835. /*
  6836. Function: Command_Location()
  6837. Purpose : Display's Help for /location commands
  6838. Params :
  6839. Dev : Scatman
  6840. Example : /location = show's help for command
  6841. */
  6842. void Commands::Command_Location(Client* client)
  6843. {
  6844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6845. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6846. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6848. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6850. }
  6851. /*
  6852. Function: Command_LocationAdd()
  6853. Purpose : Add's a location to an existing location config
  6854. Params : location_id
  6855. Dev : Scatman
  6856. Example : /location add {location_id}
  6857. */
  6858. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6859. {
  6860. if (sep && sep->arg[0] && sep->IsNumber(0))
  6861. {
  6862. int32 location_id = atoul(sep->arg[0]);
  6863. float x = client->GetPlayer()->GetX();
  6864. float y = client->GetPlayer()->GetY();
  6865. float z = client->GetPlayer()->GetZ();
  6866. if (database.AddLocationPoint(location_id, x, y, z))
  6867. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6868. else
  6869. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6870. }
  6871. else
  6872. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6873. }
  6874. /*
  6875. Function: Command_LocationCreate()
  6876. Purpose : Creates a new location config
  6877. Params : location name, 0/1 for include_y (optional)
  6878. Dev : Scatman
  6879. Example : /location create Test 1 = creates a new location named Test with include_y True
  6880. */
  6881. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6882. {
  6883. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6884. {
  6885. const char* name = sep->arg[0];
  6886. bool include_y = false;
  6887. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6888. include_y = true;
  6889. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->GetLocation(), name, include_y);
  6890. if (location_id > 0)
  6891. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6892. else
  6893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6894. }
  6895. else
  6896. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6897. }
  6898. /*
  6899. Function: Command_LocationDelete()
  6900. Purpose : Delete's a location config and all it's location points
  6901. Params : location_id
  6902. Dev : Scatman
  6903. Example : /location delete {location_id}
  6904. */
  6905. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6906. {
  6907. if (sep && sep->arg[0] && sep->IsNumber(0))
  6908. {
  6909. int32 location_id = atoul(sep->arg[0]);
  6910. if (database.DeleteLocation(location_id))
  6911. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6912. else
  6913. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6914. }
  6915. else
  6916. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6917. }
  6918. /*
  6919. Function: Command_LocationList()
  6920. Purpose : Display's a list of location points
  6921. Params : location_id
  6922. Dev : Scatman
  6923. Example : /location list {location_id}
  6924. */
  6925. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6926. {
  6927. if (sep && sep->arg[0])
  6928. {
  6929. const char* option = sep->arg[0];
  6930. if (strncmp(option, "locations", strlen(option)) == 0)
  6931. database.ListLocations(client);
  6932. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  6933. {
  6934. int32 location_id = atoul(sep->arg[1]);
  6935. database.ListLocationPoints(client, location_id);
  6936. }
  6937. else
  6938. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6939. }
  6940. else
  6941. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6942. }
  6943. /*
  6944. Function: Command_LocationRemove()
  6945. Purpose : Removes a single location point from a location config
  6946. Params : location_point_id (gotten from /location list {id})
  6947. Dev : Scatman
  6948. Example : /location remove 1 = will remove location_point_id 1
  6949. */
  6950. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  6951. {
  6952. if (sep && sep->arg[0] && sep->IsNumber(0))
  6953. {
  6954. int32 location_point_id = atoul(sep->arg[0]);
  6955. if (database.DeleteLocationPoint(location_point_id))
  6956. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  6957. else
  6958. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  6959. }
  6960. else
  6961. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  6962. }
  6963. /*
  6964. Function: Command_Merchant()
  6965. Purpose : Handles Merchant commands
  6966. Params : list
  6967. Dev : Scatman
  6968. Example : /merchant list
  6969. */
  6970. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  6971. {
  6972. if( handler == COMMAND_MERCHANT )
  6973. {
  6974. // /merchant command by itself shows help (to be extended)
  6975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6976. return;
  6977. }
  6978. else if( handler == COMMAND_MERCHANT_LIST )
  6979. {
  6980. // /merchant list command expects "description" param
  6981. if (sep && sep->arg[0])
  6982. {
  6983. const char* merchant_description = sep->argplus[0];
  6984. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  6985. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  6986. map<int32, MerchantInfo*>::iterator itr;
  6987. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  6988. {
  6989. string description = database.GetMerchantDescription(itr->first);
  6990. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  6991. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  6992. }
  6993. }
  6994. else // no description
  6995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6996. }
  6997. }
  6998. /*
  6999. Function: Command_Modify()
  7000. Purpose : to replace our other "set" commands
  7001. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  7002. Dev : John Adams
  7003. Example : /modify spell set name "Aegolism III"
  7004. */
  7005. void Commands::Command_Modify(Client* client)
  7006. {
  7007. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  7008. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  7009. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  7010. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  7011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  7012. }
  7013. /*
  7014. Function: Command_ModifySpawn()
  7015. Purpose : replace "spawn set" commands
  7016. Params : Action : the action to perform (or special handler)
  7017. : Field : the DB field to change
  7018. : Value : what to set the value to
  7019. : Target : what object to change (my target, or spawn_id)
  7020. Dev : John Adams
  7021. Example : /modify spawn set name "Lady Vox"
  7022. :
  7023. Note : Special Handlers, like "zoneto" for Signs
  7024. : /modify spawn zoneto
  7025. : Will set a sign's zone x/y/z to my current coords
  7026. */
  7027. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  7028. {
  7029. PrintSep(sep, "COMMAND_MODIFY");
  7030. // need at least 2 args for a valid command
  7031. if( sep && sep->arg[1] )
  7032. {
  7033. // JA: just a quick implementation because I need it :)
  7034. if (strcmp(sep->arg[0], "zoneto") == 0)
  7035. {
  7036. if( sep->IsNumber(1) )
  7037. {
  7038. int32 spawn_id = atoul(sep->arg[1]);
  7039. float x_coord = client->GetPlayer()->GetX();
  7040. float y_coord = client->GetPlayer()->GetY();
  7041. float z_coord = client->GetPlayer()->GetZ();
  7042. float h_coord = client->GetPlayer()->GetHeading();
  7043. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  7044. }
  7045. else
  7046. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  7047. }
  7048. }
  7049. else
  7050. Command_Modify(client);
  7051. }
  7052. /*
  7053. Function: Command_ModifyCharacter()
  7054. Purpose : to replace our other "set" commands
  7055. Params : Action : Add, Remove
  7056. : Field : copper, silver, gold, plat
  7057. : Value : min 1, max unlimited
  7058. : Target : Self, Player
  7059. Dev : Cynnar
  7060. Example : /modify character add gold 50
  7061. : /modify character remove silver 25
  7062. */
  7063. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  7064. {
  7065. PrintSep(sep, "COMMAND_MODIFY");
  7066. int64 value = 0;
  7067. Player* player = client->GetPlayer();
  7068. Client* targetClient = client;
  7069. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7070. player = (Player*)player->GetTarget();
  7071. targetClient = player->GetClient();
  7072. }
  7073. // need at least 2 args for a valid command
  7074. if( sep && sep->arg[1] )
  7075. {
  7076. if (strcmp(sep->arg[0], "add") == 0)
  7077. {
  7078. if (strcmp(sep->arg[1], "copper") == 0)
  7079. {
  7080. value = atoi64(sep->arg[2]);
  7081. player->AddCoins(value);
  7082. if (client->GetPlayer() == player)
  7083. {
  7084. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  7085. }
  7086. else {
  7087. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7088. if(targetClient) {
  7089. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7090. }
  7091. }
  7092. }
  7093. else if (strcmp(sep->arg[1], "silver") == 0)
  7094. {
  7095. value = atoi64(sep->arg[2]) * 100;
  7096. player->AddCoins(value);
  7097. if (client->GetPlayer() == player)
  7098. {
  7099. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  7100. }
  7101. else {
  7102. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  7103. if(targetClient) {
  7104. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7105. }
  7106. }
  7107. }
  7108. else if (strcmp(sep->arg[1], "gold") == 0)
  7109. {
  7110. value = atoi64(sep->arg[2]) * 10000;
  7111. player->AddCoins(value);
  7112. if (client->GetPlayer() == player)
  7113. {
  7114. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  7115. }
  7116. else {
  7117. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7118. if(targetClient) {
  7119. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7120. }
  7121. }
  7122. }
  7123. else if (strcmp(sep->arg[1], "plat") == 0)
  7124. {
  7125. value = atoi64(sep->arg[2]) * 1000000;
  7126. player->AddCoins(value);
  7127. if (client->GetPlayer() == player)
  7128. {
  7129. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  7130. }
  7131. else {
  7132. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7133. if(targetClient) {
  7134. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7135. }
  7136. }
  7137. }
  7138. else
  7139. {
  7140. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7141. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7142. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7143. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  7144. }
  7145. }
  7146. else if (strcmp(sep->arg[0], "remove") == 0)
  7147. {
  7148. if (strcmp(sep->arg[1], "copper") == 0)
  7149. {
  7150. value = atoi64(sep->arg[2]);
  7151. player->RemoveCoins(value);
  7152. if (client->GetPlayer() == player)
  7153. {
  7154. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  7155. }
  7156. else {
  7157. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  7158. if(targetClient) {
  7159. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7160. }
  7161. }
  7162. }
  7163. else if (strcmp(sep->arg[1], "silver") == 0)
  7164. {
  7165. value = atoi64(sep->arg[2]) * 100;
  7166. player->RemoveCoins(value);
  7167. if (client->GetPlayer() == player)
  7168. {
  7169. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  7170. }
  7171. else {
  7172. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  7173. if(targetClient) {
  7174. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7175. }
  7176. }
  7177. }
  7178. else if (strcmp(sep->arg[1], "gold") == 0)
  7179. {
  7180. value = atoi64(sep->arg[2]) * 10000;
  7181. player->RemoveCoins(value);
  7182. if (client->GetPlayer() == player)
  7183. {
  7184. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  7185. }
  7186. else {
  7187. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  7188. if(targetClient) {
  7189. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7190. }
  7191. }
  7192. }
  7193. else if (strcmp(sep->arg[1], "plat") == 0)
  7194. {
  7195. value = atoi64(sep->arg[2]) * 1000000;
  7196. player->RemoveCoins(value);
  7197. if (client->GetPlayer() == player)
  7198. {
  7199. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  7200. }
  7201. else {
  7202. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  7203. if(targetClient) {
  7204. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7205. }
  7206. }
  7207. }
  7208. else
  7209. {
  7210. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7211. }
  7212. }
  7213. else if (strcmp(sep->arg[0], "set") == 0) {
  7214. if (strcmp(sep->arg[1], "tslevel") == 0) {
  7215. int8 level = atoi(sep->arg[2]);
  7216. if (level > 0 && level < 256) {
  7217. if (player) {
  7218. if (client->GetPlayer() == player)
  7219. client->ChangeTSLevel(player->GetTSLevel(), level);
  7220. else if(targetClient)
  7221. targetClient->ChangeTSLevel(player->GetTSLevel(), level);
  7222. }
  7223. }
  7224. else
  7225. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  7226. }
  7227. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  7228. int8 tsclass = atoi(sep->arg[2]);
  7229. player->SetTradeskillClass(tsclass);
  7230. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  7231. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  7232. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  7233. player->SetCharSheetChanged(true);
  7234. }
  7235. else if (strcmp(sep->arg[1], "gender") == 0) {
  7236. int8 gender = atoi(sep->arg[2]);
  7237. client->GetPlayer()->GetInfoStruct()->set_gender(gender);
  7238. client->GetPlayer()->SetCharSheetChanged(true);
  7239. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  7240. }
  7241. }
  7242. }
  7243. else
  7244. {
  7245. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7246. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7247. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7248. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7249. }
  7250. }
  7251. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  7252. {
  7253. PrintSep(sep, "COMMAND_MODIFY");
  7254. // need at least 2 args for a valid command
  7255. if( sep && sep->arg[1] )
  7256. {
  7257. }
  7258. else
  7259. Command_Modify(client);
  7260. }
  7261. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  7262. {
  7263. PrintSep(sep, "COMMAND_MODIFY");
  7264. // need at least 2 args for a valid command
  7265. if( sep && sep->arg[1] )
  7266. {
  7267. }
  7268. else
  7269. Command_Modify(client);
  7270. }
  7271. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  7272. {
  7273. PrintSep(sep, "COMMAND_MODIFY");
  7274. // need at least 2 args for a valid command
  7275. if( sep && sep->arg[1] )
  7276. {
  7277. }
  7278. else
  7279. Command_Modify(client);
  7280. }
  7281. /*
  7282. Function: Command_ModifyQuest()
  7283. Purpose : to list players quest and completed quests
  7284. Params : Action : list, completed
  7285. : Target : Self, Player
  7286. Dev : Cynnar
  7287. Example : /modify quest list
  7288. : /modify quest completed
  7289. */
  7290. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  7291. {
  7292. PrintSep(sep, "COMMAND_MODIFY");
  7293. int64 value = 0;
  7294. Player* player = client->GetPlayer();
  7295. Client* targetClient = client;
  7296. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7297. player = (Player*)player->GetTarget();
  7298. targetClient = player->GetClient();
  7299. }
  7300. // need at least 2 args for a valid command
  7301. if (sep && sep->arg[1])
  7302. {
  7303. if (strcmp(sep->arg[0], "list") == 0)
  7304. {
  7305. map<int32, Quest*>* quests = player->GetPlayerQuests();
  7306. map<int32, Quest*>::iterator itr;
  7307. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  7308. if (quests->size() == 0)
  7309. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  7310. else
  7311. {
  7312. for (itr = quests->begin(); itr != quests->end(); itr++)
  7313. {
  7314. Quest* quest = itr->second;
  7315. if(quest) {
  7316. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7317. }
  7318. }
  7319. }
  7320. }
  7321. else if (strcmp(sep->arg[0], "completed") == 0)
  7322. {
  7323. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  7324. map<int32, Quest*>::iterator itr;
  7325. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  7326. if (quests->size() == 0)
  7327. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  7328. else
  7329. {
  7330. for (itr = quests->begin(); itr != quests->end(); itr++)
  7331. {
  7332. Quest* quest = itr->second;
  7333. if(quest) {
  7334. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7335. }
  7336. }
  7337. }
  7338. }
  7339. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  7340. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  7341. else if (strcmp(sep->arg[0], "remove") == 0)
  7342. {
  7343. int32 quest_id = 0;
  7344. if (sep && sep->arg[1] && sep->IsNumber(1))
  7345. quest_id = atoul(sep->arg[1]);
  7346. if (quest_id > 0)
  7347. {
  7348. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  7349. {
  7350. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7351. if (quest)
  7352. if (client->GetPlayer() == player)
  7353. {
  7354. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  7355. }
  7356. else
  7357. {
  7358. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  7359. if(targetClient) {
  7360. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  7361. }
  7362. }
  7363. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  7364. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  7365. }
  7366. client->RemovePlayerQuest(quest_id);
  7367. client->GetCurrentZone()->SendQuestUpdates(client);
  7368. }
  7369. }
  7370. else if (strcmp(sep->arg[0], "advance") == 0)
  7371. {
  7372. int32 quest_id = 0;
  7373. int32 step = 0;
  7374. if (sep && sep->arg[1] && sep->IsNumber(1))
  7375. {
  7376. quest_id = atoul(sep->arg[1]);
  7377. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7378. if(!quest) {
  7379. client->Message(CHANNEL_COLOR_RED, "Quest not found!");
  7380. return;
  7381. }
  7382. if (sep && sep->arg[2] && sep->IsNumber(1))
  7383. {
  7384. step = atoul(sep->arg[2]);
  7385. if (quest_id > 0 && step > 0)
  7386. {
  7387. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  7388. {
  7389. if (client)
  7390. {
  7391. client->AddPendingQuestUpdate(quest_id, step);
  7392. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  7393. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  7394. }
  7395. }
  7396. }
  7397. else
  7398. {
  7399. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  7400. }
  7401. }
  7402. else
  7403. {
  7404. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  7405. }
  7406. }
  7407. else
  7408. {
  7409. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  7410. }
  7411. }
  7412. else
  7413. {
  7414. Command_Modify(client);
  7415. }
  7416. }
  7417. else
  7418. {
  7419. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  7420. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  7421. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  7422. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  7423. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  7424. }
  7425. }
  7426. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  7427. {
  7428. PrintSep(sep, "COMMAND_MODIFY");
  7429. // need at least 2 args for a valid command
  7430. if( sep && sep->arg[1] )
  7431. {
  7432. if (strcmp(sep->arg[0], "add") == 0) {
  7433. const char* skill_name = sep->argplus[1];
  7434. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7435. if (skill) {
  7436. Player* player = 0;
  7437. Client* to_client = 0;
  7438. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7439. player = (Player*)client->GetPlayer()->GetTarget();
  7440. to_client = player->GetClient();
  7441. }
  7442. else {
  7443. player = client->GetPlayer();
  7444. to_client = client;
  7445. }
  7446. if (player)
  7447. {
  7448. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7449. {
  7450. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7451. if (to_client == client) {
  7452. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  7453. }
  7454. else {
  7455. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7456. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7457. }
  7458. }
  7459. else
  7460. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  7461. }
  7462. }
  7463. else
  7464. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7465. }
  7466. else if (strcmp(sep->arg[0], "remove") == 0) {
  7467. const char* skill_name = sep->argplus[1];
  7468. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7469. if (skill) {
  7470. Player* player = 0;
  7471. Client* to_client = 0;
  7472. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7473. player = (Player*)client->GetPlayer()->GetTarget();
  7474. to_client = player->GetClient();
  7475. }
  7476. else {
  7477. player = client->GetPlayer();
  7478. to_client = client;
  7479. }
  7480. if (player)
  7481. {
  7482. if (player->GetSkills()->HasSkill(skill->skill_id))
  7483. {
  7484. player->RemoveSkillFromDB(skill, true);
  7485. if (client == to_client) {
  7486. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  7487. }
  7488. else {
  7489. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7490. if(to_client) {
  7491. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7492. }
  7493. }
  7494. }
  7495. else {
  7496. if (client == to_client)
  7497. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  7498. else
  7499. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7500. }
  7501. }
  7502. }
  7503. else
  7504. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7505. }
  7506. else if (strcmp(sep->arg[0], "set") == 0) {
  7507. if (!sep->IsNumber(2)) {
  7508. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  7509. return;
  7510. }
  7511. const char* skill_name = sep->arg[1];
  7512. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7513. if (skill) {
  7514. int16 val = atoi(sep->arg[2]);
  7515. Player* player = 0;
  7516. Client* to_client = 0;
  7517. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7518. player = (Player*)client->GetPlayer()->GetTarget();
  7519. to_client = player->GetClient();
  7520. }
  7521. else {
  7522. player = client->GetPlayer();
  7523. to_client = client;
  7524. }
  7525. if (player)
  7526. {
  7527. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  7528. player->GetSkills()->SetSkill(skill->skill_id, val);
  7529. if (client != to_client)
  7530. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  7531. if(to_client) {
  7532. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  7533. }
  7534. }
  7535. else {
  7536. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  7537. }
  7538. }
  7539. }
  7540. else {
  7541. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7542. }
  7543. }
  7544. else {
  7545. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7546. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7547. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7548. }
  7549. }
  7550. else {
  7551. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7552. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7553. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7554. }
  7555. }
  7556. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  7557. {
  7558. PrintSep(sep, "COMMAND_MODIFY");
  7559. // need at least 2 args for a valid command
  7560. if( sep && sep->arg[1] )
  7561. {
  7562. }
  7563. else
  7564. Command_Modify(client);
  7565. }
  7566. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  7567. {
  7568. PrintSep(sep, "COMMAND_MODIFY");
  7569. // need at least 2 args for a valid command
  7570. if( sep && sep->arg[1] )
  7571. {
  7572. }
  7573. else
  7574. Command_Modify(client);
  7575. }
  7576. /*
  7577. Function: Command_MOTD()
  7578. Purpose : Displays server MOTD
  7579. Params :
  7580. Dev : LethalEncounter
  7581. Example : /motd
  7582. */
  7583. void Commands::Command_MOTD(Client* client)
  7584. {
  7585. if (client)
  7586. ClientPacketFunctions::SendMOTD(client);
  7587. }
  7588. /*
  7589. Function: Command_Pet()
  7590. Purpose : Handle Pet {Command} commands
  7591. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  7592. Dev :
  7593. Example : /pet preserve_master
  7594. */
  7595. void Commands::Command_Pet(Client* client, Seperator* sep)
  7596. {
  7597. PrintSep(sep, "COMMAND_PET");
  7598. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  7599. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7600. if (!sep || !sep->arg[0])
  7601. return; // should have sep->arg[0] filled
  7602. if (strcmp(sep->arg[0], "hide") == 0) {
  7603. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  7604. Entity* pet = client->GetPlayer()->GetDeityPet();
  7605. if (pet) {
  7606. if (pet->IsPrivateSpawn())
  7607. client->GetPlayer()->HideDeityPet(false);
  7608. else
  7609. client->GetPlayer()->HideDeityPet(true);
  7610. }
  7611. pet = client->GetPlayer()->GetCosmeticPet();
  7612. if (pet) {
  7613. if (pet->IsPrivateSpawn())
  7614. client->GetPlayer()->HideCosmeticPet(false);
  7615. else
  7616. client->GetPlayer()->HideCosmeticPet(true);
  7617. }
  7618. return;
  7619. }
  7620. // below is for all combat pets
  7621. if (!client->GetPlayer()->HasPet()) {
  7622. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  7623. return;
  7624. }
  7625. if (strcmp(sep->arg[0], "stay") == 0) {
  7626. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  7627. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  7628. client->GetPlayer()->SetCharSheetChanged(true);
  7629. if (client->GetPlayer()->GetPet())
  7630. client->GetPlayer()->GetPet()->following = false;
  7631. if (client->GetPlayer()->GetCharmedPet())
  7632. client->GetPlayer()->GetCharmedPet()->following = false;
  7633. }
  7634. else if (strcmp(sep->arg[0], "follow") == 0) {
  7635. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  7636. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  7637. client->GetPlayer()->SetCharSheetChanged(true);
  7638. }
  7639. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  7640. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  7641. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  7642. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  7643. }
  7644. else {
  7645. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  7646. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  7647. }
  7648. client->GetPlayer()->SetCharSheetChanged(true);
  7649. }
  7650. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  7651. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  7652. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  7653. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  7654. }
  7655. else {
  7656. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  7657. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  7658. }
  7659. client->GetPlayer()->SetCharSheetChanged(true);
  7660. }
  7661. else if (strcmp(sep->arg[0], "backoff") == 0) {
  7662. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  7663. if (client->GetPlayer()->GetPet())
  7664. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  7665. if (client->GetPlayer()->GetCharmedPet())
  7666. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  7667. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  7668. client->GetPlayer()->SetCharSheetChanged(true);
  7669. }
  7670. else if (strcmp(sep->arg[0], "attack") == 0) {
  7671. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  7672. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  7673. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  7674. if (client->GetPlayer()->GetPet())
  7675. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7676. if (client->GetPlayer()->GetCharmedPet())
  7677. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7678. }
  7679. else
  7680. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  7681. }
  7682. else
  7683. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  7684. }
  7685. else if (strcmp(sep->arg[0], "getlost") == 0) {
  7686. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  7687. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  7688. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  7689. }
  7690. else
  7691. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  7692. }
  7693. /*
  7694. Function: Command_PetName()
  7695. Purpose : Pet your name (???)
  7696. Params :
  7697. Dev :
  7698. Example :
  7699. */
  7700. void Commands::Command_PetName(Client* client, Seperator* sep)
  7701. {
  7702. if (sep && sep->arg[0]) {
  7703. const char* pet_name = sep->argplus[0];
  7704. client->SetPetName(pet_name);
  7705. }
  7706. else {
  7707. client->GetPlayer()->GetInfoStruct()->set_pet_name("");
  7708. }
  7709. }
  7710. /*
  7711. Function: Command_NamePet()
  7712. Purpose : Name your pet
  7713. Params :
  7714. Dev :
  7715. Example :
  7716. */
  7717. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7718. {
  7719. PrintSep(sep, "COMMAND_NAME_PET");
  7720. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7721. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7722. }
  7723. /*
  7724. Function: Command_Rename()
  7725. Purpose : Renames existing pet
  7726. Params :
  7727. Dev :
  7728. Example :
  7729. */
  7730. void Commands::Command_Rename(Client* client, Seperator* sep)
  7731. {
  7732. PrintSep(sep, "COMMAND_RENAME");
  7733. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7734. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7735. }
  7736. /*
  7737. Function: Command_ConfirmRename()
  7738. Purpose : Confirms renaming your pet
  7739. Params :
  7740. Dev :
  7741. Example :
  7742. */
  7743. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7744. {
  7745. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7746. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7747. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7748. }
  7749. /*
  7750. Function: Command_PetOptions()
  7751. Purpose : Sets various pet options
  7752. Params :
  7753. Dev :
  7754. Example :
  7755. */
  7756. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7757. {
  7758. PrintSep(sep, "COMMAND_PETOPTIONS");
  7759. Player* player = client->GetPlayer();
  7760. Spawn* target = player->GetTarget();
  7761. if (!target)
  7762. return;
  7763. if (target == player->GetPet())
  7764. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7765. else if (target == player->GetCharmedPet())
  7766. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7767. else if (target == player->GetCosmeticPet())
  7768. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7769. else if (target == player->GetDeityPet())
  7770. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7771. }
  7772. /*
  7773. Function: Command_Random()
  7774. Purpose : Handles /random dice roll in-game
  7775. Params : 1-100
  7776. Dev : Scatman
  7777. Example : /randon 1 100
  7778. */
  7779. void Commands::Command_Random(Client* client, Seperator* sep)
  7780. {
  7781. char message[256] = {0};
  7782. if (sep)
  7783. {
  7784. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7785. 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])));
  7786. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7787. 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])));
  7788. else
  7789. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7790. }
  7791. else
  7792. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7793. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7794. }
  7795. /*
  7796. Function: Command_Randomize()
  7797. Purpose : Sets randomize (appearance) values for NPCs
  7798. Params : Attrib Name
  7799. Dev : Scatman
  7800. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7801. */
  7802. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7803. {
  7804. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7805. if (target)
  7806. {
  7807. if (target->IsNPC())
  7808. {
  7809. if (sep && sep->arg[0] && !sep->IsNumber(0))
  7810. {
  7811. const char* value = sep->arg[0];
  7812. if (strncasecmp(value, "show", strlen(value)) == 0)
  7813. {
  7814. client->DisplayRandomizeFeatures(target->GetRandomize());
  7815. }
  7816. else
  7817. {
  7818. if (sep->arg[1] && sep->IsNumber(1))
  7819. {
  7820. int8 option = atoi(sep->arg[1]);
  7821. if (option == 0 || option == 1)
  7822. {
  7823. int32 feature = 0;
  7824. char feature_text[32] = {0};
  7825. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7826. feature = RANDOMIZE_GENDER;
  7827. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7828. }
  7829. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7830. feature = RANDOMIZE_RACE;
  7831. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7832. }
  7833. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7834. feature = RANDOMIZE_MODEL_TYPE;
  7835. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7836. }
  7837. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7838. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7839. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7840. }
  7841. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7842. feature = RANDOMIZE_HAIR_TYPE;
  7843. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7844. }
  7845. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7846. feature = RANDOMIZE_WING_TYPE;
  7847. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7848. }
  7849. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7850. feature = RANDOMIZE_CHEEK_TYPE;
  7851. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7852. }
  7853. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7854. feature = RANDOMIZE_CHIN_TYPE;
  7855. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7856. }
  7857. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7858. feature = RANDOMIZE_EAR_TYPE;
  7859. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7860. }
  7861. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7862. feature = RANDOMIZE_EYE_BROW_TYPE;
  7863. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7864. }
  7865. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7866. feature = RANDOMIZE_EYE_TYPE;
  7867. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7868. }
  7869. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7870. feature = RANDOMIZE_LIP_TYPE;
  7871. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7872. }
  7873. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7874. feature = RANDOMIZE_NOSE_TYPE;
  7875. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7876. }
  7877. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7878. feature = RANDOMIZE_EYE_COLOR;
  7879. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7880. }
  7881. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7882. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7883. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7884. }
  7885. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7886. feature = RANDOMIZE_HAIR_COLOR1;
  7887. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7888. }
  7889. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7890. feature = RANDOMIZE_HAIR_COLOR2;
  7891. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7892. }
  7893. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7894. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7895. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7896. }
  7897. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7898. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7899. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7900. }
  7901. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7902. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7903. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7904. }
  7905. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7906. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7907. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7908. }
  7909. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7910. feature = RANDOMIZE_SKIN_COLOR;
  7911. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7912. }
  7913. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7914. feature = RANDOMIZE_WING_COLOR1;
  7915. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7916. }
  7917. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7918. feature = RANDOMIZE_WING_COLOR2;
  7919. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7920. }
  7921. else {
  7922. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7923. 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'.");
  7924. }
  7925. if (feature > 0) {
  7926. if (option == 1) {
  7927. if (target->GetRandomize() & feature)
  7928. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  7929. else {
  7930. target->AddRandomize(feature);
  7931. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  7932. database.UpdateRandomize(target->GetDatabaseID(), feature);
  7933. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  7934. }
  7935. }
  7936. else {
  7937. if (target->GetRandomize() & feature) {
  7938. target->AddRandomize(-feature);
  7939. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  7940. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  7941. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  7942. }
  7943. else
  7944. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  7945. }
  7946. }
  7947. }
  7948. else
  7949. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7950. }
  7951. else
  7952. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7953. }
  7954. }
  7955. else {
  7956. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  7957. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  7958. 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'.");
  7959. }
  7960. }
  7961. else
  7962. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  7963. }
  7964. else
  7965. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  7966. }
  7967. /*
  7968. Function: Command_ShowCloak()
  7969. Purpose : Character Settings combo box for Show Cloak
  7970. Params : true/false
  7971. Dev : John Adams
  7972. Example :
  7973. */
  7974. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  7975. {
  7976. Player* player = client->GetPlayer();
  7977. if (sep && sep->arg[0])
  7978. {
  7979. const char* value = sep->arg[0];
  7980. if (strncasecmp(value, "true", strlen(value)) == 0)
  7981. {
  7982. player->set_character_flag(CF_SHOW_CLOAK);
  7983. player->reset_character_flag(CF2_SHOW_RANGED);
  7984. }
  7985. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7986. player->reset_character_flag(CF_SHOW_CLOAK);
  7987. else
  7988. {
  7989. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7990. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7991. }
  7992. }
  7993. }
  7994. /*
  7995. Function: Command_ShowHelm()
  7996. Purpose : Character Settings combo box for Show Helm
  7997. Params : true/false
  7998. Dev : John Adams
  7999. Example :
  8000. */
  8001. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  8002. {
  8003. Player* player = client->GetPlayer();
  8004. if(client->GetVersion() <= 546) {
  8005. return; // not allowed/supported
  8006. }
  8007. if (sep && sep->arg[0])
  8008. {
  8009. PrintSep(sep, "Command_ShowHelm");
  8010. const char* value = sep->arg[0];
  8011. if (strncasecmp(value, "true", strlen(value)) == 0)
  8012. {
  8013. player->toggle_character_flag(CF_HIDE_HELM);
  8014. player->toggle_character_flag(CF_HIDE_HOOD);
  8015. }
  8016. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8017. player->toggle_character_flag(CF_HIDE_HELM);
  8018. else
  8019. {
  8020. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8021. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8022. }
  8023. }
  8024. }
  8025. /*
  8026. Function: Command_ShowHood()
  8027. Purpose : Character Settings combo box for Show Hood
  8028. Params : true/false
  8029. Dev : John Adams
  8030. Example :
  8031. */
  8032. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  8033. {
  8034. Player* player = client->GetPlayer();
  8035. if (sep && sep->arg[0])
  8036. {
  8037. PrintSep(sep, "Command_ShowHood");
  8038. const char* value = sep->arg[0];
  8039. if (strncasecmp(value, "true", strlen(value)) == 0)
  8040. {
  8041. player->toggle_character_flag(CF_HIDE_HOOD);
  8042. if(client->GetVersion() > 546) { // no hide helm support in DoF
  8043. player->toggle_character_flag(CF_HIDE_HELM);
  8044. }
  8045. }
  8046. else if (strncasecmp(value, "false", strlen(value)) == 0) {
  8047. player->toggle_character_flag(CF_HIDE_HOOD);
  8048. }
  8049. else
  8050. {
  8051. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8052. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8053. }
  8054. }
  8055. }
  8056. /*
  8057. Function: Command_ShowHoodHelm()
  8058. Purpose : Character Settings combo box for Show Helm or Hood
  8059. Params : true/false
  8060. Dev : John Adams
  8061. Example :
  8062. */
  8063. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  8064. {
  8065. Player* player = client->GetPlayer();
  8066. if(client->GetVersion() <= 546) {
  8067. return; // not allowed/supported
  8068. }
  8069. if (sep && sep->arg[0])
  8070. {
  8071. PrintSep(sep, "Command_ShowHoodHelm");
  8072. const char* value = sep->arg[0];
  8073. if (strncasecmp(value, "true", strlen(value)) == 0)
  8074. {
  8075. player->toggle_character_flag(CF_HIDE_HOOD);
  8076. player->toggle_character_flag(CF_HIDE_HELM);
  8077. }
  8078. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8079. {
  8080. // don't think we ever wind up in here...
  8081. player->toggle_character_flag(CF_HIDE_HOOD);
  8082. player->toggle_character_flag(CF_HIDE_HELM);
  8083. }
  8084. else
  8085. {
  8086. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8087. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8088. }
  8089. }
  8090. }
  8091. /*
  8092. Function: Command_ShowRanged()
  8093. Purpose : Character Settings combo box for Show Ranged weapon
  8094. Params : true/false
  8095. Dev : John Adams
  8096. Example :
  8097. */
  8098. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  8099. {
  8100. Player* player = client->GetPlayer();
  8101. if (sep && sep->arg[0])
  8102. {
  8103. const char* value = sep->arg[0];
  8104. if (strncasecmp(value, "true", strlen(value)) == 0)
  8105. {
  8106. player->set_character_flag(CF2_SHOW_RANGED);
  8107. player->reset_character_flag(CF_SHOW_CLOAK);
  8108. }
  8109. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8110. player->reset_character_flag(CF2_SHOW_RANGED);
  8111. else
  8112. {
  8113. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8114. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8115. }
  8116. }
  8117. }
  8118. /*
  8119. Function:
  8120. Purpose :
  8121. Params :
  8122. Dev :
  8123. Example :
  8124. */
  8125. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  8126. {
  8127. Player* player = 0;
  8128. Client* to_client = 0;
  8129. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  8130. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  8131. switch(handler)
  8132. {
  8133. case COMMAND_SKILL:
  8134. {
  8135. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  8136. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  8137. break;
  8138. }
  8139. case COMMAND_SKILL_ADD:
  8140. {
  8141. if (sep && sep->arg[0])
  8142. {
  8143. const char* skill_name = sep->argplus[0];
  8144. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8145. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  8146. {
  8147. player = to_client->GetPlayer();
  8148. if (player)
  8149. {
  8150. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8151. {
  8152. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8153. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  8154. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  8155. }
  8156. else
  8157. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  8158. }
  8159. }
  8160. else if (skill) // add skill to yourself
  8161. {
  8162. player = client->GetPlayer();
  8163. if (player)
  8164. {
  8165. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8166. {
  8167. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8168. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  8169. }
  8170. else
  8171. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  8172. }
  8173. }
  8174. else
  8175. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8176. }
  8177. else
  8178. {
  8179. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  8180. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8181. }
  8182. break;
  8183. }
  8184. case COMMAND_SKILL_REMOVE:
  8185. {
  8186. if (sep && sep->arg[0])
  8187. {
  8188. const char* skill_name = sep->argplus[0];
  8189. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8190. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  8191. {
  8192. player = to_client->GetPlayer();
  8193. if (player)
  8194. {
  8195. if (player->GetSkills()->HasSkill(skill->skill_id))
  8196. {
  8197. player->RemoveSkillFromDB(skill, true);
  8198. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  8199. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  8200. }
  8201. else
  8202. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  8203. }
  8204. }
  8205. else if(skill) // remove skill from yourself
  8206. {
  8207. Player* player = client->GetPlayer();
  8208. if (player)
  8209. {
  8210. if (player->GetSkills()->HasSkill(skill->skill_id))
  8211. {
  8212. player->RemoveSkillFromDB(skill, true);
  8213. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  8214. }
  8215. else
  8216. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  8217. }
  8218. }
  8219. else
  8220. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8221. }
  8222. else
  8223. {
  8224. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  8225. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8226. }
  8227. break;
  8228. }
  8229. case COMMAND_SKILL_LIST:
  8230. {
  8231. if (sep && sep->arg[0])
  8232. {
  8233. const char* skill_name = sep->argplus[0];
  8234. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  8235. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  8236. map<int32, Skill*>::iterator itr;
  8237. if (skills && skills->size() > 0)
  8238. {
  8239. for (itr = skills->begin(); itr != skills->end(); itr++)
  8240. {
  8241. Skill* skill = itr->second;
  8242. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  8243. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  8244. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  8245. }
  8246. }
  8247. }
  8248. else
  8249. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  8250. break;
  8251. }
  8252. }
  8253. }
  8254. /*
  8255. Function: Command_SpawnTemplate()
  8256. Purpose : Create or Use defined Spawn Templates
  8257. Params : create, save, rempve, list
  8258. Dev : John Adams
  8259. Example : /spawn template create "Test"
  8260. */
  8261. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  8262. {
  8263. if (sep == NULL || sep->arg[0] == NULL)
  8264. {
  8265. 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.");
  8266. return;
  8267. }
  8268. // got params, continue
  8269. const char * template_cmd = sep->arg[0];
  8270. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  8271. {
  8272. if (!sep->IsSet(1))
  8273. {
  8274. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  8275. 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.");
  8276. return;
  8277. }
  8278. map<int32, string>* template_names = 0;
  8279. if (sep->IsNumber(1))
  8280. {
  8281. int32 location_id = 0;
  8282. location_id = atoi(sep->arg[1]);
  8283. template_names = database.GetSpawnTemplateListByID(location_id);
  8284. }
  8285. else
  8286. {
  8287. const char* name = 0;
  8288. name = sep->argplus[1];
  8289. template_names = database.GetSpawnTemplateListByName(name);
  8290. }
  8291. if(!template_names)
  8292. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  8293. else
  8294. {
  8295. map<int32, string>::iterator itr;
  8296. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  8297. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  8298. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  8299. safe_delete(template_names);
  8300. }
  8301. }
  8302. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  8303. {
  8304. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8305. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  8306. {
  8307. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  8308. {
  8309. // first, lookup to see if template name already exists
  8310. const char* name = 0;
  8311. name = sep->argplus[1];
  8312. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  8313. if(!template_names)
  8314. {
  8315. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  8316. if( new_template_id > 0 )
  8317. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  8318. else
  8319. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  8320. }
  8321. else
  8322. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  8323. }
  8324. else
  8325. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  8326. }
  8327. else
  8328. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  8329. }
  8330. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  8331. {
  8332. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  8333. {
  8334. int32 template_id = 0;
  8335. template_id = atoi(sep->arg[1]);
  8336. if (database.RemoveSpawnTemplate(template_id))
  8337. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  8338. else
  8339. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  8340. }
  8341. else
  8342. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  8343. }
  8344. // Renamed create to spawn
  8345. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  8346. {
  8347. if (sep && sep->arg[1][0])
  8348. {
  8349. int32 new_location = 0;
  8350. if (sep->IsNumber(1))
  8351. {
  8352. int32 template_id = 0;
  8353. template_id = atoi(sep->arg[1]);
  8354. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  8355. if( new_location > 0 )
  8356. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  8357. else
  8358. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  8359. }
  8360. else
  8361. {
  8362. const char* name = 0;
  8363. name = sep->argplus[1];
  8364. new_location = database.CreateSpawnFromTemplateByName(client, name);
  8365. if( new_location > 0 )
  8366. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  8367. else
  8368. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  8369. }
  8370. }
  8371. else
  8372. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  8373. }
  8374. else
  8375. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  8376. }
  8377. void Commands::Command_Speed(Client* client, Seperator* sep) {
  8378. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  8379. float new_speed = atof(sep->arg[0]);
  8380. if (new_speed > 0.0f)
  8381. {
  8382. client->GetPlayer()->SetSpeed(new_speed, true);
  8383. client->GetPlayer()->SetCharSheetChanged(true);
  8384. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  8385. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  8386. }
  8387. else
  8388. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  8389. }
  8390. else{
  8391. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  8392. }
  8393. }
  8394. /*
  8395. Function: Command_StationMarketPlace()
  8396. Purpose : just trying to eat the console spam for now
  8397. Params :
  8398. Dev : John
  8399. */
  8400. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  8401. {
  8402. PrintSep(sep, "COMMAND_SMP");
  8403. // This will reduce the spam from once every 10 sec to once every 30 sec,
  8404. // can't seem to reduce it any more get rid of it completely...
  8405. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  8406. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  8407. if (packet) {
  8408. packet->setDataByName("account_id", client->GetAccountID());
  8409. packet->setDataByName("character_id", client->GetCharacterID());
  8410. packet->setDataByName("unknown1", 1, 5);
  8411. packet->setDataByName("unknown1", 26, 6);
  8412. packet->setDataByName("unknown2", 0xFFFFFFFF);
  8413. packet->setDataByName("unknown3", 248, 1);
  8414. client->QueuePacket(packet->serialize());
  8415. }
  8416. safe_delete(packet);
  8417. }
  8418. }
  8419. /*
  8420. Function: Command_StopDrinking()
  8421. Purpose : Stops player from auto-consuming drink
  8422. Params :
  8423. Dev : Zcoretri
  8424. Example : /stopdrinking
  8425. */
  8426. void Commands::Command_StopDrinking(Client* client)
  8427. {
  8428. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  8429. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  8430. }
  8431. /*
  8432. Function: Command_StopEating()
  8433. Purpose : Stops player from auto-consuming food
  8434. Params :
  8435. Dev : Zcoretri
  8436. Example : /stopeating
  8437. */
  8438. void Commands::Command_StopEating(Client* client)
  8439. {
  8440. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  8441. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  8442. }
  8443. /*
  8444. Function: Command_Title()
  8445. Purpose : Help for /title command
  8446. Params : n/a
  8447. Dev : Zcoretri
  8448. Example : /title
  8449. */
  8450. void Commands::Command_Title(Client* client)
  8451. {
  8452. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  8453. }
  8454. /*
  8455. Function: Command_TitleList()
  8456. Purpose : List available titles for player
  8457. Params : n/a
  8458. Dev : Zcoretri
  8459. Example : /title list
  8460. */
  8461. void Commands::Command_TitleList(Client* client)
  8462. {
  8463. // must call release read lock before leaving function on GetPlayerTitles
  8464. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  8465. vector<Title*>::iterator itr;
  8466. Title* title;
  8467. sint32 i = 0;
  8468. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  8469. for(itr = titles->begin(); itr != titles->end(); itr++)
  8470. {
  8471. title = *itr;
  8472. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  8473. i++;
  8474. }
  8475. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  8476. }
  8477. /*
  8478. Function: Command_TitleSetPrefix()
  8479. Purpose : Set Prefix title for player
  8480. Params : Title ID
  8481. Dev : Zcoretri
  8482. Example : /title setprefix 1
  8483. */
  8484. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  8485. {
  8486. if (sep && sep->arg[0] && sep->IsNumber(0))
  8487. {
  8488. sint32 index = atoul(sep->arg[0]);
  8489. if(index > -1)
  8490. {
  8491. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8492. if(!title)
  8493. {
  8494. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8495. return;
  8496. }
  8497. else if(!title->GetPrefix())
  8498. {
  8499. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  8500. return;
  8501. }
  8502. }
  8503. else // make sure client doesn't pass some bogus negative index
  8504. index = -1;
  8505. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  8506. client->SendTitleUpdate();
  8507. }
  8508. }
  8509. /*
  8510. Function: Command_TitleSetSuffix()
  8511. Purpose : Set Suffix title for player
  8512. Params : Title ID
  8513. Dev : Zcoretri
  8514. Example : /title setsuffix 1
  8515. */
  8516. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  8517. {
  8518. if (sep && sep->arg[0] && sep->IsNumber(0))
  8519. {
  8520. sint32 index = atoul(sep->arg[0]);
  8521. if(index > -1)
  8522. {
  8523. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8524. if(!title)
  8525. {
  8526. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8527. return;
  8528. }
  8529. else if(title->GetPrefix())
  8530. {
  8531. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  8532. return;
  8533. }
  8534. }
  8535. else // make sure client doesn't pass some bogus negative index
  8536. index = -1;
  8537. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  8538. client->SendTitleUpdate();
  8539. }
  8540. }
  8541. /*
  8542. Function: Command_TitleFix()
  8543. Purpose : Fix title for player (???)
  8544. Params :
  8545. Dev : Zcoretri
  8546. Example :
  8547. */
  8548. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  8549. {
  8550. PrintSep(sep, "COMMAND_TITLE_FIX");
  8551. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  8552. }
  8553. /*
  8554. Function: Command_Toggle_Anonymous()
  8555. Purpose : Toggles player Anonymous
  8556. Params :
  8557. Dev : paulgh
  8558. Example : /anon
  8559. */
  8560. void Commands::Command_Toggle_Anonymous(Client* client)
  8561. {
  8562. Player* player = client->GetPlayer();
  8563. player->toggle_character_flag(CF_ANONYMOUS);
  8564. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  8565. if (player->get_character_flag(CF_ANONYMOUS))
  8566. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  8567. else
  8568. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  8569. }
  8570. /*
  8571. Function: Command_Toggle_AutoConsume()
  8572. Purpose : Toggles player food/drink auto consume
  8573. Params : unknown
  8574. Dev : paulgh
  8575. Example : /set_auto_consume
  8576. */
  8577. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  8578. {
  8579. Player* player = client->GetPlayer();
  8580. if (sep && sep->arg[0])
  8581. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  8582. if (sep && sep->arg[0] && sep->IsNumber(0))
  8583. {
  8584. int8 slot = atoi(sep->arg[0]);
  8585. int8 flag = atoi(sep->arg[1]);
  8586. if (client->GetVersion() <= 283) {
  8587. slot += 4;
  8588. }
  8589. else if (client->GetVersion() <= 546) {
  8590. slot += 2;
  8591. }
  8592. if (slot == EQ2_FOOD_SLOT)
  8593. {
  8594. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  8595. player->SetCharSheetChanged(true);
  8596. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8597. if (flag == 1)
  8598. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  8599. else
  8600. {
  8601. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  8602. return;
  8603. }
  8604. }
  8605. else
  8606. {
  8607. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  8608. player->SetCharSheetChanged(true);
  8609. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8610. if (flag == 1)
  8611. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  8612. else
  8613. {
  8614. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  8615. return;
  8616. }
  8617. }
  8618. if(!client->CheckConsumptionAllowed(slot, false))
  8619. return;
  8620. Item* item = player->GetEquipmentList()->GetItem(slot);
  8621. if(item)
  8622. client->ConsumeFoodDrink(item, slot);
  8623. }
  8624. }
  8625. /*
  8626. Function: Command_Toggle_BonusXP()
  8627. Purpose : Toggles player Bonus XP
  8628. Params :
  8629. Dev : John Adams
  8630. Example : /disable_char_bonus_exp
  8631. */
  8632. void Commands::Command_Toggle_BonusXP(Client* client)
  8633. {
  8634. Player* player = client->GetPlayer();
  8635. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  8636. player->SetCharSheetChanged(true);
  8637. }
  8638. /*
  8639. Function: Command_Toggle_CombatXP()
  8640. Purpose : Toggles player Adventure XP
  8641. Params :
  8642. Dev : John Adams
  8643. Example : /disable_combat_exp
  8644. */
  8645. void Commands::Command_Toggle_CombatXP(Client* client)
  8646. {
  8647. Player* player = client->GetPlayer();
  8648. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  8649. player->SetCharSheetChanged(true);
  8650. }
  8651. /*
  8652. Function: Command_Toggle_GMHide()
  8653. Purpose : Toggles hiding player GM status
  8654. Params :
  8655. Dev : Scatman
  8656. Example : /gm_hide
  8657. */
  8658. void Commands::Command_Toggle_GMHide(Client* client)
  8659. {
  8660. Player* player = client->GetPlayer();
  8661. player->toggle_character_flag(CF_HIDE_STATUS);
  8662. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  8663. }
  8664. /*
  8665. Function: Command_Toggle_GMVanish()
  8666. Purpose : Toggles hiding GM players from /who searches
  8667. Params :
  8668. Dev : Scatman
  8669. Example : /gm_vanish
  8670. */
  8671. void Commands::Command_Toggle_GMVanish(Client* client)
  8672. {
  8673. Player* player = client->GetPlayer();
  8674. player->toggle_character_flag(CF_GM_HIDDEN);
  8675. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  8676. }
  8677. /*
  8678. Function: Command_Toggle_Illusions()
  8679. Purpose : Toggles player illusion form
  8680. Params : not sure sep is needed, testing
  8681. Dev : paulgh
  8682. Example : /hide_illusions
  8683. */
  8684. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  8685. {
  8686. if (sep && sep->arg[0])
  8687. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  8688. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  8689. }
  8690. /*
  8691. Function: Command_Toggle_LFG()
  8692. Purpose : Toggles player LFG Flag
  8693. Params :
  8694. Dev : paulgh
  8695. Example : /lfg
  8696. */
  8697. void Commands::Command_Toggle_LFG(Client* client)
  8698. {
  8699. Player* player = client->GetPlayer();
  8700. player->toggle_character_flag(CF_LFG);
  8701. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  8702. if (player->get_character_flag(CF_LFG))
  8703. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  8704. else
  8705. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  8706. }
  8707. /*
  8708. Function: Command_Toggle_LFW()
  8709. Purpose : Toggles player LFW Flag
  8710. Params :
  8711. Dev : paulgh
  8712. Example : /lfw
  8713. */
  8714. void Commands::Command_Toggle_LFW(Client* client)
  8715. {
  8716. Player* player = client->GetPlayer();
  8717. player->toggle_character_flag(CF_LFW);
  8718. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8719. if (player->get_character_flag(CF_LFW))
  8720. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8721. else
  8722. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8723. }
  8724. /*
  8725. Function: Command_Toggle_QuestXP()
  8726. Purpose : Toggles player Quest XP
  8727. Params :
  8728. Dev : John Adams
  8729. Example : /disable_quest_exp
  8730. */
  8731. void Commands::Command_Toggle_QuestXP(Client* client)
  8732. {
  8733. Player* player = client->GetPlayer();
  8734. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8735. player->SetCharSheetChanged(true);
  8736. }
  8737. /*
  8738. Function: Command_Toggle_Roleplaying()
  8739. Purpose : Toggles player Roleplaying flag
  8740. Params :
  8741. Dev : paulgh
  8742. Example : /role
  8743. */
  8744. void Commands::Command_Toggle_Roleplaying(Client* client)
  8745. {
  8746. Player* player = client->GetPlayer();
  8747. player->toggle_character_flag(CF_ROLEPLAYING);
  8748. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8749. if (player->get_character_flag(CF_ROLEPLAYING))
  8750. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8751. else
  8752. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8753. }
  8754. void Commands::Command_Toggle_Duels(Client* client)
  8755. {
  8756. Player* player = client->GetPlayer();
  8757. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8758. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8759. }
  8760. void Commands::Command_Toggle_Trades(Client* client)
  8761. {
  8762. Player* player = client->GetPlayer();
  8763. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8764. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8765. }
  8766. void Commands::Command_Toggle_Guilds(Client* client)
  8767. {
  8768. Player* player = client->GetPlayer();
  8769. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8770. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8771. }
  8772. void Commands::Command_Toggle_Groups(Client* client)
  8773. {
  8774. Player* player = client->GetPlayer();
  8775. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8776. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8777. }
  8778. void Commands::Command_Toggle_Raids(Client* client)
  8779. {
  8780. Player* player = client->GetPlayer();
  8781. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8782. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8783. }
  8784. void Commands::Command_Toggle_LON(Client* client)
  8785. {
  8786. Player* player = client->GetPlayer();
  8787. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8788. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8789. }
  8790. void Commands::Command_Toggle_VoiceChat(Client* client)
  8791. {
  8792. Player* player = client->GetPlayer();
  8793. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8794. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8795. }
  8796. /*
  8797. Function: Command_TradeStart()
  8798. Purpose : Starts item/coin trade between players
  8799. Params :
  8800. Dev :
  8801. Example :
  8802. */
  8803. #include "../Trade.h"
  8804. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  8805. {
  8806. PrintSep(sep, "COMMAND_START_TRADE");
  8807. Entity* trader = client->GetPlayer();
  8808. Entity* trader2 = 0;
  8809. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8810. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  8811. if (spawn) {
  8812. if (spawn->IsEntity())
  8813. trader2 = (Entity*)spawn;
  8814. }
  8815. }
  8816. else if (client->GetPlayer()->GetTarget()) {
  8817. if (client->GetPlayer()->GetTarget()->IsEntity())
  8818. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  8819. }
  8820. // can only trade with player or bots
  8821. if (trader && trader2) {
  8822. if (trader == trader2) {
  8823. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  8824. }
  8825. else if (trader2->IsPlayer() || trader2->IsBot()) {
  8826. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  8827. if (trader->trade)
  8828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  8829. else if (trader2->trade)
  8830. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  8831. else {
  8832. Trade* trade = new Trade(trader, trader2);
  8833. trader->trade = trade;
  8834. trader2->trade = trade;
  8835. }
  8836. }
  8837. else {
  8838. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8839. }
  8840. }
  8841. else
  8842. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8843. }
  8844. /*
  8845. Function: Command_Track()
  8846. Purpose : Starts/Stops Tracking for a player
  8847. Params :
  8848. Dev : Scatman
  8849. Example : /track
  8850. */
  8851. void Commands::Command_Track(Client* client)
  8852. {
  8853. if (!client->GetPlayer()->GetIsTracking())
  8854. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8855. else
  8856. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8857. }
  8858. /*
  8859. Function: Command_TradeAccept()
  8860. Purpose : Accepts item/coin trade between players
  8861. Params :
  8862. Dev :
  8863. Example :
  8864. */
  8865. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8866. {
  8867. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8868. Trade* trade = client->GetPlayer()->trade;
  8869. if (trade) {
  8870. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8871. if (trade_complete)
  8872. safe_delete(trade);
  8873. }
  8874. else
  8875. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8876. }
  8877. /*
  8878. Function: Command_TradeReject()
  8879. Purpose : Rejects item/coin trade between players
  8880. Params :
  8881. Dev :
  8882. Example :
  8883. */
  8884. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8885. {
  8886. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8887. Command_TradeCancel(client, sep);
  8888. }
  8889. /*
  8890. Function: Command_TradeCancel()
  8891. Purpose : Cancels item/coin trade between players
  8892. Params :
  8893. Dev :
  8894. Example :
  8895. */
  8896. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8897. {
  8898. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8899. Trade* trade = client->GetPlayer()->trade;
  8900. if (trade) {
  8901. trade->CancelTrade(client->GetPlayer());
  8902. safe_delete(trade);
  8903. }
  8904. else
  8905. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8906. }
  8907. /*
  8908. Function: Command_TradeSetCoin()
  8909. Purpose : Sets coin trade between players
  8910. Params :
  8911. Dev :
  8912. Example :
  8913. */
  8914. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8915. {
  8916. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8917. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8918. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8919. }
  8920. /*
  8921. Function: Command_TradeAddCoin()
  8922. Purpose : Adds coin to trade between players
  8923. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8924. Dev :
  8925. Example :
  8926. */
  8927. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  8928. {
  8929. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  8930. Trade* trade = client->GetPlayer()->trade;
  8931. if (trade) {
  8932. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8933. int32 amount = atoi(sep->arg[0]);
  8934. int64 val = 0;
  8935. switch (handler) {
  8936. case COMMAND_ADD_TRADE_COPPER:
  8937. {
  8938. val = amount;
  8939. trade->AddCoinToTrade(client->GetPlayer(), val);
  8940. break;
  8941. }
  8942. case COMMAND_ADD_TRADE_SILVER:
  8943. {
  8944. val = amount * 100;
  8945. trade->AddCoinToTrade(client->GetPlayer(), val);
  8946. break;
  8947. }
  8948. case COMMAND_ADD_TRADE_GOLD:
  8949. {
  8950. val = amount * 10000;
  8951. trade->AddCoinToTrade(client->GetPlayer(), val);
  8952. break;
  8953. }
  8954. case COMMAND_ADD_TRADE_PLAT:
  8955. {
  8956. val = amount * 1000000;
  8957. trade->AddCoinToTrade(client->GetPlayer(), val);
  8958. break;
  8959. }
  8960. default:
  8961. {
  8962. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8963. break;
  8964. }
  8965. }
  8966. }
  8967. else
  8968. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  8969. }
  8970. else
  8971. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8972. }
  8973. /*
  8974. Function: Command_TradeRemoveCoin()
  8975. Purpose : Removes coin from trade between players
  8976. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8977. Dev :
  8978. Example :
  8979. */
  8980. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  8981. {
  8982. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  8983. Trade* trade = client->GetPlayer()->trade;
  8984. if (trade) {
  8985. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8986. int32 amount = atoi(sep->arg[0]);
  8987. int64 val = 0;
  8988. switch (handler) {
  8989. case COMMAND_REMOVE_TRADE_COPPER:
  8990. {
  8991. val = amount;
  8992. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8993. break;
  8994. }
  8995. case COMMAND_REMOVE_TRADE_SILVER:
  8996. {
  8997. val = amount * 100;
  8998. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8999. break;
  9000. }
  9001. case COMMAND_REMOVE_TRADE_GOLD:
  9002. {
  9003. val = amount * 10000;
  9004. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9005. break;
  9006. }
  9007. case COMMAND_REMOVE_TRADE_PLAT:
  9008. {
  9009. val = amount * 1000000;
  9010. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9011. break;
  9012. }
  9013. default:
  9014. {
  9015. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  9016. break;
  9017. }
  9018. }
  9019. }
  9020. else
  9021. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  9022. }
  9023. else
  9024. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9025. }
  9026. /*
  9027. Function: Command_TradeAddItem()
  9028. Purpose : Adds item to trade between players
  9029. Params :
  9030. Dev :
  9031. Example :
  9032. */
  9033. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  9034. {
  9035. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  9036. /*
  9037. arg[0] = item index
  9038. arg[1] = slot
  9039. arg[2] = quantity
  9040. */
  9041. if (!client->GetPlayer()->trade) {
  9042. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  9043. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9044. return;
  9045. }
  9046. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  9047. Item* item = 0;
  9048. int32 index = atoi(sep->arg[0]);
  9049. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  9050. if (item) {
  9051. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  9052. if (result == 1)
  9053. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  9054. else if (result == 2)
  9055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  9056. else if (result == 3)
  9057. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  9058. else if (result == 255)
  9059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  9060. }
  9061. else {
  9062. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  9063. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  9064. }
  9065. }
  9066. else
  9067. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9068. }
  9069. /*
  9070. Function: Command_TradeRemoveItem()
  9071. Purpose : Removes item from trade between players
  9072. Params :
  9073. Dev :
  9074. Example :
  9075. */
  9076. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  9077. {
  9078. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  9079. /*
  9080. arg[0] = trade window slot
  9081. */
  9082. Trade* trade = client->GetPlayer()->trade;
  9083. if (trade) {
  9084. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9085. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  9086. }
  9087. else
  9088. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9089. }
  9090. else
  9091. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9092. }
  9093. void Commands::Command_TryOn(Client* client, Seperator* sep)
  9094. {
  9095. Item *item = 0;
  9096. sint32 crc;
  9097. if (sep) {
  9098. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  9099. if (client->GetVersion() < 1096) {
  9100. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  9101. {
  9102. item = master_item_list.GetItem(atoul(sep->arg[1]));
  9103. crc = atol(sep->arg[2]);
  9104. }
  9105. }
  9106. else {
  9107. // From the broker and links in chat
  9108. if (strcmp(sep->arg[0], "crc") == 0) {
  9109. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  9110. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9111. crc = atol(sep->arg[3]);
  9112. }
  9113. }
  9114. // From inventory
  9115. if (strcmp(sep->arg[0], "dbid") == 0) {
  9116. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  9117. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9118. crc = atol(sep->arg[4]);
  9119. }
  9120. }
  9121. }
  9122. if (item)
  9123. client->ShowDressingRoom(item, crc);
  9124. }
  9125. }
  9126. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  9127. const char *channel_name, *password = NULL;
  9128. if (sep == NULL || !sep->IsSet(0)) {
  9129. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  9130. return;
  9131. }
  9132. channel_name = sep->arg[0];
  9133. if (sep->IsSet(1))
  9134. password = sep->arg[1];
  9135. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  9136. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  9137. return;
  9138. }
  9139. if (chat.IsInChannel(client, channel_name)) {
  9140. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  9141. return;
  9142. }
  9143. if (chat.HasPassword(channel_name)) {
  9144. if (password == NULL) {
  9145. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  9146. return;
  9147. }
  9148. if (!chat.PasswordMatches(channel_name, password)) {
  9149. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  9150. return;
  9151. }
  9152. }
  9153. if (!chat.JoinChannel(client, channel_name))
  9154. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  9155. }
  9156. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  9157. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  9158. Command_JoinChannel(client, sep);
  9159. }
  9160. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  9161. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  9162. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  9163. PrintSep(sep, "tellchannel");
  9164. return;
  9165. }
  9166. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  9167. }
  9168. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  9169. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9170. if (sep->IsSet(0)) {
  9171. if (atoi(sep->arg[0]) == 1) {
  9172. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  9173. if (packet2) {
  9174. packet2->setDataByName("spell_type", 2);
  9175. packet2->setDataByName("spell_id", 8308);
  9176. packet2->setDataByName("spell_name", "Sprint");
  9177. packet2->setDataByName("add_silently", 0);
  9178. packet2->setDataByName("tier", 1);
  9179. packet2->setDataByName("blah1", 1);
  9180. packet2->setDataByName("blah2", 1);
  9181. EQ2Packet* outapp = packet2->serialize();
  9182. DumpPacket(outapp);
  9183. client->QueuePacket(outapp);
  9184. safe_delete(packet2);
  9185. }
  9186. }
  9187. else if (atoi(sep->arg[0]) == 2) {
  9188. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  9189. if (packet2) {
  9190. packet2->setDataByName("guild_name", "Test");
  9191. packet2->setDataByName("guild_motd", "Test MOTD");
  9192. packet2->setDataByName("guild_id", 1234);
  9193. packet2->setDataByName("guild_level", 1);
  9194. packet2->setDataByName("unknown", 2);
  9195. packet2->setDataByName("unknown2", 3);
  9196. packet2->setDataByName("exp_current", 1);
  9197. packet2->setDataByName("exp_to_next_level", 4);
  9198. EQ2Packet* outapp = packet2->serialize();
  9199. DumpPacket(outapp);
  9200. client->QueuePacket(outapp);
  9201. safe_delete(packet2);
  9202. }
  9203. }
  9204. else if (atoi(sep->arg[0]) == 3) {
  9205. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  9206. if (packet2) {
  9207. packet2->setDataByName("guild_id", 1234);
  9208. packet2->setDataByName("character_id", 1);
  9209. packet2->setDataByName("account_id", 2);
  9210. packet2->setDataByName("guild_level", 1);
  9211. packet2->setDataByName("name", "Test");
  9212. packet2->setDataByName("unknown2", 0);
  9213. packet2->setDataByName("unknown3", 1);
  9214. packet2->setDataByName("adventure_class", 6);
  9215. packet2->setDataByName("adventure_level", 7);
  9216. packet2->setDataByName("tradeskill_class", 4);
  9217. packet2->setDataByName("tradeskill_level", 5);
  9218. packet2->setDataByName("rank", 0);
  9219. packet2->setDataByName("member_flags", 2);
  9220. packet2->setDataByName("join_date", 1591112273);
  9221. packet2->setDataByName("guild_status", 2);
  9222. packet2->setDataByName("last_login", 1591132273);
  9223. packet2->setDataByName("recruiter_id", 1);
  9224. packet2->setDataByName("points", 2345);
  9225. packet2->setDataByName("note", "note");
  9226. packet2->setMediumStringByName("officer_note", "O note");
  9227. packet2->setMediumStringByName("zone", "Blah");
  9228. EQ2Packet* outapp = packet2->serialize();
  9229. DumpPacket(outapp);
  9230. client->QueuePacket(outapp);
  9231. safe_delete(packet2);
  9232. }
  9233. }
  9234. else if (atoi(sep->arg[0]) == 5) {
  9235. int16 offset = atoi(sep->arg[1]);
  9236. int32 value1 = atol(sep->arg[2]);
  9237. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  9238. client->QueuePacket(outapp);
  9239. }
  9240. else if (atoi(sep->arg[0]) == 6) {
  9241. Spawn* spawn = client->GetPlayer()->GetTarget();
  9242. if (!spawn)
  9243. spawn = client->GetPlayer();
  9244. else if (spawn->IsEntity())
  9245. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  9246. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  9247. }
  9248. else if (atoi(sep->arg[0]) == 7) {
  9249. int32 id = 0;
  9250. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  9251. if (spawn) {
  9252. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9253. spawn->SetY(client->GetPlayer()->GetY(), false);
  9254. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9255. float heading = client->GetPlayer()->GetHeading() + 180;
  9256. if (heading > 360)
  9257. heading -= 360;
  9258. spawn->SetLevel(5);
  9259. spawn->SetAdventureClass(4);
  9260. spawn->SetHeading(heading, false);
  9261. spawn->SetSpawnOrigX(spawn->GetX());
  9262. spawn->SetSpawnOrigY(spawn->GetY());
  9263. spawn->SetSpawnOrigZ(spawn->GetZ());
  9264. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9265. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9266. spawn->appearance.targetable = 1;
  9267. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9268. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9269. spawn->SetHP(spawn->GetTotalHP());
  9270. }
  9271. if (spawn->GetTotalPower() == 0) {
  9272. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9273. spawn->SetPower(spawn->GetTotalPower());
  9274. }
  9275. int16 offset = atoi(sep->arg[1]);
  9276. int32 value1 = atol(sep->arg[2]);
  9277. sprintf(spawn->appearance.name, "Offset %i", offset);
  9278. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  9279. DumpPacket(ret);
  9280. client->QueuePacket(ret);
  9281. }
  9282. }
  9283. else if (atoi(sep->arg[0]) == 8) {
  9284. int32 id = atoi(sep->arg[1]);
  9285. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  9286. if (spawn) {
  9287. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9288. spawn->SetY(client->GetPlayer()->GetY(), false);
  9289. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9290. float heading = client->GetPlayer()->GetHeading() + 180;
  9291. if (heading > 360)
  9292. heading -= 360;
  9293. spawn->SetLevel(5);
  9294. spawn->SetAdventureClass(4);
  9295. spawn->SetHeading(heading, false);
  9296. spawn->SetSpawnOrigX(spawn->GetX());
  9297. spawn->SetSpawnOrigY(spawn->GetY());
  9298. spawn->SetSpawnOrigZ(spawn->GetZ());
  9299. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9300. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9301. spawn->appearance.targetable = 1;
  9302. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9303. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9304. spawn->SetHP(spawn->GetTotalHP());
  9305. }
  9306. if (spawn->GetTotalPower() == 0) {
  9307. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9308. spawn->SetPower(spawn->GetTotalPower());
  9309. }
  9310. int16 offset = atoi(sep->arg[2]);
  9311. int16 offset2 = atoi(sep->arg[3]);
  9312. int32 value1 = atol(sep->arg[4]);
  9313. int16 offset3 = 0;
  9314. int16 offset4 = 0;
  9315. int32 value2 = 0;
  9316. if (sep->IsSet(7)) {
  9317. offset3 = atoi(sep->arg[5]);
  9318. offset4 = atoi(sep->arg[6]);
  9319. value2 = atol(sep->arg[7]);
  9320. }
  9321. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  9322. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  9323. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  9324. DumpPacket(ret);
  9325. client->QueuePacket(ret);
  9326. }
  9327. }
  9328. else if (atoi(sep->arg[0]) == 9) {
  9329. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  9330. if (packet2) {
  9331. packet2->setArrayLengthByName("location_count", 1);
  9332. packet2->setArrayDataByName("location_ida", 1234);
  9333. packet2->setArrayDataByName("unknown2a", 3);
  9334. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  9335. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  9336. packet2->setArrayDataByName("distance", 134);
  9337. EQ2Packet* app = packet2->serialize();
  9338. if (sep->IsSet(2)) {
  9339. int8 offset = atoi(sep->arg[1]);
  9340. uchar* ptr2 = app->pBuffer;
  9341. ptr2 += offset;
  9342. if (sep->IsNumber(2)) {
  9343. int32 value1 = atol(sep->arg[2]);
  9344. if (value1 > 0xFFFF)
  9345. memcpy(ptr2, (uchar*)&value1, 4);
  9346. else if (value1 > 0xFF)
  9347. memcpy(ptr2, (uchar*)&value1, 2);
  9348. else
  9349. memcpy(ptr2, (uchar*)&value1, 1);
  9350. }
  9351. else {
  9352. int8 len = strlen(sep->arg[2]);
  9353. memcpy(ptr2, (uchar*)&len, 1);
  9354. ptr2 += 1;
  9355. memcpy(ptr2, sep->arg[2], len);
  9356. }
  9357. }
  9358. DumpPacket(app);
  9359. client->QueuePacket(app);
  9360. safe_delete(packet2);
  9361. }
  9362. }
  9363. else if (atoi(sep->arg[0]) == 10) {
  9364. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  9365. if (packet2) {
  9366. packet2->setArrayLengthByName("num_quests", 1);
  9367. packet2->setArrayDataByName("active", 1);
  9368. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  9369. packet2->setArrayDataByName("quest_type", "Hallmark");
  9370. packet2->setArrayDataByName("quest_zone", "Hallmark");
  9371. packet2->setArrayDataByName("journal_updated", 1);
  9372. packet2->setArrayDataByName("quest_id", 524);
  9373. packet2->setArrayDataByName("day", 19);
  9374. packet2->setArrayDataByName("month", 6);
  9375. packet2->setArrayDataByName("year", 20);
  9376. packet2->setArrayDataByName("level", 2);
  9377. packet2->setArrayDataByName("encounter_level", 4);
  9378. packet2->setArrayDataByName("difficulty", 3);
  9379. packet2->setArrayDataByName("visible", 1);
  9380. packet2->setDataByName("visible_quest_id", 524);
  9381. packet2->setDataByName("player_crc", 2900677088);
  9382. packet2->setDataByName("player_name", "LethalEncounter");
  9383. EQ2Packet* app = packet2->serialize();
  9384. if (sep->IsSet(2)) {
  9385. int8 offset = atoi(sep->arg[1]);
  9386. uchar* ptr2 = app->pBuffer;
  9387. ptr2 += offset;
  9388. if (sep->IsNumber(2)) {
  9389. int32 value1 = atol(sep->arg[2]);
  9390. if (value1 > 0xFFFF)
  9391. memcpy(ptr2, (uchar*)&value1, 4);
  9392. else if (value1 > 0xFF)
  9393. memcpy(ptr2, (uchar*)&value1, 2);
  9394. else
  9395. memcpy(ptr2, (uchar*)&value1, 1);
  9396. }
  9397. else {
  9398. int8 len = strlen(sep->arg[2]);
  9399. memcpy(ptr2, (uchar*)&len, 1);
  9400. ptr2 += 1;
  9401. memcpy(ptr2, sep->arg[2], len);
  9402. }
  9403. }
  9404. DumpPacket(app);
  9405. client->QueuePacket(app);
  9406. safe_delete(packet2);
  9407. }
  9408. }
  9409. else if (atoi(sep->arg[0]) == 11) {
  9410. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9411. if (packet2) {
  9412. packet2->setDataByName("quest_id", 524);
  9413. packet2->setDataByName("player_crc", 2900677088);
  9414. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  9415. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  9416. packet2->setDataByName("type", "Hallmark");
  9417. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9418. packet2->setDataByName("day", 19);
  9419. packet2->setDataByName("month", 6);
  9420. packet2->setDataByName("year", 20);
  9421. packet2->setDataByName("level", 1);
  9422. packet2->setDataByName("encounter_level", 1);
  9423. packet2->setDataByName("difficulty", 1);
  9424. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9425. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9426. //packet2->setDataByName("timer_duration", 300);
  9427. //packet2->setDataByName("timer_running", 1);
  9428. packet2->setArrayLengthByName("task_groups_completed", 9);
  9429. packet2->setArrayLengthByName("num_task_groups", 10);
  9430. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  9431. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  9432. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  9433. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  9434. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  9435. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  9436. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  9437. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  9438. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  9439. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  9440. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  9441. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9442. packet2->setSubArrayLengthByName("num_updates", 1);
  9443. packet2->setSubArrayDataByName("update_currentval", 0);
  9444. packet2->setSubArrayDataByName("update_maxval", 1);
  9445. packet2->setSubArrayDataByName("icon", 11);
  9446. */
  9447. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9448. packet2->setDataByName("journal_updated", 1);
  9449. packet2->setDataByName("bullets", 1);
  9450. EQ2Packet* app = packet2->serialize();
  9451. if (sep->IsSet(2)) {
  9452. int16 offset = atoi(sep->arg[1]);
  9453. uchar* ptr2 = app->pBuffer;
  9454. ptr2 += offset;
  9455. if (sep->IsNumber(2)) {
  9456. int32 value1 = atol(sep->arg[2]);
  9457. if (value1 > 0xFFFF)
  9458. memcpy(ptr2, (uchar*)&value1, 4);
  9459. else if (value1 > 0xFF)
  9460. memcpy(ptr2, (uchar*)&value1, 2);
  9461. else
  9462. memcpy(ptr2, (uchar*)&value1, 1);
  9463. }
  9464. else {
  9465. int16 len = strlen(sep->arg[2]);
  9466. memcpy(ptr2, (uchar*)&len, 2);
  9467. ptr2 += 2;
  9468. memcpy(ptr2, sep->arg[2], len);
  9469. }
  9470. }
  9471. DumpPacket(app);
  9472. client->QueuePacket(app);
  9473. safe_delete(packet2);
  9474. }
  9475. }
  9476. else if (atoi(sep->arg[0]) == 12) {
  9477. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9478. if (packet2) {
  9479. packet2->setDataByName("quest_id", 524);
  9480. packet2->setDataByName("player_crc", 2900677088);
  9481. packet2->setDataByName("name", "Archetype Selection");
  9482. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  9483. packet2->setDataByName("type", "Hallmark");
  9484. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9485. packet2->setDataByName("day", 19);
  9486. packet2->setDataByName("month", 6);
  9487. packet2->setDataByName("year", 20);
  9488. packet2->setDataByName("level", 2);
  9489. packet2->setDataByName("encounter_level", 4);
  9490. packet2->setDataByName("difficulty", 3);
  9491. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9492. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9493. packet2->setDataByName("timer_duration", 300);
  9494. packet2->setDataByName("timer_running", 1);
  9495. packet2->setArrayLengthByName("task_groups_completed", 0);
  9496. packet2->setArrayLengthByName("num_task_groups", 1);
  9497. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  9498. packet2->setSubArrayLengthByName("num_tasks", 1);
  9499. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9500. packet2->setSubArrayLengthByName("num_updates", 1);
  9501. packet2->setSubArrayDataByName("update_currentval", 0);
  9502. packet2->setSubArrayDataByName("update_maxval", 1);
  9503. packet2->setSubArrayDataByName("icon", 11);
  9504. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9505. packet2->setDataByName("journal_updated", 1);
  9506. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9507. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9508. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  9509. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9510. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9511. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9512. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9513. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  9514. Item* item = master_item_list.GetItem(152755);
  9515. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9516. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9517. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  9518. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  9519. packet2->setSubstructDataByName("item", "icon", 0xe7);
  9520. packet2->setSubstructDataByName("item", "tier", 4);
  9521. packet2->setSubstructDataByName("item", "flags", 0x60);
  9522. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  9523. packet2->setSubstructDataByName("item", "stat_type", 1);
  9524. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  9525. packet2->setSubstructDataByName("item", "value", 3);
  9526. packet2->setSubstructDataByName("item", "condition", 100);
  9527. packet2->setSubstructDataByName("item", "weight", 1);
  9528. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  9529. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  9530. packet2->setSubstructDataByName("item", "skill_min", 1);
  9531. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  9532. packet2->setSubstructDataByName("item", "adventure_class", 1);
  9533. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  9534. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  9535. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  9536. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  9537. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  9538. packet2->setSubstructDataByName("item", "level", 0x1e);
  9539. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  9540. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  9541. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  9542. //packet2->PrintPacket();
  9543. EQ2Packet* app = packet2->serialize();
  9544. if (sep->IsSet(2)) {
  9545. int16 offset = atoi(sep->arg[1]);
  9546. uchar* ptr2 = app->pBuffer;
  9547. ptr2 += offset;
  9548. if (sep->IsNumber(2)) {
  9549. int32 value1 = atol(sep->arg[2]);
  9550. if (value1 > 0xFFFF)
  9551. memcpy(ptr2, (uchar*)&value1, 4);
  9552. else if (value1 > 0xFF)
  9553. memcpy(ptr2, (uchar*)&value1, 2);
  9554. else
  9555. memcpy(ptr2, (uchar*)&value1, 1);
  9556. }
  9557. else {
  9558. int16 len = strlen(sep->arg[2]);
  9559. memcpy(ptr2, (uchar*)&len, 2);
  9560. ptr2 += 2;
  9561. memcpy(ptr2, sep->arg[2], len);
  9562. }
  9563. }
  9564. DumpPacket(app);
  9565. client->QueuePacket(app);
  9566. safe_delete(packet2);
  9567. }
  9568. }
  9569. else if (atoi(sep->arg[0]) == 13) {
  9570. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  9571. if (packet2 && sep->IsSet(7)) {
  9572. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  9573. char blah[128];
  9574. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  9575. packet2->setDataByName("text", blah);
  9576. packet2->setDataByName("message_type", sep->arg[3]);
  9577. packet2->setDataByName("size", atof(sep->arg[4]));
  9578. packet2->setDataByName("red", atoi(sep->arg[5]));
  9579. packet2->setDataByName("green", atoi(sep->arg[6]));
  9580. packet2->setDataByName("blue", atoi(sep->arg[7]));
  9581. EQ2Packet* app = packet2->serialize();
  9582. DumpPacket(app);
  9583. client->QueuePacket(app);
  9584. safe_delete(packet2);
  9585. }
  9586. }
  9587. else if (atoi(sep->arg[0]) == 14) {
  9588. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  9589. if (packet2 && sep->IsSet(3)) {
  9590. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  9591. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  9592. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  9593. 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.");
  9594. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  9595. packet2->setArrayLengthByName("num_goals", 1);
  9596. //packet2->setArrayDataByName("goal_text", )
  9597. packet2->setSubArrayLengthByName("num_tasks", 1);
  9598. packet2->setSubArrayDataByName("task_text", "continue");
  9599. packet2->setDataByName("complete_sound", "click");
  9600. packet2->setDataByName("signal", "introduction");
  9601. packet2->setDataByName("voice_key1", 0xcda65173);
  9602. packet2->setDataByName("voice_key2", 0x984bfc6d);
  9603. EQ2Packet* app = packet2->serialize();
  9604. DumpPacket(app);
  9605. client->QueuePacket(app);
  9606. safe_delete(packet2);
  9607. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  9608. packet2->setDataByName("window", "MainHUD.StartMenu");
  9609. packet2->setDataByName("show", 1);
  9610. app = packet2->serialize();
  9611. DumpPacket(app);
  9612. client->QueuePacket(app);
  9613. safe_delete(packet2);
  9614. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  9615. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  9616. packet2->setDataByName("flash_seconds", 10);
  9617. app = packet2->serialize();
  9618. DumpPacket(app);
  9619. client->QueuePacket(app);
  9620. safe_delete(packet2);
  9621. }
  9622. }
  9623. else if (atoi(sep->arg[0]) == 15) {
  9624. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9625. if (packet2) {
  9626. packet2->setArrayLengthByName("loot_count", 1);
  9627. packet2->setArrayDataByName("name", "Test");
  9628. packet2->setArrayDataByName("item_id", 1234);
  9629. packet2->setArrayDataByName("count", 1);
  9630. packet2->setArrayDataByName("icon", 258);
  9631. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  9632. Spawn* spawn = client->GetPlayer()->GetTarget();
  9633. if (spawn)
  9634. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9635. packet2->setDataByName("unknown3", 1);
  9636. packet2->setDataByName("unknown4", 1);
  9637. packet2->setDataByName("unknown5", 60);
  9638. EQ2Packet* app = packet2->serialize();
  9639. DumpPacket(app);
  9640. client->QueuePacket(app);
  9641. safe_delete(packet2);
  9642. }
  9643. }
  9644. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  9645. char blah[32];
  9646. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  9647. client->SimpleMessage(atoi(sep->arg[1]), blah);
  9648. }
  9649. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  9650. if (sep->IsSet(2)) {
  9651. int16 offset = atoi(sep->arg[1]);
  9652. if (sep->IsNumber(2)) {
  9653. int32 value1 = atol(sep->arg[2]);
  9654. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  9655. cout << "Sent" << endl;
  9656. }
  9657. }
  9658. }
  9659. else if (atoi(sep->arg[0]) == 18) {
  9660. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  9661. if (packet2) {
  9662. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9663. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9664. packet2->setSubstructDataByName("reward_data", "max_coin", 0);
  9665. packet2->setSubstructDataByName("reward_data", "text", "Some custom text to mess things up?");
  9666. //packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9667. //packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9668. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9669. Item* item = new Item(master_item_list.GetItem(9357));
  9670. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9671. //item->stack_count = 20;
  9672. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9673. safe_delete(item);
  9674. /*item = new Item(master_item_list.GetItem(36685));
  9675. item->stack_count = 20;
  9676. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9677. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  9678. safe_delete(item);
  9679. item = master_item_list.GetItem(1414);
  9680. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9681. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  9682. item = master_item_list.GetItem(75057);
  9683. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9684. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);*/
  9685. EQ2Packet* app = packet2->serialize();
  9686. if (sep->IsSet(2)) {
  9687. int16 offset = atoi(sep->arg[1]);
  9688. uchar* ptr2 = app->pBuffer;
  9689. ptr2 += offset;
  9690. if (sep->IsNumber(2)) {
  9691. int32 value1 = atol(sep->arg[2]);
  9692. if (value1 > 0xFFFF)
  9693. memcpy(ptr2, (uchar*)&value1, 4);
  9694. else if (value1 > 0xFF)
  9695. memcpy(ptr2, (uchar*)&value1, 2);
  9696. else
  9697. memcpy(ptr2, (uchar*)&value1, 1);
  9698. }
  9699. else {
  9700. int16 len = strlen(sep->arg[2]);
  9701. memcpy(ptr2, (uchar*)&len, 2);
  9702. ptr2 += 2;
  9703. memcpy(ptr2, sep->arg[2], len);
  9704. }
  9705. }
  9706. DumpPacket(app);
  9707. client->QueuePacket(app);
  9708. safe_delete(packet2);
  9709. }
  9710. }
  9711. else if (atoi(sep->arg[0]) == 19) {
  9712. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9713. Spawn* spawn = client->GetPlayer()->GetTarget();
  9714. if (packet2 && spawn) {
  9715. Item* item = master_item_list.GetItem(130053);
  9716. packet2->setArrayLengthByName("loot_count", 1);
  9717. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9718. packet2->setArrayDataByName("unknown2", 1);
  9719. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9720. packet2->setDataByName("display", 1);
  9721. packet2->setDataByName("unknown2b", 1);
  9722. packet2->setDataByName("unknown3", 0x3c);
  9723. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9724. packet2->PrintPacket();
  9725. EQ2Packet* app = packet2->serialize();
  9726. if (sep->IsSet(2)) {
  9727. int16 offset = atoi(sep->arg[1]);
  9728. int16 offset2 = 0;
  9729. int32 value1 = 0;
  9730. if (sep->IsSet(3)) {
  9731. offset2 = atoi(sep->arg[2]);
  9732. value1 = atol(sep->arg[3]);
  9733. }
  9734. else
  9735. value1 = atol(sep->arg[2]);
  9736. int16 offset3 = 0;
  9737. int16 offset4 = 0;
  9738. int32 value2 = 0;
  9739. if (sep->IsSet(6)) {
  9740. offset3 = atoi(sep->arg[4]);
  9741. offset4 = atoi(sep->arg[5]);
  9742. value2 = atol(sep->arg[6]);
  9743. }
  9744. offset--;
  9745. if (offset2 > 0 && offset2 >= offset) {
  9746. offset2--;
  9747. uchar* ptr2 = app->pBuffer;
  9748. ptr2 += offset;
  9749. for (int i = offset; i <= offset2; i++) {
  9750. if (value1 > 0xFFFF) {
  9751. memcpy(ptr2, (uchar*)&value1, 4);
  9752. i += 3;
  9753. ptr2 += 3;
  9754. }
  9755. else if (value1 > 0xFF) {
  9756. memcpy(ptr2, (uchar*)&value1, 2);
  9757. i++;
  9758. ptr2++;
  9759. }
  9760. else
  9761. memcpy(ptr2, (uchar*)&value1, 1);
  9762. ptr2++;
  9763. }
  9764. }
  9765. if (offset4 > 0 && offset4 >= offset3) {
  9766. offset3--;
  9767. offset4--;
  9768. uchar* ptr2 = app->pBuffer;
  9769. ptr2 += offset3;
  9770. for (int i = offset3; i <= offset4; i++) {
  9771. if (value2 > 0xFFFF) {
  9772. memcpy(ptr2, (uchar*)&value2, 4);
  9773. i += 3;
  9774. ptr2 += 3;
  9775. }
  9776. else if (value2 > 0xFF) {
  9777. memcpy(ptr2, (uchar*)&value2, 2);
  9778. i++;
  9779. ptr2++;
  9780. }
  9781. else
  9782. memcpy(ptr2, (uchar*)&value2, 1);
  9783. ptr2++;
  9784. }
  9785. }
  9786. }
  9787. DumpPacket(app);
  9788. client->QueuePacket(app);
  9789. safe_delete(packet2);
  9790. }
  9791. }
  9792. else if (atoi(sep->arg[0]) == 21) {
  9793. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9794. if (packet2) {
  9795. packet2->setDataByName("unknown0", 255);
  9796. packet2->setDataByName("reward", "New Quest");
  9797. packet2->setDataByName("title", "Title");
  9798. packet2->setDataByName("description", "description");
  9799. packet2->setDataByName("quest_difficulty", 3);
  9800. packet2->setDataByName("unknown1", 5);
  9801. packet2->setDataByName("level", 3);
  9802. packet2->setDataByName("coin", 150);
  9803. packet2->setDataByName("status_points", 5);
  9804. packet2->setDataByName("exp_bonus", 10);
  9805. packet2->setArrayLengthByName("num_rewards", 1);
  9806. Item* item = new Item(master_item_list.GetItem(36212));
  9807. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9808. item->stack_count = 20;
  9809. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9810. safe_delete(item);
  9811. char accept[35] = { 0 };
  9812. char decline[35] = { 0 };
  9813. sprintf(accept, "q_accept_pending_quest %u", 0);
  9814. sprintf(decline, "q_deny_pending_quest %u", 0);
  9815. packet2->setDataByName("accept_command", accept);
  9816. packet2->setDataByName("decline_command", decline);
  9817. EQ2Packet* app = packet2->serialize();
  9818. if (sep->IsSet(2)) {
  9819. int16 offset = atoi(sep->arg[1]);
  9820. uchar* ptr2 = app->pBuffer;
  9821. ptr2 += offset;
  9822. if (sep->IsNumber(2)) {
  9823. int32 value1 = atol(sep->arg[2]);
  9824. if (value1 > 0xFFFF)
  9825. memcpy(ptr2, (uchar*)&value1, 4);
  9826. else if (value1 > 0xFF)
  9827. memcpy(ptr2, (uchar*)&value1, 2);
  9828. else
  9829. memcpy(ptr2, (uchar*)&value1, 1);
  9830. }
  9831. DumpPacket(app);
  9832. client->QueuePacket(app);
  9833. safe_delete(packet2);
  9834. }
  9835. }
  9836. }
  9837. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9838. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9839. if (packet2) {
  9840. packet2->setDataByName("unknown0", 255);
  9841. packet2->setDataByName("reward", "New Quest");
  9842. packet2->setDataByName("title", "Title");
  9843. packet2->setDataByName("description", "description");
  9844. packet2->setDataByName("quest_difficulty", 3);
  9845. packet2->setDataByName("unknown1", 5);
  9846. packet2->setDataByName("level", 3);
  9847. packet2->setDataByName("coin", 150);
  9848. packet2->setDataByName("status_points", 5);
  9849. packet2->setDataByName("exp_bonus", 10);
  9850. packet2->setArrayLengthByName("num_rewards", 1);
  9851. Item* item = new Item(master_item_list.GetItem(36212));
  9852. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9853. item->stack_count = 20;
  9854. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9855. safe_delete(item);
  9856. char accept[35] = { 0 };
  9857. char decline[35] = { 0 };
  9858. sprintf(accept, "q_accept_pending_quest %u", 0);
  9859. sprintf(decline, "q_deny_pending_quest %u", 0);
  9860. packet2->setDataByName("accept_command", accept);
  9861. packet2->setDataByName("decline_command", decline);
  9862. EQ2Packet* app = packet2->serialize();
  9863. if (sep->IsSet(2)) {
  9864. int16 offset = atoi(sep->arg[1]);
  9865. uchar* ptr2 = app->pBuffer;
  9866. ptr2 += offset;
  9867. if (sep->IsNumber(2)) {
  9868. int32 value1 = atol(sep->arg[2]);
  9869. if (value1 > 0xFFFF)
  9870. memcpy(ptr2, (uchar*)&value1, 4);
  9871. else if (value1 > 0xFF)
  9872. memcpy(ptr2, (uchar*)&value1, 2);
  9873. else
  9874. memcpy(ptr2, (uchar*)&value1, 1);
  9875. }
  9876. else {
  9877. int8 len = strlen(sep->arg[2]);
  9878. memcpy(ptr2, (uchar*)&len, 1);
  9879. ptr2 += 1;
  9880. memcpy(ptr2, sep->arg[2], len);
  9881. }
  9882. }
  9883. DumpPacket(app);
  9884. client->QueuePacket(app);
  9885. safe_delete(packet2);
  9886. }
  9887. }
  9888. else if (atoi(sep->arg[0]) == 23) {
  9889. if (client->GetPlayer()->GetTarget()) {
  9890. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9891. if (packet2) {
  9892. Spawn* target = client->GetPlayer()->GetTarget();
  9893. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9894. Item* item = new Item(master_item_list.GetItem(12565));
  9895. int8 i = 0;
  9896. packet2->setArrayLengthByName("num_items", 1);
  9897. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9898. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9899. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9900. packet2->setArrayDataByName("icon", item->details.icon, i);
  9901. int8 tmp_level = 0;
  9902. if (item->generic_info.adventure_default_level > 0)
  9903. tmp_level = item->generic_info.adventure_default_level;
  9904. else
  9905. tmp_level = item->generic_info.tradeskill_default_level;
  9906. packet2->setArrayDataByName("level", tmp_level, i);
  9907. packet2->setArrayDataByName("tier", item->details.tier, i);
  9908. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9909. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9910. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9911. item_difficulty = ARROW_COLOR_WHITE;
  9912. item_difficulty -= 6;
  9913. if (item_difficulty < 0)
  9914. item_difficulty *= -1;
  9915. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9916. packet2->setArrayDataByName("quantity", 2, i);
  9917. packet2->setArrayDataByName("unknown5", 255, i);
  9918. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9919. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9920. packet2->setDataByName("type", 2);
  9921. EQ2Packet* app = packet2->serialize();
  9922. if (sep->IsSet(2)) {
  9923. int16 offset = atoi(sep->arg[1]);
  9924. uchar* ptr2 = app->pBuffer;
  9925. ptr2 += offset;
  9926. if (sep->IsNumber(2)) {
  9927. int32 value1 = atol(sep->arg[2]);
  9928. if (value1 > 0xFFFF)
  9929. memcpy(ptr2, (uchar*)&value1, 4);
  9930. else if (value1 > 0xFF)
  9931. memcpy(ptr2, (uchar*)&value1, 2);
  9932. else
  9933. memcpy(ptr2, (uchar*)&value1, 1);
  9934. }
  9935. else {
  9936. int8 len = strlen(sep->arg[2]);
  9937. memcpy(ptr2, (uchar*)&len, 1);
  9938. ptr2 += 1;
  9939. memcpy(ptr2, sep->arg[2], len);
  9940. }
  9941. }
  9942. DumpPacket(app);
  9943. client->QueuePacket(app);
  9944. safe_delete(packet2);
  9945. }
  9946. }
  9947. }
  9948. else if (atoi(sep->arg[0]) == 24) {
  9949. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  9950. if (packet2) {
  9951. if (sep->IsSet(2)) {
  9952. packet2->setDataByName("event_name", sep->arg[1]);
  9953. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  9954. EQ2Packet* app = packet2->serialize();
  9955. DumpPacket(app);
  9956. client->QueuePacket(app);
  9957. safe_delete(packet2);
  9958. }
  9959. }
  9960. }
  9961. else if (atoi(sep->arg[0]) == 25) {
  9962. if (sep->IsSet(1)) {
  9963. Widget* new_spawn = new Widget();
  9964. int32 id = atoul(sep->arg[1]);
  9965. new_spawn->SetWidgetID(id);
  9966. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9967. client->QueuePacket(ret);
  9968. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  9969. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  9970. if (packet2) {
  9971. packet2->setDataByName("spawn_index", index);
  9972. packet2->setDataByName("delete", 1);
  9973. EQ2Packet* app = packet2->serialize();
  9974. client->QueuePacket(app);
  9975. safe_delete(packet2);
  9976. }
  9977. }
  9978. }
  9979. else if (atoi(sep->arg[0]) == 26) {
  9980. if (sep->IsSet(4)) {
  9981. Widget* new_spawn = new Widget();
  9982. int32 id = atoul(sep->arg[1]);
  9983. new_spawn->SetWidgetID(id);
  9984. float x = atof(sep->arg[2]);
  9985. float y = atof(sep->arg[3]);
  9986. float z = atof(sep->arg[4]);
  9987. new_spawn->SetLocation(client->GetPlayer()->GetLocation());
  9988. new_spawn->SetWidgetX(x);
  9989. new_spawn->SetWidgetY(y);
  9990. new_spawn->SetWidgetZ(z);
  9991. new_spawn->SetX(x);
  9992. new_spawn->SetY(y);
  9993. new_spawn->SetZ(z);
  9994. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9995. client->QueuePacket(ret);
  9996. }
  9997. }
  9998. else if (atoi(sep->arg[0]) == 27) {
  9999. Spawn* target = client->GetPlayer()->GetTarget();
  10000. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  10001. if (packet2 && target && sep->IsSet(4)) {
  10002. client->GetPlayer()->GetZone()->SendDamagePacket(client->GetPlayer(), target, atoul(sep->arg[1]), atoul(sep->arg[2]), atoul(sep->arg[3]), atoul(sep->arg[4]), sep->arg[5] != nullptr ? sep->arg[5] : "");
  10003. }
  10004. }
  10005. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  10006. World::newValue = strtoull(sep->arg[1], NULL, 0);
  10007. }
  10008. else if (atoi(sep->arg[0]) == 29 && sep->IsNumber(1)) {
  10009. client->SendHearCast(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10010. strtoull(sep->arg[1], NULL, 0), atoul(sep->arg[2]));
  10011. }
  10012. else if (atoi(sep->arg[0]) == 30) {
  10013. PacketStruct* packet = configReader.getStruct("WS_UpdateSkillBook", client->GetVersion());
  10014. if (packet) {
  10015. packet->setDataByName("unknown", World::newValue);
  10016. EQ2Packet* outapp = packet->serialize();
  10017. DumpPacket(outapp);
  10018. client->QueuePacket(outapp);
  10019. safe_delete(packet);
  10020. }
  10021. }
  10022. else if (atoi(sep->arg[0]) == 31) {
  10023. client->SendRecipeList();
  10024. }
  10025. else if (atoi(sep->arg[0]) == 32 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10026. if(client->GetVersion() <= 546) {
  10027. int32 param = atoul(sep->arg[1]);
  10028. int32 paramvalue = atoul(sep->arg[2]);
  10029. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param %u param value %u", param, paramvalue);
  10030. ClientPacketFunctions::SendServerControlFlagsClassic(client, param, paramvalue);
  10031. }
  10032. else if(sep->IsNumber(3)) {
  10033. int8 param1 = atoul(sep->arg[1]);
  10034. int8 param2 = atoul(sep->arg[2]);
  10035. int8 paramval = atoul(sep->arg[3]);
  10036. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param1 %u param2 %u param value %u", param1, param2, paramval);
  10037. ClientPacketFunctions::SendServerControlFlags(client, param1, param2, paramval);
  10038. }
  10039. }
  10040. else if (atoi(sep->arg[0]) == 33 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10041. client->GetCurrentZone()->SendHealPacket(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10042. atoul(sep->arg[1]), atoul(sep->arg[2]), "TestSpell");
  10043. }
  10044. }
  10045. else {
  10046. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  10047. if (packet2) {
  10048. packet2->setSubstructDataByName("info_header", "show_name", 1);
  10049. packet2->setSubstructDataByName("info_header", "unknown", 7);
  10050. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  10051. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  10052. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  10053. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  10054. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  10055. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  10056. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  10057. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  10058. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  10059. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  10060. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  10061. packet2->setSubstructDataByName("info_header", "packettype", 3);
  10062. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  10063. packet2->setSubstructDataByName("spell_info", "level", 19);
  10064. packet2->setSubstructDataByName("spell_info", "tier", 1);
  10065. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  10066. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  10067. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  10068. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  10069. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  10070. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  10071. packet2->setSubstructDataByName("spell_info", "recast", 280);
  10072. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  10073. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  10074. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  10075. packet2->setSubstructDataByName("spell_info", "quality", 3);
  10076. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  10077. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  10078. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  10079. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  10080. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  10081. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  10082. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  10083. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  10084. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  10085. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  10086. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  10087. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  10088. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  10089. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  10090. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  10091. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  10092. packet2->setArrayDataByName("reagent", "Alcohol");
  10093. packet2->setArrayDataByName("consumed", "123");
  10094. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  10095. packet2->setSubstructDataByName("spell_info", "id", 8308);
  10096. packet2->setSubstructDataByName("spell_info", "icon", 303);
  10097. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  10098. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  10099. packet2->setSubstructDataByName("spell_info", "type", 2);
  10100. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  10101. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  10102. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  10103. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  10104. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  10105. EQ2Packet* outapp = packet2->serialize();
  10106. DumpPacket(outapp);
  10107. client->QueuePacket(outapp);
  10108. safe_delete(packet2);
  10109. }
  10110. }
  10111. return;
  10112. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  10113. if (!p) return;
  10114. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10115. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  10116. //}
  10117. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10118. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  10119. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  10120. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  10121. if (packet) {
  10122. client->QueuePacket(packet->serialize());
  10123. safe_delete(packet);
  10124. }
  10125. }*/
  10126. /*if (client->GetCurrentZone()->Grid != nullptr) {
  10127. int32 numFaces = 0;
  10128. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  10129. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  10130. map<int32, vector<Face*> >::iterator itr;
  10131. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  10132. numFaces += (*itr).second.size();
  10133. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  10134. }*/
  10135. //uchar blah[] = {
  10136. // 1208 - OP_EQUpdateStoreCmd
  10137. // /*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
  10138. // /*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
  10139. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  10140. // /*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
  10141. /*};
  10142. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10143. int8 val = 0;
  10144. int16 pos = 0;
  10145. int idx = 0;
  10146. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  10147. pos = atoi(sep2->arg[idx]);
  10148. val = atoi(sep2->arg[idx+1]);
  10149. memset(blah+pos, val, 1);
  10150. idx+=2;
  10151. }
  10152. DumpPacket(blah, sizeof(blah));
  10153. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  10154. if (client->GetPlayer()->GetTarget()) {
  10155. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  10156. if (packet) {
  10157. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10158. packet->setDataByName("size", 0);
  10159. packet->setDataByName("unknown2", 0);
  10160. EQ2Packet* app = packet->serialize();
  10161. client->QueuePacket(app);
  10162. safe_delete(packet);
  10163. }
  10164. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  10165. if (set_pov) {
  10166. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10167. EQ2Packet* app_pov = set_pov->serialize();
  10168. client->QueuePacket(app_pov);
  10169. safe_delete(set_pov);
  10170. }
  10171. }
  10172. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10173. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  10174. if (packet) {
  10175. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  10176. packet->setDataByName("Type", atoi(sep2->arg[0]));
  10177. else
  10178. packet->setDataByName("Type", 2);
  10179. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  10180. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  10181. else
  10182. packet->setDataByName("race_id", 0);
  10183. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  10184. packet->setDataByName("gender", atoi(sep2->arg[2]));
  10185. else
  10186. packet->setDataByName("gender", 2);
  10187. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  10188. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  10189. else
  10190. packet->setDataByName("unknown", 0, 0);
  10191. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  10192. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  10193. else
  10194. packet->setDataByName("unknown", 0, 1);
  10195. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  10196. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  10197. else
  10198. packet->setDataByName("unknown", 0, 2);
  10199. client->QueuePacket(packet->serialize());
  10200. }
  10201. safe_delete(packet);
  10202. safe_delete(sep2);
  10203. }
  10204. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  10205. const char *channel_name;
  10206. if (sep == NULL || !sep->IsSet(0)) {
  10207. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  10208. PrintSep(sep);
  10209. return;
  10210. }
  10211. channel_name = sep->arg[0];
  10212. if (!chat.IsInChannel(client, channel_name))
  10213. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  10214. else if (!chat.LeaveChannel(client, channel_name))
  10215. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  10216. }
  10217. /*
  10218. Function:
  10219. Purpose :
  10220. Params :
  10221. Dev :
  10222. Example :
  10223. */
  10224. void Commands::Command_WeaponStats(Client* client)
  10225. {
  10226. Player* player = client->GetPlayer();
  10227. Spawn* target = player->GetTarget();
  10228. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10229. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10230. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10231. const char* charName = player->GetName();
  10232. if(target && target->IsEntity()) {
  10233. primary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10234. secondary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10235. ranged = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10236. charName = target->GetName();
  10237. }
  10238. else {
  10239. target = nullptr;
  10240. }
  10241. client->Message(0, "WeaponStats for %s", charName);
  10242. client->SimpleMessage(0, "Primary:");
  10243. if (primary) {
  10244. client->Message(0, "Name: %s", primary->name.c_str());
  10245. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  10246. client->Message(0, "Mastery Damage: %u - %u", primary->weapon_info->damage_low2, primary->weapon_info->damage_high2);
  10247. client->Message(0, "Damage: %u - %u", primary->weapon_info->damage_low1, primary->weapon_info->damage_high1);
  10248. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10249. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10250. client->Message(0, "Actual Delay: %u", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay());
  10251. client->Message(0, "Proc Percent: %d%%", 0);
  10252. client->Message(0, "Procs Per Minute: %d", 0);
  10253. }
  10254. else {
  10255. client->SimpleMessage(0, "Name: fist");
  10256. client->Message(0, "Base Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10257. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10258. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10259. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10260. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay() * 0.1);
  10261. client->Message(0, "Proc Percent: %d%%", 0);
  10262. client->Message(0, "Procs Per Minute: %d", 0);
  10263. }
  10264. client->SimpleMessage(0, " ");
  10265. client->SimpleMessage(0, " ");
  10266. if (secondary) {
  10267. client->SimpleMessage(0, "Secondary:");
  10268. client->Message(0, "Name: %s", secondary->name.c_str());
  10269. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  10270. client->Message(0, "Mastery Damage: %u - %u", secondary->weapon_info->damage_low2, secondary->weapon_info->damage_high2);
  10271. client->Message(0, "Damage: %u - %u", secondary->weapon_info->damage_low1, secondary->weapon_info->damage_high1);
  10272. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetSecondaryWeaponMinDamage() : player->GetSecondaryWeaponMinDamage(),
  10273. target ? ((Entity*)target)->GetSecondaryWeaponMaxDamage() : player->GetSecondaryWeaponMaxDamage());
  10274. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetSecondaryWeaponDelay() : player->GetSecondaryWeaponDelay() * 0.1);
  10275. client->Message(0, "Proc Percent: %d%%", 0);
  10276. client->Message(0, "Procs Per Minute: %d", 0);
  10277. client->SimpleMessage(0, " ");
  10278. client->SimpleMessage(0, " ");
  10279. }
  10280. client->SimpleMessage(0, "Ranged:");
  10281. if (ranged) {
  10282. client->Message(0, "Name: %s", ranged->name.c_str());
  10283. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  10284. client->Message(0, "Mastery Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low2, ranged->ranged_info->weapon_info.damage_high2);
  10285. client->Message(0, "Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low1, ranged->ranged_info->weapon_info.damage_high1);
  10286. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetRangedWeaponMinDamage() : player->GetRangedWeaponMinDamage(),
  10287. target ? ((Entity*)target)->GetRangedWeaponMaxDamage() : player->GetRangedWeaponMaxDamage());
  10288. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetRangeWeaponDelay() : player->GetRangeWeaponDelay() * 0.1);
  10289. client->Message(0, "Proc Percent: %d%%", 0);
  10290. client->Message(0, "Procs Per Minute: %d", 0);
  10291. }
  10292. else
  10293. client->SimpleMessage(0, "None");
  10294. }
  10295. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  10296. const char *channel_name;
  10297. if (sep == NULL || !sep->IsSet(0)) {
  10298. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  10299. return;
  10300. }
  10301. channel_name = sep->arg[0];
  10302. if (!chat.ChannelExists(channel_name))
  10303. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  10304. else
  10305. chat.SendChannelUserList(client, channel_name);
  10306. }
  10307. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  10308. {
  10309. ZoneServer* zone = 0;
  10310. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  10311. if (zone_id > 0)
  10312. {
  10313. zone = zone_list.Get(zone_id, false, false, false);
  10314. if (zone)
  10315. {
  10316. zone->SetSafeX(client->GetPlayer()->GetX());
  10317. zone->SetSafeY(client->GetPlayer()->GetY());
  10318. zone->SetSafeZ(client->GetPlayer()->GetZ());
  10319. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  10320. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  10321. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  10322. else
  10323. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  10324. }
  10325. }
  10326. }
  10327. /*
  10328. Function:
  10329. Purpose :
  10330. Params :
  10331. Dev :
  10332. Example :
  10333. */
  10334. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  10335. {
  10336. ZoneInfo* zone_info = new ZoneInfo;
  10337. if (sep && sep->arg[0])
  10338. {
  10339. if (sep->IsNumber(0))
  10340. zone_info->id = atoi(sep->arg[0]);
  10341. else
  10342. zone_info->id = database.GetZoneID(sep->arg[0]);
  10343. if (zone_info->id > 0)
  10344. {
  10345. database.LoadZoneInfo(zone_info);
  10346. 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);
  10347. 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);
  10348. 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);
  10349. 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);
  10350. 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);
  10351. 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);
  10352. 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);
  10353. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  10354. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  10355. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  10356. }
  10357. else
  10358. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10359. }
  10360. else
  10361. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  10362. safe_delete(zone_info);
  10363. }
  10364. /*
  10365. Function:
  10366. Purpose :
  10367. Params :
  10368. Dev :
  10369. Example :
  10370. */
  10371. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  10372. {
  10373. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  10374. {
  10375. ZoneServer* zone = 0;
  10376. int32 zone_id = 0;
  10377. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  10378. {
  10379. zone_id = atoi(sep->arg[0]);
  10380. zone = zone_list.Get(atoi(sep->arg[0]), false, false, false);
  10381. }
  10382. else
  10383. {
  10384. zone_id = database.GetZoneID(sep->arg[0]);
  10385. if (zone_id > 0)
  10386. zone = zone_list.Get(sep->arg[0], false, false, false);
  10387. }
  10388. if (zone_id > 0)
  10389. {
  10390. if (zone_set_values.count(string(sep->arg[1])) > 0)
  10391. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  10392. else
  10393. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  10394. }
  10395. else
  10396. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10397. }
  10398. else
  10399. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  10400. }
  10401. void Commands::Command_Rain(Client* client, Seperator* sep) {
  10402. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10403. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  10404. return;
  10405. }
  10406. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  10407. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  10408. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  10409. }
  10410. void Commands::Command_Wind(Client* client, Seperator* sep) {
  10411. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10412. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  10413. return;
  10414. }
  10415. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  10416. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  10417. }
  10418. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  10419. Spawn* spawn = client->GetPlayer()->GetTarget();
  10420. if(client->GetVersion() <= 546) {
  10421. sell = false; // doesn't support in the same way as AoM just open the normal buy/sell window
  10422. }
  10423. if(spawn) {
  10424. client->SetMerchantTransaction(spawn);
  10425. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  10426. client->SendHailCommand(spawn);
  10427. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  10428. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  10429. client->SendBuyMerchantList(sell);
  10430. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  10431. client->SendSellMerchantList(sell);
  10432. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  10433. client->SendBuyBackList(sell);
  10434. if(client->GetVersion() > 546) {
  10435. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10436. if (packet) {
  10437. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  10438. packet->setDataByName("type", 16);
  10439. EQ2Packet* outapp = packet->serialize();
  10440. if (outapp)
  10441. client->QueuePacket(outapp);
  10442. safe_delete(packet);
  10443. }
  10444. }
  10445. }
  10446. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  10447. client->SendRepairList();
  10448. }
  10449. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  10450. }
  10451. void Commands::Command_Weather(Client* client, Seperator* sep)
  10452. {
  10453. //PrintSep(sep, "Weather");
  10454. if( sep && sep->arg[0] )
  10455. {
  10456. ZoneServer* zsZone = client->GetCurrentZone();
  10457. const char* value = sep->arg[0];
  10458. // process single-param commands first
  10459. if( strncasecmp(value, "details", strlen(value)) == 0 )
  10460. {
  10461. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  10462. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  10463. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  10464. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  10465. }
  10466. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  10467. {
  10468. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10469. zsZone->ProcessWeather();
  10470. }
  10471. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  10472. {
  10473. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  10474. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  10475. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  10476. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  10477. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  10478. zsZone->SetWeatherPattern(1);
  10479. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  10480. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  10481. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  10482. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10483. zsZone->ProcessWeather();
  10484. }
  10485. // process commands with params
  10486. if( sep->arg[1] )
  10487. {
  10488. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  10489. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  10490. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  10491. zsZone->SetWeatherType(atoi(sep->arg[1]));
  10492. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  10493. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  10494. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  10495. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  10496. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  10497. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  10498. }
  10499. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  10500. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  10501. zsZone->SetRain(zsZone->GetCurrentWeather());
  10502. }
  10503. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  10504. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  10505. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  10506. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  10507. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10508. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  10509. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10510. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  10511. }
  10512. }
  10513. else
  10514. {
  10515. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  10516. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  10517. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  10518. return;
  10519. }
  10520. }
  10521. void Commands::Command_Select(Client* client, Seperator* sep) {
  10522. if (sep && sep->arg[1]) {
  10523. Spawn* spawn = client->GetPlayer()->GetTarget();
  10524. if (spawn && strlen(sep->arg[1]) > 0)
  10525. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  10526. }
  10527. }
  10528. /*
  10529. Function: Command_ConsumeFood()
  10530. Purpose : Consume Food/Drink and apply mods
  10531. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  10532. Dev : Zcoretri
  10533. Example : /consume_food 22
  10534. */
  10535. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  10536. if (sep && sep->arg[0] && sep->IsNumber(0))
  10537. {
  10538. Player* player = client->GetPlayer();
  10539. int8 slot = atoi(sep->arg[0]);
  10540. if (client->GetVersion() <= 283) {
  10541. slot += 4;
  10542. }
  10543. else if (client->GetVersion() <= 546) {
  10544. slot += 2;
  10545. }
  10546. Item* item = player->GetEquipmentList()->GetItem(slot);
  10547. if(client->CheckConsumptionAllowed(slot)) {
  10548. client->ConsumeFoodDrink(item, slot);
  10549. }
  10550. }
  10551. }
  10552. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  10553. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10554. if (atoi(sep->arg[0]) == 1) {
  10555. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  10556. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  10557. client->GetPlayer()->SetCharSheetChanged(true);
  10558. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  10559. }
  10560. else {
  10561. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  10562. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  10563. client->GetPlayer()->SetCharSheetChanged(true);
  10564. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  10565. }
  10566. }
  10567. else
  10568. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  10569. }
  10570. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  10571. {
  10572. if(sep)
  10573. {
  10574. string data;
  10575. if(sep->arg[0]){
  10576. data = string(sep->arg[0]);
  10577. }
  10578. for(int i=1;i<sep->GetMaxArgNum();i++){
  10579. if(sep->arg[i])
  10580. data.append(" ").append(sep->arg[i]);
  10581. }
  10582. if(!sep->IsSet(7)){
  10583. data.append(" ").append(std::to_string(client->GetVersion())).append("\a");
  10584. }
  10585. const char* target_name = 0;
  10586. int32 spawn_id = 0;
  10587. if(client->GetPlayer()->GetTarget())
  10588. {
  10589. target_name = client->GetPlayer()->GetTarget()->GetName();
  10590. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10591. }
  10592. else
  10593. target_name = "N/A";
  10594. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  10595. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  10596. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  10597. else
  10598. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  10599. }
  10600. }
  10601. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  10602. PrintSep(sep, "Command_Attune_Inv");
  10603. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10604. // Get the item index from the first parameter
  10605. int16 index = atoi(sep->arg[0]);
  10606. // Check to see if this is a valid item index for the player, if not exit out of the function
  10607. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  10608. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  10609. return;
  10610. }
  10611. // Get the item
  10612. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  10613. if(item) {
  10614. // Valid item lets check to make sure this item is attunable, if not return out
  10615. if (!item->CheckFlag(ATTUNEABLE)) {
  10616. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  10617. return;
  10618. }
  10619. // Remove the attunable flag
  10620. item->generic_info.item_flags -= ATTUNEABLE;
  10621. // Set the attuned flag
  10622. item->generic_info.item_flags += ATTUNED;
  10623. // Flag this item for saving
  10624. item->save_needed = true;
  10625. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  10626. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  10627. EQ2Packet* outapp = 0;
  10628. for (int32 i=0;i<packets.size();i++) {
  10629. outapp = packets[i];
  10630. if(outapp)
  10631. client->QueuePacket(outapp);
  10632. }
  10633. }
  10634. }
  10635. }
  10636. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  10637. PrintSep(sep, "Command_Reset_Zone_Timer");
  10638. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10639. int32 db_id = atoul(sep->arg[0]);
  10640. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  10641. if (data) {
  10642. // TODO: add a check to timers to ensure it can be reset
  10643. // Delete the character from the instance
  10644. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  10645. data->instance_id = 0;
  10646. // Update the success time and set to 0 so the player can enter it again
  10647. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  10648. data->last_success_timestamp = 0;
  10649. }
  10650. }*/
  10651. }
  10652. void Commands::Command_Player(Client* client, Seperator* sep) {
  10653. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  10654. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  10655. }
  10656. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  10657. // /player coins add 10
  10658. // /player coins add plat 10
  10659. Player* player = client->GetPlayer();
  10660. Client* targetClient = client;
  10661. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  10662. player = (Player*)player->GetTarget();
  10663. targetClient = player->GetClient();
  10664. }
  10665. if (sep && sep->arg[0] && sep->arg[1]) {
  10666. const char* action = sep->arg[0];
  10667. int64 value = 0;
  10668. if (strncasecmp(action, "add", strlen(action)) == 0) {
  10669. if (sep->IsNumber(1)) {
  10670. value = atoi64(sep->arg[1]);
  10671. player->AddCoins(value);
  10672. if (client->GetPlayer() == player)
  10673. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10674. else {
  10675. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10676. if(targetClient) {
  10677. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10678. }
  10679. }
  10680. return;
  10681. }
  10682. else if (sep->arg[2] && sep->IsNumber(2)) {
  10683. const char* type = sep->arg[1];
  10684. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  10685. value = atoi64(sep->arg[2]);
  10686. }
  10687. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  10688. value = atoi64(sep->arg[2]) * 100;
  10689. }
  10690. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  10691. value = atoi64(sep->arg[2]) * 10000;
  10692. }
  10693. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  10694. value = atoi64(sep->arg[2]) * 1000000;
  10695. }
  10696. player->AddCoins(value);
  10697. if (client->GetPlayer() == player)
  10698. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10699. else {
  10700. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10701. if(targetClient) {
  10702. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10703. }
  10704. }
  10705. return;
  10706. }
  10707. }
  10708. }
  10709. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  10710. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  10711. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  10712. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  10713. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  10714. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  10715. }
  10716. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  10717. PrintSep(sep, "ACHIEVEMENT_ADD");
  10718. if (sep && sep->IsSet(0)) {
  10719. int32 spell_id = atoul(sep->arg[1]);
  10720. int8 spell_tier = 0;
  10721. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10722. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10723. // addspellbookentry here
  10724. if (spell_tier >= data->maxRank) {
  10725. return;
  10726. }
  10727. if (!spell_tier) {
  10728. spell_tier = 1;
  10729. }
  10730. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10731. {
  10732. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10733. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10734. client->GetPlayer()->UnlockSpell(spell);
  10735. client->SendSpellUpdate(spell);
  10736. }
  10737. else
  10738. {
  10739. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  10740. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10741. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10742. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10743. client->GetPlayer()->UnlockSpell(spell);
  10744. client->SendSpellUpdate(spell);
  10745. }
  10746. // cast spell here
  10747. if (!spell_tier)
  10748. spell_tier = 1;
  10749. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10750. if (spell) {
  10751. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10752. }
  10753. }
  10754. else {
  10755. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10756. }
  10757. master_aa_list.DisplayAA(client, 0, 0);
  10758. }
  10759. void Commands::Command_Editor(Client* client, Seperator* sep) {
  10760. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  10761. if (packet) {
  10762. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  10763. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  10764. char command[255];
  10765. url = "browser " + url;
  10766. int32 spawn_id = 0;
  10767. int32 zone_id = 0;
  10768. string type;
  10769. if (client->GetCurrentZone())
  10770. zone_id = client->GetCurrentZone()->GetZoneID();
  10771. if (client->GetPlayer()->GetTarget()) {
  10772. Spawn* target = client->GetPlayer()->GetTarget();
  10773. if (target->IsWidget())
  10774. type = "widgets";
  10775. else if (target->IsSign())
  10776. type = "signs";
  10777. else if (target->IsObject())
  10778. type = "objects";
  10779. else if (target->IsNPC())
  10780. type = "npcs";
  10781. else if (target->IsGroundSpawn())
  10782. type = "ground";
  10783. else
  10784. type = "spawn";
  10785. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10786. }
  10787. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  10788. packet->setDataByName("accept_command", command);
  10789. }
  10790. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  10791. char command[255];
  10792. url = "browser " + url;
  10793. if (client->GetPlayer()->GetTarget())
  10794. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  10795. packet->setDataByName("accept_command", command);
  10796. }
  10797. else {
  10798. string command = "browser " + url;
  10799. packet->setDataByName("accept_command", command.c_str());
  10800. }
  10801. packet->setDataByName("text", "Open the web editor?");
  10802. packet->setDataByName("accept_text", "Open");
  10803. packet->setDataByName("cancel_text", "Cancel");
  10804. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  10805. packet->setDataByName("unknown2", 50);
  10806. packet->setDataByName("unknown4", 1);
  10807. client->QueuePacket(packet->serialize());
  10808. safe_delete(packet);
  10809. }
  10810. }
  10811. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  10812. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10813. return;
  10814. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10815. if(client->GetCurrentRez()->active)
  10816. client->AcceptResurrection();
  10817. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10818. }
  10819. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  10820. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10821. return;
  10822. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10823. if(client->GetCurrentRez()->active)
  10824. client->GetCurrentRez()->should_delete = true;
  10825. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10826. }
  10827. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  10828. PrintSep(sep, "Switch_AA_Profile");
  10829. if (sep && sep->IsSet(0)) {
  10830. string type = sep->arg[0];
  10831. int8 newtemplate = atoul(sep->arg[1]);
  10832. master_aa_list.DisplayAA(client, newtemplate, 1);
  10833. }
  10834. }
  10835. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  10836. PrintSep(sep, "Get_AA_Xml");
  10837. if (sep && sep->IsSet(0)) {
  10838. string tabnum = sep->arg[0];
  10839. string spellid = sep->arg[1];
  10840. }
  10841. }
  10842. void Commands::Add_AA(Client* client, Seperator* sep) {
  10843. PrintSep(sep, "Add_AA");
  10844. if (sep && sep->IsSet(0)) {
  10845. int32 spell_id = atoul(sep->arg[1]);
  10846. int8 spell_tier = 0;
  10847. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10848. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10849. // addspellbookentry here
  10850. if(!data) {
  10851. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  10852. return;
  10853. }
  10854. if (spell_tier >= data->maxRank) {
  10855. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  10856. return;
  10857. }
  10858. if (!spell_tier) {
  10859. spell_tier = 1;
  10860. }
  10861. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10862. {
  10863. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10864. if(spell)
  10865. {
  10866. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10867. client->GetPlayer()->UnlockSpell(spell);
  10868. client->SendSpellUpdate(spell);
  10869. }
  10870. }
  10871. else
  10872. {
  10873. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10874. if(spell)
  10875. {
  10876. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10877. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10878. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10879. client->GetPlayer()->UnlockSpell(spell);
  10880. client->SendSpellUpdate(spell);
  10881. }
  10882. }
  10883. // cast spell here
  10884. if (!spell_tier)
  10885. spell_tier = 1;
  10886. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10887. if (spell) {
  10888. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10889. }
  10890. }
  10891. else {
  10892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10893. }
  10894. master_aa_list.DisplayAA(client, 0, 0);
  10895. }
  10896. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  10897. PrintSep(sep, "Commit_AA_Profile");
  10898. if (sep && sep->IsSet(0)) {
  10899. }
  10900. }
  10901. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  10902. PrintSep(sep, "Begin_AA_Profile");
  10903. if (sep && sep->IsSet(0)) {
  10904. master_aa_list.DisplayAA(client, 100, 2);
  10905. }
  10906. }
  10907. void Commands::Back_AA(Client* client, Seperator* sep) {
  10908. if (sep && sep->IsSet(0)) {
  10909. PrintSep(sep, "Back_AA");
  10910. }
  10911. }
  10912. void Commands::Remove_AA(Client* client, Seperator* sep) {
  10913. if (sep && sep->IsSet(0)) {
  10914. PrintSep(sep, "Remove_AA");
  10915. }
  10916. }
  10917. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  10918. MasterAAList master_aa_list;
  10919. PrintSep(sep, "Cancel_AA_Profile");
  10920. master_aa_list.DisplayAA(client, 0, 0);
  10921. }
  10922. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  10923. if (sep && sep->IsSet(0)) {
  10924. PrintSep(sep, "Save_AA_Profile");
  10925. }
  10926. }
  10927. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  10928. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  10929. if (!sep->IsNumber(0)) return;
  10930. int32 request_id = atoul(sep->arg[0]);
  10931. if (!sep->IsNumber(1)) return;
  10932. sint32 item_id = atoi(sep->arg[1]);
  10933. if (client->IsCurrentTransmuteID(request_id)) {
  10934. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  10935. }
  10936. else if (client->IsCurrentTransmuteID(item_id)) {
  10937. if (!sep->IsSet(2)) return;
  10938. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  10939. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  10940. }
  10941. }
  10942. }
  10943. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  10944. if(sep)
  10945. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  10946. }
  10947. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  10948. if(sep && sep->arg[0][0] && sep->arg[1][0])
  10949. {
  10950. char* name = sep->arg[0];
  10951. char* zoneName = sep->arg[1];
  10952. char query[256];
  10953. 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);
  10954. if (database.RunQuery(query, strnlen(query, 256)))
  10955. {
  10956. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  10957. }
  10958. else
  10959. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  10960. }
  10961. }
  10962. void Commands::Command_Mood(Client* client, Seperator* sep) {
  10963. Player* player = client->GetPlayer();
  10964. if( sep && sep->arg[0] )
  10965. {
  10966. const char* value = sep->arg[0];
  10967. InfoStruct* info = player->GetInfoStruct();
  10968. int32 cid = client->GetCharacterID();
  10969. char* characterName = database.GetCharacterName(cid);
  10970. char tmp[1024]; // our emote string "xyz appears zyx"
  10971. //char properties vals
  10972. char* pname = "mood";
  10973. char* pval; // mood value
  10974. bool pt; //used to verify return from DB.
  10975. //This should never be seen.
  10976. sprintf(tmp, " ");
  10977. if( strncasecmp(value, "angry", strlen(value)) == 0 )
  10978. {
  10979. sprintf(tmp, "%s appears angry", characterName);
  10980. pval = "11852";
  10981. player->SetMoodState(11852, 1);
  10982. info->set_mood(11852);
  10983. pt = database.insertCharacterProperty(client, pname, pval);
  10984. }
  10985. else if( strncasecmp(value, "afraid", strlen(value)) == 0 )
  10986. {
  10987. sprintf(tmp, "%s appears afraid", characterName);
  10988. pval = "11851";
  10989. player->SetMoodState(11851, 1);
  10990. info->set_mood(11851);
  10991. pt = database.insertCharacterProperty(client, pname, pval);
  10992. }
  10993. else if( strncasecmp(value, "happy", strlen(value)) == 0 )
  10994. {
  10995. sprintf(tmp, "%s appears happy", characterName);
  10996. pval = "11854";
  10997. player->SetMoodState(11854, 1);
  10998. info->set_mood(11854);
  10999. pt = database.insertCharacterProperty(client, pname, pval);
  11000. }
  11001. else if( strncasecmp(value, "sad", strlen(value)) == 0 ) {
  11002. sprintf(tmp, "%s appears sad", characterName);
  11003. pval = "11856";
  11004. player->SetMoodState(11856, 1);
  11005. info->set_mood(11856);
  11006. pt = database.insertCharacterProperty(client, pname, pval);
  11007. }
  11008. else if( strncasecmp(value, "tired", strlen(value)) == 0 )
  11009. {
  11010. sprintf(tmp, "%s appears tired", characterName);
  11011. pval = "11857";
  11012. player->SetMoodState(11857, 1);
  11013. info->set_mood(11857);
  11014. pt = database.insertCharacterProperty(client, pname, pval);
  11015. }
  11016. else if( strncasecmp(value, "none", strlen(value)) == 0 )
  11017. {
  11018. //using 11855 mood_idle for none, I assume thats what its for?
  11019. pval = "11855";
  11020. player->SetMoodState(11855, 1);
  11021. info->set_mood(11855);
  11022. pt = database.insertCharacterProperty(client, pname, pval);
  11023. //return since we have nothing left to do. No emote for none.
  11024. return;
  11025. }else{
  11026. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11027. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11028. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11029. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11030. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11031. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11032. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11033. return;
  11034. }
  11035. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, tmp);
  11036. return;
  11037. }
  11038. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11039. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11040. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11041. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11042. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11043. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11044. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11045. return;
  11046. }
  11047. /*
  11048. Function: Command_CancelEffect()
  11049. Purpose : Cancels (good) effect spells
  11050. Example : /cancel_effect spell_id - would cancel the spell with the <spell_id> value in spell effects list
  11051. */
  11052. void Commands::Command_CancelEffect(Client* client, Seperator* sep)
  11053. {
  11054. if (sep && sep->arg[0] && sep->IsNumber(0))
  11055. {
  11056. int32 spell_id = atoul(sep->arg[0]);
  11057. SpellEffects* effect = client->GetPlayer()->GetSpellEffect(spell_id);
  11058. if(!effect || effect->spell->spell->GetSpellData()->det_type) {
  11059. return;
  11060. }
  11061. MaintainedEffects* meffect = effect->caster->GetMaintainedSpell(spell_id);
  11062. if (!meffect || !meffect->spell || !meffect->spell->caster || !meffect->spell->caster->GetZone() ||
  11063. !meffect->spell->caster->GetZone()->GetSpellProcess()->DeleteCasterSpell(meffect->spell, "canceled", false, client->GetPlayer()))
  11064. client->Message(CHANNEL_COLOR_RED, "The spell effect could not be cancelled.");
  11065. }
  11066. }
  11067. /*
  11068. Function: Command_CurePlayer()
  11069. Purpose : Identifies spell to cast for cure based on type
  11070. Example : /cureplayer ??
  11071. https://eq2.fandom.com/wiki/Update:58
  11072. New command /cureplayer [playername|group or raid position][trauma|arcane|noxious|elemental|curse] optional [spell|potion]
  11073. Example: /cureplayer g0 noxious spell
  11074. Will attempt to cure yourself of a noxious detriment with only spells and without using potions (even if you have them).
  11075. Example: /cureplayer r4 noxious
  11076. Will attempt to cure the character in raid slot 4 of a noxious detriment using a spell or potion (whichever is available).
  11077. */
  11078. void Commands::Command_CurePlayer(Client* client, Seperator* sep)
  11079. {
  11080. Entity* target = nullptr;
  11081. bool use_spells = true;
  11082. bool use_potions = true;
  11083. if (sep && sep->arg[0] && sep->arg[1]) {
  11084. if(sep->arg[2]) {
  11085. std::string type(sep->arg[2]);
  11086. boost::algorithm::to_lower(type);
  11087. if(type == "potion")
  11088. use_spells = false;
  11089. else if(type == "spell")
  11090. use_potions = false;
  11091. }
  11092. if(strlen(sep->arg[0]) > 1 && isdigit(sep->arg[0][1])) {
  11093. int32 mapped_position = (int32)(sep->arg[0][1]) - 48;
  11094. // TODO: RAID Support ('r' argument)
  11095. if(sep->arg[0][0] == 'g' && !mapped_position) {
  11096. target = (Entity*)client->GetPlayer();
  11097. }
  11098. else {
  11099. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11100. if (gmi && gmi->group_id) {
  11101. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11102. if(group) {
  11103. target = group->GetGroupMemberByPosition(client->GetPlayer(), mapped_position);
  11104. }
  11105. }
  11106. }
  11107. }
  11108. else {
  11109. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11110. if(target_client && target_client->GetPlayer() && target_client->GetPlayer()->GetZone() == client->GetPlayer()->GetZone()) {
  11111. target = (Entity*)target_client->GetPlayer();
  11112. }
  11113. }
  11114. ItemEffectType type = EFFECT_CURE_TYPE_ALL;
  11115. bool successful_spell = false;
  11116. bool successful_potion = false;
  11117. if(target) {
  11118. SpellBookEntry* entry = nullptr;
  11119. std::string str(sep->arg[1]);
  11120. boost::algorithm::to_lower(str);
  11121. if(str == "arcane") {
  11122. type = EFFECT_CURE_TYPE_ARCANE;
  11123. // cure arcane spell missing in DB?
  11124. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()) {
  11125. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()); // cure noxious
  11126. }
  11127. }
  11128. else if(str == "trauma") {
  11129. type = EFFECT_CURE_TYPE_TRAUMA;
  11130. // cure trauma spell missing in DB?
  11131. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()) {
  11132. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()); // cure noxious
  11133. }
  11134. }
  11135. else if(str == "noxious") {
  11136. type = EFFECT_CURE_TYPE_NOXIOUS;
  11137. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()) {
  11138. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()); // cure noxious
  11139. }
  11140. }
  11141. else if(str == "curse") {
  11142. type = EFFECT_CURE_TYPE_CURSE;
  11143. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()) {
  11144. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()); // cure curse
  11145. }
  11146. }
  11147. else if(str == "magic") {
  11148. type = EFFECT_CURE_TYPE_MAGIC;
  11149. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()) {
  11150. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()); // cure magic
  11151. }
  11152. }
  11153. if(use_spells) {
  11154. // check if any of the specific cure types are available, if not then check the base cures
  11155. if(!entry && rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()) {
  11156. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()); // cure
  11157. }
  11158. if(entry && entry->spell_id) {
  11159. Spell* spell = master_spell_list.GetSpell(entry->spell_id, entry->tier);
  11160. target->GetZone()->ProcessSpell(spell, (Entity*)client->GetPlayer(), target, true, false);
  11161. successful_spell = true;
  11162. }
  11163. }
  11164. }
  11165. if(!successful_spell && use_potions && target && type != NO_EFFECT_TYPE) {
  11166. vector<Item*>* potential_items = client->GetItemsByEffectType(type, EFFECT_CURE_TYPE_ALL);
  11167. if (potential_items && potential_items->size() > 0) {
  11168. vector<Item*>::iterator itr;
  11169. for (itr = potential_items->begin(); itr != potential_items->end(); itr++)
  11170. {
  11171. Item* item = *itr;
  11172. if(client->UseItem(item, target)) {
  11173. successful_potion = true;
  11174. break;
  11175. }
  11176. }
  11177. }
  11178. safe_delete(potential_items);
  11179. }
  11180. }
  11181. }
  11182. /*
  11183. Function: Command_ShareQuest()
  11184. Purpose : Share quest with the group
  11185. Example : /share_quest [quest_id]
  11186. */
  11187. void Commands::Command_ShareQuest(Client* client, Seperator* sep)
  11188. {
  11189. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  11190. int32 quest_id = atoul(sep->arg[0]);
  11191. bool hasQuest = client->GetPlayer()->HasAnyQuest(quest_id);
  11192. if(hasQuest) {
  11193. Quest* quest = master_quest_list.GetQuest(quest_id, false);
  11194. if(quest) {
  11195. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11196. if (gmi && gmi->group_id) {
  11197. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11198. if (group) {
  11199. group->ShareQuestWithGroup(client, quest);
  11200. }
  11201. }
  11202. }
  11203. }
  11204. else {
  11205. client->SimpleMessage(CHANNEL_COLOR_RED, "Cannot find quest.");
  11206. }
  11207. }
  11208. }
  11209. /*
  11210. Function: Command_Yell()
  11211. Purpose : Yell to break an encounter
  11212. Example : /yell
  11213. * Uses self target, encounter target or no target
  11214. */
  11215. void Commands::Command_Yell(Client* client, Seperator* sep) {
  11216. Entity* player = (Entity*)client->GetPlayer();
  11217. Spawn* res = nullptr;
  11218. Spawn* prev = nullptr;
  11219. bool cycleAll = false;
  11220. if (player->GetTarget() == player) {
  11221. cycleAll = true; // self target breaks all encounters
  11222. }
  11223. else if (player->GetTarget()) {
  11224. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11225. }
  11226. if (res && !client->GetPlayer()->IsEngagedBySpawnID(res->GetID()))
  11227. return;
  11228. bool groupPermissionYell = true;
  11229. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11230. // If the player has a group and has a target
  11231. if (gmi) {
  11232. deque<GroupMemberInfo*>::iterator itr;
  11233. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  11234. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11235. if (group && !group->GetGroupOptions()->default_yell && !gmi->leader) { // default_yell_method = 0 means leader only
  11236. groupPermissionYell = false;
  11237. }
  11238. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  11239. }
  11240. if (!groupPermissionYell) {
  11241. LogWrite(COMMAND__ERROR, 0, "Command", "%s permission to yell denied due to group yell method set to leader only", client->GetPlayer()->GetName());
  11242. return;
  11243. }
  11244. bool alreadyYelled = false;
  11245. do {
  11246. if (!res && player->IsEngagedInEncounter(&res)) { // no target is set, dis-engage top of hated by list
  11247. }
  11248. if (!res || prev == res) {
  11249. return;
  11250. }
  11251. if (res->IsNPC() && ((NPC*)res)->Brain()) {
  11252. if (!alreadyYelled) {
  11253. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You yell for help!");
  11254. string yellMsg = std::string(client->GetPlayer()->GetName()) + " yelled for help!";
  11255. client->GetPlayer()->GetZone()->SimpleMessage(CHANNEL_COLOR_RED, yellMsg.c_str(), client->GetPlayer(), 35.0f, false);
  11256. client->GetPlayer()->GetZone()->SendYellPacket(client->GetPlayer());
  11257. }
  11258. alreadyYelled = true;
  11259. NPC* npc = (NPC*)res;
  11260. npc->Brain()->ClearEncounter();
  11261. npc->SetLockedNoLoot(ENCOUNTER_STATE_BROKEN);
  11262. npc->UpdateEncounterState(ENCOUNTER_STATE_BROKEN);
  11263. }
  11264. prev = res;
  11265. res = nullptr;
  11266. } while (cycleAll);
  11267. if (!player->IsEngagedInEncounter()) {
  11268. if (player->GetInfoStruct()->get_engaged_encounter()) {
  11269. player->GetInfoStruct()->set_engaged_encounter(0);
  11270. player->SetRegenValues((player->GetInfoStruct()->get_effective_level() > 0) ? player->GetInfoStruct()->get_effective_level() : player->GetLevel());
  11271. client->GetPlayer()->SetCharSheetChanged(true);
  11272. player->info_changed = true;
  11273. }
  11274. }
  11275. }
  11276. /*
  11277. Function: Command_SetAutoLootMode()
  11278. Purpose : Set player auto loot mode (0 = disabled, 1 = need/lotto, 2 = decline).
  11279. Example : /setautolootmode [mode]
  11280. */
  11281. void Commands::Command_SetAutoLootMode(Client* client, Seperator* sep) {
  11282. if (sep && sep->IsNumber(0)) {
  11283. int8 mode = atoul(sep->arg[0]);
  11284. switch (mode) {
  11285. case AutoLootMode::METHOD_DISABLED: {
  11286. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Disabled auto loot mode");
  11287. break;
  11288. }
  11289. case AutoLootMode::METHOD_ACCEPT: {
  11290. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Enabled auto loot mode for need and lotto.");
  11291. break;
  11292. }
  11293. default: {
  11294. mode = AutoLootMode::METHOD_DECLINE;
  11295. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Enabled auto loot mode to decline need and lotto.");
  11296. break;
  11297. }
  11298. }
  11299. client->GetPlayer()->GetInfoStruct()->set_group_auto_loot_method(mode);
  11300. database.insertCharacterProperty(client, CHAR_PROPERTY_AUTOLOOTMETHOD, (char*)std::to_string(mode).c_str());
  11301. client->SendDefaultGroupOptions();
  11302. }
  11303. }
  11304. /*
  11305. Function: Command_AutoAttack()
  11306. Purpose : Attack / Auto Attack
  11307. Example : /attack, /autoattack type
  11308. */
  11309. void Commands::Command_AutoAttack(Client* client, Seperator* sep) {
  11310. int8 type = 1;
  11311. bool update = false;
  11312. Player* player = client->GetPlayer();
  11313. if(!player)
  11314. return;
  11315. bool incombat = player->EngagedInCombat();
  11316. if(sep && sep->arg[0] && sep->IsNumber(0))
  11317. type = atoi(sep->arg[0]);
  11318. if(!client->GetPlayer()->Alive()){
  11319. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  11320. return;
  11321. }
  11322. if(type == 0){
  11323. if(incombat)
  11324. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  11325. player->StopCombat(type);
  11326. update = true;
  11327. }
  11328. else {
  11329. if(type == 2){
  11330. player->InCombat(false);
  11331. if(incombat && player->GetRangeAttack()){
  11332. player->StopCombat(type);
  11333. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  11334. update = true;
  11335. }
  11336. else{
  11337. player->SetRangeAttack(true);
  11338. player->InCombat(true, true);
  11339. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  11340. update = true;
  11341. }
  11342. }
  11343. else {
  11344. player->InCombat(false, true);
  11345. player->SetRangeAttack(false);
  11346. player->InCombat(true);
  11347. if(!incombat) {
  11348. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  11349. update = true;
  11350. }
  11351. }
  11352. /*else
  11353. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  11354. }
  11355. if(update) {
  11356. player->SetCharSheetChanged(true);
  11357. }
  11358. }
  11359. /*
  11360. Function: Command_Assist()
  11361. Purpose : Assist target
  11362. Example : /assist [name]
  11363. * Uses target or character name
  11364. */
  11365. void Commands::Command_Assist(Client* client, Seperator* sep) {
  11366. Entity* player = (Entity*)client->GetPlayer();
  11367. Spawn* res = nullptr;
  11368. if(sep && sep->arg[0]) {
  11369. if(!stricmp(sep->arg[0], "on")) {
  11370. database.insertCharacterProperty(client, CHAR_PROPERTY_ASSISTAUTOATTACK, "1");
  11371. return;
  11372. }
  11373. else if(!stricmp(sep->arg[0], "off")) {
  11374. database.insertCharacterProperty(client, CHAR_PROPERTY_ASSISTAUTOATTACK, "0");
  11375. return;
  11376. }
  11377. Client* otherClient = client->GetPlayer()->GetZone()->GetClientByName(sep->arg[0]);
  11378. if(otherClient) {
  11379. res = otherClient->GetPlayer();
  11380. }
  11381. }
  11382. if (player->GetTarget()) {
  11383. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11384. }
  11385. if(res && res->GetTarget()) {
  11386. res = res->GetTarget();
  11387. }
  11388. if(res) {
  11389. client->TargetSpawn(res);
  11390. if(client->GetPlayer()->GetInfoStruct()->get_assist_auto_attack() && !player->EngagedInCombat()) {
  11391. Command_AutoAttack(client, nullptr);
  11392. }
  11393. }
  11394. }