9
3

Commands.cpp 441 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158
  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. int8 type = 1;
  3951. bool update = false;
  3952. Player* player = client->GetPlayer();
  3953. if(!player)
  3954. break;
  3955. bool incombat = player->EngagedInCombat();
  3956. if(sep && sep->arg[0] && sep->IsNumber(0))
  3957. type = atoi(sep->arg[0]);
  3958. if(!client->GetPlayer()->Alive()){
  3959. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  3960. break;
  3961. }
  3962. if(type == 0){
  3963. if(incombat)
  3964. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3965. player->StopCombat(type);
  3966. update = true;
  3967. }
  3968. else {
  3969. if(type == 2){
  3970. player->InCombat(false);
  3971. if(incombat && player->GetRangeAttack()){
  3972. player->StopCombat(type);
  3973. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3974. update = true;
  3975. }
  3976. else{
  3977. player->SetRangeAttack(true);
  3978. player->InCombat(true, true);
  3979. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3980. update = true;
  3981. }
  3982. }
  3983. else {
  3984. player->InCombat(false, true);
  3985. player->SetRangeAttack(false);
  3986. player->InCombat(true);
  3987. if(!incombat) {
  3988. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3989. update = true;
  3990. }
  3991. }
  3992. /*else
  3993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  3994. }
  3995. if(update) {
  3996. player->SetCharSheetChanged(true);
  3997. }
  3998. break;
  3999. }
  4000. case COMMAND_DEPOP:{
  4001. bool allow_respawns = false;
  4002. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4003. if(atoi(sep->arg[0]) == 1)
  4004. allow_respawns = true;
  4005. }
  4006. client->GetCurrentZone()->Depop(allow_respawns);
  4007. break;
  4008. }
  4009. case COMMAND_REPOP:{
  4010. client->GetCurrentZone()->Depop(false, true);
  4011. break;
  4012. }
  4013. case COMMAND_BUYBACK:{
  4014. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4015. // 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
  4016. int64 id = atoi64(sep->arg[0]);
  4017. // get the first int32, the item id
  4018. //int32 item_id = (int32)id;
  4019. // get the second int32, the unique id
  4020. int32 unique_id = (int32)(id>>32);
  4021. int8 quantity = atoi(sep->arg[1]);
  4022. if(quantity == 255)
  4023. quantity = 1;
  4024. client->BuyBack(unique_id, quantity);
  4025. }
  4026. break;
  4027. }
  4028. case COMMAND_MERCHANT_BUY:{
  4029. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4030. int32 item_id = atoul(sep->arg[0]);
  4031. int8 quantity = atoi(sep->arg[1]);
  4032. client->BuyItem(item_id, quantity);
  4033. }
  4034. else
  4035. Command_SendMerchantWindow(client, sep);
  4036. break;
  4037. }
  4038. case COMMAND_MERCHANT_SELL:{
  4039. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4040. // 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
  4041. int64 id = atoi64(sep->arg[0]);
  4042. // get the first int32, the item id
  4043. int32 item_id = (int32)id;
  4044. // get the second int32, the unique id
  4045. int32 unique_id = (int32)(id>>32);
  4046. int8 quantity = atoi(sep->arg[1]);
  4047. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  4048. client->SellItem(item_id, quantity, unique_id);
  4049. }
  4050. break;
  4051. }
  4052. case COMMAND_MENDER_REPAIR: {
  4053. if (sep && sep->arg[0] && sep->IsNumber(0))
  4054. client->RepairItem(atoul(sep->arg[0]));
  4055. break;
  4056. }
  4057. case COMMAND_MENDER_REPAIR_ALL: {
  4058. client->RepairAllItems();
  4059. break;
  4060. }
  4061. case COMMAND_CANCEL_MERCHANT:{
  4062. client->SetMerchantTransaction(0);
  4063. break;
  4064. }
  4065. case COMMAND_START_MERCHANT:{
  4066. break;
  4067. }
  4068. case COMMAND_INVULNERABLE:{
  4069. sint8 val = -1;
  4070. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4071. val = atoi(sep->arg[0]);
  4072. //devn00b: Fix for linux builds
  4073. #if defined(__GNUC__)
  4074. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  4075. #else
  4076. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4077. #endif
  4078. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4079. client->GetPlayer()->SetInvulnerable(val==1);
  4080. if(client->GetPlayer()->GetInvulnerable())
  4081. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  4082. else
  4083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  4084. }
  4085. if(val == -1)
  4086. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  4087. break;
  4088. }
  4089. case COMMAND_REPAIR: {
  4090. Spawn* spawn = cmdTarget;
  4091. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  4092. client->SendHailCommand(spawn);
  4093. client->SetMerchantTransaction(spawn);
  4094. client->SendRepairList();
  4095. }
  4096. break;
  4097. }
  4098. case COMMAND_LOTTO: {
  4099. Spawn* spawn = cmdTarget;
  4100. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  4101. client->SetMerchantTransaction(spawn);
  4102. client->ShowLottoWindow();
  4103. }
  4104. break;
  4105. }
  4106. case COMMAND_ACCEPT_REWARD:{
  4107. int32 unknown = 0;
  4108. int32 selectable_item_id = 0;
  4109. //Quest *quest = 0;
  4110. /* no idea what the first argument is for (faction maybe?)
  4111. if the reward has a selectable item reward, it's sent as the second argument
  4112. if neither of these are included in the reward, there is no sep
  4113. 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
  4114. only 1 quest or collection reward may be displayed at a time */
  4115. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  4116. unknown = atoul(sep->arg[0]);
  4117. selectable_item_id = atoul(sep->arg[1]);
  4118. }
  4119. /* 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
  4120. ** Otherwise it will likely be a DoF client scenario (pending item rewards, selectable item rewards) which is specifying an item id
  4121. ** 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
  4122. */
  4123. int32 item_id = 0;
  4124. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  4125. item_id = atoul(sep->arg[0]);
  4126. bool collectedItems = client->GetPlayer()->AcceptQuestReward(item_id, selectable_item_id);
  4127. if (collectedItems) {
  4128. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4129. if (outapp)
  4130. client->QueuePacket(outapp);
  4131. }
  4132. else
  4133. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  4134. break;
  4135. }
  4136. case COMMAND_BUY_FROM_BROKER:{
  4137. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4138. int32 item_id = atoul(sep->arg[0]);
  4139. int16 quantity = atoul(sep->arg[1]);
  4140. Item* item = master_item_list.GetItem(item_id);
  4141. if(item && item->generic_info.max_charges > 1)
  4142. quantity = item->generic_info.max_charges;
  4143. client->AddItem(item_id, quantity, AddItemType::BUY_FROM_BROKER);
  4144. }
  4145. break;
  4146. }
  4147. case COMMAND_SEARCH_STORES_PAGE:{
  4148. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4149. int32 page = atoul(sep->arg[0]);
  4150. client->SearchStore(page);
  4151. }
  4152. break;
  4153. }
  4154. case COMMAND_SEARCH_STORES:{
  4155. if(sep && sep->arg[0][0]){
  4156. const char* values = sep->argplus[0];
  4157. if(values){
  4158. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  4159. map<string, string> str_values = TranslateBrokerRequest(values);
  4160. vector<Item*>* items = master_item_list.GetItems(str_values, client);
  4161. if(items){
  4162. client->SetItemSearch(items);
  4163. client->SearchStore(0);
  4164. }
  4165. }
  4166. }
  4167. break;
  4168. }
  4169. case COMMAND_LUADEBUG:{
  4170. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  4171. client->SetLuaDebugClient(true);
  4172. if(lua_interface)
  4173. lua_interface->UpdateDebugClients(client);
  4174. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4175. }
  4176. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  4177. client->SetLuaDebugClient(false);
  4178. if(lua_interface)
  4179. lua_interface->RemoveDebugClients(client);
  4180. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4181. }
  4182. else{
  4183. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  4184. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  4185. }
  4186. break;
  4187. }
  4188. case COMMAND_SPAWN_GROUP:
  4189. {
  4190. Spawn* target = cmdTarget;
  4191. if(target && target->IsPlayer() == false)
  4192. {
  4193. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  4194. {
  4195. if(target->GetSpawnLocationPlacementID() > 0)
  4196. {
  4197. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  4198. {
  4199. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  4200. if(id > 0)
  4201. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  4202. else
  4203. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  4204. target->SetSpawnGroupID(id);
  4205. target->AddSpawnToGroup(target);
  4206. }
  4207. else
  4208. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  4209. }
  4210. else
  4211. 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.");
  4212. }
  4213. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  4214. {
  4215. if(sep->arg[1] && sep->IsNumber(1))
  4216. {
  4217. int32 group_id = atoul(sep->arg[1]);
  4218. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  4219. if(leader)
  4220. {
  4221. leader->AddSpawnToGroup(target);
  4222. target->SetSpawnGroupID(group_id);
  4223. if(database.SpawnGroupAddSpawn(target, group_id))
  4224. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  4225. else
  4226. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  4227. }
  4228. else
  4229. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  4230. }
  4231. else
  4232. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  4233. }
  4234. else if(target->GetSpawnGroupID() == 0)
  4235. {
  4236. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  4237. }
  4238. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  4239. {
  4240. int32 group_id = target->GetSpawnGroupID();
  4241. target->RemoveSpawnFromGroup();
  4242. if(database.SpawnGroupRemoveSpawn(target, group_id))
  4243. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  4244. else
  4245. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  4246. }
  4247. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  4248. {
  4249. int32 group_id = target->GetSpawnGroupID();
  4250. if(sep->arg[1] && sep->IsNumber(1))
  4251. {
  4252. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  4253. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  4254. else
  4255. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  4256. }
  4257. else
  4258. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  4259. }
  4260. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  4261. {
  4262. int32 group_id = target->GetSpawnGroupID();
  4263. if(sep->arg[1] && sep->IsNumber(1))
  4264. {
  4265. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  4266. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  4267. else
  4268. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  4269. }
  4270. else
  4271. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  4272. }
  4273. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  4274. {
  4275. if(sep->arg[1] && sep->IsNumber(1))
  4276. {
  4277. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  4278. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  4279. else
  4280. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  4281. }
  4282. else
  4283. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  4284. }
  4285. else
  4286. {
  4287. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  4288. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  4289. }
  4290. }
  4291. else
  4292. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  4293. break;
  4294. }
  4295. case COMMAND_SPAWN_COMBINE:{
  4296. Spawn* spawn = cmdTarget;
  4297. float radius = 0;
  4298. bool failed = true;
  4299. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  4300. failed = false;
  4301. if(spawn->GetSpawnGroupID() > 0){
  4302. 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.");
  4303. }
  4304. else if(sep->IsNumber(0)){
  4305. radius = atof(sep->arg[0]);
  4306. client->CombineSpawns(radius, spawn);
  4307. }
  4308. else{
  4309. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  4310. client->AddCombineSpawn(spawn);
  4311. }
  4312. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  4313. client->RemoveCombineSpawn(spawn);
  4314. }
  4315. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  4316. const char* name = 0;
  4317. if(sep->arg[1] && sep->arg[1][0])
  4318. name = sep->argplus[1];
  4319. client->SaveCombineSpawns(name);
  4320. }
  4321. else
  4322. failed = true;
  4323. }
  4324. }
  4325. if(failed){
  4326. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  4327. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  4328. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  4329. }
  4330. break;
  4331. }
  4332. case COMMAND_SPAWN_CREATE:{
  4333. Spawn* spawn = 0;
  4334. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4335. spawn = new Object();
  4336. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4337. }
  4338. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4339. spawn = new GroundSpawn();
  4340. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4341. }
  4342. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4343. spawn = new Sign();
  4344. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4345. }
  4346. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4347. spawn = new NPC();
  4348. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4349. spawn->appearance.pos.collision_radius = 32;
  4350. spawn->secondary_command_list_id = 0;
  4351. spawn->primary_command_list_id = 0;
  4352. spawn->appearance.display_name = 1;
  4353. spawn->appearance.show_level = 1;
  4354. spawn->appearance.attackable = 1;
  4355. }
  4356. else{
  4357. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  4358. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  4359. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  4360. break;
  4361. }
  4362. spawn->SetID(Spawn::NextID());
  4363. spawn->SetX(client->GetPlayer()->GetX());
  4364. spawn->SetY(client->GetPlayer()->GetY());
  4365. spawn->SetZ(client->GetPlayer()->GetZ());
  4366. spawn->SetHeading(client->GetPlayer()->GetHeading());
  4367. spawn->SetSpawnOrigX(spawn->GetX());
  4368. spawn->SetSpawnOrigY(spawn->GetY());
  4369. spawn->SetSpawnOrigZ(spawn->GetZ());
  4370. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4371. if(spawn->IsSign())
  4372. {
  4373. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  4374. ((Sign*)spawn)->SetSignDistance(20.0f);
  4375. ((Sign*)spawn)->SetIncludeLocation(1);
  4376. ((Sign*)spawn)->SetIncludeHeading(1);
  4377. ((Sign*)spawn)->SetInitialState(1);
  4378. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  4379. ((Sign*)spawn)->SetActivityStatus(64);
  4380. spawn->appearance.race = 0;
  4381. spawn->SetLevel(0);
  4382. spawn->SetHP(0);
  4383. spawn->SetTotalHP(0);
  4384. spawn->SetPower(0);
  4385. spawn->SetTotalPower(0);
  4386. spawn->SetDifficulty(0);
  4387. spawn->SetTargetable(0);
  4388. spawn->SetSogaModelType(0);
  4389. spawn->SetCollisionRadius(19);
  4390. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  4391. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  4392. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  4393. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4394. spawn->appearance.model_type = atoul(sep->arg[1]);
  4395. }
  4396. else
  4397. {
  4398. spawn->appearance.targetable = 1;
  4399. spawn->appearance.race = 255;
  4400. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4401. spawn->SetModelType(atoi(sep->arg[1]));
  4402. spawn->SetAdventureClass(atoi(sep->arg[2]));
  4403. spawn->SetLevel(atoi(sep->arg[3]));
  4404. spawn->SetName(sep->arg[4]);
  4405. if(sep->arg[5][0] && sep->IsNumber(5))
  4406. spawn->SetDifficulty(atoi(sep->arg[5]));
  4407. if(sep->arg[6][0] && sep->IsNumber(6))
  4408. spawn->size = atoi(sep->arg[6]);
  4409. if(spawn->GetTotalHP() == 0){
  4410. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  4411. spawn->SetHP(25*spawn->GetLevel() + 1);
  4412. }
  4413. if(spawn->GetTotalPower() == 0){
  4414. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  4415. spawn->SetPower(25*spawn->GetLevel() + 1);
  4416. }
  4417. }
  4418. client->GetCurrentZone()->AddSpawn(spawn);
  4419. break;
  4420. }
  4421. case COMMAND_SPAWN_EQUIPMENT:{
  4422. Spawn* spawn = cmdTarget;
  4423. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  4424. int8 slot = atoi(sep->arg[0]);
  4425. int16 type = atoi(sep->arg[1]);
  4426. int8 red = 0;
  4427. int8 green = 0;
  4428. int8 blue = 0;
  4429. int8 h_red = 0;
  4430. int8 h_green = 0;
  4431. int8 h_blue = 0;
  4432. if(sep->arg[2])
  4433. red = atoi(sep->arg[2]);
  4434. if(sep->arg[3])
  4435. green = atoi(sep->arg[3]);
  4436. if(sep->arg[4])
  4437. blue = atoi(sep->arg[4]);
  4438. if(sep->arg[5])
  4439. h_red = atoi(sep->arg[5]);
  4440. if(sep->arg[6])
  4441. h_green = atoi(sep->arg[6]);
  4442. if(sep->arg[7])
  4443. h_blue = atoi(sep->arg[7]);
  4444. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  4445. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  4446. }
  4447. else{
  4448. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  4449. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  4450. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  4451. }
  4452. break;
  4453. }
  4454. case COMMAND_SPAWN_DETAILS: {
  4455. Spawn* spawn = cmdTarget;
  4456. if (sep && sep->arg[0][0]) {
  4457. if (cmdTarget)
  4458. {
  4459. if (ToLower(string(sep->arg[0])) == "los")
  4460. {
  4461. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  4462. if (hasLOS)
  4463. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  4464. else
  4465. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  4466. break;
  4467. }
  4468. else if (ToLower(string(sep->arg[0])) == "bestz")
  4469. {
  4470. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  4471. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  4472. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  4473. break;
  4474. }
  4475. else if (ToLower(string(sep->arg[0])) == "inwater")
  4476. {
  4477. if (cmdTarget->GetRegionMap() == nullptr)
  4478. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  4479. else
  4480. {
  4481. bool inWater = cmdTarget->InWater();
  4482. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  4483. }
  4484. break;
  4485. }
  4486. else if (ToLower(string(sep->arg[0])) == "inlava")
  4487. {
  4488. if (cmdTarget->GetRegionMap() == nullptr)
  4489. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4490. else
  4491. {
  4492. bool inLava = cmdTarget->InLava();
  4493. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  4494. }
  4495. break;
  4496. }
  4497. else if (ToLower(string(sep->arg[0])) == "regions")
  4498. {
  4499. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  4500. if (cmdTarget->GetRegionMap() == nullptr)
  4501. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4502. else
  4503. {
  4504. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  4505. }
  4506. break;
  4507. }
  4508. else if (ToLower(string(sep->arg[0])) == "behind")
  4509. {
  4510. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  4511. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  4512. break;
  4513. }
  4514. else if (ToLower(string(sep->arg[0])) == "infront")
  4515. {
  4516. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  4517. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  4518. break;
  4519. }
  4520. else if (ToLower(string(sep->arg[0])) == "flank")
  4521. {
  4522. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  4523. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  4524. break;
  4525. }
  4526. else if (ToLower(string(sep->arg[0])) == "aggro")
  4527. {
  4528. if(cmdTarget->IsNPC() && ((NPC*)cmdTarget)->Brain()) {
  4529. ((NPC*)cmdTarget)->Brain()->SendEncounterList(client);
  4530. ((NPC*)cmdTarget)->Brain()->SendHateList(client);
  4531. }
  4532. else {
  4533. client->SimpleMessage(CHANNEL_COLOR_RED, "/spawn details aggro is for NPCs only!");
  4534. }
  4535. break;
  4536. }
  4537. else if (ToLower(string(sep->arg[0])) == "angle")
  4538. {
  4539. float spawnAngle = client->GetPlayer()->GetFaceTarget(cmdTarget->GetX(), cmdTarget->GetZ());
  4540. 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());
  4541. break;
  4542. }
  4543. }
  4544. if (sep->IsNumber(0))
  4545. {
  4546. float radius = atof(sep->arg[0]);
  4547. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  4548. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  4549. break;
  4550. }
  4551. }
  4552. if (spawn) {
  4553. const char* type = "NPC";
  4554. if (spawn->IsObject())
  4555. type = "Object";
  4556. else if (spawn->IsSign())
  4557. type = "Sign";
  4558. else if (spawn->IsWidget())
  4559. type = "Widget";
  4560. else if (spawn->IsGroundSpawn())
  4561. type = "GroundSpawn";
  4562. int16 race_type = race_types_list.GetRaceType(spawn->GetModelType());
  4563. int16 race_base_type = race_types_list.GetRaceBaseType(spawn->GetModelType());
  4564. char* category = race_types_list.GetRaceTypeCategory(spawn->GetModelType());
  4565. char* subcategory = race_types_list.GetRaceTypeSubCategory(spawn->GetModelType());
  4566. char* modelname = race_types_list.GetRaceTypeModelName(spawn->GetModelType());
  4567. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  4568. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  4569. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  4570. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  4571. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  4572. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  4573. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u / %u, Power: %u / %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetTotalHP(), spawn->GetPower(), spawn->GetTotalPower());
  4574. 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());
  4575. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetDifficulty(), spawn->GetHeroic());
  4576. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  4577. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  4578. if (spawn->IsEntity()) {
  4579. 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());
  4580. 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());
  4581. }
  4582. 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);
  4583. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  4584. 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());
  4585. 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);
  4586. if (spawn->IsNPC())
  4587. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  4588. if (spawn->IsNPC()){
  4589. client->Message(CHANNEL_COLOR_YELLOW, "Heat Resist/Base: %u/%u",((NPC*)spawn)->GetHeatResistance(), ((NPC*)spawn)->GetHeatResistanceBase());
  4590. client->Message(CHANNEL_COLOR_YELLOW, "Cold Resist/Base: %u/%u",((NPC*)spawn)->GetColdResistance(), ((NPC*)spawn)->GetColdResistanceBase());
  4591. client->Message(CHANNEL_COLOR_YELLOW, "Magic Resist/Base: %u/%u",((NPC*)spawn)->GetMagicResistance(), ((NPC*)spawn)->GetMagicResistanceBase());
  4592. client->Message(CHANNEL_COLOR_YELLOW, "Mental Resist/Base: %u/%u",((NPC*)spawn)->GetMentalResistance(), ((NPC*)spawn)->GetMentalResistanceBase());
  4593. client->Message(CHANNEL_COLOR_YELLOW, "Divine Resist/Base: %u/%u",((NPC*)spawn)->GetDivineResistance(), ((NPC*)spawn)->GetDivineResistanceBase());
  4594. client->Message(CHANNEL_COLOR_YELLOW, "Disease Resist/Base: %u/%u",((NPC*)spawn)->GetDiseaseResistance(), ((NPC*)spawn)->GetDiseaseResistanceBase());
  4595. client->Message(CHANNEL_COLOR_YELLOW, "Poison Resist/Base: %u/%u",((NPC*)spawn)->GetPoisonResistance(), ((NPC*)spawn)->GetPoisonResistanceBase());
  4596. }
  4597. string details;
  4598. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  4599. details += "Type: " + string(type) + "\n";
  4600. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  4601. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  4602. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  4603. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  4604. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  4605. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  4606. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  4607. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  4608. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  4609. details += "HP: " + to_string(spawn->GetHP()) + " / " + to_string(spawn->GetTotalHP()) + "(" + to_string(spawn->GetIntHPRatio()) + "%)\n";
  4610. details += "Power: " + to_string(spawn->GetPower()) + + " / " + to_string(spawn->GetTotalPower()) + "\n";
  4611. details += "Difficulty: " + to_string(spawn->GetDifficulty()) + "\n";
  4612. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  4613. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  4614. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  4615. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  4616. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  4617. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  4618. char x[16];
  4619. sprintf(x, "%.2f", spawn->GetX());
  4620. char y[16];
  4621. sprintf(y, "%.2f", spawn->GetY());
  4622. char z[16];
  4623. sprintf(z, "%.2f", spawn->GetZ());
  4624. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  4625. string details2;
  4626. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  4627. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  4628. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  4629. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  4630. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  4631. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  4632. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  4633. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  4634. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  4635. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  4636. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  4637. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  4638. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  4639. details2 += "Race Type: " + to_string(race_type) + "\n";
  4640. details2 += "Race Base Type: " + to_string(race_base_type) + "\n";
  4641. details2 += "Race Category (Sub Category): " + std::string(category) + " (" + std::string(subcategory) + ")\n";
  4642. details2 += "Model Name: " + std::string(modelname) + "\n";
  4643. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  4644. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  4645. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  4646. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  4647. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  4648. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  4649. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  4650. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  4651. string details3;
  4652. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  4653. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  4654. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  4655. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  4656. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  4657. if(spawn->IsSign()) {
  4658. details3 += "Sign Language: " + to_string(((Sign*)spawn)->GetLanguage()) + "\n";
  4659. }
  4660. if(spawn->IsEntity())
  4661. {
  4662. Entity* ent = (Entity*)spawn;
  4663. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  4664. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  4665. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  4666. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  4667. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  4668. }
  4669. string details4;
  4670. if (spawn->IsEntity()) {
  4671. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  4672. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4673. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4674. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4675. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4676. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4677. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4678. if (spawn->IsNPC()) {
  4679. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4680. }
  4681. }
  4682. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4683. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4684. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4685. client->SendShowBook(client->GetPlayer(), title, 0, 4, details, details2, details3, details4);
  4686. }
  4687. else {
  4688. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4689. 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.");
  4690. }
  4691. break;
  4692. }
  4693. case COMMAND_SPAWN_TARGET:{
  4694. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4695. int32 spawn_id = atoul(sep->arg[0]);
  4696. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4697. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4698. }
  4699. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4700. float distance = atof(sep->arg[1]);
  4701. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4702. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4703. }
  4704. else{
  4705. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4706. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4707. }
  4708. break;
  4709. }
  4710. case COMMAND_SPAWN_SET:
  4711. {
  4712. Spawn* spawn = cmdTarget;
  4713. sint16 set_type = -1;
  4714. string type_str;
  4715. if (spawn)
  4716. {
  4717. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4718. 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)
  4719. {
  4720. // set the type, which will be 0 if location or list or invalid
  4721. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4722. }
  4723. if(set_type > 0)
  4724. {
  4725. // check if spawn set is NOT a char update, or not location, or isn't a number
  4726. 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)
  4727. {
  4728. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4729. }
  4730. else
  4731. {
  4732. string name = string(spawn->GetName());
  4733. bool customSetSpawn = false;
  4734. if(set_type >= SPAWN_SET_CHEEK_TYPE && set_type <= SPAWN_SET_SOGA_NOSE_TYPE)
  4735. {
  4736. int8 index = sep->IsNumber(2) ? atoul(sep->arg[2]) : 0;
  4737. // override the standard setspawncommand, we pass arguments different!
  4738. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1], true, false, nullptr, index))
  4739. customSetSpawn = true;
  4740. }
  4741. if(customSetSpawn || SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4742. {
  4743. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4744. {
  4745. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4746. }
  4747. else if (set_type == SPAWN_SET_VALUE_NAME)
  4748. {
  4749. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4750. }
  4751. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4752. {
  4753. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4754. }
  4755. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4756. {
  4757. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4758. 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());
  4759. }
  4760. else
  4761. {
  4762. 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());
  4763. }
  4764. switch (set_type)
  4765. {
  4766. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4767. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4768. case SPAWN_SET_VALUE_FACTION:
  4769. case SPAWN_SET_AAXP_REWARDS:
  4770. case SPAWN_SET_CHEEK_TYPE:
  4771. case SPAWN_SET_CHIN_TYPE:
  4772. case SPAWN_SET_EAR_TYPE:
  4773. case SPAWN_SET_EYE_BROW_TYPE:
  4774. case SPAWN_SET_EYE_TYPE:
  4775. case SPAWN_SET_LIP_TYPE:
  4776. case SPAWN_SET_NOSE_TYPE:
  4777. case SPAWN_SET_BODY_SIZE:
  4778. case SPAWN_SET_BODY_AGE:
  4779. case SPAWN_SET_SOGA_CHEEK_TYPE:
  4780. case SPAWN_SET_SOGA_CHIN_TYPE:
  4781. case SPAWN_SET_SOGA_EAR_TYPE:
  4782. case SPAWN_SET_SOGA_EYE_BROW_TYPE:
  4783. case SPAWN_SET_SOGA_EYE_TYPE:
  4784. case SPAWN_SET_SOGA_LIP_TYPE:
  4785. case SPAWN_SET_SOGA_NOSE_TYPE:
  4786. case SPAWN_SET_SOGA_BODY_SIZE:
  4787. case SPAWN_SET_SOGA_BODY_AGE:
  4788. case SPAWN_SET_ATTACK_TYPE:
  4789. case SPAWN_SET_RACE_TYPE:
  4790. case SPAWN_SET_LOOT_TIER:
  4791. case SPAWN_SET_LOOT_DROP_TYPE:
  4792. case SPAWN_SET_SCARED_STRONG_PLAYERS:
  4793. {
  4794. // not applicable already ran db command
  4795. break;
  4796. }
  4797. default:
  4798. {
  4799. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4800. break;
  4801. }
  4802. }
  4803. 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))
  4804. {
  4805. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4806. {
  4807. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4808. }
  4809. else if(spawn->GetSpawnLocationID() > 0)
  4810. {
  4811. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4812. }
  4813. }
  4814. else
  4815. {
  4816. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4817. {
  4818. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4819. }
  4820. else if(spawn->GetDatabaseID() > 0)
  4821. {
  4822. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4823. }
  4824. }
  4825. }
  4826. }
  4827. }
  4828. else if(set_type == 0)
  4829. {
  4830. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4831. map<string, int8>::iterator itr;
  4832. int i=0;
  4833. string list;
  4834. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4835. {
  4836. if(i==10)
  4837. {
  4838. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4839. i = 0;
  4840. }
  4841. if(i>0)
  4842. {
  4843. list.append(", ").append(itr->first);
  4844. }
  4845. else
  4846. {
  4847. list = itr->first;
  4848. }
  4849. }
  4850. if(list.length() > 0)
  4851. {
  4852. // if 1 or more, display in client.
  4853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4854. }
  4855. }
  4856. else
  4857. {
  4858. // syntax fail
  4859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4863. }
  4864. }
  4865. break;
  4866. }
  4867. case COMMAND_SPAWN_REMOVE:{
  4868. Spawn* spawn = cmdTarget;
  4869. if(spawn && !spawn->IsPlayer()){
  4870. if(spawn->GetSpawnLocationID() > 0){
  4871. string name = string(spawn->GetName());
  4872. int32 dbid = spawn->GetDatabaseID();
  4873. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4874. client->GetCurrentZone()->RemoveSpawn(spawn, true, false, true, true, true);
  4875. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone for spawn '%s' (DBID: %u)", name.c_str(), dbid);
  4876. }
  4877. else
  4878. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4879. }
  4880. else
  4881. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4882. }
  4883. else{
  4884. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4885. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4886. }
  4887. break;
  4888. }
  4889. case COMMAND_SPAWN_LIST:{
  4890. if(sep && sep->arg[0][0]){
  4891. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4892. vector<string>::iterator itr;
  4893. if(results){
  4894. for(itr=results->begin();itr!=results->end();itr++){
  4895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4896. }
  4897. safe_delete(results);
  4898. }
  4899. else
  4900. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4901. }
  4902. else{
  4903. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4904. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4905. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4906. }
  4907. break;
  4908. }
  4909. case COMMAND_SPAWN_ADD:{
  4910. Spawn* spawn = cmdTarget;
  4911. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  4912. if(spawn->GetSpawnLocationID() > 0){
  4913. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4914. break;
  4915. }
  4916. if(spawn->GetDatabaseID() == 0){
  4917. if(database.SaveSpawnInfo(spawn)) {
  4918. char spawn_type[32];
  4919. memset(spawn_type, 0, sizeof(spawn_type));
  4920. if (spawn->IsNPC())
  4921. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4922. else if (spawn->IsObject())
  4923. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4924. else if (spawn->IsSign())
  4925. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4926. else if (spawn->IsGroundSpawn())
  4927. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4928. else
  4929. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4930. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4931. }
  4932. else
  4933. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4934. }
  4935. int32 spawn_group_id = 0;
  4936. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4937. spawn_group_id = database.GetNextSpawnLocation();
  4938. else
  4939. spawn_group_id = atol(sep->arg[0]);
  4940. int8 percent = 100;
  4941. if(sep->arg[2] && sep->IsNumber(2))
  4942. percent = atoi(sep->arg[2]);
  4943. spawn->SetSpawnLocationID(spawn_group_id);
  4944. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4945. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4946. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4947. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4948. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4949. else
  4950. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  4951. }
  4952. else{
  4953. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  4954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  4955. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  4956. }
  4957. break;
  4958. }
  4959. case COMMAND_SPAWN:{
  4960. int32 id = 0;
  4961. Spawn* spawn = 0;
  4962. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4963. id = atol(sep->arg[0]);
  4964. spawn = client->GetCurrentZone()->GetSpawn(id);
  4965. }
  4966. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  4967. id = 0;
  4968. if(!id || !spawn){
  4969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  4970. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  4971. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  4972. safe_delete(sep);
  4973. return;
  4974. }
  4975. if(sep && sep->arg[1][0]){
  4976. float x = atof(sep->arg[1]);
  4977. spawn->appearance.pos.X = x;
  4978. }
  4979. else
  4980. spawn->SetX(client->GetPlayer()->GetX(), false);
  4981. if(sep && sep->arg[2][0]){
  4982. float y = atof(sep->arg[2]);
  4983. spawn->appearance.pos.Y = y;
  4984. }
  4985. else
  4986. spawn->SetY(client->GetPlayer()->GetY(), false);
  4987. if(sep && sep->arg[3][0]){
  4988. float z = atof(sep->arg[3]);
  4989. spawn->appearance.pos.Z = z;
  4990. }
  4991. else
  4992. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  4993. if(sep && sep->arg[4][0]){
  4994. float heading = atof(sep->arg[4]);
  4995. spawn->SetHeading(heading);
  4996. }
  4997. else
  4998. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  4999. spawn->SetSpawnOrigX(spawn->GetX());
  5000. spawn->SetSpawnOrigY(spawn->GetY());
  5001. spawn->SetSpawnOrigZ(spawn->GetZ());
  5002. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  5003. if(sep && sep->arg[5][0])
  5004. spawn->SetLocation(atoul(sep->arg[5]));
  5005. else
  5006. spawn->SetLocation(client->GetPlayer()->GetLocation());
  5007. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  5008. spawn->SetTotalHP(spawn->GetLevel() * 15);
  5009. spawn->SetHP(spawn->GetTotalHP());
  5010. }
  5011. if(spawn->GetTotalPower() == 0){
  5012. spawn->SetTotalPower(spawn->GetLevel() * 15);
  5013. spawn->SetPower(spawn->GetTotalPower());
  5014. }
  5015. const char* script = world.GetSpawnScript(id);
  5016. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  5017. spawn->SetSpawnScript(string(script));
  5018. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  5019. client->GetCurrentZone()->AddSpawn(spawn);
  5020. if(spawn->IsNPC())
  5021. spawn->GetZone()->AddLoot((NPC*)spawn);
  5022. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  5023. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  5024. break;
  5025. }
  5026. case COMMAND_ADMINFLAG:
  5027. {
  5028. if(sep && sep->arg[0]){
  5029. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  5030. sint16 new_status = atoi(sep->arg[1]);
  5031. if(tmp_status == -10)
  5032. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  5033. else if(tmp_status >= client->GetAdminStatus())
  5034. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  5035. else if (new_status > client->GetAdminStatus())
  5036. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  5037. else{
  5038. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  5039. if (!client2)
  5040. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  5041. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  5042. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  5043. if (client2) {
  5044. client2->SetAdminStatus(new_status);
  5045. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  5046. }
  5047. }
  5048. else
  5049. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  5050. }
  5051. }else{
  5052. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  5053. if(status != client->GetAdminStatus())
  5054. {
  5055. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  5056. client->SetAdminStatus(status);
  5057. }
  5058. else
  5059. {
  5060. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  5061. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  5062. client->Message(CHANNEL_COLOR_YELLOW," Admin User: %i", status);
  5063. }
  5064. }
  5065. break;
  5066. }
  5067. case COMMAND_CANNEDEMOTE:{
  5068. client->GetCurrentZone()->HandleEmote(client->GetPlayer(), command_parms->data);
  5069. break;
  5070. }
  5071. case COMMAND_BROADCAST: {
  5072. if (sep && sep->arg[0])
  5073. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  5074. else
  5075. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  5076. break;
  5077. }
  5078. case COMMAND_ANNOUNCE: {
  5079. if (sep && sep->arg[0])
  5080. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  5081. else
  5082. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  5083. break;
  5084. }
  5085. case COMMAND_RELOAD_ITEMS:{
  5086. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  5087. int32 item_id = (sep && sep->arg[0]) ? atoul(sep->arg[0]) : 0;
  5088. if(item_id > 0) {
  5089. client->Message(CHANNEL_COLOR_YELLOW, "Reloading item %u based on /reload items [item_id].", item_id);
  5090. }
  5091. else {
  5092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  5093. }
  5094. database.ReloadItemList(item_id);
  5095. if(!item_id) {
  5096. database.LoadMerchantInformation(); // we skip if there is only a reload of single item not all items
  5097. }
  5098. if(item_id > 0) {
  5099. client->Message(CHANNEL_COLOR_YELLOW, "Reloaded item %u.", item_id);
  5100. }
  5101. else {
  5102. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  5103. }
  5104. break;
  5105. }
  5106. case COMMAND_ENABLE_ABILITY_QUE:{
  5107. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  5108. if(app)
  5109. client->QueuePacket(app);
  5110. break;
  5111. }
  5112. case COMMAND_ITEMSEARCH:
  5113. case COMMAND_FROMBROKER:{
  5114. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  5115. if (packet) {
  5116. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  5117. //packet->setDataByName("unknown", 1);
  5118. packet->setDataByName("unknown2", 5, 0);
  5119. packet->setDataByName("unknown2", 20, 1);
  5120. packet->setDataByName("unknown2", 58, 3);
  5121. packet->setDataByName("unknown2", 40, 4);
  5122. client->QueuePacket(packet->serialize());
  5123. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  5124. if (packet2) {
  5125. packet2->setDataByName("char_id", client->GetCharacterID());
  5126. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  5127. safe_delete(packet2);
  5128. }
  5129. safe_delete(packet);
  5130. }
  5131. break;
  5132. }
  5133. case COMMAND_ANIMTEST:{
  5134. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  5135. if(command_packet){
  5136. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  5137. if (cmdTarget)
  5138. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  5139. command_packet->setDataByName ( "spawn_id" , id);
  5140. int animID = 1;
  5141. if(sep && sep->arg[0] && sep->IsNumber(0))
  5142. animID = atoi(sep->arg[0]);
  5143. VisualState* vs = NULL;
  5144. if(animID == 0)
  5145. {
  5146. vs = visual_states.FindVisualState(sep->arg[0]);
  5147. }
  5148. char msg[128];
  5149. sprintf(msg,"Animation Test ID: %i",animID);
  5150. command_packet->setMediumStringByName ( "emote_msg" , msg );
  5151. if(vs != NULL)
  5152. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  5153. else
  5154. command_packet->setDataByName ( "anim_type", animID );
  5155. command_packet->setDataByName ( "unknown0", 0 );
  5156. EQ2Packet* outapp = command_packet->serialize();
  5157. client->QueuePacket(outapp);
  5158. safe_delete(command_packet);
  5159. }
  5160. break;
  5161. }
  5162. case COMMAND_KICK:
  5163. {
  5164. if( sep == 0 || sep->arg[0] == 0)
  5165. {
  5166. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  5167. }
  5168. else
  5169. {
  5170. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  5171. if ( kickClient == client )
  5172. {
  5173. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  5174. break;
  5175. }
  5176. else if(kickClient != NULL)
  5177. {
  5178. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5179. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  5180. {
  5181. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5182. break;
  5183. }
  5184. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  5185. kickClient->Disconnect();
  5186. }
  5187. else
  5188. {
  5189. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5190. }
  5191. }
  5192. break;
  5193. }
  5194. case COMMAND_LOCK:
  5195. {
  5196. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  5197. int worldLocked = atoi(sep->arg[0]);
  5198. net.world_locked = worldLocked;
  5199. if ( worldLocked )
  5200. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  5201. else
  5202. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  5203. }
  5204. else
  5205. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  5206. break;
  5207. }
  5208. case COMMAND_BAN:{
  5209. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  5210. {
  5211. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  5212. }
  5213. else
  5214. {
  5215. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  5216. if ( kickClient == client )
  5217. {
  5218. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  5219. break;
  5220. }
  5221. else if(kickClient != NULL)
  5222. {
  5223. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5224. if ( maxStatus > client->GetAdminStatus( ) ||
  5225. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  5226. {
  5227. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5228. break;
  5229. }
  5230. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  5231. int perm = atol(sep->arg[1]);
  5232. if ( perm == 1 )
  5233. database.UpdateAdminStatus(sep->arg[0],-2);
  5234. else
  5235. database.UpdateAdminStatus(sep->arg[0],-1);
  5236. kickClient->Disconnect();
  5237. }
  5238. else
  5239. {
  5240. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5241. }
  5242. }
  5243. break;
  5244. }
  5245. case COMMAND_SET_COMBAT_VOICE:{
  5246. int32 value = 0;
  5247. if(sep && sep->arg[0] && sep->IsNumber(0))
  5248. value = atoi(sep->arg[0]);
  5249. client->GetPlayer()->SetCombatVoice(value);
  5250. break;
  5251. }
  5252. case COMMAND_SET_EMOTE_VOICE:{
  5253. int32 value = 0;
  5254. if(sep && sep->arg[0] && sep->IsNumber(0))
  5255. value = atoi(sep->arg[0]);
  5256. client->GetPlayer()->SetEmoteVoice(value);
  5257. break;
  5258. }
  5259. case COMMAND_GIVEITEM:{
  5260. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  5261. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  5262. if ( itemToClient == NULL )
  5263. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  5264. else
  5265. {
  5266. int32 item_id = atol(sep->arg[1]);
  5267. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  5268. itemToClient->AddItem(item_id);
  5269. }
  5270. }
  5271. else
  5272. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  5273. break;
  5274. }
  5275. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  5276. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  5277. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  5278. case COMMAND_SKILL :
  5279. case COMMAND_SKILL_ADD :
  5280. case COMMAND_SKILL_REMOVE :
  5281. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  5282. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  5283. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  5284. case COMMAND_ENTITYCOMMAND :
  5285. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  5286. case COMMAND_MERCHANT :
  5287. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  5288. case COMMAND_APPEARANCE :
  5289. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  5290. case COMMAND_TRACK : { Command_Track(client); break; }
  5291. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  5292. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  5293. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  5294. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  5295. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  5296. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  5297. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  5298. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  5299. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  5300. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  5301. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  5302. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  5303. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  5304. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  5305. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  5306. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  5307. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  5308. case COMMAND_LOCATION : { Command_Location(client); break; }
  5309. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  5310. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  5311. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  5312. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  5313. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  5314. case COMMAND_GRID : { Command_Grid(client, sep); break; }
  5315. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  5316. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  5317. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  5318. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  5319. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  5320. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  5321. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  5322. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  5323. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  5324. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  5325. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  5326. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  5327. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  5328. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  5329. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  5330. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  5331. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  5332. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  5333. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  5334. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  5335. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  5336. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  5337. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  5338. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  5339. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  5340. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  5341. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  5342. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  5343. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  5344. case COMMAND_MOTD : { Command_MOTD(client); break; }
  5345. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  5346. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  5347. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  5348. case COMMAND_TITLE : { Command_Title(client); break; }
  5349. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  5350. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  5351. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  5352. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  5353. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  5354. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  5355. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  5356. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  5357. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  5358. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  5359. case COMMAND_PET : { Command_Pet(client, sep); break; }
  5360. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  5361. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  5362. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  5363. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  5364. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  5365. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  5366. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  5367. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  5368. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  5369. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  5370. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  5371. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  5372. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  5373. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  5374. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  5375. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  5376. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  5377. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  5378. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  5379. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  5380. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  5381. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  5382. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  5383. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  5384. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  5385. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  5386. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  5387. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  5388. //devn00b
  5389. case COMMAND_MOOD : { Command_Mood(client, sep); break;}
  5390. case COMMAND_MODIFY : { Command_Modify(client); break; }
  5391. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  5392. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  5393. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  5394. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  5395. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  5396. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  5397. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  5398. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  5399. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  5400. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  5401. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  5402. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  5403. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  5404. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  5405. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  5406. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  5407. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  5408. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  5409. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  5410. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  5411. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  5412. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5413. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  5414. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  5415. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  5416. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  5417. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  5418. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  5419. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  5420. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  5421. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  5422. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  5423. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  5424. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  5425. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  5426. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  5427. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  5428. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  5429. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  5430. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  5431. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  5432. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  5433. case ADD_AA : { Add_AA(client, sep); break; }
  5434. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  5435. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  5436. case BACK_AA : { Back_AA(client, sep); break; }
  5437. case REMOVE_AA : { Remove_AA(client, sep); break; }
  5438. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  5439. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  5440. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  5441. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  5442. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  5443. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  5444. case COMMAND_CRAFTITEM: {
  5445. Item* item = 0;
  5446. if (sep && sep->IsNumber(0)) {
  5447. int32 item_id = atol(sep->arg[0]);
  5448. int32 quantity = 1;
  5449. if (sep->arg[1] && sep->IsNumber(1))
  5450. quantity = atoi(sep->arg[1]);
  5451. item = new Item(master_item_list.GetItem(item_id));
  5452. if (!item) {
  5453. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  5454. }
  5455. else {
  5456. item->details.count = quantity;
  5457. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  5458. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  5459. bool itemDeleted = false;
  5460. client->AddItem(item, &itemDeleted);
  5461. //Check for crafting quest updates
  5462. int8 update_amt = 0;
  5463. if (!itemDeleted && item->stack_count > 1)
  5464. update_amt = 1;
  5465. else
  5466. update_amt = quantity;
  5467. if(!itemDeleted)
  5468. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  5469. }
  5470. }
  5471. else {
  5472. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  5473. }
  5474. break;
  5475. }
  5476. case COMMAND_UNMENTOR:
  5477. case COMMAND_MENTOR: {
  5478. client->GetPlayer()->MentorTarget();
  5479. break;
  5480. }
  5481. case COMMAND_CANCEL_EFFECT: { Command_CancelEffect(client, sep); break; }
  5482. case COMMAND_CUREPLAYER: { Command_CurePlayer(client, sep); break; }
  5483. case COMMAND_SHARE_QUEST: { Command_ShareQuest(client, sep); break; }
  5484. case COMMAND_YELL: { Command_Yell(client, sep); break; }
  5485. case COMMAND_SETAUTOLOOTMODE: { Command_SetAutoLootMode(client, sep); break; }
  5486. default:
  5487. {
  5488. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  5489. break;
  5490. }
  5491. }
  5492. safe_delete(sep);
  5493. }
  5494. /******************** New COMMAND Handler Functions ********************/
  5495. /*
  5496. Started breaking apart the huge switch() for commands into sepErate
  5497. functions so it is easier to locate the blocks of code by command
  5498. -- JA 2012.03.03
  5499. */
  5500. // sample function header
  5501. /*
  5502. Function:
  5503. Purpose :
  5504. Params :
  5505. Dev :
  5506. Example :
  5507. */
  5508. //void Commands::Command()
  5509. //{
  5510. //}
  5511. /*
  5512. Function: Command_AcceptAdvancement()
  5513. Purpose : Player accepts a new advancement option
  5514. Params : Spell ID
  5515. Dev : Jabantiz
  5516. */
  5517. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  5518. {
  5519. Player *player = client->GetPlayer();
  5520. if (sep && sep->IsSet(0)) {
  5521. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  5522. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  5523. if (!player->HasSpell(trait->spellID, 0, true))
  5524. {
  5525. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5526. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5527. }
  5528. else
  5529. {
  5530. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5531. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  5532. player->RemoveSpellBookEntry(spell->GetSpellID());
  5533. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5534. player->UnlockSpell(spell);
  5535. client->SendSpellUpdate(spell);
  5536. }
  5537. // Spell book update
  5538. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  5539. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  5540. }
  5541. }
  5542. /*
  5543. Function:
  5544. Purpose :
  5545. Params :
  5546. Dev :
  5547. Example :
  5548. */
  5549. void Commands::Command_AFK(Client* client, Seperator* sep)
  5550. {
  5551. Player* player = client->GetPlayer();
  5552. player->toggle_character_flag(CF_AFK);
  5553. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  5554. if (player->get_character_flag(CF_AFK))
  5555. {
  5556. if (sep && sep->argplus[0])
  5557. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  5558. else
  5559. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  5560. string message = string(player->GetName()) + " is going afk.";
  5561. Spawn* target = player->GetTarget();
  5562. if (target && target != player)
  5563. {
  5564. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  5565. player->GetGender() == 1 ? message += "he" : message += "she";
  5566. message += " is going afk.";
  5567. }
  5568. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  5569. }
  5570. }
  5571. /*
  5572. Function: Command_Appearance()
  5573. Purpose : Handles /appearance commands
  5574. Params : list
  5575. Dev : Scatman
  5576. Example : /appearance list
  5577. */
  5578. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  5579. {
  5580. if( handler == COMMAND_APPEARANCE )
  5581. {
  5582. // /appearance command by itself shows help (to be extended)
  5583. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5584. return;
  5585. }
  5586. else if( handler == COMMAND_APPEARANCE_LIST )
  5587. {
  5588. // /appearance list command expects "name" param
  5589. if (sep && sep->arg[0])
  5590. {
  5591. const char* appearance_name = sep->argplus[0];
  5592. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  5593. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  5594. if (appearances)
  5595. {
  5596. vector<int16>::iterator itr;
  5597. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  5598. {
  5599. int16 id = *itr;
  5600. string name = database.GetAppearanceName(id);
  5601. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  5602. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  5603. }
  5604. safe_delete(appearances);
  5605. }
  5606. }
  5607. else // no param
  5608. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5609. }
  5610. }
  5611. /*
  5612. Function: Command_Claim()
  5613. Purpose : Summon veteran rewards
  5614. Params : nothing = show claim window, any number claims that item.
  5615. Dev : devn00b
  5616. Example : /claim 0 (claims the 1st item added to the list claim[0])
  5617. */
  5618. void Commands::Command_Claim(Client* client, Seperator* sep)
  5619. {
  5620. //if we were passed a claim id
  5621. if (sep && sep->argplus[0] && sep->IsNumber(0))
  5622. {
  5623. int32 char_id = client->GetCharacterID();
  5624. int8 my_claim_id = atoi(sep->argplus[0]);
  5625. vector<ClaimItems> claim = database.LoadCharacterClaimItems(char_id);
  5626. Item* item = master_item_list.GetItem(claim[my_claim_id].item_id);
  5627. database.ClaimItem(char_id, item->details.item_id, client);
  5628. return;
  5629. }
  5630. else {
  5631. //if no arg just send the window.
  5632. client->ShowClaimWindow();
  5633. return;
  5634. }
  5635. return;
  5636. }
  5637. /*
  5638. Function: Command_ClearAllQueued()
  5639. Purpose :
  5640. Params :
  5641. Dev :
  5642. Example :
  5643. */
  5644. void Commands::Command_ClearAllQueued(Client* client)
  5645. {
  5646. ZoneServer* zone = client->GetPlayer()->GetZone();
  5647. if (zone && zone->GetSpellProcess())
  5648. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  5649. }
  5650. /*
  5651. Function: Command_CancelMaintained()
  5652. Purpose : Cancels maintained spells
  5653. Params : Maintained Spell Index
  5654. Dev : Zcoretri
  5655. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  5656. */
  5657. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  5658. {
  5659. if (sep && sep->arg[0] && sep->IsNumber(0))
  5660. {
  5661. int32 spell_index = atoul(sep->arg[0]);
  5662. if(spell_index > 29)
  5663. return;
  5664. client->GetPlayer()->MMaintainedSpells.readlock(__FUNCTION__, __LINE__);
  5665. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  5666. client->GetPlayer()->MMaintainedSpells.releasereadlock(__FUNCTION__, __LINE__);
  5667. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled", false))
  5668. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  5669. }
  5670. }
  5671. /*
  5672. Function: Command_Create()
  5673. Purpose : Handler for starting Tradeskilling table
  5674. Params :
  5675. Dev : Zcoretri
  5676. Example :
  5677. */
  5678. void Commands::Command_Create(Client* client, Seperator* sep)
  5679. {
  5680. PrintSep(sep, "COMMAND_CREATE");
  5681. client->ShowRecipeBook();
  5682. }
  5683. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  5684. {
  5685. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  5686. if (sep && sep->arg[0] && sep->IsNumber(0))
  5687. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  5688. }
  5689. /*
  5690. Function: Command_Distance()
  5691. Purpose : Displays distance from targeted spawn
  5692. Params :
  5693. Dev : Scatman
  5694. Example : /distance
  5695. */
  5696. void Commands::Command_Distance(Client* client)
  5697. {
  5698. Spawn* target = client->GetPlayer()->GetTarget();
  5699. if (target)
  5700. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  5701. else
  5702. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  5703. }
  5704. /*
  5705. Function: Command_Duel()
  5706. Purpose : Handle the /duel commands - not yet implemented
  5707. Params : unknown
  5708. Dev :
  5709. Example :
  5710. */
  5711. void Commands::Command_Duel(Client* client, Seperator* sep)
  5712. {
  5713. PrintSep(sep, "COMMAND_DUEL");
  5714. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  5715. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5716. }
  5717. /*
  5718. Function: Command_DuelBet()
  5719. Purpose : Handle the /duel commands - not yet implemented
  5720. Params : unknown
  5721. Dev :
  5722. Example :
  5723. */
  5724. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  5725. {
  5726. PrintSep(sep, "COMMAND_DUELBET");
  5727. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  5728. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5729. }
  5730. /*
  5731. Function: Command_DuelAccept()
  5732. Purpose : Handle the /duel commands - not yet implemented
  5733. Params : unknown
  5734. Dev :
  5735. Example :
  5736. */
  5737. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5738. {
  5739. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5740. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5741. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5742. }
  5743. /*
  5744. Function: Command_DuelDecline()
  5745. Purpose : Handle the /duel commands - not yet implemented
  5746. Params : unknown
  5747. Dev :
  5748. Example :
  5749. */
  5750. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5751. {
  5752. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5753. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5754. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5755. }
  5756. /*
  5757. Function: Command_DuelSurrender()
  5758. Purpose : Handle the /duel commands - not yet implemented
  5759. Params : unknown
  5760. Dev :
  5761. Example :
  5762. */
  5763. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5764. {
  5765. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5766. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5767. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5768. // JA, just messin around ;)
  5769. char surrender[64];
  5770. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5771. zone_list.HandleGlobalAnnouncement(surrender);
  5772. }
  5773. /*
  5774. Function: Command_DuelToggle()
  5775. Purpose : Handle the /duel commands - not yet implemented
  5776. Params : unknown
  5777. Dev :
  5778. Example :
  5779. */
  5780. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5781. {
  5782. PrintSep(sep, "COMMAND_DUEL");
  5783. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5784. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5785. }
  5786. /*
  5787. Function:
  5788. Purpose :
  5789. Params :
  5790. Dev :
  5791. Example :
  5792. */
  5793. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5794. {
  5795. if( handler == COMMAND_ENTITYCOMMAND )
  5796. {
  5797. // /entitycommand command by itself shows help (to be extended)
  5798. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5799. return;
  5800. }
  5801. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5802. {
  5803. // /entitycommand list command expects "name" param
  5804. if (sep && sep->arg[0])
  5805. {
  5806. const char* entity_command_name = sep->argplus[0];
  5807. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5808. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5809. map<int32, vector<EntityCommand*>*>::iterator itr;
  5810. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5811. {
  5812. vector<EntityCommand*>* entity_command_list = itr->second;
  5813. vector<EntityCommand*>::iterator itr2;
  5814. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5815. {
  5816. EntityCommand* entity_command = *itr2;
  5817. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5818. 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);
  5819. }
  5820. }
  5821. }
  5822. else // no command name
  5823. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5824. }
  5825. }
  5826. /*
  5827. Function: Command_Follow()
  5828. Purpose : Handle the /follow command - not yet implemented
  5829. Params :
  5830. Dev :
  5831. Example :
  5832. */
  5833. void Commands::Command_Follow(Client* client, Seperator* sep)
  5834. {
  5835. PrintSep(sep, "COMMAND_FOLLOW");
  5836. // flag to toggle if the players target is in the players group
  5837. bool targetInGroup = false;
  5838. // get a pointer to the players group
  5839. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5840. // If the player has a group and has a target
  5841. if (gmi && client->GetPlayer()->GetTarget()) {
  5842. deque<GroupMemberInfo*>::iterator itr;
  5843. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5844. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5845. if (group)
  5846. {
  5847. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5848. deque<GroupMemberInfo*>* members = group->GetMembers();
  5849. // Loop through the group members
  5850. for (itr = members->begin(); itr != members->end(); itr++) {
  5851. // If a group member matches a target
  5852. if ((*itr)->member && (*itr)->member == client->GetPlayer()->GetTarget()) {
  5853. // toggle the flag and break the loop
  5854. targetInGroup = true;
  5855. break;
  5856. }
  5857. }
  5858. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5859. }
  5860. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5861. }
  5862. if (targetInGroup) {
  5863. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5864. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5865. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5866. client->GetPlayer()->info_changed = true;
  5867. client->GetPlayer()->changed = true;
  5868. }
  5869. else
  5870. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5871. }
  5872. /*
  5873. Function: Command_StopFollow()
  5874. Purpose : Handle the /stop_follow command - not yet implemented
  5875. Params :
  5876. Dev :
  5877. Example :
  5878. */
  5879. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5880. {
  5881. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5882. if (client->GetPlayer()->GetFollowTarget()) {
  5883. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5884. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5885. client->GetPlayer()->SetFollowTarget(0);
  5886. client->GetPlayer()->info_changed = true;
  5887. client->GetPlayer()->changed = true;
  5888. }
  5889. }
  5890. /*
  5891. Function: Command_Grid()
  5892. Purpose : Show player's current Grid ID
  5893. Params :
  5894. Dev : Scatman
  5895. Example : /grid
  5896. */
  5897. void Commands::Command_Grid(Client* client, Seperator* sep)
  5898. {
  5899. if (client->GetPlayer()->GetMap() != nullptr) {
  5900. if(sep && sep->arg[0][0] && strncasecmp("spawns", sep->arg[0], 6) == 0) {
  5901. int32 grid = client->GetPlayer()->GetLocation();
  5902. if(sep->IsNumber(1))
  5903. grid = atoul(sep->arg[1]);
  5904. client->GetCurrentZone()->SendClientSpawnListInGrid(client, grid);
  5905. }
  5906. else {
  5907. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->GetLocation());
  5908. auto loc = glm::vec3(client->GetPlayer()->GetX(), client->GetPlayer()->GetZ(), client->GetPlayer()->GetY());
  5909. uint32 GridID = 0;
  5910. uint32 WidgetID = 0;
  5911. float new_z = client->GetPlayer()->FindBestZ(loc, nullptr, &GridID, &WidgetID);
  5912. float minY = client->GetPlayer()->GetMap()->GetMinY();
  5913. float maxY = client->GetPlayer()->GetMap()->GetMaxY();
  5914. float minZ = client->GetPlayer()->GetMap()->GetMinZ();
  5915. float maxZ = client->GetPlayer()->GetMap()->GetMaxZ();
  5916. int32 grid_spawn_count = client->GetPlayer()->GetZone()->GetSpawnCountInGrid(GridID);
  5917. 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);
  5918. }
  5919. }
  5920. }
  5921. /*
  5922. Function: Command_Guild()
  5923. Purpose : Handler for all UI-related guild commands
  5924. Dev : Scatman
  5925. */
  5926. void Commands::Command_Guild(Client* client, Seperator* sep)
  5927. {
  5928. Guild* guild = client->GetPlayer()->GetGuild();
  5929. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  5930. {
  5931. const char* command = sep->arg[0];
  5932. int32 length = strlen(command);
  5933. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  5934. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  5935. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  5936. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5937. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5938. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5939. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5940. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  5941. guild->KickGuildMember(client, sep->arg[1]);
  5942. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  5943. guild->DemoteGuildMember(client, sep->arg[1]);
  5944. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  5945. guild->PromoteGuildMember(client, sep->arg[1]);
  5946. else if (strncmp(command, "points", length) == 0 && guild)
  5947. {
  5948. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  5949. {
  5950. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5951. {
  5952. float points = atof(sep->arg[2]);
  5953. const char* option = sep->arg[3];
  5954. const char* comment = sep->argplus[4];
  5955. if (strncmp(option, "all", strlen(option)) == 0)
  5956. guild->AddPointsToAll(client, points, comment);
  5957. else if (strncmp(option, "online", strlen(option)) == 0)
  5958. guild->AddPointsToAllOnline(client, points, comment);
  5959. else if (strncmp(option, "group", strlen(option)) == 0)
  5960. guild->AddPointsToGroup(client, points, comment);
  5961. else if (strncmp(option, "raid", strlen(option)) == 0)
  5962. guild->AddPointsToRaid(client, points, comment);
  5963. else
  5964. guild->AddPointsToGuildMember(client, points, option, comment);
  5965. }
  5966. }
  5967. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  5968. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  5969. else
  5970. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  5971. }
  5972. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  5973. guild->SetMOTD(sep->argplus[1]);
  5974. else if (strncmp(command, "recruiting", length) == 0 && guild)
  5975. {
  5976. if (sep->arg[1])
  5977. {
  5978. const char* option = sep->arg[1];
  5979. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  5980. guild->SetRecruitingShortDesc(sep->argplus[2]);
  5981. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  5982. guild->SetRecruitingFullDesc(sep->argplus[2]);
  5983. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5984. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5985. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5986. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  5987. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5988. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  5989. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  5990. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  5991. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  5992. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5993. else
  5994. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5995. }
  5996. else
  5997. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5998. }
  5999. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  6000. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6001. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  6002. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6003. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  6004. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  6005. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  6006. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  6007. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  6008. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  6009. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  6010. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  6011. else if (strncmp(command, "invite", length) == 0 && guild)
  6012. {
  6013. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6014. guild->InvitePlayer(client, sep->arg[1]);
  6015. else
  6016. {
  6017. Spawn* target = client->GetPlayer()->GetTarget();
  6018. if (target)
  6019. {
  6020. if (target->IsPlayer())
  6021. guild->InvitePlayer(client, target->GetName());
  6022. else
  6023. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  6024. }
  6025. }
  6026. }
  6027. else if (strncmp(command, "accept", length) == 0)
  6028. {
  6029. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  6030. if (pgi && pgi->guild && pgi->invited_by)
  6031. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  6032. client->SetPendingGuildInvite(0);
  6033. }
  6034. else if (strncmp(command, "decline", length) == 0)
  6035. {
  6036. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  6037. if (pgi && pgi->guild && pgi->invited_by && pgi->invited_by->IsPlayer())
  6038. {
  6039. Client* client_inviter = ((Player*)pgi->invited_by)->GetClient();
  6040. if (client_inviter) {
  6041. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  6042. }
  6043. }
  6044. client->SetPendingGuildInvite(0);
  6045. }
  6046. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  6047. {
  6048. const char* guild_name = sep->argplus[1];
  6049. if (!guild_list.GetGuild(guild_name))
  6050. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6051. else
  6052. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  6053. }
  6054. else if (strncmp(command, "search", length) == 0)
  6055. client->ShowGuildSearchWindow();
  6056. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6057. {
  6058. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6059. if (to_guild)
  6060. to_guild->SendGuildRecruitingDetails(client);
  6061. }
  6062. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6063. {
  6064. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6065. if (to_guild)
  6066. to_guild->SendGuildRecruitingImages(client);
  6067. }
  6068. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  6069. {
  6070. if (sep->arg[1])
  6071. {
  6072. const char* option = sep->arg[1];
  6073. if (strncmp(option, "toggle", strlen(option)) == 0)
  6074. guild->ToggleGuildRecruiterAdventureClass(client);
  6075. }
  6076. else
  6077. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  6078. }
  6079. else if (strncmp(command, "display_heraldry", length) == 0)
  6080. {
  6081. // JA: not sure this is right...
  6082. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  6083. client->GetPlayer()->SetCharSheetChanged(true);
  6084. }
  6085. else
  6086. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  6087. }
  6088. }
  6089. /*
  6090. Function: Command_GuildCreate()
  6091. Purpose : Display's in-game Guild Creation window
  6092. Dev : Scatman
  6093. */
  6094. void Commands::Command_CreateGuild(Client* client)
  6095. {
  6096. client->SendGuildCreateWindow();
  6097. }
  6098. /*
  6099. Function: Command_SetGuildOfficerNote()
  6100. Purpose :
  6101. Dev : Scatman
  6102. */
  6103. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  6104. {
  6105. if (sep && sep->arg[0] && sep->arg[1])
  6106. {
  6107. Guild* guild = client->GetPlayer()->GetGuild();
  6108. if (guild)
  6109. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  6110. }
  6111. }
  6112. /*
  6113. Function: Command_SetGuildMemberNote()
  6114. Purpose :
  6115. Dev : Scatman
  6116. */
  6117. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  6118. {
  6119. if (sep && sep->arg[0] && sep->arg[1])
  6120. {
  6121. Guild* guild = client->GetPlayer()->GetGuild();
  6122. if (guild)
  6123. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  6124. }
  6125. }
  6126. /*
  6127. Function: Command_GuildSay()
  6128. Purpose :
  6129. Dev : Scatman
  6130. */
  6131. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  6132. {
  6133. Guild* guild = client->GetPlayer()->GetGuild();
  6134. if (guild)
  6135. {
  6136. if (sep && sep->arg[0])
  6137. guild->HandleGuildSay(client, sep->argplus[0]);
  6138. }
  6139. else
  6140. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6141. }
  6142. /*
  6143. Function: Command_OfficerSay()
  6144. Purpose :
  6145. Dev : Scatman
  6146. */
  6147. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  6148. {
  6149. Guild* guild = client->GetPlayer()->GetGuild();
  6150. if (guild)
  6151. {
  6152. if (sep && sep->arg[0])
  6153. guild->HandleOfficerSay(client, sep->argplus[0]);
  6154. }
  6155. else
  6156. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6157. }
  6158. /*
  6159. Function: Command_Guilds()
  6160. Purpose : Shows help for /guild command
  6161. Params :
  6162. Dev : Scatman
  6163. Example :
  6164. */
  6165. void Commands::Command_Guilds(Client* client)
  6166. {
  6167. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  6168. }
  6169. /*
  6170. Function: Command_GuildsAdd()
  6171. Purpose : Add's players to a guild
  6172. Params : guild_name|guild_id, player name
  6173. Dev : Scatman
  6174. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  6175. */
  6176. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  6177. {
  6178. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6179. {
  6180. Guild* guild = 0;
  6181. bool found = true;
  6182. if (sep->IsNumber(0))
  6183. {
  6184. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6185. if (!guild)
  6186. {
  6187. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6188. found = false;
  6189. }
  6190. }
  6191. else
  6192. {
  6193. guild = guild_list.GetGuild(sep->arg[0]);
  6194. if (!guild)
  6195. {
  6196. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6197. found = false;
  6198. }
  6199. }
  6200. if (found)
  6201. {
  6202. Client* to_client = 0;
  6203. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6204. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6205. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6206. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6207. if (to_client)
  6208. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  6209. else
  6210. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6211. }
  6212. }
  6213. else
  6214. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  6215. }
  6216. /*
  6217. Function: Command_GuildsCreate()
  6218. Purpose : Creates a guild
  6219. Params : guild_name, player_name (optional)
  6220. Dev : Scatman
  6221. Example : /guilds create [guild name] (player name)
  6222. */
  6223. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  6224. {
  6225. if (sep && sep->arg[0])
  6226. {
  6227. const char* guild_name = sep->arg[0];
  6228. if (!guild_list.GetGuild(guild_name))
  6229. {
  6230. bool ret = false;
  6231. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6232. {
  6233. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6234. if (to_client)
  6235. {
  6236. world.CreateGuild(guild_name, to_client);
  6237. ret = true;
  6238. }
  6239. else
  6240. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  6241. }
  6242. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6243. {
  6244. Client* to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6245. if (to_client)
  6246. {
  6247. world.CreateGuild(guild_name, to_client);
  6248. ret = true;
  6249. }
  6250. }
  6251. else
  6252. {
  6253. world.CreateGuild(guild_name);
  6254. ret = true;
  6255. }
  6256. if (ret)
  6257. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  6258. else
  6259. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  6260. }
  6261. else
  6262. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  6263. }
  6264. else
  6265. 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.");
  6266. }
  6267. /*
  6268. Function: Command_GuildsDelete()
  6269. Purpose : Delete's a guild
  6270. Params : guild name
  6271. Dev : Scatman
  6272. Example : /guilds delete Test
  6273. */
  6274. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  6275. {
  6276. if (sep && sep->arg[0])
  6277. {
  6278. Guild* guild = 0;
  6279. bool found = true;
  6280. if (sep->IsNumber(0))
  6281. {
  6282. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6283. if (!guild)
  6284. {
  6285. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6286. found = false;
  6287. }
  6288. }
  6289. else
  6290. {
  6291. guild = guild_list.GetGuild(sep->arg[0]);
  6292. if (!guild)
  6293. {
  6294. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6295. found = false;
  6296. }
  6297. }
  6298. if (found)
  6299. {
  6300. guild->RemoveAllGuildMembers();
  6301. database.DeleteGuild(guild);
  6302. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  6303. guild_list.RemoveGuild(guild, true);
  6304. }
  6305. }
  6306. else
  6307. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  6308. }
  6309. /*
  6310. Function: Command_GuildsList()
  6311. Purpose : Lists current guilds on server
  6312. Params :
  6313. Dev : Scatman
  6314. Example : /guilds list
  6315. */
  6316. void Commands::Command_GuildsList(Client* client)
  6317. {
  6318. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  6319. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  6320. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  6321. if (guilds->size() == 0)
  6322. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  6323. else {
  6324. while (itr.Next()) {
  6325. Guild* guild = itr.second;
  6326. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  6327. }
  6328. }
  6329. }
  6330. /*
  6331. Function: Command_GuildsRemove()
  6332. Purpose : Removes a player from a guild
  6333. Params : guild name|guild id, player name
  6334. Dev : Scatman
  6335. Example : /guilds remove 1 Admin = removes Admin from guild 1
  6336. */
  6337. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  6338. {
  6339. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6340. {
  6341. Guild* guild = 0;
  6342. bool found = true;
  6343. if (sep->IsNumber(0))
  6344. {
  6345. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6346. if (!guild)
  6347. {
  6348. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6349. found = false;
  6350. }
  6351. }
  6352. else
  6353. {
  6354. guild = guild_list.GetGuild(sep->arg[0]);
  6355. if (!guild)
  6356. {
  6357. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6358. found = false;
  6359. }
  6360. }
  6361. if (found)
  6362. {
  6363. Client* to_client = 0;
  6364. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6365. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6366. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6367. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6368. if (to_client)
  6369. {
  6370. Player* to_player = to_client->GetPlayer();
  6371. if (to_player->GetGuild())
  6372. {
  6373. if (to_player->GetGuild() == guild)
  6374. {
  6375. guild->KickGuildMember(client, to_player->GetName());
  6376. }
  6377. else
  6378. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  6379. }
  6380. else
  6381. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  6382. }
  6383. else
  6384. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6385. }
  6386. }
  6387. else
  6388. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  6389. }
  6390. /*
  6391. Function: Command_InspectPlayer()
  6392. Purpose : Handle the Inspect functions
  6393. Params : Client to inspect
  6394. Dev : Scatman
  6395. Example : /inspect Scatman
  6396. */
  6397. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  6398. {
  6399. if (sep && sep->arg[0])
  6400. {
  6401. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  6402. if (inspect_client)
  6403. client->InspectPlayer(inspect_client->GetPlayer());
  6404. }
  6405. else
  6406. {
  6407. Spawn* target = client->GetPlayer()->GetTarget();
  6408. if (target && target->IsPlayer())
  6409. client->InspectPlayer((Player*)target);
  6410. }
  6411. }
  6412. /*
  6413. Function: Command_Inventory()
  6414. Purpose : Handle changes in player inventory
  6415. Params : <TBD>
  6416. Dev : All
  6417. Example : /inventory delete item_id
  6418. */
  6419. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  6420. {
  6421. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  6422. Player* player = client->GetPlayer();
  6423. if(sep && sep->arg[0][0])
  6424. {
  6425. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  6426. if(!client->GetPlayer()->Alive())
  6427. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  6428. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6429. {
  6430. int16 index = atoi(sep->arg[1]);
  6431. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6432. if(item)
  6433. {
  6434. if(item->details.item_locked) {
  6435. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item in use.");
  6436. return;
  6437. }
  6438. else if(item->CheckFlag(NO_DESTROY)) {
  6439. client->SimpleMessage(CHANNEL_COLOR_RED, "You can't destroy this item.");
  6440. return;
  6441. }
  6442. if(item->GetItemScript() && lua_interface)
  6443. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  6444. //reobtain item make sure it wasn't removed
  6445. item = player->item_list.GetItemFromIndex(index);
  6446. int32 bag_id = 0;
  6447. if(item){
  6448. bag_id = item->details.inv_slot_id;
  6449. database.DeleteItem(client->GetCharacterID(), item, 0);
  6450. }
  6451. client->GetPlayer()->item_list.DestroyItem(index);
  6452. client->GetPlayer()->UpdateInventory(bag_id);
  6453. client->GetPlayer()->CalculateApplyWeight();
  6454. }
  6455. }
  6456. 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))
  6457. {
  6458. int16 from_index = atoi(sep->arg[1]);
  6459. sint16 to_slot = atoi(sep->arg[2]); // don't convert slot since this is inventory not equipment
  6460. sint32 bag_id = atol(sep->arg[3]);
  6461. int8 charges = atoi(sep->arg[4]);
  6462. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  6463. if(!item) {
  6464. client->SimpleMessage(CHANNEL_COLOR_RED, "You have no item.");
  6465. return;
  6466. }
  6467. if(to_slot == item->details.slot_id && (bag_id < 0 || bag_id == item->details.inv_slot_id)) {
  6468. return;
  6469. }
  6470. if(item->details.item_locked)
  6471. {
  6472. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot move the item in use.");
  6473. return;
  6474. }
  6475. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  6476. {
  6477. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  6478. return;
  6479. }
  6480. sint32 old_inventory_id = 0;
  6481. if(item)
  6482. old_inventory_id = item->details.inv_slot_id;
  6483. //autobank
  6484. if (bag_id == -3 && to_slot == -1)
  6485. {
  6486. if (player->HasFreeBankSlot())
  6487. to_slot = player->FindFreeBankSlot();
  6488. else
  6489. {
  6490. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  6491. return;
  6492. }
  6493. }
  6494. //auto inventory
  6495. if (bag_id == 0 && to_slot == -1)
  6496. {
  6497. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6498. {
  6499. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  6500. return;
  6501. }
  6502. }
  6503. bool item_deleted = false;
  6504. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, &item_deleted, client->GetVersion());
  6505. client->QueuePacket(outapp);
  6506. if(item_deleted)
  6507. item = nullptr;
  6508. //removed from bag send update
  6509. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  6510. {
  6511. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  6512. if(outapp)
  6513. client->QueuePacket(outapp);
  6514. }
  6515. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  6516. {
  6517. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  6518. if(outapp)
  6519. client->QueuePacket(outapp);
  6520. }
  6521. }
  6522. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  6523. {
  6524. if(client->GetPlayer()->EngagedInCombat())
  6525. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  6526. else
  6527. {
  6528. int16 index = atoi(sep->arg[1]);
  6529. int8 slot_id = 255;
  6530. int8 unk3 = 0;
  6531. int8 appearance_equip = 0;
  6532. if(sep->arg[2][0] && sep->IsNumber(2))
  6533. slot_id = player->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6534. if(sep->arg[3][0] && sep->IsNumber(3))
  6535. unk3 = atoul(sep->arg[3]);
  6536. if(sep->arg[4][0] && sep->IsNumber(4))
  6537. appearance_equip = atoul(sep->arg[4]);
  6538. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  6539. EQ2Packet* outapp = 0;
  6540. for(int32 i=0;i<packets.size();i++)
  6541. {
  6542. outapp = packets[i];
  6543. if(outapp)
  6544. client->QueuePacket(outapp);
  6545. }
  6546. client->GetPlayer()->UpdateWeapons();
  6547. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6548. client->QueuePacket(characterSheetPackets);
  6549. }
  6550. }
  6551. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6552. {
  6553. if (client->GetPlayer()->EngagedInCombat())
  6554. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  6555. else {
  6556. int16 index = atoi(sep->arg[1]);
  6557. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6558. if (item) {
  6559. if(item->details.item_locked)
  6560. {
  6561. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot unpack the item in use.");
  6562. return;
  6563. }
  6564. // client->GetPlayer()->item_list.DestroyItem(index);
  6565. if (item->item_sets.size() > 0) {
  6566. for (int32 i = 0; i < item->item_sets.size(); i++) {
  6567. ItemSet* set = item->item_sets[i];
  6568. if (set->item_stack_size == 0)
  6569. set->item_stack_size += 1;
  6570. client->AddItem(set->item_id, set->item_stack_size);
  6571. }
  6572. }
  6573. }
  6574. client->RemoveItem(item, 1);
  6575. }
  6576. }
  6577. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  6578. {
  6579. if(client->GetPlayer()->EngagedInCombat())
  6580. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  6581. else
  6582. {
  6583. int16 index = player->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6584. sint32 bag_id = -999;
  6585. int8 to_slot = 255;
  6586. if(sep->arg[3][0])
  6587. {
  6588. if(sep->IsNumber(2))
  6589. bag_id = atol(sep->arg[2]);
  6590. if(sep->IsNumber(3))
  6591. to_slot = atoi(sep->arg[3]);
  6592. }
  6593. sint8 unk4 = 0;
  6594. int8 appearance_equip = 0;
  6595. if(sep->arg[4][0] && sep->IsNumber(4))
  6596. unk4 = atoi(sep->arg[4]);
  6597. if(sep->arg[5][0] && sep->IsNumber(5))
  6598. appearance_equip = atoul(sep->arg[5]);
  6599. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  6600. EQ2Packet* outapp = 0;
  6601. for(int32 i=0;i<packets.size();i++)
  6602. {
  6603. outapp = packets[i];
  6604. if(outapp)
  6605. client->QueuePacket(outapp);
  6606. }
  6607. client->UnequipItem(index, bag_id, to_slot, appearance_equip);
  6608. }
  6609. }
  6610. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6611. {
  6612. if(client->GetPlayer()->EngagedInCombat()) {
  6613. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not swap items while in combat.");
  6614. }
  6615. else {
  6616. int16 index1 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6617. int16 index2 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6618. int8 type = 0;
  6619. if(sep->IsNumber(3))
  6620. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  6621. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  6622. if(outapp)
  6623. client->QueuePacket(outapp);
  6624. else
  6625. {
  6626. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  6627. return;
  6628. }
  6629. }
  6630. }
  6631. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6632. {
  6633. sint16 to_slot = atoi(sep->arg[1]);
  6634. sint32 bag_id = atoi(sep->arg[2]);
  6635. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  6636. if (item) {
  6637. //auto inventory
  6638. if (bag_id == 0 && to_slot == -1)
  6639. {
  6640. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6641. {
  6642. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  6643. return;
  6644. }
  6645. // Set the slot for the item
  6646. item->details.inv_slot_id = bag_id;
  6647. item->details.slot_id = to_slot;
  6648. // Flag the item so it gets saved in its new location
  6649. item->save_needed = true;
  6650. // Add the item to its new location
  6651. if(player->item_list.AddItem(item)) {
  6652. // Remove the item from the overflow list
  6653. player->item_list.RemoveOverflowItem(item);
  6654. }
  6655. // Send the inventory update packet
  6656. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6657. return;
  6658. }
  6659. else if (bag_id == -3 && to_slot == -1) {
  6660. // Auto Bank
  6661. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  6662. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  6663. return;
  6664. }
  6665. item->details.inv_slot_id = bag_id;
  6666. item->details.slot_id = to_slot;
  6667. item->save_needed = true;
  6668. if(player->item_list.AddItem(item)) {
  6669. player->item_list.RemoveOverflowItem(item);
  6670. }
  6671. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6672. }
  6673. else if (bag_id == -4) {
  6674. // Shared Bank
  6675. if (!player->item_list.SharedBankAddAllowed(item)) {
  6676. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  6677. return;
  6678. }
  6679. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  6680. if (tmp_item) {
  6681. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6682. return;
  6683. }
  6684. else {
  6685. item->details.inv_slot_id = bag_id;
  6686. item->details.slot_id = to_slot;
  6687. item->save_needed = true;
  6688. if(player->item_list.AddItem(item)) {
  6689. player->item_list.RemoveOverflowItem(item);
  6690. }
  6691. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6692. return;
  6693. }
  6694. }
  6695. else {
  6696. // Try to get an item from the given bag id and slot id
  6697. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  6698. // Check to see if we got an item, if we do send an error,
  6699. // if we don't put the overflow item into this slot
  6700. if (tmp_item) {
  6701. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6702. }
  6703. else {
  6704. item->details.inv_slot_id = bag_id;
  6705. item->details.slot_id = to_slot;
  6706. item->save_needed = true;
  6707. if(player->item_list.AddItem(item)) {
  6708. player->item_list.RemoveOverflowItem(item);
  6709. }
  6710. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6711. return;
  6712. }
  6713. }
  6714. }
  6715. }
  6716. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6717. {
  6718. sint64 data = strtoull(sep->arg[1], NULL, 0);
  6719. int32 character_item_id = (int32) (data >> 32);
  6720. int32 item_id = (int32) (data & 0xffffffffL);
  6721. int8 sale_setting = atoi(sep->arg[2]);
  6722. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  6723. if(item)
  6724. {
  6725. item->no_sale = sale_setting;
  6726. item->save_needed = true;
  6727. client->SendSellMerchantList();
  6728. }
  6729. }
  6730. }
  6731. else
  6732. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  6733. }
  6734. /*
  6735. Function: Command_Languages()
  6736. Purpose : Show's languages the player knows
  6737. Params :
  6738. Dev : Zcoretri
  6739. Example :
  6740. */
  6741. void Commands::Command_Languages(Client* client, Seperator* sep)
  6742. {
  6743. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6744. list<Language*>::iterator itr;
  6745. Language* language;
  6746. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6747. for(itr = languages->begin(); itr != languages->end(); itr++)
  6748. {
  6749. language = *itr;
  6750. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6751. }
  6752. }
  6753. /*
  6754. Function: Command_SetLanguage()
  6755. Purpose : Handles language commands
  6756. Params : Language ID
  6757. Dev : Zcoretri
  6758. Example :
  6759. */
  6760. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6761. {
  6762. Player* player = client->GetPlayer();
  6763. if (sep && sep->arg[0])
  6764. {
  6765. if(!sep->IsNumber(0))
  6766. {
  6767. //String passed in
  6768. const char* value = sep->arg[0];
  6769. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6770. {
  6771. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6772. client->SendLanguagesUpdate(0);
  6773. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6774. }
  6775. else
  6776. {
  6777. if(player->HasLanguage(value))
  6778. {
  6779. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6780. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6781. client->SendLanguagesUpdate(language->GetID());
  6782. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6783. }
  6784. else
  6785. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6786. }
  6787. }
  6788. else
  6789. {
  6790. //Number passed in
  6791. int32 id = atoul(sep->arg[0]);
  6792. if(player->HasLanguage(id))
  6793. {
  6794. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6795. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6796. client->SendLanguagesUpdate(id);
  6797. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6798. }
  6799. else
  6800. {
  6801. Language* language = master_languages_list.GetLanguage(id);
  6802. if(language)
  6803. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6804. }
  6805. }
  6806. }
  6807. else
  6808. {
  6809. //No value was passed in
  6810. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6811. if(id > 0)
  6812. {
  6813. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6814. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6815. }
  6816. else
  6817. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6818. }
  6819. }
  6820. /*
  6821. Function: Command_LastName()
  6822. Purpose : Sets player surname
  6823. Params : Name text
  6824. Dev : theFoof
  6825. Example :
  6826. */
  6827. void Commands::Command_LastName(Client* client, Seperator* sep)
  6828. {
  6829. if (!client)
  6830. return;
  6831. if (sep && sep->arg[0])
  6832. {
  6833. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6834. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6835. return;
  6836. }
  6837. client->RemovePendingLastName();
  6838. uchar* checkname = (uchar*)sep->arg[0];
  6839. bool valid_name = true;
  6840. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6841. if (!alpha_check(checkname[i])) {
  6842. valid_name = false;
  6843. break;
  6844. }
  6845. }
  6846. if (!valid_name) {
  6847. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6848. return;
  6849. }
  6850. string last_name = (string)sep->arg[0];
  6851. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6852. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6853. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6854. client->SetPendingLastName(last_name);
  6855. client->SendLastNameConfirmation();
  6856. }
  6857. else
  6858. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6859. }
  6860. }
  6861. /*
  6862. Function: Command_ConfirmLastName()
  6863. Purpose : Confirms setting of player surname
  6864. Params : Name text
  6865. Dev : theFoof
  6866. Example :
  6867. */
  6868. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6869. {
  6870. if (!client)
  6871. return;
  6872. string* name = client->GetPendingLastName();
  6873. if (name){
  6874. Player* player = client->GetPlayer();
  6875. player->SetLastName(name->c_str(), false);
  6876. client->SendTitleUpdate();
  6877. player->SetCharSheetChanged(true);
  6878. client->RemovePendingLastName();
  6879. }
  6880. }
  6881. /*
  6882. Function: Command_Location()
  6883. Purpose : Display's Help for /location commands
  6884. Params :
  6885. Dev : Scatman
  6886. Example : /location = show's help for command
  6887. */
  6888. void Commands::Command_Location(Client* client)
  6889. {
  6890. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6891. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6894. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6896. }
  6897. /*
  6898. Function: Command_LocationAdd()
  6899. Purpose : Add's a location to an existing location config
  6900. Params : location_id
  6901. Dev : Scatman
  6902. Example : /location add {location_id}
  6903. */
  6904. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6905. {
  6906. if (sep && sep->arg[0] && sep->IsNumber(0))
  6907. {
  6908. int32 location_id = atoul(sep->arg[0]);
  6909. float x = client->GetPlayer()->GetX();
  6910. float y = client->GetPlayer()->GetY();
  6911. float z = client->GetPlayer()->GetZ();
  6912. if (database.AddLocationPoint(location_id, x, y, z))
  6913. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6914. else
  6915. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6916. }
  6917. else
  6918. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6919. }
  6920. /*
  6921. Function: Command_LocationCreate()
  6922. Purpose : Creates a new location config
  6923. Params : location name, 0/1 for include_y (optional)
  6924. Dev : Scatman
  6925. Example : /location create Test 1 = creates a new location named Test with include_y True
  6926. */
  6927. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6928. {
  6929. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6930. {
  6931. const char* name = sep->arg[0];
  6932. bool include_y = false;
  6933. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6934. include_y = true;
  6935. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->GetLocation(), name, include_y);
  6936. if (location_id > 0)
  6937. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6938. else
  6939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6940. }
  6941. else
  6942. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6943. }
  6944. /*
  6945. Function: Command_LocationDelete()
  6946. Purpose : Delete's a location config and all it's location points
  6947. Params : location_id
  6948. Dev : Scatman
  6949. Example : /location delete {location_id}
  6950. */
  6951. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6952. {
  6953. if (sep && sep->arg[0] && sep->IsNumber(0))
  6954. {
  6955. int32 location_id = atoul(sep->arg[0]);
  6956. if (database.DeleteLocation(location_id))
  6957. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6958. else
  6959. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6960. }
  6961. else
  6962. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6963. }
  6964. /*
  6965. Function: Command_LocationList()
  6966. Purpose : Display's a list of location points
  6967. Params : location_id
  6968. Dev : Scatman
  6969. Example : /location list {location_id}
  6970. */
  6971. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6972. {
  6973. if (sep && sep->arg[0])
  6974. {
  6975. const char* option = sep->arg[0];
  6976. if (strncmp(option, "locations", strlen(option)) == 0)
  6977. database.ListLocations(client);
  6978. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  6979. {
  6980. int32 location_id = atoul(sep->arg[1]);
  6981. database.ListLocationPoints(client, location_id);
  6982. }
  6983. else
  6984. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6985. }
  6986. else
  6987. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6988. }
  6989. /*
  6990. Function: Command_LocationRemove()
  6991. Purpose : Removes a single location point from a location config
  6992. Params : location_point_id (gotten from /location list {id})
  6993. Dev : Scatman
  6994. Example : /location remove 1 = will remove location_point_id 1
  6995. */
  6996. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  6997. {
  6998. if (sep && sep->arg[0] && sep->IsNumber(0))
  6999. {
  7000. int32 location_point_id = atoul(sep->arg[0]);
  7001. if (database.DeleteLocationPoint(location_point_id))
  7002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  7003. else
  7004. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  7005. }
  7006. else
  7007. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  7008. }
  7009. /*
  7010. Function: Command_Merchant()
  7011. Purpose : Handles Merchant commands
  7012. Params : list
  7013. Dev : Scatman
  7014. Example : /merchant list
  7015. */
  7016. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  7017. {
  7018. if( handler == COMMAND_MERCHANT )
  7019. {
  7020. // /merchant command by itself shows help (to be extended)
  7021. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  7022. return;
  7023. }
  7024. else if( handler == COMMAND_MERCHANT_LIST )
  7025. {
  7026. // /merchant list command expects "description" param
  7027. if (sep && sep->arg[0])
  7028. {
  7029. const char* merchant_description = sep->argplus[0];
  7030. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  7031. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  7032. map<int32, MerchantInfo*>::iterator itr;
  7033. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  7034. {
  7035. string description = database.GetMerchantDescription(itr->first);
  7036. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  7037. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  7038. }
  7039. }
  7040. else // no description
  7041. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  7042. }
  7043. }
  7044. /*
  7045. Function: Command_Modify()
  7046. Purpose : to replace our other "set" commands
  7047. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  7048. Dev : John Adams
  7049. Example : /modify spell set name "Aegolism III"
  7050. */
  7051. void Commands::Command_Modify(Client* client)
  7052. {
  7053. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  7054. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  7055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  7056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  7057. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  7058. }
  7059. /*
  7060. Function: Command_ModifySpawn()
  7061. Purpose : replace "spawn set" commands
  7062. Params : Action : the action to perform (or special handler)
  7063. : Field : the DB field to change
  7064. : Value : what to set the value to
  7065. : Target : what object to change (my target, or spawn_id)
  7066. Dev : John Adams
  7067. Example : /modify spawn set name "Lady Vox"
  7068. :
  7069. Note : Special Handlers, like "zoneto" for Signs
  7070. : /modify spawn zoneto
  7071. : Will set a sign's zone x/y/z to my current coords
  7072. */
  7073. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  7074. {
  7075. PrintSep(sep, "COMMAND_MODIFY");
  7076. // need at least 2 args for a valid command
  7077. if( sep && sep->arg[1] )
  7078. {
  7079. // JA: just a quick implementation because I need it :)
  7080. if (strcmp(sep->arg[0], "zoneto") == 0)
  7081. {
  7082. if( sep->IsNumber(1) )
  7083. {
  7084. int32 spawn_id = atoul(sep->arg[1]);
  7085. float x_coord = client->GetPlayer()->GetX();
  7086. float y_coord = client->GetPlayer()->GetY();
  7087. float z_coord = client->GetPlayer()->GetZ();
  7088. float h_coord = client->GetPlayer()->GetHeading();
  7089. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  7090. }
  7091. else
  7092. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  7093. }
  7094. }
  7095. else
  7096. Command_Modify(client);
  7097. }
  7098. /*
  7099. Function: Command_ModifyCharacter()
  7100. Purpose : to replace our other "set" commands
  7101. Params : Action : Add, Remove
  7102. : Field : copper, silver, gold, plat
  7103. : Value : min 1, max unlimited
  7104. : Target : Self, Player
  7105. Dev : Cynnar
  7106. Example : /modify character add gold 50
  7107. : /modify character remove silver 25
  7108. */
  7109. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  7110. {
  7111. PrintSep(sep, "COMMAND_MODIFY");
  7112. int64 value = 0;
  7113. Player* player = client->GetPlayer();
  7114. Client* targetClient = client;
  7115. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7116. player = (Player*)player->GetTarget();
  7117. targetClient = player->GetClient();
  7118. }
  7119. // need at least 2 args for a valid command
  7120. if( sep && sep->arg[1] )
  7121. {
  7122. if (strcmp(sep->arg[0], "add") == 0)
  7123. {
  7124. if (strcmp(sep->arg[1], "copper") == 0)
  7125. {
  7126. value = atoi64(sep->arg[2]);
  7127. player->AddCoins(value);
  7128. if (client->GetPlayer() == player)
  7129. {
  7130. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  7131. }
  7132. else {
  7133. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7134. if(targetClient) {
  7135. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7136. }
  7137. }
  7138. }
  7139. else if (strcmp(sep->arg[1], "silver") == 0)
  7140. {
  7141. value = atoi64(sep->arg[2]) * 100;
  7142. player->AddCoins(value);
  7143. if (client->GetPlayer() == player)
  7144. {
  7145. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  7146. }
  7147. else {
  7148. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  7149. if(targetClient) {
  7150. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7151. }
  7152. }
  7153. }
  7154. else if (strcmp(sep->arg[1], "gold") == 0)
  7155. {
  7156. value = atoi64(sep->arg[2]) * 10000;
  7157. player->AddCoins(value);
  7158. if (client->GetPlayer() == player)
  7159. {
  7160. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  7161. }
  7162. else {
  7163. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7164. if(targetClient) {
  7165. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7166. }
  7167. }
  7168. }
  7169. else if (strcmp(sep->arg[1], "plat") == 0)
  7170. {
  7171. value = atoi64(sep->arg[2]) * 1000000;
  7172. player->AddCoins(value);
  7173. if (client->GetPlayer() == player)
  7174. {
  7175. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  7176. }
  7177. else {
  7178. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7179. if(targetClient) {
  7180. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7181. }
  7182. }
  7183. }
  7184. else
  7185. {
  7186. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7187. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7188. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7189. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  7190. }
  7191. }
  7192. else if (strcmp(sep->arg[0], "remove") == 0)
  7193. {
  7194. if (strcmp(sep->arg[1], "copper") == 0)
  7195. {
  7196. value = atoi64(sep->arg[2]);
  7197. player->RemoveCoins(value);
  7198. if (client->GetPlayer() == player)
  7199. {
  7200. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  7201. }
  7202. else {
  7203. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  7204. if(targetClient) {
  7205. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7206. }
  7207. }
  7208. }
  7209. else if (strcmp(sep->arg[1], "silver") == 0)
  7210. {
  7211. value = atoi64(sep->arg[2]) * 100;
  7212. player->RemoveCoins(value);
  7213. if (client->GetPlayer() == player)
  7214. {
  7215. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  7216. }
  7217. else {
  7218. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  7219. if(targetClient) {
  7220. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7221. }
  7222. }
  7223. }
  7224. else if (strcmp(sep->arg[1], "gold") == 0)
  7225. {
  7226. value = atoi64(sep->arg[2]) * 10000;
  7227. player->RemoveCoins(value);
  7228. if (client->GetPlayer() == player)
  7229. {
  7230. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  7231. }
  7232. else {
  7233. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  7234. if(targetClient) {
  7235. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7236. }
  7237. }
  7238. }
  7239. else if (strcmp(sep->arg[1], "plat") == 0)
  7240. {
  7241. value = atoi64(sep->arg[2]) * 1000000;
  7242. player->RemoveCoins(value);
  7243. if (client->GetPlayer() == player)
  7244. {
  7245. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  7246. }
  7247. else {
  7248. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  7249. if(targetClient) {
  7250. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7251. }
  7252. }
  7253. }
  7254. else
  7255. {
  7256. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7257. }
  7258. }
  7259. else if (strcmp(sep->arg[0], "set") == 0) {
  7260. if (strcmp(sep->arg[1], "tslevel") == 0) {
  7261. int8 level = atoi(sep->arg[2]);
  7262. if (level > 0 && level < 256) {
  7263. if (player) {
  7264. if (client->GetPlayer() == player)
  7265. client->ChangeTSLevel(player->GetTSLevel(), level);
  7266. else if(targetClient)
  7267. targetClient->ChangeTSLevel(player->GetTSLevel(), level);
  7268. }
  7269. }
  7270. else
  7271. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  7272. }
  7273. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  7274. int8 tsclass = atoi(sep->arg[2]);
  7275. player->SetTradeskillClass(tsclass);
  7276. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  7277. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  7278. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  7279. player->SetCharSheetChanged(true);
  7280. }
  7281. else if (strcmp(sep->arg[1], "gender") == 0) {
  7282. int8 gender = atoi(sep->arg[2]);
  7283. client->GetPlayer()->GetInfoStruct()->set_gender(gender);
  7284. client->GetPlayer()->SetCharSheetChanged(true);
  7285. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  7286. }
  7287. }
  7288. }
  7289. else
  7290. {
  7291. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7292. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7293. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7294. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7295. }
  7296. }
  7297. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  7298. {
  7299. PrintSep(sep, "COMMAND_MODIFY");
  7300. // need at least 2 args for a valid command
  7301. if( sep && sep->arg[1] )
  7302. {
  7303. }
  7304. else
  7305. Command_Modify(client);
  7306. }
  7307. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  7308. {
  7309. PrintSep(sep, "COMMAND_MODIFY");
  7310. // need at least 2 args for a valid command
  7311. if( sep && sep->arg[1] )
  7312. {
  7313. }
  7314. else
  7315. Command_Modify(client);
  7316. }
  7317. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  7318. {
  7319. PrintSep(sep, "COMMAND_MODIFY");
  7320. // need at least 2 args for a valid command
  7321. if( sep && sep->arg[1] )
  7322. {
  7323. }
  7324. else
  7325. Command_Modify(client);
  7326. }
  7327. /*
  7328. Function: Command_ModifyQuest()
  7329. Purpose : to list players quest and completed quests
  7330. Params : Action : list, completed
  7331. : Target : Self, Player
  7332. Dev : Cynnar
  7333. Example : /modify quest list
  7334. : /modify quest completed
  7335. */
  7336. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  7337. {
  7338. PrintSep(sep, "COMMAND_MODIFY");
  7339. int64 value = 0;
  7340. Player* player = client->GetPlayer();
  7341. Client* targetClient = client;
  7342. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7343. player = (Player*)player->GetTarget();
  7344. targetClient = player->GetClient();
  7345. }
  7346. // need at least 2 args for a valid command
  7347. if (sep && sep->arg[1])
  7348. {
  7349. if (strcmp(sep->arg[0], "list") == 0)
  7350. {
  7351. map<int32, Quest*>* quests = player->GetPlayerQuests();
  7352. map<int32, Quest*>::iterator itr;
  7353. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  7354. if (quests->size() == 0)
  7355. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  7356. else
  7357. {
  7358. for (itr = quests->begin(); itr != quests->end(); itr++)
  7359. {
  7360. Quest* quest = itr->second;
  7361. if(quest) {
  7362. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7363. }
  7364. }
  7365. }
  7366. }
  7367. else if (strcmp(sep->arg[0], "completed") == 0)
  7368. {
  7369. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  7370. map<int32, Quest*>::iterator itr;
  7371. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  7372. if (quests->size() == 0)
  7373. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  7374. else
  7375. {
  7376. for (itr = quests->begin(); itr != quests->end(); itr++)
  7377. {
  7378. Quest* quest = itr->second;
  7379. if(quest) {
  7380. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7381. }
  7382. }
  7383. }
  7384. }
  7385. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  7386. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  7387. else if (strcmp(sep->arg[0], "remove") == 0)
  7388. {
  7389. int32 quest_id = 0;
  7390. if (sep && sep->arg[1] && sep->IsNumber(1))
  7391. quest_id = atoul(sep->arg[1]);
  7392. if (quest_id > 0)
  7393. {
  7394. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  7395. {
  7396. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7397. if (quest)
  7398. if (client->GetPlayer() == player)
  7399. {
  7400. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  7401. }
  7402. else
  7403. {
  7404. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  7405. if(targetClient) {
  7406. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  7407. }
  7408. }
  7409. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  7410. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  7411. }
  7412. client->RemovePlayerQuest(quest_id);
  7413. client->GetCurrentZone()->SendQuestUpdates(client);
  7414. }
  7415. }
  7416. else if (strcmp(sep->arg[0], "advance") == 0)
  7417. {
  7418. int32 quest_id = 0;
  7419. int32 step = 0;
  7420. if (sep && sep->arg[1] && sep->IsNumber(1))
  7421. {
  7422. quest_id = atoul(sep->arg[1]);
  7423. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7424. if(!quest) {
  7425. client->Message(CHANNEL_COLOR_RED, "Quest not found!");
  7426. return;
  7427. }
  7428. if (sep && sep->arg[2] && sep->IsNumber(1))
  7429. {
  7430. step = atoul(sep->arg[2]);
  7431. if (quest_id > 0 && step > 0)
  7432. {
  7433. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  7434. {
  7435. if (client)
  7436. {
  7437. client->AddPendingQuestUpdate(quest_id, step);
  7438. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  7439. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  7440. }
  7441. }
  7442. }
  7443. else
  7444. {
  7445. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  7446. }
  7447. }
  7448. else
  7449. {
  7450. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  7451. }
  7452. }
  7453. else
  7454. {
  7455. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  7456. }
  7457. }
  7458. else
  7459. {
  7460. Command_Modify(client);
  7461. }
  7462. }
  7463. else
  7464. {
  7465. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  7466. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  7467. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  7468. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  7469. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  7470. }
  7471. }
  7472. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  7473. {
  7474. PrintSep(sep, "COMMAND_MODIFY");
  7475. // need at least 2 args for a valid command
  7476. if( sep && sep->arg[1] )
  7477. {
  7478. if (strcmp(sep->arg[0], "add") == 0) {
  7479. const char* skill_name = sep->argplus[1];
  7480. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7481. if (skill) {
  7482. Player* player = 0;
  7483. Client* to_client = 0;
  7484. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7485. player = (Player*)client->GetPlayer()->GetTarget();
  7486. to_client = player->GetClient();
  7487. }
  7488. else {
  7489. player = client->GetPlayer();
  7490. to_client = client;
  7491. }
  7492. if (player)
  7493. {
  7494. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7495. {
  7496. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7497. if (to_client == client) {
  7498. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  7499. }
  7500. else {
  7501. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7502. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7503. }
  7504. }
  7505. else
  7506. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  7507. }
  7508. }
  7509. else
  7510. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7511. }
  7512. else if (strcmp(sep->arg[0], "remove") == 0) {
  7513. const char* skill_name = sep->argplus[1];
  7514. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7515. if (skill) {
  7516. Player* player = 0;
  7517. Client* to_client = 0;
  7518. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7519. player = (Player*)client->GetPlayer()->GetTarget();
  7520. to_client = player->GetClient();
  7521. }
  7522. else {
  7523. player = client->GetPlayer();
  7524. to_client = client;
  7525. }
  7526. if (player)
  7527. {
  7528. if (player->GetSkills()->HasSkill(skill->skill_id))
  7529. {
  7530. player->RemoveSkillFromDB(skill, true);
  7531. if (client == to_client) {
  7532. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  7533. }
  7534. else {
  7535. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7536. if(to_client) {
  7537. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7538. }
  7539. }
  7540. }
  7541. else {
  7542. if (client == to_client)
  7543. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  7544. else
  7545. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7546. }
  7547. }
  7548. }
  7549. else
  7550. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7551. }
  7552. else if (strcmp(sep->arg[0], "set") == 0) {
  7553. if (!sep->IsNumber(2)) {
  7554. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  7555. return;
  7556. }
  7557. const char* skill_name = sep->arg[1];
  7558. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7559. if (skill) {
  7560. int16 val = atoi(sep->arg[2]);
  7561. Player* player = 0;
  7562. Client* to_client = 0;
  7563. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7564. player = (Player*)client->GetPlayer()->GetTarget();
  7565. to_client = player->GetClient();
  7566. }
  7567. else {
  7568. player = client->GetPlayer();
  7569. to_client = client;
  7570. }
  7571. if (player)
  7572. {
  7573. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  7574. player->GetSkills()->SetSkill(skill->skill_id, val);
  7575. if (client != to_client)
  7576. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  7577. if(to_client) {
  7578. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  7579. }
  7580. }
  7581. else {
  7582. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  7583. }
  7584. }
  7585. }
  7586. else {
  7587. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7588. }
  7589. }
  7590. else {
  7591. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7592. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7593. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7594. }
  7595. }
  7596. else {
  7597. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7598. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7599. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7600. }
  7601. }
  7602. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  7603. {
  7604. PrintSep(sep, "COMMAND_MODIFY");
  7605. // need at least 2 args for a valid command
  7606. if( sep && sep->arg[1] )
  7607. {
  7608. }
  7609. else
  7610. Command_Modify(client);
  7611. }
  7612. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  7613. {
  7614. PrintSep(sep, "COMMAND_MODIFY");
  7615. // need at least 2 args for a valid command
  7616. if( sep && sep->arg[1] )
  7617. {
  7618. }
  7619. else
  7620. Command_Modify(client);
  7621. }
  7622. /*
  7623. Function: Command_MOTD()
  7624. Purpose : Displays server MOTD
  7625. Params :
  7626. Dev : LethalEncounter
  7627. Example : /motd
  7628. */
  7629. void Commands::Command_MOTD(Client* client)
  7630. {
  7631. if (client)
  7632. ClientPacketFunctions::SendMOTD(client);
  7633. }
  7634. /*
  7635. Function: Command_Pet()
  7636. Purpose : Handle Pet {Command} commands
  7637. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  7638. Dev :
  7639. Example : /pet preserve_master
  7640. */
  7641. void Commands::Command_Pet(Client* client, Seperator* sep)
  7642. {
  7643. PrintSep(sep, "COMMAND_PET");
  7644. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  7645. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7646. if (!sep || !sep->arg[0])
  7647. return; // should have sep->arg[0] filled
  7648. if (strcmp(sep->arg[0], "hide") == 0) {
  7649. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  7650. Entity* pet = client->GetPlayer()->GetDeityPet();
  7651. if (pet) {
  7652. if (pet->IsPrivateSpawn())
  7653. client->GetPlayer()->HideDeityPet(false);
  7654. else
  7655. client->GetPlayer()->HideDeityPet(true);
  7656. }
  7657. pet = client->GetPlayer()->GetCosmeticPet();
  7658. if (pet) {
  7659. if (pet->IsPrivateSpawn())
  7660. client->GetPlayer()->HideCosmeticPet(false);
  7661. else
  7662. client->GetPlayer()->HideCosmeticPet(true);
  7663. }
  7664. return;
  7665. }
  7666. // below is for all combat pets
  7667. if (!client->GetPlayer()->HasPet()) {
  7668. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  7669. return;
  7670. }
  7671. if (strcmp(sep->arg[0], "stay") == 0) {
  7672. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  7673. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  7674. client->GetPlayer()->SetCharSheetChanged(true);
  7675. if (client->GetPlayer()->GetPet())
  7676. client->GetPlayer()->GetPet()->following = false;
  7677. if (client->GetPlayer()->GetCharmedPet())
  7678. client->GetPlayer()->GetCharmedPet()->following = false;
  7679. }
  7680. else if (strcmp(sep->arg[0], "follow") == 0) {
  7681. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  7682. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  7683. client->GetPlayer()->SetCharSheetChanged(true);
  7684. }
  7685. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  7686. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  7687. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  7688. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  7689. }
  7690. else {
  7691. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  7692. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  7693. }
  7694. client->GetPlayer()->SetCharSheetChanged(true);
  7695. }
  7696. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  7697. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  7698. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  7699. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  7700. }
  7701. else {
  7702. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  7703. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  7704. }
  7705. client->GetPlayer()->SetCharSheetChanged(true);
  7706. }
  7707. else if (strcmp(sep->arg[0], "backoff") == 0) {
  7708. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  7709. if (client->GetPlayer()->GetPet())
  7710. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  7711. if (client->GetPlayer()->GetCharmedPet())
  7712. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  7713. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  7714. client->GetPlayer()->SetCharSheetChanged(true);
  7715. }
  7716. else if (strcmp(sep->arg[0], "attack") == 0) {
  7717. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  7718. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  7719. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  7720. if (client->GetPlayer()->GetPet())
  7721. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7722. if (client->GetPlayer()->GetCharmedPet())
  7723. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7724. }
  7725. else
  7726. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  7727. }
  7728. else
  7729. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  7730. }
  7731. else if (strcmp(sep->arg[0], "getlost") == 0) {
  7732. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  7733. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  7734. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  7735. }
  7736. else
  7737. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  7738. }
  7739. /*
  7740. Function: Command_PetName()
  7741. Purpose : Pet your name (???)
  7742. Params :
  7743. Dev :
  7744. Example :
  7745. */
  7746. void Commands::Command_PetName(Client* client, Seperator* sep)
  7747. {
  7748. if (sep && sep->arg[0]) {
  7749. const char* pet_name = sep->argplus[0];
  7750. client->SetPetName(pet_name);
  7751. }
  7752. else {
  7753. client->GetPlayer()->GetInfoStruct()->set_pet_name("");
  7754. }
  7755. }
  7756. /*
  7757. Function: Command_NamePet()
  7758. Purpose : Name your pet
  7759. Params :
  7760. Dev :
  7761. Example :
  7762. */
  7763. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7764. {
  7765. PrintSep(sep, "COMMAND_NAME_PET");
  7766. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7767. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7768. }
  7769. /*
  7770. Function: Command_Rename()
  7771. Purpose : Renames existing pet
  7772. Params :
  7773. Dev :
  7774. Example :
  7775. */
  7776. void Commands::Command_Rename(Client* client, Seperator* sep)
  7777. {
  7778. PrintSep(sep, "COMMAND_RENAME");
  7779. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7780. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7781. }
  7782. /*
  7783. Function: Command_ConfirmRename()
  7784. Purpose : Confirms renaming your pet
  7785. Params :
  7786. Dev :
  7787. Example :
  7788. */
  7789. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7790. {
  7791. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7792. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7793. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7794. }
  7795. /*
  7796. Function: Command_PetOptions()
  7797. Purpose : Sets various pet options
  7798. Params :
  7799. Dev :
  7800. Example :
  7801. */
  7802. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7803. {
  7804. PrintSep(sep, "COMMAND_PETOPTIONS");
  7805. Player* player = client->GetPlayer();
  7806. Spawn* target = player->GetTarget();
  7807. if (!target)
  7808. return;
  7809. if (target == player->GetPet())
  7810. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7811. else if (target == player->GetCharmedPet())
  7812. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7813. else if (target == player->GetCosmeticPet())
  7814. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7815. else if (target == player->GetDeityPet())
  7816. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7817. }
  7818. /*
  7819. Function: Command_Random()
  7820. Purpose : Handles /random dice roll in-game
  7821. Params : 1-100
  7822. Dev : Scatman
  7823. Example : /randon 1 100
  7824. */
  7825. void Commands::Command_Random(Client* client, Seperator* sep)
  7826. {
  7827. char message[256] = {0};
  7828. if (sep)
  7829. {
  7830. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7831. 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])));
  7832. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7833. 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])));
  7834. else
  7835. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7836. }
  7837. else
  7838. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7839. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7840. }
  7841. /*
  7842. Function: Command_Randomize()
  7843. Purpose : Sets randomize (appearance) values for NPCs
  7844. Params : Attrib Name
  7845. Dev : Scatman
  7846. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7847. */
  7848. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7849. {
  7850. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7851. if (target)
  7852. {
  7853. if (target->IsNPC())
  7854. {
  7855. if (sep && sep->arg[0] && !sep->IsNumber(0))
  7856. {
  7857. const char* value = sep->arg[0];
  7858. if (strncasecmp(value, "show", strlen(value)) == 0)
  7859. {
  7860. client->DisplayRandomizeFeatures(target->GetRandomize());
  7861. }
  7862. else
  7863. {
  7864. if (sep->arg[1] && sep->IsNumber(1))
  7865. {
  7866. int8 option = atoi(sep->arg[1]);
  7867. if (option == 0 || option == 1)
  7868. {
  7869. int32 feature = 0;
  7870. char feature_text[32] = {0};
  7871. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7872. feature = RANDOMIZE_GENDER;
  7873. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7874. }
  7875. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7876. feature = RANDOMIZE_RACE;
  7877. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7878. }
  7879. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7880. feature = RANDOMIZE_MODEL_TYPE;
  7881. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7882. }
  7883. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7884. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7885. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7886. }
  7887. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7888. feature = RANDOMIZE_HAIR_TYPE;
  7889. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7890. }
  7891. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7892. feature = RANDOMIZE_WING_TYPE;
  7893. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7894. }
  7895. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7896. feature = RANDOMIZE_CHEEK_TYPE;
  7897. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7898. }
  7899. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7900. feature = RANDOMIZE_CHIN_TYPE;
  7901. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7902. }
  7903. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7904. feature = RANDOMIZE_EAR_TYPE;
  7905. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7906. }
  7907. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7908. feature = RANDOMIZE_EYE_BROW_TYPE;
  7909. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7910. }
  7911. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7912. feature = RANDOMIZE_EYE_TYPE;
  7913. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7914. }
  7915. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7916. feature = RANDOMIZE_LIP_TYPE;
  7917. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7918. }
  7919. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7920. feature = RANDOMIZE_NOSE_TYPE;
  7921. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7922. }
  7923. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7924. feature = RANDOMIZE_EYE_COLOR;
  7925. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7926. }
  7927. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7928. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7929. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7930. }
  7931. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7932. feature = RANDOMIZE_HAIR_COLOR1;
  7933. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7934. }
  7935. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7936. feature = RANDOMIZE_HAIR_COLOR2;
  7937. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7938. }
  7939. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7940. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7941. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7942. }
  7943. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7944. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7945. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7946. }
  7947. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7948. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7949. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7950. }
  7951. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7952. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7953. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7954. }
  7955. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7956. feature = RANDOMIZE_SKIN_COLOR;
  7957. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7958. }
  7959. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7960. feature = RANDOMIZE_WING_COLOR1;
  7961. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7962. }
  7963. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7964. feature = RANDOMIZE_WING_COLOR2;
  7965. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7966. }
  7967. else {
  7968. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7969. 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'.");
  7970. }
  7971. if (feature > 0) {
  7972. if (option == 1) {
  7973. if (target->GetRandomize() & feature)
  7974. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  7975. else {
  7976. target->AddRandomize(feature);
  7977. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  7978. database.UpdateRandomize(target->GetDatabaseID(), feature);
  7979. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  7980. }
  7981. }
  7982. else {
  7983. if (target->GetRandomize() & feature) {
  7984. target->AddRandomize(-feature);
  7985. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  7986. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  7987. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  7988. }
  7989. else
  7990. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  7991. }
  7992. }
  7993. }
  7994. else
  7995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7996. }
  7997. else
  7998. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7999. }
  8000. }
  8001. else {
  8002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  8003. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  8004. 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'.");
  8005. }
  8006. }
  8007. else
  8008. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  8009. }
  8010. else
  8011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  8012. }
  8013. /*
  8014. Function: Command_ShowCloak()
  8015. Purpose : Character Settings combo box for Show Cloak
  8016. Params : true/false
  8017. Dev : John Adams
  8018. Example :
  8019. */
  8020. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  8021. {
  8022. Player* player = client->GetPlayer();
  8023. if (sep && sep->arg[0])
  8024. {
  8025. const char* value = sep->arg[0];
  8026. if (strncasecmp(value, "true", strlen(value)) == 0)
  8027. {
  8028. player->set_character_flag(CF_SHOW_CLOAK);
  8029. player->reset_character_flag(CF2_SHOW_RANGED);
  8030. }
  8031. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8032. player->reset_character_flag(CF_SHOW_CLOAK);
  8033. else
  8034. {
  8035. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8036. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8037. }
  8038. }
  8039. }
  8040. /*
  8041. Function: Command_ShowHelm()
  8042. Purpose : Character Settings combo box for Show Helm
  8043. Params : true/false
  8044. Dev : John Adams
  8045. Example :
  8046. */
  8047. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  8048. {
  8049. Player* player = client->GetPlayer();
  8050. if(client->GetVersion() <= 546) {
  8051. return; // not allowed/supported
  8052. }
  8053. if (sep && sep->arg[0])
  8054. {
  8055. PrintSep(sep, "Command_ShowHelm");
  8056. const char* value = sep->arg[0];
  8057. if (strncasecmp(value, "true", strlen(value)) == 0)
  8058. {
  8059. player->toggle_character_flag(CF_HIDE_HELM);
  8060. player->toggle_character_flag(CF_HIDE_HOOD);
  8061. }
  8062. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8063. player->toggle_character_flag(CF_HIDE_HELM);
  8064. else
  8065. {
  8066. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8067. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8068. }
  8069. }
  8070. }
  8071. /*
  8072. Function: Command_ShowHood()
  8073. Purpose : Character Settings combo box for Show Hood
  8074. Params : true/false
  8075. Dev : John Adams
  8076. Example :
  8077. */
  8078. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  8079. {
  8080. Player* player = client->GetPlayer();
  8081. if (sep && sep->arg[0])
  8082. {
  8083. PrintSep(sep, "Command_ShowHood");
  8084. const char* value = sep->arg[0];
  8085. if (strncasecmp(value, "true", strlen(value)) == 0)
  8086. {
  8087. player->toggle_character_flag(CF_HIDE_HOOD);
  8088. if(client->GetVersion() > 546) { // no hide helm support in DoF
  8089. player->toggle_character_flag(CF_HIDE_HELM);
  8090. }
  8091. }
  8092. else if (strncasecmp(value, "false", strlen(value)) == 0) {
  8093. player->toggle_character_flag(CF_HIDE_HOOD);
  8094. }
  8095. else
  8096. {
  8097. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8098. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8099. }
  8100. }
  8101. }
  8102. /*
  8103. Function: Command_ShowHoodHelm()
  8104. Purpose : Character Settings combo box for Show Helm or Hood
  8105. Params : true/false
  8106. Dev : John Adams
  8107. Example :
  8108. */
  8109. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  8110. {
  8111. Player* player = client->GetPlayer();
  8112. if(client->GetVersion() <= 546) {
  8113. return; // not allowed/supported
  8114. }
  8115. if (sep && sep->arg[0])
  8116. {
  8117. PrintSep(sep, "Command_ShowHoodHelm");
  8118. const char* value = sep->arg[0];
  8119. if (strncasecmp(value, "true", strlen(value)) == 0)
  8120. {
  8121. player->toggle_character_flag(CF_HIDE_HOOD);
  8122. player->toggle_character_flag(CF_HIDE_HELM);
  8123. }
  8124. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8125. {
  8126. // don't think we ever wind up in here...
  8127. player->toggle_character_flag(CF_HIDE_HOOD);
  8128. player->toggle_character_flag(CF_HIDE_HELM);
  8129. }
  8130. else
  8131. {
  8132. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8133. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8134. }
  8135. }
  8136. }
  8137. /*
  8138. Function: Command_ShowRanged()
  8139. Purpose : Character Settings combo box for Show Ranged weapon
  8140. Params : true/false
  8141. Dev : John Adams
  8142. Example :
  8143. */
  8144. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  8145. {
  8146. Player* player = client->GetPlayer();
  8147. if (sep && sep->arg[0])
  8148. {
  8149. const char* value = sep->arg[0];
  8150. if (strncasecmp(value, "true", strlen(value)) == 0)
  8151. {
  8152. player->set_character_flag(CF2_SHOW_RANGED);
  8153. player->reset_character_flag(CF_SHOW_CLOAK);
  8154. }
  8155. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8156. player->reset_character_flag(CF2_SHOW_RANGED);
  8157. else
  8158. {
  8159. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8160. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8161. }
  8162. }
  8163. }
  8164. /*
  8165. Function:
  8166. Purpose :
  8167. Params :
  8168. Dev :
  8169. Example :
  8170. */
  8171. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  8172. {
  8173. Player* player = 0;
  8174. Client* to_client = 0;
  8175. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  8176. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  8177. switch(handler)
  8178. {
  8179. case COMMAND_SKILL:
  8180. {
  8181. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  8182. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  8183. break;
  8184. }
  8185. case COMMAND_SKILL_ADD:
  8186. {
  8187. if (sep && sep->arg[0])
  8188. {
  8189. const char* skill_name = sep->argplus[0];
  8190. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8191. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  8192. {
  8193. player = to_client->GetPlayer();
  8194. if (player)
  8195. {
  8196. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8197. {
  8198. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8199. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  8200. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  8201. }
  8202. else
  8203. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  8204. }
  8205. }
  8206. else if (skill) // add skill to yourself
  8207. {
  8208. player = client->GetPlayer();
  8209. if (player)
  8210. {
  8211. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8212. {
  8213. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8214. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  8215. }
  8216. else
  8217. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  8218. }
  8219. }
  8220. else
  8221. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8222. }
  8223. else
  8224. {
  8225. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  8226. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8227. }
  8228. break;
  8229. }
  8230. case COMMAND_SKILL_REMOVE:
  8231. {
  8232. if (sep && sep->arg[0])
  8233. {
  8234. const char* skill_name = sep->argplus[0];
  8235. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8236. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  8237. {
  8238. player = to_client->GetPlayer();
  8239. if (player)
  8240. {
  8241. if (player->GetSkills()->HasSkill(skill->skill_id))
  8242. {
  8243. player->RemoveSkillFromDB(skill, true);
  8244. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  8245. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  8246. }
  8247. else
  8248. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  8249. }
  8250. }
  8251. else if(skill) // remove skill from yourself
  8252. {
  8253. Player* player = client->GetPlayer();
  8254. if (player)
  8255. {
  8256. if (player->GetSkills()->HasSkill(skill->skill_id))
  8257. {
  8258. player->RemoveSkillFromDB(skill, true);
  8259. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  8260. }
  8261. else
  8262. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  8263. }
  8264. }
  8265. else
  8266. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8267. }
  8268. else
  8269. {
  8270. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  8271. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8272. }
  8273. break;
  8274. }
  8275. case COMMAND_SKILL_LIST:
  8276. {
  8277. if (sep && sep->arg[0])
  8278. {
  8279. const char* skill_name = sep->argplus[0];
  8280. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  8281. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  8282. map<int32, Skill*>::iterator itr;
  8283. if (skills && skills->size() > 0)
  8284. {
  8285. for (itr = skills->begin(); itr != skills->end(); itr++)
  8286. {
  8287. Skill* skill = itr->second;
  8288. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  8289. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  8290. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  8291. }
  8292. }
  8293. }
  8294. else
  8295. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  8296. break;
  8297. }
  8298. }
  8299. }
  8300. /*
  8301. Function: Command_SpawnTemplate()
  8302. Purpose : Create or Use defined Spawn Templates
  8303. Params : create, save, rempve, list
  8304. Dev : John Adams
  8305. Example : /spawn template create "Test"
  8306. */
  8307. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  8308. {
  8309. if (sep == NULL || sep->arg[0] == NULL)
  8310. {
  8311. 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.");
  8312. return;
  8313. }
  8314. // got params, continue
  8315. const char * template_cmd = sep->arg[0];
  8316. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  8317. {
  8318. if (!sep->IsSet(1))
  8319. {
  8320. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  8321. 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.");
  8322. return;
  8323. }
  8324. map<int32, string>* template_names = 0;
  8325. if (sep->IsNumber(1))
  8326. {
  8327. int32 location_id = 0;
  8328. location_id = atoi(sep->arg[1]);
  8329. template_names = database.GetSpawnTemplateListByID(location_id);
  8330. }
  8331. else
  8332. {
  8333. const char* name = 0;
  8334. name = sep->argplus[1];
  8335. template_names = database.GetSpawnTemplateListByName(name);
  8336. }
  8337. if(!template_names)
  8338. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  8339. else
  8340. {
  8341. map<int32, string>::iterator itr;
  8342. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  8343. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  8344. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  8345. safe_delete(template_names);
  8346. }
  8347. }
  8348. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  8349. {
  8350. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8351. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  8352. {
  8353. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  8354. {
  8355. // first, lookup to see if template name already exists
  8356. const char* name = 0;
  8357. name = sep->argplus[1];
  8358. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  8359. if(!template_names)
  8360. {
  8361. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  8362. if( new_template_id > 0 )
  8363. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  8364. else
  8365. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  8366. }
  8367. else
  8368. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  8369. }
  8370. else
  8371. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  8372. }
  8373. else
  8374. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  8375. }
  8376. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  8377. {
  8378. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  8379. {
  8380. int32 template_id = 0;
  8381. template_id = atoi(sep->arg[1]);
  8382. if (database.RemoveSpawnTemplate(template_id))
  8383. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  8384. else
  8385. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  8386. }
  8387. else
  8388. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  8389. }
  8390. // Renamed create to spawn
  8391. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  8392. {
  8393. if (sep && sep->arg[1][0])
  8394. {
  8395. int32 new_location = 0;
  8396. if (sep->IsNumber(1))
  8397. {
  8398. int32 template_id = 0;
  8399. template_id = atoi(sep->arg[1]);
  8400. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  8401. if( new_location > 0 )
  8402. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  8403. else
  8404. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  8405. }
  8406. else
  8407. {
  8408. const char* name = 0;
  8409. name = sep->argplus[1];
  8410. new_location = database.CreateSpawnFromTemplateByName(client, name);
  8411. if( new_location > 0 )
  8412. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  8413. else
  8414. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  8415. }
  8416. }
  8417. else
  8418. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  8419. }
  8420. else
  8421. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  8422. }
  8423. void Commands::Command_Speed(Client* client, Seperator* sep) {
  8424. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  8425. float new_speed = atof(sep->arg[0]);
  8426. if (new_speed > 0.0f)
  8427. {
  8428. client->GetPlayer()->SetSpeed(new_speed, true);
  8429. client->GetPlayer()->SetCharSheetChanged(true);
  8430. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  8431. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  8432. }
  8433. else
  8434. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  8435. }
  8436. else{
  8437. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  8438. }
  8439. }
  8440. /*
  8441. Function: Command_StationMarketPlace()
  8442. Purpose : just trying to eat the console spam for now
  8443. Params :
  8444. Dev : John
  8445. */
  8446. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  8447. {
  8448. PrintSep(sep, "COMMAND_SMP");
  8449. // This will reduce the spam from once every 10 sec to once every 30 sec,
  8450. // can't seem to reduce it any more get rid of it completely...
  8451. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  8452. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  8453. if (packet) {
  8454. packet->setDataByName("account_id", client->GetAccountID());
  8455. packet->setDataByName("character_id", client->GetCharacterID());
  8456. packet->setDataByName("unknown1", 1, 5);
  8457. packet->setDataByName("unknown1", 26, 6);
  8458. packet->setDataByName("unknown2", 0xFFFFFFFF);
  8459. packet->setDataByName("unknown3", 248, 1);
  8460. client->QueuePacket(packet->serialize());
  8461. }
  8462. safe_delete(packet);
  8463. }
  8464. }
  8465. /*
  8466. Function: Command_StopDrinking()
  8467. Purpose : Stops player from auto-consuming drink
  8468. Params :
  8469. Dev : Zcoretri
  8470. Example : /stopdrinking
  8471. */
  8472. void Commands::Command_StopDrinking(Client* client)
  8473. {
  8474. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  8475. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  8476. }
  8477. /*
  8478. Function: Command_StopEating()
  8479. Purpose : Stops player from auto-consuming food
  8480. Params :
  8481. Dev : Zcoretri
  8482. Example : /stopeating
  8483. */
  8484. void Commands::Command_StopEating(Client* client)
  8485. {
  8486. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  8487. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  8488. }
  8489. /*
  8490. Function: Command_Title()
  8491. Purpose : Help for /title command
  8492. Params : n/a
  8493. Dev : Zcoretri
  8494. Example : /title
  8495. */
  8496. void Commands::Command_Title(Client* client)
  8497. {
  8498. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  8499. }
  8500. /*
  8501. Function: Command_TitleList()
  8502. Purpose : List available titles for player
  8503. Params : n/a
  8504. Dev : Zcoretri
  8505. Example : /title list
  8506. */
  8507. void Commands::Command_TitleList(Client* client)
  8508. {
  8509. // must call release read lock before leaving function on GetPlayerTitles
  8510. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  8511. vector<Title*>::iterator itr;
  8512. Title* title;
  8513. sint32 i = 0;
  8514. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  8515. for(itr = titles->begin(); itr != titles->end(); itr++)
  8516. {
  8517. title = *itr;
  8518. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  8519. i++;
  8520. }
  8521. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  8522. }
  8523. /*
  8524. Function: Command_TitleSetPrefix()
  8525. Purpose : Set Prefix title for player
  8526. Params : Title ID
  8527. Dev : Zcoretri
  8528. Example : /title setprefix 1
  8529. */
  8530. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  8531. {
  8532. if (sep && sep->arg[0] && sep->IsNumber(0))
  8533. {
  8534. sint32 index = atoul(sep->arg[0]);
  8535. if(index > -1)
  8536. {
  8537. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8538. if(!title)
  8539. {
  8540. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8541. return;
  8542. }
  8543. else if(!title->GetPrefix())
  8544. {
  8545. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  8546. return;
  8547. }
  8548. }
  8549. else // make sure client doesn't pass some bogus negative index
  8550. index = -1;
  8551. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  8552. client->SendTitleUpdate();
  8553. }
  8554. }
  8555. /*
  8556. Function: Command_TitleSetSuffix()
  8557. Purpose : Set Suffix title for player
  8558. Params : Title ID
  8559. Dev : Zcoretri
  8560. Example : /title setsuffix 1
  8561. */
  8562. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  8563. {
  8564. if (sep && sep->arg[0] && sep->IsNumber(0))
  8565. {
  8566. sint32 index = atoul(sep->arg[0]);
  8567. if(index > -1)
  8568. {
  8569. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8570. if(!title)
  8571. {
  8572. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8573. return;
  8574. }
  8575. else if(title->GetPrefix())
  8576. {
  8577. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  8578. return;
  8579. }
  8580. }
  8581. else // make sure client doesn't pass some bogus negative index
  8582. index = -1;
  8583. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  8584. client->SendTitleUpdate();
  8585. }
  8586. }
  8587. /*
  8588. Function: Command_TitleFix()
  8589. Purpose : Fix title for player (???)
  8590. Params :
  8591. Dev : Zcoretri
  8592. Example :
  8593. */
  8594. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  8595. {
  8596. PrintSep(sep, "COMMAND_TITLE_FIX");
  8597. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  8598. }
  8599. /*
  8600. Function: Command_Toggle_Anonymous()
  8601. Purpose : Toggles player Anonymous
  8602. Params :
  8603. Dev : paulgh
  8604. Example : /anon
  8605. */
  8606. void Commands::Command_Toggle_Anonymous(Client* client)
  8607. {
  8608. Player* player = client->GetPlayer();
  8609. player->toggle_character_flag(CF_ANONYMOUS);
  8610. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  8611. if (player->get_character_flag(CF_ANONYMOUS))
  8612. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  8613. else
  8614. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  8615. }
  8616. /*
  8617. Function: Command_Toggle_AutoConsume()
  8618. Purpose : Toggles player food/drink auto consume
  8619. Params : unknown
  8620. Dev : paulgh
  8621. Example : /set_auto_consume
  8622. */
  8623. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  8624. {
  8625. Player* player = client->GetPlayer();
  8626. if (sep && sep->arg[0])
  8627. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  8628. if (sep && sep->arg[0] && sep->IsNumber(0))
  8629. {
  8630. int8 slot = atoi(sep->arg[0]);
  8631. int8 flag = atoi(sep->arg[1]);
  8632. if (client->GetVersion() <= 283) {
  8633. slot += 4;
  8634. }
  8635. else if (client->GetVersion() <= 546) {
  8636. slot += 2;
  8637. }
  8638. if (slot == EQ2_FOOD_SLOT)
  8639. {
  8640. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  8641. player->SetCharSheetChanged(true);
  8642. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8643. if (flag == 1)
  8644. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  8645. else
  8646. {
  8647. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  8648. return;
  8649. }
  8650. }
  8651. else
  8652. {
  8653. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  8654. player->SetCharSheetChanged(true);
  8655. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8656. if (flag == 1)
  8657. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  8658. else
  8659. {
  8660. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  8661. return;
  8662. }
  8663. }
  8664. if(!client->CheckConsumptionAllowed(slot, false))
  8665. return;
  8666. Item* item = player->GetEquipmentList()->GetItem(slot);
  8667. if(item)
  8668. client->ConsumeFoodDrink(item, slot);
  8669. }
  8670. }
  8671. /*
  8672. Function: Command_Toggle_BonusXP()
  8673. Purpose : Toggles player Bonus XP
  8674. Params :
  8675. Dev : John Adams
  8676. Example : /disable_char_bonus_exp
  8677. */
  8678. void Commands::Command_Toggle_BonusXP(Client* client)
  8679. {
  8680. Player* player = client->GetPlayer();
  8681. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  8682. player->SetCharSheetChanged(true);
  8683. }
  8684. /*
  8685. Function: Command_Toggle_CombatXP()
  8686. Purpose : Toggles player Adventure XP
  8687. Params :
  8688. Dev : John Adams
  8689. Example : /disable_combat_exp
  8690. */
  8691. void Commands::Command_Toggle_CombatXP(Client* client)
  8692. {
  8693. Player* player = client->GetPlayer();
  8694. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  8695. player->SetCharSheetChanged(true);
  8696. }
  8697. /*
  8698. Function: Command_Toggle_GMHide()
  8699. Purpose : Toggles hiding player GM status
  8700. Params :
  8701. Dev : Scatman
  8702. Example : /gm_hide
  8703. */
  8704. void Commands::Command_Toggle_GMHide(Client* client)
  8705. {
  8706. Player* player = client->GetPlayer();
  8707. player->toggle_character_flag(CF_HIDE_STATUS);
  8708. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  8709. }
  8710. /*
  8711. Function: Command_Toggle_GMVanish()
  8712. Purpose : Toggles hiding GM players from /who searches
  8713. Params :
  8714. Dev : Scatman
  8715. Example : /gm_vanish
  8716. */
  8717. void Commands::Command_Toggle_GMVanish(Client* client)
  8718. {
  8719. Player* player = client->GetPlayer();
  8720. player->toggle_character_flag(CF_GM_HIDDEN);
  8721. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  8722. }
  8723. /*
  8724. Function: Command_Toggle_Illusions()
  8725. Purpose : Toggles player illusion form
  8726. Params : not sure sep is needed, testing
  8727. Dev : paulgh
  8728. Example : /hide_illusions
  8729. */
  8730. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  8731. {
  8732. if (sep && sep->arg[0])
  8733. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  8734. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  8735. }
  8736. /*
  8737. Function: Command_Toggle_LFG()
  8738. Purpose : Toggles player LFG Flag
  8739. Params :
  8740. Dev : paulgh
  8741. Example : /lfg
  8742. */
  8743. void Commands::Command_Toggle_LFG(Client* client)
  8744. {
  8745. Player* player = client->GetPlayer();
  8746. player->toggle_character_flag(CF_LFG);
  8747. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  8748. if (player->get_character_flag(CF_LFG))
  8749. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  8750. else
  8751. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  8752. }
  8753. /*
  8754. Function: Command_Toggle_LFW()
  8755. Purpose : Toggles player LFW Flag
  8756. Params :
  8757. Dev : paulgh
  8758. Example : /lfw
  8759. */
  8760. void Commands::Command_Toggle_LFW(Client* client)
  8761. {
  8762. Player* player = client->GetPlayer();
  8763. player->toggle_character_flag(CF_LFW);
  8764. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8765. if (player->get_character_flag(CF_LFW))
  8766. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8767. else
  8768. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8769. }
  8770. /*
  8771. Function: Command_Toggle_QuestXP()
  8772. Purpose : Toggles player Quest XP
  8773. Params :
  8774. Dev : John Adams
  8775. Example : /disable_quest_exp
  8776. */
  8777. void Commands::Command_Toggle_QuestXP(Client* client)
  8778. {
  8779. Player* player = client->GetPlayer();
  8780. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8781. player->SetCharSheetChanged(true);
  8782. }
  8783. /*
  8784. Function: Command_Toggle_Roleplaying()
  8785. Purpose : Toggles player Roleplaying flag
  8786. Params :
  8787. Dev : paulgh
  8788. Example : /role
  8789. */
  8790. void Commands::Command_Toggle_Roleplaying(Client* client)
  8791. {
  8792. Player* player = client->GetPlayer();
  8793. player->toggle_character_flag(CF_ROLEPLAYING);
  8794. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8795. if (player->get_character_flag(CF_ROLEPLAYING))
  8796. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8797. else
  8798. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8799. }
  8800. void Commands::Command_Toggle_Duels(Client* client)
  8801. {
  8802. Player* player = client->GetPlayer();
  8803. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8804. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8805. }
  8806. void Commands::Command_Toggle_Trades(Client* client)
  8807. {
  8808. Player* player = client->GetPlayer();
  8809. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8810. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8811. }
  8812. void Commands::Command_Toggle_Guilds(Client* client)
  8813. {
  8814. Player* player = client->GetPlayer();
  8815. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8816. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8817. }
  8818. void Commands::Command_Toggle_Groups(Client* client)
  8819. {
  8820. Player* player = client->GetPlayer();
  8821. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8822. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8823. }
  8824. void Commands::Command_Toggle_Raids(Client* client)
  8825. {
  8826. Player* player = client->GetPlayer();
  8827. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8828. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8829. }
  8830. void Commands::Command_Toggle_LON(Client* client)
  8831. {
  8832. Player* player = client->GetPlayer();
  8833. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8834. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8835. }
  8836. void Commands::Command_Toggle_VoiceChat(Client* client)
  8837. {
  8838. Player* player = client->GetPlayer();
  8839. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8840. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8841. }
  8842. /*
  8843. Function: Command_TradeStart()
  8844. Purpose : Starts item/coin trade between players
  8845. Params :
  8846. Dev :
  8847. Example :
  8848. */
  8849. #include "../Trade.h"
  8850. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  8851. {
  8852. PrintSep(sep, "COMMAND_START_TRADE");
  8853. Entity* trader = client->GetPlayer();
  8854. Entity* trader2 = 0;
  8855. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8856. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  8857. if (spawn) {
  8858. if (spawn->IsEntity())
  8859. trader2 = (Entity*)spawn;
  8860. }
  8861. }
  8862. else if (client->GetPlayer()->GetTarget()) {
  8863. if (client->GetPlayer()->GetTarget()->IsEntity())
  8864. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  8865. }
  8866. // can only trade with player or bots
  8867. if (trader && trader2) {
  8868. if (trader == trader2) {
  8869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  8870. }
  8871. else if (trader2->IsPlayer() || trader2->IsBot()) {
  8872. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  8873. if (trader->trade)
  8874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  8875. else if (trader2->trade)
  8876. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  8877. else {
  8878. Trade* trade = new Trade(trader, trader2);
  8879. trader->trade = trade;
  8880. trader2->trade = trade;
  8881. }
  8882. }
  8883. else {
  8884. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8885. }
  8886. }
  8887. else
  8888. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8889. }
  8890. /*
  8891. Function: Command_Track()
  8892. Purpose : Starts/Stops Tracking for a player
  8893. Params :
  8894. Dev : Scatman
  8895. Example : /track
  8896. */
  8897. void Commands::Command_Track(Client* client)
  8898. {
  8899. if (!client->GetPlayer()->GetIsTracking())
  8900. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8901. else
  8902. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8903. }
  8904. /*
  8905. Function: Command_TradeAccept()
  8906. Purpose : Accepts item/coin trade between players
  8907. Params :
  8908. Dev :
  8909. Example :
  8910. */
  8911. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8912. {
  8913. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8914. Trade* trade = client->GetPlayer()->trade;
  8915. if (trade) {
  8916. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8917. if (trade_complete)
  8918. safe_delete(trade);
  8919. }
  8920. else
  8921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8922. }
  8923. /*
  8924. Function: Command_TradeReject()
  8925. Purpose : Rejects item/coin trade between players
  8926. Params :
  8927. Dev :
  8928. Example :
  8929. */
  8930. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8931. {
  8932. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8933. Command_TradeCancel(client, sep);
  8934. }
  8935. /*
  8936. Function: Command_TradeCancel()
  8937. Purpose : Cancels item/coin trade between players
  8938. Params :
  8939. Dev :
  8940. Example :
  8941. */
  8942. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8943. {
  8944. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8945. Trade* trade = client->GetPlayer()->trade;
  8946. if (trade) {
  8947. trade->CancelTrade(client->GetPlayer());
  8948. safe_delete(trade);
  8949. }
  8950. else
  8951. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8952. }
  8953. /*
  8954. Function: Command_TradeSetCoin()
  8955. Purpose : Sets coin trade between players
  8956. Params :
  8957. Dev :
  8958. Example :
  8959. */
  8960. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8961. {
  8962. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8963. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8964. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8965. }
  8966. /*
  8967. Function: Command_TradeAddCoin()
  8968. Purpose : Adds coin to trade between players
  8969. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8970. Dev :
  8971. Example :
  8972. */
  8973. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  8974. {
  8975. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  8976. Trade* trade = client->GetPlayer()->trade;
  8977. if (trade) {
  8978. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8979. int32 amount = atoi(sep->arg[0]);
  8980. int64 val = 0;
  8981. switch (handler) {
  8982. case COMMAND_ADD_TRADE_COPPER:
  8983. {
  8984. val = amount;
  8985. trade->AddCoinToTrade(client->GetPlayer(), val);
  8986. break;
  8987. }
  8988. case COMMAND_ADD_TRADE_SILVER:
  8989. {
  8990. val = amount * 100;
  8991. trade->AddCoinToTrade(client->GetPlayer(), val);
  8992. break;
  8993. }
  8994. case COMMAND_ADD_TRADE_GOLD:
  8995. {
  8996. val = amount * 10000;
  8997. trade->AddCoinToTrade(client->GetPlayer(), val);
  8998. break;
  8999. }
  9000. case COMMAND_ADD_TRADE_PLAT:
  9001. {
  9002. val = amount * 1000000;
  9003. trade->AddCoinToTrade(client->GetPlayer(), val);
  9004. break;
  9005. }
  9006. default:
  9007. {
  9008. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  9009. break;
  9010. }
  9011. }
  9012. }
  9013. else
  9014. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  9015. }
  9016. else
  9017. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9018. }
  9019. /*
  9020. Function: Command_TradeRemoveCoin()
  9021. Purpose : Removes coin from trade between players
  9022. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  9023. Dev :
  9024. Example :
  9025. */
  9026. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  9027. {
  9028. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  9029. Trade* trade = client->GetPlayer()->trade;
  9030. if (trade) {
  9031. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9032. int32 amount = atoi(sep->arg[0]);
  9033. int64 val = 0;
  9034. switch (handler) {
  9035. case COMMAND_REMOVE_TRADE_COPPER:
  9036. {
  9037. val = amount;
  9038. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9039. break;
  9040. }
  9041. case COMMAND_REMOVE_TRADE_SILVER:
  9042. {
  9043. val = amount * 100;
  9044. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9045. break;
  9046. }
  9047. case COMMAND_REMOVE_TRADE_GOLD:
  9048. {
  9049. val = amount * 10000;
  9050. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9051. break;
  9052. }
  9053. case COMMAND_REMOVE_TRADE_PLAT:
  9054. {
  9055. val = amount * 1000000;
  9056. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9057. break;
  9058. }
  9059. default:
  9060. {
  9061. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  9062. break;
  9063. }
  9064. }
  9065. }
  9066. else
  9067. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  9068. }
  9069. else
  9070. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9071. }
  9072. /*
  9073. Function: Command_TradeAddItem()
  9074. Purpose : Adds item to trade between players
  9075. Params :
  9076. Dev :
  9077. Example :
  9078. */
  9079. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  9080. {
  9081. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  9082. /*
  9083. arg[0] = item index
  9084. arg[1] = slot
  9085. arg[2] = quantity
  9086. */
  9087. if (!client->GetPlayer()->trade) {
  9088. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  9089. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9090. return;
  9091. }
  9092. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  9093. Item* item = 0;
  9094. int32 index = atoi(sep->arg[0]);
  9095. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  9096. if (item) {
  9097. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  9098. if (result == 1)
  9099. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  9100. else if (result == 2)
  9101. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  9102. else if (result == 3)
  9103. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  9104. else if (result == 255)
  9105. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  9106. }
  9107. else {
  9108. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  9109. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  9110. }
  9111. }
  9112. else
  9113. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9114. }
  9115. /*
  9116. Function: Command_TradeRemoveItem()
  9117. Purpose : Removes item from trade between players
  9118. Params :
  9119. Dev :
  9120. Example :
  9121. */
  9122. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  9123. {
  9124. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  9125. /*
  9126. arg[0] = trade window slot
  9127. */
  9128. Trade* trade = client->GetPlayer()->trade;
  9129. if (trade) {
  9130. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9131. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  9132. }
  9133. else
  9134. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9135. }
  9136. else
  9137. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9138. }
  9139. void Commands::Command_TryOn(Client* client, Seperator* sep)
  9140. {
  9141. Item *item = 0;
  9142. sint32 crc;
  9143. if (sep) {
  9144. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  9145. if (client->GetVersion() < 1096) {
  9146. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  9147. {
  9148. item = master_item_list.GetItem(atoul(sep->arg[1]));
  9149. crc = atol(sep->arg[2]);
  9150. }
  9151. }
  9152. else {
  9153. // From the broker and links in chat
  9154. if (strcmp(sep->arg[0], "crc") == 0) {
  9155. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  9156. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9157. crc = atol(sep->arg[3]);
  9158. }
  9159. }
  9160. // From inventory
  9161. if (strcmp(sep->arg[0], "dbid") == 0) {
  9162. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  9163. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9164. crc = atol(sep->arg[4]);
  9165. }
  9166. }
  9167. }
  9168. if (item)
  9169. client->ShowDressingRoom(item, crc);
  9170. }
  9171. }
  9172. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  9173. const char *channel_name, *password = NULL;
  9174. if (sep == NULL || !sep->IsSet(0)) {
  9175. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  9176. return;
  9177. }
  9178. channel_name = sep->arg[0];
  9179. if (sep->IsSet(1))
  9180. password = sep->arg[1];
  9181. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  9182. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  9183. return;
  9184. }
  9185. if (chat.IsInChannel(client, channel_name)) {
  9186. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  9187. return;
  9188. }
  9189. if (chat.HasPassword(channel_name)) {
  9190. if (password == NULL) {
  9191. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  9192. return;
  9193. }
  9194. if (!chat.PasswordMatches(channel_name, password)) {
  9195. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  9196. return;
  9197. }
  9198. }
  9199. if (!chat.JoinChannel(client, channel_name))
  9200. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  9201. }
  9202. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  9203. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  9204. Command_JoinChannel(client, sep);
  9205. }
  9206. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  9207. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  9208. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  9209. PrintSep(sep, "tellchannel");
  9210. return;
  9211. }
  9212. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  9213. }
  9214. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  9215. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9216. if (sep->IsSet(0)) {
  9217. if (atoi(sep->arg[0]) == 1) {
  9218. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  9219. if (packet2) {
  9220. packet2->setDataByName("spell_type", 2);
  9221. packet2->setDataByName("spell_id", 8308);
  9222. packet2->setDataByName("spell_name", "Sprint");
  9223. packet2->setDataByName("add_silently", 0);
  9224. packet2->setDataByName("tier", 1);
  9225. packet2->setDataByName("blah1", 1);
  9226. packet2->setDataByName("blah2", 1);
  9227. EQ2Packet* outapp = packet2->serialize();
  9228. DumpPacket(outapp);
  9229. client->QueuePacket(outapp);
  9230. safe_delete(packet2);
  9231. }
  9232. }
  9233. else if (atoi(sep->arg[0]) == 2) {
  9234. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  9235. if (packet2) {
  9236. packet2->setDataByName("guild_name", "Test");
  9237. packet2->setDataByName("guild_motd", "Test MOTD");
  9238. packet2->setDataByName("guild_id", 1234);
  9239. packet2->setDataByName("guild_level", 1);
  9240. packet2->setDataByName("unknown", 2);
  9241. packet2->setDataByName("unknown2", 3);
  9242. packet2->setDataByName("exp_current", 1);
  9243. packet2->setDataByName("exp_to_next_level", 4);
  9244. EQ2Packet* outapp = packet2->serialize();
  9245. DumpPacket(outapp);
  9246. client->QueuePacket(outapp);
  9247. safe_delete(packet2);
  9248. }
  9249. }
  9250. else if (atoi(sep->arg[0]) == 3) {
  9251. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  9252. if (packet2) {
  9253. packet2->setDataByName("guild_id", 1234);
  9254. packet2->setDataByName("character_id", 1);
  9255. packet2->setDataByName("account_id", 2);
  9256. packet2->setDataByName("guild_level", 1);
  9257. packet2->setDataByName("name", "Test");
  9258. packet2->setDataByName("unknown2", 0);
  9259. packet2->setDataByName("unknown3", 1);
  9260. packet2->setDataByName("adventure_class", 6);
  9261. packet2->setDataByName("adventure_level", 7);
  9262. packet2->setDataByName("tradeskill_class", 4);
  9263. packet2->setDataByName("tradeskill_level", 5);
  9264. packet2->setDataByName("rank", 0);
  9265. packet2->setDataByName("member_flags", 2);
  9266. packet2->setDataByName("join_date", 1591112273);
  9267. packet2->setDataByName("guild_status", 2);
  9268. packet2->setDataByName("last_login", 1591132273);
  9269. packet2->setDataByName("recruiter_id", 1);
  9270. packet2->setDataByName("points", 2345);
  9271. packet2->setDataByName("note", "note");
  9272. packet2->setMediumStringByName("officer_note", "O note");
  9273. packet2->setMediumStringByName("zone", "Blah");
  9274. EQ2Packet* outapp = packet2->serialize();
  9275. DumpPacket(outapp);
  9276. client->QueuePacket(outapp);
  9277. safe_delete(packet2);
  9278. }
  9279. }
  9280. else if (atoi(sep->arg[0]) == 5) {
  9281. int16 offset = atoi(sep->arg[1]);
  9282. int32 value1 = atol(sep->arg[2]);
  9283. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  9284. client->QueuePacket(outapp);
  9285. }
  9286. else if (atoi(sep->arg[0]) == 6) {
  9287. Spawn* spawn = client->GetPlayer()->GetTarget();
  9288. if (!spawn)
  9289. spawn = client->GetPlayer();
  9290. else if (spawn->IsEntity())
  9291. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  9292. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  9293. }
  9294. else if (atoi(sep->arg[0]) == 7) {
  9295. int32 id = 0;
  9296. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  9297. if (spawn) {
  9298. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9299. spawn->SetY(client->GetPlayer()->GetY(), false);
  9300. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9301. float heading = client->GetPlayer()->GetHeading() + 180;
  9302. if (heading > 360)
  9303. heading -= 360;
  9304. spawn->SetLevel(5);
  9305. spawn->SetAdventureClass(4);
  9306. spawn->SetHeading(heading, false);
  9307. spawn->SetSpawnOrigX(spawn->GetX());
  9308. spawn->SetSpawnOrigY(spawn->GetY());
  9309. spawn->SetSpawnOrigZ(spawn->GetZ());
  9310. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9311. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9312. spawn->appearance.targetable = 1;
  9313. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9314. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9315. spawn->SetHP(spawn->GetTotalHP());
  9316. }
  9317. if (spawn->GetTotalPower() == 0) {
  9318. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9319. spawn->SetPower(spawn->GetTotalPower());
  9320. }
  9321. int16 offset = atoi(sep->arg[1]);
  9322. int32 value1 = atol(sep->arg[2]);
  9323. sprintf(spawn->appearance.name, "Offset %i", offset);
  9324. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  9325. DumpPacket(ret);
  9326. client->QueuePacket(ret);
  9327. }
  9328. }
  9329. else if (atoi(sep->arg[0]) == 8) {
  9330. int32 id = atoi(sep->arg[1]);
  9331. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  9332. if (spawn) {
  9333. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9334. spawn->SetY(client->GetPlayer()->GetY(), false);
  9335. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9336. float heading = client->GetPlayer()->GetHeading() + 180;
  9337. if (heading > 360)
  9338. heading -= 360;
  9339. spawn->SetLevel(5);
  9340. spawn->SetAdventureClass(4);
  9341. spawn->SetHeading(heading, false);
  9342. spawn->SetSpawnOrigX(spawn->GetX());
  9343. spawn->SetSpawnOrigY(spawn->GetY());
  9344. spawn->SetSpawnOrigZ(spawn->GetZ());
  9345. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9346. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9347. spawn->appearance.targetable = 1;
  9348. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9349. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9350. spawn->SetHP(spawn->GetTotalHP());
  9351. }
  9352. if (spawn->GetTotalPower() == 0) {
  9353. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9354. spawn->SetPower(spawn->GetTotalPower());
  9355. }
  9356. int16 offset = atoi(sep->arg[2]);
  9357. int16 offset2 = atoi(sep->arg[3]);
  9358. int32 value1 = atol(sep->arg[4]);
  9359. int16 offset3 = 0;
  9360. int16 offset4 = 0;
  9361. int32 value2 = 0;
  9362. if (sep->IsSet(7)) {
  9363. offset3 = atoi(sep->arg[5]);
  9364. offset4 = atoi(sep->arg[6]);
  9365. value2 = atol(sep->arg[7]);
  9366. }
  9367. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  9368. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  9369. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  9370. DumpPacket(ret);
  9371. client->QueuePacket(ret);
  9372. }
  9373. }
  9374. else if (atoi(sep->arg[0]) == 9) {
  9375. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  9376. if (packet2) {
  9377. packet2->setArrayLengthByName("location_count", 1);
  9378. packet2->setArrayDataByName("location_ida", 1234);
  9379. packet2->setArrayDataByName("unknown2a", 3);
  9380. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  9381. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  9382. packet2->setArrayDataByName("distance", 134);
  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]) == 10) {
  9410. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  9411. if (packet2) {
  9412. packet2->setArrayLengthByName("num_quests", 1);
  9413. packet2->setArrayDataByName("active", 1);
  9414. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  9415. packet2->setArrayDataByName("quest_type", "Hallmark");
  9416. packet2->setArrayDataByName("quest_zone", "Hallmark");
  9417. packet2->setArrayDataByName("journal_updated", 1);
  9418. packet2->setArrayDataByName("quest_id", 524);
  9419. packet2->setArrayDataByName("day", 19);
  9420. packet2->setArrayDataByName("month", 6);
  9421. packet2->setArrayDataByName("year", 20);
  9422. packet2->setArrayDataByName("level", 2);
  9423. packet2->setArrayDataByName("encounter_level", 4);
  9424. packet2->setArrayDataByName("difficulty", 3);
  9425. packet2->setArrayDataByName("visible", 1);
  9426. packet2->setDataByName("visible_quest_id", 524);
  9427. packet2->setDataByName("player_crc", 2900677088);
  9428. packet2->setDataByName("player_name", "LethalEncounter");
  9429. EQ2Packet* app = packet2->serialize();
  9430. if (sep->IsSet(2)) {
  9431. int8 offset = atoi(sep->arg[1]);
  9432. uchar* ptr2 = app->pBuffer;
  9433. ptr2 += offset;
  9434. if (sep->IsNumber(2)) {
  9435. int32 value1 = atol(sep->arg[2]);
  9436. if (value1 > 0xFFFF)
  9437. memcpy(ptr2, (uchar*)&value1, 4);
  9438. else if (value1 > 0xFF)
  9439. memcpy(ptr2, (uchar*)&value1, 2);
  9440. else
  9441. memcpy(ptr2, (uchar*)&value1, 1);
  9442. }
  9443. else {
  9444. int8 len = strlen(sep->arg[2]);
  9445. memcpy(ptr2, (uchar*)&len, 1);
  9446. ptr2 += 1;
  9447. memcpy(ptr2, sep->arg[2], len);
  9448. }
  9449. }
  9450. DumpPacket(app);
  9451. client->QueuePacket(app);
  9452. safe_delete(packet2);
  9453. }
  9454. }
  9455. else if (atoi(sep->arg[0]) == 11) {
  9456. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9457. if (packet2) {
  9458. packet2->setDataByName("quest_id", 524);
  9459. packet2->setDataByName("player_crc", 2900677088);
  9460. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  9461. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  9462. packet2->setDataByName("type", "Hallmark");
  9463. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9464. packet2->setDataByName("day", 19);
  9465. packet2->setDataByName("month", 6);
  9466. packet2->setDataByName("year", 20);
  9467. packet2->setDataByName("level", 1);
  9468. packet2->setDataByName("encounter_level", 1);
  9469. packet2->setDataByName("difficulty", 1);
  9470. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9471. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9472. //packet2->setDataByName("timer_duration", 300);
  9473. //packet2->setDataByName("timer_running", 1);
  9474. packet2->setArrayLengthByName("task_groups_completed", 9);
  9475. packet2->setArrayLengthByName("num_task_groups", 10);
  9476. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  9477. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  9478. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  9479. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  9480. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  9481. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  9482. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  9483. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  9484. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  9485. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  9486. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  9487. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9488. packet2->setSubArrayLengthByName("num_updates", 1);
  9489. packet2->setSubArrayDataByName("update_currentval", 0);
  9490. packet2->setSubArrayDataByName("update_maxval", 1);
  9491. packet2->setSubArrayDataByName("icon", 11);
  9492. */
  9493. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9494. packet2->setDataByName("journal_updated", 1);
  9495. packet2->setDataByName("bullets", 1);
  9496. EQ2Packet* app = packet2->serialize();
  9497. if (sep->IsSet(2)) {
  9498. int16 offset = atoi(sep->arg[1]);
  9499. uchar* ptr2 = app->pBuffer;
  9500. ptr2 += offset;
  9501. if (sep->IsNumber(2)) {
  9502. int32 value1 = atol(sep->arg[2]);
  9503. if (value1 > 0xFFFF)
  9504. memcpy(ptr2, (uchar*)&value1, 4);
  9505. else if (value1 > 0xFF)
  9506. memcpy(ptr2, (uchar*)&value1, 2);
  9507. else
  9508. memcpy(ptr2, (uchar*)&value1, 1);
  9509. }
  9510. else {
  9511. int16 len = strlen(sep->arg[2]);
  9512. memcpy(ptr2, (uchar*)&len, 2);
  9513. ptr2 += 2;
  9514. memcpy(ptr2, sep->arg[2], len);
  9515. }
  9516. }
  9517. DumpPacket(app);
  9518. client->QueuePacket(app);
  9519. safe_delete(packet2);
  9520. }
  9521. }
  9522. else if (atoi(sep->arg[0]) == 12) {
  9523. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9524. if (packet2) {
  9525. packet2->setDataByName("quest_id", 524);
  9526. packet2->setDataByName("player_crc", 2900677088);
  9527. packet2->setDataByName("name", "Archetype Selection");
  9528. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  9529. packet2->setDataByName("type", "Hallmark");
  9530. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9531. packet2->setDataByName("day", 19);
  9532. packet2->setDataByName("month", 6);
  9533. packet2->setDataByName("year", 20);
  9534. packet2->setDataByName("level", 2);
  9535. packet2->setDataByName("encounter_level", 4);
  9536. packet2->setDataByName("difficulty", 3);
  9537. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9538. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9539. packet2->setDataByName("timer_duration", 300);
  9540. packet2->setDataByName("timer_running", 1);
  9541. packet2->setArrayLengthByName("task_groups_completed", 0);
  9542. packet2->setArrayLengthByName("num_task_groups", 1);
  9543. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  9544. packet2->setSubArrayLengthByName("num_tasks", 1);
  9545. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9546. packet2->setSubArrayLengthByName("num_updates", 1);
  9547. packet2->setSubArrayDataByName("update_currentval", 0);
  9548. packet2->setSubArrayDataByName("update_maxval", 1);
  9549. packet2->setSubArrayDataByName("icon", 11);
  9550. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9551. packet2->setDataByName("journal_updated", 1);
  9552. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9553. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9554. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  9555. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9556. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9557. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9558. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9559. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  9560. Item* item = master_item_list.GetItem(152755);
  9561. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9562. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9563. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  9564. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  9565. packet2->setSubstructDataByName("item", "icon", 0xe7);
  9566. packet2->setSubstructDataByName("item", "tier", 4);
  9567. packet2->setSubstructDataByName("item", "flags", 0x60);
  9568. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  9569. packet2->setSubstructDataByName("item", "stat_type", 1);
  9570. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  9571. packet2->setSubstructDataByName("item", "value", 3);
  9572. packet2->setSubstructDataByName("item", "condition", 100);
  9573. packet2->setSubstructDataByName("item", "weight", 1);
  9574. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  9575. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  9576. packet2->setSubstructDataByName("item", "skill_min", 1);
  9577. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  9578. packet2->setSubstructDataByName("item", "adventure_class", 1);
  9579. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  9580. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  9581. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  9582. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  9583. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  9584. packet2->setSubstructDataByName("item", "level", 0x1e);
  9585. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  9586. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  9587. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  9588. //packet2->PrintPacket();
  9589. EQ2Packet* app = packet2->serialize();
  9590. if (sep->IsSet(2)) {
  9591. int16 offset = atoi(sep->arg[1]);
  9592. uchar* ptr2 = app->pBuffer;
  9593. ptr2 += offset;
  9594. if (sep->IsNumber(2)) {
  9595. int32 value1 = atol(sep->arg[2]);
  9596. if (value1 > 0xFFFF)
  9597. memcpy(ptr2, (uchar*)&value1, 4);
  9598. else if (value1 > 0xFF)
  9599. memcpy(ptr2, (uchar*)&value1, 2);
  9600. else
  9601. memcpy(ptr2, (uchar*)&value1, 1);
  9602. }
  9603. else {
  9604. int16 len = strlen(sep->arg[2]);
  9605. memcpy(ptr2, (uchar*)&len, 2);
  9606. ptr2 += 2;
  9607. memcpy(ptr2, sep->arg[2], len);
  9608. }
  9609. }
  9610. DumpPacket(app);
  9611. client->QueuePacket(app);
  9612. safe_delete(packet2);
  9613. }
  9614. }
  9615. else if (atoi(sep->arg[0]) == 13) {
  9616. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  9617. if (packet2 && sep->IsSet(7)) {
  9618. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  9619. char blah[128];
  9620. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  9621. packet2->setDataByName("text", blah);
  9622. packet2->setDataByName("message_type", sep->arg[3]);
  9623. packet2->setDataByName("size", atof(sep->arg[4]));
  9624. packet2->setDataByName("red", atoi(sep->arg[5]));
  9625. packet2->setDataByName("green", atoi(sep->arg[6]));
  9626. packet2->setDataByName("blue", atoi(sep->arg[7]));
  9627. EQ2Packet* app = packet2->serialize();
  9628. DumpPacket(app);
  9629. client->QueuePacket(app);
  9630. safe_delete(packet2);
  9631. }
  9632. }
  9633. else if (atoi(sep->arg[0]) == 14) {
  9634. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  9635. if (packet2 && sep->IsSet(3)) {
  9636. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  9637. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  9638. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  9639. 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.");
  9640. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  9641. packet2->setArrayLengthByName("num_goals", 1);
  9642. //packet2->setArrayDataByName("goal_text", )
  9643. packet2->setSubArrayLengthByName("num_tasks", 1);
  9644. packet2->setSubArrayDataByName("task_text", "continue");
  9645. packet2->setDataByName("complete_sound", "click");
  9646. packet2->setDataByName("signal", "introduction");
  9647. packet2->setDataByName("voice_key1", 0xcda65173);
  9648. packet2->setDataByName("voice_key2", 0x984bfc6d);
  9649. EQ2Packet* app = packet2->serialize();
  9650. DumpPacket(app);
  9651. client->QueuePacket(app);
  9652. safe_delete(packet2);
  9653. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  9654. packet2->setDataByName("window", "MainHUD.StartMenu");
  9655. packet2->setDataByName("show", 1);
  9656. app = packet2->serialize();
  9657. DumpPacket(app);
  9658. client->QueuePacket(app);
  9659. safe_delete(packet2);
  9660. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  9661. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  9662. packet2->setDataByName("flash_seconds", 10);
  9663. app = packet2->serialize();
  9664. DumpPacket(app);
  9665. client->QueuePacket(app);
  9666. safe_delete(packet2);
  9667. }
  9668. }
  9669. else if (atoi(sep->arg[0]) == 15) {
  9670. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9671. if (packet2) {
  9672. packet2->setArrayLengthByName("loot_count", 1);
  9673. packet2->setArrayDataByName("name", "Test");
  9674. packet2->setArrayDataByName("item_id", 1234);
  9675. packet2->setArrayDataByName("count", 1);
  9676. packet2->setArrayDataByName("icon", 258);
  9677. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  9678. Spawn* spawn = client->GetPlayer()->GetTarget();
  9679. if (spawn)
  9680. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9681. packet2->setDataByName("unknown3", 1);
  9682. packet2->setDataByName("unknown4", 1);
  9683. packet2->setDataByName("unknown5", 60);
  9684. EQ2Packet* app = packet2->serialize();
  9685. DumpPacket(app);
  9686. client->QueuePacket(app);
  9687. safe_delete(packet2);
  9688. }
  9689. }
  9690. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  9691. char blah[32];
  9692. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  9693. client->SimpleMessage(atoi(sep->arg[1]), blah);
  9694. }
  9695. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  9696. if (sep->IsSet(2)) {
  9697. int16 offset = atoi(sep->arg[1]);
  9698. if (sep->IsNumber(2)) {
  9699. int32 value1 = atol(sep->arg[2]);
  9700. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  9701. cout << "Sent" << endl;
  9702. }
  9703. }
  9704. }
  9705. else if (atoi(sep->arg[0]) == 18) {
  9706. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  9707. if (packet2) {
  9708. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9709. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9710. packet2->setSubstructDataByName("reward_data", "max_coin", 0);
  9711. packet2->setSubstructDataByName("reward_data", "text", "Some custom text to mess things up?");
  9712. //packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9713. //packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9714. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9715. Item* item = new Item(master_item_list.GetItem(9357));
  9716. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9717. //item->stack_count = 20;
  9718. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9719. safe_delete(item);
  9720. /*item = new Item(master_item_list.GetItem(36685));
  9721. item->stack_count = 20;
  9722. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9723. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  9724. safe_delete(item);
  9725. item = master_item_list.GetItem(1414);
  9726. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9727. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  9728. item = master_item_list.GetItem(75057);
  9729. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9730. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);*/
  9731. EQ2Packet* app = packet2->serialize();
  9732. if (sep->IsSet(2)) {
  9733. int16 offset = atoi(sep->arg[1]);
  9734. uchar* ptr2 = app->pBuffer;
  9735. ptr2 += offset;
  9736. if (sep->IsNumber(2)) {
  9737. int32 value1 = atol(sep->arg[2]);
  9738. if (value1 > 0xFFFF)
  9739. memcpy(ptr2, (uchar*)&value1, 4);
  9740. else if (value1 > 0xFF)
  9741. memcpy(ptr2, (uchar*)&value1, 2);
  9742. else
  9743. memcpy(ptr2, (uchar*)&value1, 1);
  9744. }
  9745. else {
  9746. int16 len = strlen(sep->arg[2]);
  9747. memcpy(ptr2, (uchar*)&len, 2);
  9748. ptr2 += 2;
  9749. memcpy(ptr2, sep->arg[2], len);
  9750. }
  9751. }
  9752. DumpPacket(app);
  9753. client->QueuePacket(app);
  9754. safe_delete(packet2);
  9755. }
  9756. }
  9757. else if (atoi(sep->arg[0]) == 19) {
  9758. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9759. Spawn* spawn = client->GetPlayer()->GetTarget();
  9760. if (packet2 && spawn) {
  9761. Item* item = master_item_list.GetItem(130053);
  9762. packet2->setArrayLengthByName("loot_count", 1);
  9763. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9764. packet2->setArrayDataByName("unknown2", 1);
  9765. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9766. packet2->setDataByName("display", 1);
  9767. packet2->setDataByName("unknown2b", 1);
  9768. packet2->setDataByName("unknown3", 0x3c);
  9769. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9770. packet2->PrintPacket();
  9771. EQ2Packet* app = packet2->serialize();
  9772. if (sep->IsSet(2)) {
  9773. int16 offset = atoi(sep->arg[1]);
  9774. int16 offset2 = 0;
  9775. int32 value1 = 0;
  9776. if (sep->IsSet(3)) {
  9777. offset2 = atoi(sep->arg[2]);
  9778. value1 = atol(sep->arg[3]);
  9779. }
  9780. else
  9781. value1 = atol(sep->arg[2]);
  9782. int16 offset3 = 0;
  9783. int16 offset4 = 0;
  9784. int32 value2 = 0;
  9785. if (sep->IsSet(6)) {
  9786. offset3 = atoi(sep->arg[4]);
  9787. offset4 = atoi(sep->arg[5]);
  9788. value2 = atol(sep->arg[6]);
  9789. }
  9790. offset--;
  9791. if (offset2 > 0 && offset2 >= offset) {
  9792. offset2--;
  9793. uchar* ptr2 = app->pBuffer;
  9794. ptr2 += offset;
  9795. for (int i = offset; i <= offset2; i++) {
  9796. if (value1 > 0xFFFF) {
  9797. memcpy(ptr2, (uchar*)&value1, 4);
  9798. i += 3;
  9799. ptr2 += 3;
  9800. }
  9801. else if (value1 > 0xFF) {
  9802. memcpy(ptr2, (uchar*)&value1, 2);
  9803. i++;
  9804. ptr2++;
  9805. }
  9806. else
  9807. memcpy(ptr2, (uchar*)&value1, 1);
  9808. ptr2++;
  9809. }
  9810. }
  9811. if (offset4 > 0 && offset4 >= offset3) {
  9812. offset3--;
  9813. offset4--;
  9814. uchar* ptr2 = app->pBuffer;
  9815. ptr2 += offset3;
  9816. for (int i = offset3; i <= offset4; i++) {
  9817. if (value2 > 0xFFFF) {
  9818. memcpy(ptr2, (uchar*)&value2, 4);
  9819. i += 3;
  9820. ptr2 += 3;
  9821. }
  9822. else if (value2 > 0xFF) {
  9823. memcpy(ptr2, (uchar*)&value2, 2);
  9824. i++;
  9825. ptr2++;
  9826. }
  9827. else
  9828. memcpy(ptr2, (uchar*)&value2, 1);
  9829. ptr2++;
  9830. }
  9831. }
  9832. }
  9833. DumpPacket(app);
  9834. client->QueuePacket(app);
  9835. safe_delete(packet2);
  9836. }
  9837. }
  9838. else if (atoi(sep->arg[0]) == 21) {
  9839. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9840. if (packet2) {
  9841. packet2->setDataByName("unknown0", 255);
  9842. packet2->setDataByName("reward", "New Quest");
  9843. packet2->setDataByName("title", "Title");
  9844. packet2->setDataByName("description", "description");
  9845. packet2->setDataByName("quest_difficulty", 3);
  9846. packet2->setDataByName("unknown1", 5);
  9847. packet2->setDataByName("level", 3);
  9848. packet2->setDataByName("coin", 150);
  9849. packet2->setDataByName("status_points", 5);
  9850. packet2->setDataByName("exp_bonus", 10);
  9851. packet2->setArrayLengthByName("num_rewards", 1);
  9852. Item* item = new Item(master_item_list.GetItem(36212));
  9853. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9854. item->stack_count = 20;
  9855. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9856. safe_delete(item);
  9857. char accept[35] = { 0 };
  9858. char decline[35] = { 0 };
  9859. sprintf(accept, "q_accept_pending_quest %u", 0);
  9860. sprintf(decline, "q_deny_pending_quest %u", 0);
  9861. packet2->setDataByName("accept_command", accept);
  9862. packet2->setDataByName("decline_command", decline);
  9863. EQ2Packet* app = packet2->serialize();
  9864. if (sep->IsSet(2)) {
  9865. int16 offset = atoi(sep->arg[1]);
  9866. uchar* ptr2 = app->pBuffer;
  9867. ptr2 += offset;
  9868. if (sep->IsNumber(2)) {
  9869. int32 value1 = atol(sep->arg[2]);
  9870. if (value1 > 0xFFFF)
  9871. memcpy(ptr2, (uchar*)&value1, 4);
  9872. else if (value1 > 0xFF)
  9873. memcpy(ptr2, (uchar*)&value1, 2);
  9874. else
  9875. memcpy(ptr2, (uchar*)&value1, 1);
  9876. }
  9877. DumpPacket(app);
  9878. client->QueuePacket(app);
  9879. safe_delete(packet2);
  9880. }
  9881. }
  9882. }
  9883. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9884. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9885. if (packet2) {
  9886. packet2->setDataByName("unknown0", 255);
  9887. packet2->setDataByName("reward", "New Quest");
  9888. packet2->setDataByName("title", "Title");
  9889. packet2->setDataByName("description", "description");
  9890. packet2->setDataByName("quest_difficulty", 3);
  9891. packet2->setDataByName("unknown1", 5);
  9892. packet2->setDataByName("level", 3);
  9893. packet2->setDataByName("coin", 150);
  9894. packet2->setDataByName("status_points", 5);
  9895. packet2->setDataByName("exp_bonus", 10);
  9896. packet2->setArrayLengthByName("num_rewards", 1);
  9897. Item* item = new Item(master_item_list.GetItem(36212));
  9898. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9899. item->stack_count = 20;
  9900. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9901. safe_delete(item);
  9902. char accept[35] = { 0 };
  9903. char decline[35] = { 0 };
  9904. sprintf(accept, "q_accept_pending_quest %u", 0);
  9905. sprintf(decline, "q_deny_pending_quest %u", 0);
  9906. packet2->setDataByName("accept_command", accept);
  9907. packet2->setDataByName("decline_command", decline);
  9908. EQ2Packet* app = packet2->serialize();
  9909. if (sep->IsSet(2)) {
  9910. int16 offset = atoi(sep->arg[1]);
  9911. uchar* ptr2 = app->pBuffer;
  9912. ptr2 += offset;
  9913. if (sep->IsNumber(2)) {
  9914. int32 value1 = atol(sep->arg[2]);
  9915. if (value1 > 0xFFFF)
  9916. memcpy(ptr2, (uchar*)&value1, 4);
  9917. else if (value1 > 0xFF)
  9918. memcpy(ptr2, (uchar*)&value1, 2);
  9919. else
  9920. memcpy(ptr2, (uchar*)&value1, 1);
  9921. }
  9922. else {
  9923. int8 len = strlen(sep->arg[2]);
  9924. memcpy(ptr2, (uchar*)&len, 1);
  9925. ptr2 += 1;
  9926. memcpy(ptr2, sep->arg[2], len);
  9927. }
  9928. }
  9929. DumpPacket(app);
  9930. client->QueuePacket(app);
  9931. safe_delete(packet2);
  9932. }
  9933. }
  9934. else if (atoi(sep->arg[0]) == 23) {
  9935. if (client->GetPlayer()->GetTarget()) {
  9936. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9937. if (packet2) {
  9938. Spawn* target = client->GetPlayer()->GetTarget();
  9939. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9940. Item* item = new Item(master_item_list.GetItem(12565));
  9941. int8 i = 0;
  9942. packet2->setArrayLengthByName("num_items", 1);
  9943. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9944. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9945. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9946. packet2->setArrayDataByName("icon", item->details.icon, i);
  9947. int8 tmp_level = 0;
  9948. if (item->generic_info.adventure_default_level > 0)
  9949. tmp_level = item->generic_info.adventure_default_level;
  9950. else
  9951. tmp_level = item->generic_info.tradeskill_default_level;
  9952. packet2->setArrayDataByName("level", tmp_level, i);
  9953. packet2->setArrayDataByName("tier", item->details.tier, i);
  9954. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9955. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9956. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9957. item_difficulty = ARROW_COLOR_WHITE;
  9958. item_difficulty -= 6;
  9959. if (item_difficulty < 0)
  9960. item_difficulty *= -1;
  9961. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9962. packet2->setArrayDataByName("quantity", 2, i);
  9963. packet2->setArrayDataByName("unknown5", 255, i);
  9964. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9965. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9966. packet2->setDataByName("type", 2);
  9967. EQ2Packet* app = packet2->serialize();
  9968. if (sep->IsSet(2)) {
  9969. int16 offset = atoi(sep->arg[1]);
  9970. uchar* ptr2 = app->pBuffer;
  9971. ptr2 += offset;
  9972. if (sep->IsNumber(2)) {
  9973. int32 value1 = atol(sep->arg[2]);
  9974. if (value1 > 0xFFFF)
  9975. memcpy(ptr2, (uchar*)&value1, 4);
  9976. else if (value1 > 0xFF)
  9977. memcpy(ptr2, (uchar*)&value1, 2);
  9978. else
  9979. memcpy(ptr2, (uchar*)&value1, 1);
  9980. }
  9981. else {
  9982. int8 len = strlen(sep->arg[2]);
  9983. memcpy(ptr2, (uchar*)&len, 1);
  9984. ptr2 += 1;
  9985. memcpy(ptr2, sep->arg[2], len);
  9986. }
  9987. }
  9988. DumpPacket(app);
  9989. client->QueuePacket(app);
  9990. safe_delete(packet2);
  9991. }
  9992. }
  9993. }
  9994. else if (atoi(sep->arg[0]) == 24) {
  9995. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  9996. if (packet2) {
  9997. if (sep->IsSet(2)) {
  9998. packet2->setDataByName("event_name", sep->arg[1]);
  9999. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  10000. EQ2Packet* app = packet2->serialize();
  10001. DumpPacket(app);
  10002. client->QueuePacket(app);
  10003. safe_delete(packet2);
  10004. }
  10005. }
  10006. }
  10007. else if (atoi(sep->arg[0]) == 25) {
  10008. if (sep->IsSet(1)) {
  10009. Widget* new_spawn = new Widget();
  10010. int32 id = atoul(sep->arg[1]);
  10011. new_spawn->SetWidgetID(id);
  10012. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  10013. client->QueuePacket(ret);
  10014. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  10015. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  10016. if (packet2) {
  10017. packet2->setDataByName("spawn_index", index);
  10018. packet2->setDataByName("delete", 1);
  10019. EQ2Packet* app = packet2->serialize();
  10020. client->QueuePacket(app);
  10021. safe_delete(packet2);
  10022. }
  10023. }
  10024. }
  10025. else if (atoi(sep->arg[0]) == 26) {
  10026. if (sep->IsSet(4)) {
  10027. Widget* new_spawn = new Widget();
  10028. int32 id = atoul(sep->arg[1]);
  10029. new_spawn->SetWidgetID(id);
  10030. float x = atof(sep->arg[2]);
  10031. float y = atof(sep->arg[3]);
  10032. float z = atof(sep->arg[4]);
  10033. new_spawn->SetLocation(client->GetPlayer()->GetLocation());
  10034. new_spawn->SetWidgetX(x);
  10035. new_spawn->SetWidgetY(y);
  10036. new_spawn->SetWidgetZ(z);
  10037. new_spawn->SetX(x);
  10038. new_spawn->SetY(y);
  10039. new_spawn->SetZ(z);
  10040. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  10041. client->QueuePacket(ret);
  10042. }
  10043. }
  10044. else if (atoi(sep->arg[0]) == 27) {
  10045. Spawn* target = client->GetPlayer()->GetTarget();
  10046. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  10047. if (packet2 && target && sep->IsSet(4)) {
  10048. 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] : "");
  10049. }
  10050. }
  10051. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  10052. World::newValue = strtoull(sep->arg[1], NULL, 0);
  10053. }
  10054. else if (atoi(sep->arg[0]) == 29 && sep->IsNumber(1)) {
  10055. client->SendHearCast(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10056. strtoull(sep->arg[1], NULL, 0), atoul(sep->arg[2]));
  10057. }
  10058. else if (atoi(sep->arg[0]) == 30) {
  10059. PacketStruct* packet = configReader.getStruct("WS_UpdateSkillBook", client->GetVersion());
  10060. if (packet) {
  10061. packet->setDataByName("unknown", World::newValue);
  10062. EQ2Packet* outapp = packet->serialize();
  10063. DumpPacket(outapp);
  10064. client->QueuePacket(outapp);
  10065. safe_delete(packet);
  10066. }
  10067. }
  10068. else if (atoi(sep->arg[0]) == 31) {
  10069. client->SendRecipeList();
  10070. }
  10071. else if (atoi(sep->arg[0]) == 32 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10072. if(client->GetVersion() <= 546) {
  10073. int32 param = atoul(sep->arg[1]);
  10074. int32 paramvalue = atoul(sep->arg[2]);
  10075. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param %u param value %u", param, paramvalue);
  10076. ClientPacketFunctions::SendServerControlFlagsClassic(client, param, paramvalue);
  10077. }
  10078. else if(sep->IsNumber(3)) {
  10079. int8 param1 = atoul(sep->arg[1]);
  10080. int8 param2 = atoul(sep->arg[2]);
  10081. int8 paramval = atoul(sep->arg[3]);
  10082. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param1 %u param2 %u param value %u", param1, param2, paramval);
  10083. ClientPacketFunctions::SendServerControlFlags(client, param1, param2, paramval);
  10084. }
  10085. }
  10086. else if (atoi(sep->arg[0]) == 33 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10087. client->GetCurrentZone()->SendHealPacket(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10088. atoul(sep->arg[1]), atoul(sep->arg[2]), "TestSpell");
  10089. }
  10090. }
  10091. else {
  10092. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  10093. if (packet2) {
  10094. packet2->setSubstructDataByName("info_header", "show_name", 1);
  10095. packet2->setSubstructDataByName("info_header", "unknown", 7);
  10096. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  10097. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  10098. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  10099. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  10100. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  10101. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  10102. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  10103. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  10104. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  10105. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  10106. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  10107. packet2->setSubstructDataByName("info_header", "packettype", 3);
  10108. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  10109. packet2->setSubstructDataByName("spell_info", "level", 19);
  10110. packet2->setSubstructDataByName("spell_info", "tier", 1);
  10111. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  10112. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  10113. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  10114. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  10115. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  10116. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  10117. packet2->setSubstructDataByName("spell_info", "recast", 280);
  10118. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  10119. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  10120. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  10121. packet2->setSubstructDataByName("spell_info", "quality", 3);
  10122. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  10123. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  10124. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  10125. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  10126. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  10127. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  10128. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  10129. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  10130. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  10131. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  10132. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  10133. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  10134. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  10135. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  10136. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  10137. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  10138. packet2->setArrayDataByName("reagent", "Alcohol");
  10139. packet2->setArrayDataByName("consumed", "123");
  10140. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  10141. packet2->setSubstructDataByName("spell_info", "id", 8308);
  10142. packet2->setSubstructDataByName("spell_info", "icon", 303);
  10143. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  10144. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  10145. packet2->setSubstructDataByName("spell_info", "type", 2);
  10146. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  10147. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  10148. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  10149. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  10150. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  10151. EQ2Packet* outapp = packet2->serialize();
  10152. DumpPacket(outapp);
  10153. client->QueuePacket(outapp);
  10154. safe_delete(packet2);
  10155. }
  10156. }
  10157. return;
  10158. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  10159. if (!p) return;
  10160. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10161. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  10162. //}
  10163. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10164. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  10165. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  10166. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  10167. if (packet) {
  10168. client->QueuePacket(packet->serialize());
  10169. safe_delete(packet);
  10170. }
  10171. }*/
  10172. /*if (client->GetCurrentZone()->Grid != nullptr) {
  10173. int32 numFaces = 0;
  10174. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  10175. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  10176. map<int32, vector<Face*> >::iterator itr;
  10177. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  10178. numFaces += (*itr).second.size();
  10179. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  10180. }*/
  10181. //uchar blah[] = {
  10182. // 1208 - OP_EQUpdateStoreCmd
  10183. // /*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
  10184. // /*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
  10185. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  10186. // /*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
  10187. /*};
  10188. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10189. int8 val = 0;
  10190. int16 pos = 0;
  10191. int idx = 0;
  10192. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  10193. pos = atoi(sep2->arg[idx]);
  10194. val = atoi(sep2->arg[idx+1]);
  10195. memset(blah+pos, val, 1);
  10196. idx+=2;
  10197. }
  10198. DumpPacket(blah, sizeof(blah));
  10199. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  10200. if (client->GetPlayer()->GetTarget()) {
  10201. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  10202. if (packet) {
  10203. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10204. packet->setDataByName("size", 0);
  10205. packet->setDataByName("unknown2", 0);
  10206. EQ2Packet* app = packet->serialize();
  10207. client->QueuePacket(app);
  10208. safe_delete(packet);
  10209. }
  10210. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  10211. if (set_pov) {
  10212. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10213. EQ2Packet* app_pov = set_pov->serialize();
  10214. client->QueuePacket(app_pov);
  10215. safe_delete(set_pov);
  10216. }
  10217. }
  10218. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10219. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  10220. if (packet) {
  10221. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  10222. packet->setDataByName("Type", atoi(sep2->arg[0]));
  10223. else
  10224. packet->setDataByName("Type", 2);
  10225. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  10226. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  10227. else
  10228. packet->setDataByName("race_id", 0);
  10229. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  10230. packet->setDataByName("gender", atoi(sep2->arg[2]));
  10231. else
  10232. packet->setDataByName("gender", 2);
  10233. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  10234. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  10235. else
  10236. packet->setDataByName("unknown", 0, 0);
  10237. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  10238. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  10239. else
  10240. packet->setDataByName("unknown", 0, 1);
  10241. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  10242. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  10243. else
  10244. packet->setDataByName("unknown", 0, 2);
  10245. client->QueuePacket(packet->serialize());
  10246. }
  10247. safe_delete(packet);
  10248. safe_delete(sep2);
  10249. }
  10250. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  10251. const char *channel_name;
  10252. if (sep == NULL || !sep->IsSet(0)) {
  10253. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  10254. PrintSep(sep);
  10255. return;
  10256. }
  10257. channel_name = sep->arg[0];
  10258. if (!chat.IsInChannel(client, channel_name))
  10259. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  10260. else if (!chat.LeaveChannel(client, channel_name))
  10261. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  10262. }
  10263. /*
  10264. Function:
  10265. Purpose :
  10266. Params :
  10267. Dev :
  10268. Example :
  10269. */
  10270. void Commands::Command_WeaponStats(Client* client)
  10271. {
  10272. Player* player = client->GetPlayer();
  10273. Spawn* target = player->GetTarget();
  10274. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10275. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10276. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10277. const char* charName = player->GetName();
  10278. if(target && target->IsEntity()) {
  10279. primary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10280. secondary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10281. ranged = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10282. charName = target->GetName();
  10283. }
  10284. else {
  10285. target = nullptr;
  10286. }
  10287. client->Message(0, "WeaponStats for %s", charName);
  10288. client->SimpleMessage(0, "Primary:");
  10289. if (primary) {
  10290. client->Message(0, "Name: %s", primary->name.c_str());
  10291. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  10292. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10293. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10294. client->Message(0, "Actual Delay: %u", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay());
  10295. client->Message(0, "Proc Percent: %d%%", 0);
  10296. client->Message(0, "Procs Per Minute: %d", 0);
  10297. }
  10298. else {
  10299. client->SimpleMessage(0, "Name: fist");
  10300. client->Message(0, "Base Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10301. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10302. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10303. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10304. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay() * 0.1);
  10305. client->Message(0, "Proc Percent: %d%%", 0);
  10306. client->Message(0, "Procs Per Minute: %d", 0);
  10307. }
  10308. client->SimpleMessage(0, " ");
  10309. client->SimpleMessage(0, " ");
  10310. if (secondary) {
  10311. client->SimpleMessage(0, "Secondary:");
  10312. client->Message(0, "Name: %s", secondary->name.c_str());
  10313. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  10314. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetSecondaryWeaponMinDamage() : player->GetSecondaryWeaponMinDamage(),
  10315. target ? ((Entity*)target)->GetSecondaryWeaponMaxDamage() : player->GetSecondaryWeaponMaxDamage());
  10316. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetSecondaryWeaponDelay() : player->GetSecondaryWeaponDelay() * 0.1);
  10317. client->Message(0, "Proc Percent: %d%%", 0);
  10318. client->Message(0, "Procs Per Minute: %d", 0);
  10319. client->SimpleMessage(0, " ");
  10320. client->SimpleMessage(0, " ");
  10321. }
  10322. client->SimpleMessage(0, "Ranged:");
  10323. if (ranged) {
  10324. client->Message(0, "Name: %s", ranged->name.c_str());
  10325. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  10326. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetRangedWeaponMinDamage() : player->GetRangedWeaponMinDamage(),
  10327. target ? ((Entity*)target)->GetRangedWeaponMaxDamage() : player->GetRangedWeaponMaxDamage());
  10328. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetRangeWeaponDelay() : player->GetRangeWeaponDelay() * 0.1);
  10329. client->Message(0, "Proc Percent: %d%%", 0);
  10330. client->Message(0, "Procs Per Minute: %d", 0);
  10331. }
  10332. else
  10333. client->SimpleMessage(0, "None");
  10334. }
  10335. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  10336. const char *channel_name;
  10337. if (sep == NULL || !sep->IsSet(0)) {
  10338. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  10339. return;
  10340. }
  10341. channel_name = sep->arg[0];
  10342. if (!chat.ChannelExists(channel_name))
  10343. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  10344. else
  10345. chat.SendChannelUserList(client, channel_name);
  10346. }
  10347. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  10348. {
  10349. ZoneServer* zone = 0;
  10350. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  10351. if (zone_id > 0)
  10352. {
  10353. zone = zone_list.Get(zone_id, false, false, false);
  10354. if (zone)
  10355. {
  10356. zone->SetSafeX(client->GetPlayer()->GetX());
  10357. zone->SetSafeY(client->GetPlayer()->GetY());
  10358. zone->SetSafeZ(client->GetPlayer()->GetZ());
  10359. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  10360. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  10361. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  10362. else
  10363. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  10364. }
  10365. }
  10366. }
  10367. /*
  10368. Function:
  10369. Purpose :
  10370. Params :
  10371. Dev :
  10372. Example :
  10373. */
  10374. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  10375. {
  10376. ZoneInfo* zone_info = new ZoneInfo;
  10377. if (sep && sep->arg[0])
  10378. {
  10379. if (sep->IsNumber(0))
  10380. zone_info->id = atoi(sep->arg[0]);
  10381. else
  10382. zone_info->id = database.GetZoneID(sep->arg[0]);
  10383. if (zone_info->id > 0)
  10384. {
  10385. database.LoadZoneInfo(zone_info);
  10386. 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);
  10387. 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);
  10388. 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);
  10389. 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);
  10390. 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);
  10391. 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);
  10392. 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);
  10393. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  10394. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  10395. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  10396. }
  10397. else
  10398. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10399. }
  10400. else
  10401. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  10402. safe_delete(zone_info);
  10403. }
  10404. /*
  10405. Function:
  10406. Purpose :
  10407. Params :
  10408. Dev :
  10409. Example :
  10410. */
  10411. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  10412. {
  10413. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  10414. {
  10415. ZoneServer* zone = 0;
  10416. int32 zone_id = 0;
  10417. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  10418. {
  10419. zone_id = atoi(sep->arg[0]);
  10420. zone = zone_list.Get(atoi(sep->arg[0]), false, false, false);
  10421. }
  10422. else
  10423. {
  10424. zone_id = database.GetZoneID(sep->arg[0]);
  10425. if (zone_id > 0)
  10426. zone = zone_list.Get(sep->arg[0], false, false, false);
  10427. }
  10428. if (zone_id > 0)
  10429. {
  10430. if (zone_set_values.count(string(sep->arg[1])) > 0)
  10431. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  10432. else
  10433. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  10434. }
  10435. else
  10436. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10437. }
  10438. else
  10439. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  10440. }
  10441. void Commands::Command_Rain(Client* client, Seperator* sep) {
  10442. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10443. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  10444. return;
  10445. }
  10446. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  10447. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  10448. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  10449. }
  10450. void Commands::Command_Wind(Client* client, Seperator* sep) {
  10451. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10452. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  10453. return;
  10454. }
  10455. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  10456. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  10457. }
  10458. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  10459. Spawn* spawn = client->GetPlayer()->GetTarget();
  10460. if(client->GetVersion() <= 546) {
  10461. sell = false; // doesn't support in the same way as AoM just open the normal buy/sell window
  10462. }
  10463. if(spawn) {
  10464. client->SetMerchantTransaction(spawn);
  10465. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  10466. client->SendHailCommand(spawn);
  10467. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  10468. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  10469. client->SendBuyMerchantList(sell);
  10470. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  10471. client->SendSellMerchantList(sell);
  10472. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  10473. client->SendBuyBackList(sell);
  10474. if(client->GetVersion() > 546) {
  10475. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10476. if (packet) {
  10477. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  10478. packet->setDataByName("type", 16);
  10479. EQ2Packet* outapp = packet->serialize();
  10480. if (outapp)
  10481. client->QueuePacket(outapp);
  10482. safe_delete(packet);
  10483. }
  10484. }
  10485. }
  10486. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  10487. client->SendRepairList();
  10488. }
  10489. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  10490. }
  10491. void Commands::Command_Weather(Client* client, Seperator* sep)
  10492. {
  10493. //PrintSep(sep, "Weather");
  10494. if( sep && sep->arg[0] )
  10495. {
  10496. ZoneServer* zsZone = client->GetCurrentZone();
  10497. const char* value = sep->arg[0];
  10498. // process single-param commands first
  10499. if( strncasecmp(value, "details", strlen(value)) == 0 )
  10500. {
  10501. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  10502. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  10503. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  10504. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  10505. }
  10506. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  10507. {
  10508. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10509. zsZone->ProcessWeather();
  10510. }
  10511. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  10512. {
  10513. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  10514. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  10515. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  10516. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  10517. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  10518. zsZone->SetWeatherPattern(1);
  10519. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  10520. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  10521. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  10522. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10523. zsZone->ProcessWeather();
  10524. }
  10525. // process commands with params
  10526. if( sep->arg[1] )
  10527. {
  10528. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  10529. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  10530. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  10531. zsZone->SetWeatherType(atoi(sep->arg[1]));
  10532. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  10533. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  10534. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  10535. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  10536. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  10537. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  10538. }
  10539. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  10540. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  10541. zsZone->SetRain(zsZone->GetCurrentWeather());
  10542. }
  10543. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  10544. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  10545. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  10546. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  10547. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10548. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  10549. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10550. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  10551. }
  10552. }
  10553. else
  10554. {
  10555. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  10556. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  10557. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  10558. return;
  10559. }
  10560. }
  10561. void Commands::Command_Select(Client* client, Seperator* sep) {
  10562. if (sep && sep->arg[1]) {
  10563. Spawn* spawn = client->GetPlayer()->GetTarget();
  10564. if (spawn && strlen(sep->arg[1]) > 0)
  10565. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  10566. }
  10567. }
  10568. /*
  10569. Function: Command_ConsumeFood()
  10570. Purpose : Consume Food/Drink and apply mods
  10571. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  10572. Dev : Zcoretri
  10573. Example : /consume_food 22
  10574. */
  10575. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  10576. if (sep && sep->arg[0] && sep->IsNumber(0))
  10577. {
  10578. Player* player = client->GetPlayer();
  10579. int8 slot = atoi(sep->arg[0]);
  10580. if (client->GetVersion() <= 283) {
  10581. slot += 4;
  10582. }
  10583. else if (client->GetVersion() <= 546) {
  10584. slot += 2;
  10585. }
  10586. Item* item = player->GetEquipmentList()->GetItem(slot);
  10587. if(client->CheckConsumptionAllowed(slot)) {
  10588. client->ConsumeFoodDrink(item, slot);
  10589. }
  10590. }
  10591. }
  10592. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  10593. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10594. if (atoi(sep->arg[0]) == 1) {
  10595. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  10596. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  10597. client->GetPlayer()->SetCharSheetChanged(true);
  10598. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  10599. }
  10600. else {
  10601. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  10602. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  10603. client->GetPlayer()->SetCharSheetChanged(true);
  10604. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  10605. }
  10606. }
  10607. else
  10608. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  10609. }
  10610. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  10611. {
  10612. if(sep)
  10613. {
  10614. string data;
  10615. if(sep->arg[0]){
  10616. data = string(sep->arg[0]);
  10617. }
  10618. for(int i=1;i<sep->GetMaxArgNum();i++){
  10619. if(sep->arg[i])
  10620. data.append(" ").append(sep->arg[i]);
  10621. }
  10622. if(!sep->IsSet(7)){
  10623. data.append(" ").append(std::to_string(client->GetVersion())).append("\a");
  10624. }
  10625. const char* target_name = 0;
  10626. int32 spawn_id = 0;
  10627. if(client->GetPlayer()->GetTarget())
  10628. {
  10629. target_name = client->GetPlayer()->GetTarget()->GetName();
  10630. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10631. }
  10632. else
  10633. target_name = "N/A";
  10634. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  10635. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  10636. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  10637. else
  10638. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  10639. }
  10640. }
  10641. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  10642. PrintSep(sep, "Command_Attune_Inv");
  10643. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10644. // Get the item index from the first parameter
  10645. int16 index = atoi(sep->arg[0]);
  10646. // Check to see if this is a valid item index for the player, if not exit out of the function
  10647. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  10648. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  10649. return;
  10650. }
  10651. // Get the item
  10652. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  10653. if(item) {
  10654. // Valid item lets check to make sure this item is attunable, if not return out
  10655. if (!item->CheckFlag(ATTUNEABLE)) {
  10656. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  10657. return;
  10658. }
  10659. // Remove the attunable flag
  10660. item->generic_info.item_flags -= ATTUNEABLE;
  10661. // Set the attuned flag
  10662. item->generic_info.item_flags += ATTUNED;
  10663. // Flag this item for saving
  10664. item->save_needed = true;
  10665. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  10666. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  10667. EQ2Packet* outapp = 0;
  10668. for (int32 i=0;i<packets.size();i++) {
  10669. outapp = packets[i];
  10670. if(outapp)
  10671. client->QueuePacket(outapp);
  10672. }
  10673. }
  10674. }
  10675. }
  10676. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  10677. PrintSep(sep, "Command_Reset_Zone_Timer");
  10678. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10679. int32 db_id = atoul(sep->arg[0]);
  10680. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  10681. if (data) {
  10682. // TODO: add a check to timers to ensure it can be reset
  10683. // Delete the character from the instance
  10684. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  10685. data->instance_id = 0;
  10686. // Update the success time and set to 0 so the player can enter it again
  10687. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  10688. data->last_success_timestamp = 0;
  10689. }
  10690. }*/
  10691. }
  10692. void Commands::Command_Player(Client* client, Seperator* sep) {
  10693. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  10694. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  10695. }
  10696. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  10697. // /player coins add 10
  10698. // /player coins add plat 10
  10699. Player* player = client->GetPlayer();
  10700. Client* targetClient = client;
  10701. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  10702. player = (Player*)player->GetTarget();
  10703. targetClient = player->GetClient();
  10704. }
  10705. if (sep && sep->arg[0] && sep->arg[1]) {
  10706. const char* action = sep->arg[0];
  10707. int64 value = 0;
  10708. if (strncasecmp(action, "add", strlen(action)) == 0) {
  10709. if (sep->IsNumber(1)) {
  10710. value = atoi64(sep->arg[1]);
  10711. player->AddCoins(value);
  10712. if (client->GetPlayer() == player)
  10713. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10714. else {
  10715. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10716. if(targetClient) {
  10717. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10718. }
  10719. }
  10720. return;
  10721. }
  10722. else if (sep->arg[2] && sep->IsNumber(2)) {
  10723. const char* type = sep->arg[1];
  10724. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  10725. value = atoi64(sep->arg[2]);
  10726. }
  10727. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  10728. value = atoi64(sep->arg[2]) * 100;
  10729. }
  10730. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  10731. value = atoi64(sep->arg[2]) * 10000;
  10732. }
  10733. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  10734. value = atoi64(sep->arg[2]) * 1000000;
  10735. }
  10736. player->AddCoins(value);
  10737. if (client->GetPlayer() == player)
  10738. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10739. else {
  10740. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10741. if(targetClient) {
  10742. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10743. }
  10744. }
  10745. return;
  10746. }
  10747. }
  10748. }
  10749. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  10750. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  10751. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  10752. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  10753. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  10754. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  10755. }
  10756. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  10757. PrintSep(sep, "ACHIEVEMENT_ADD");
  10758. if (sep && sep->IsSet(0)) {
  10759. int32 spell_id = atoul(sep->arg[1]);
  10760. int8 spell_tier = 0;
  10761. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10762. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10763. // addspellbookentry here
  10764. if (spell_tier >= data->maxRank) {
  10765. return;
  10766. }
  10767. if (!spell_tier) {
  10768. spell_tier = 1;
  10769. }
  10770. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10771. {
  10772. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10773. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10774. client->GetPlayer()->UnlockSpell(spell);
  10775. client->SendSpellUpdate(spell);
  10776. }
  10777. else
  10778. {
  10779. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  10780. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10781. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10782. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10783. client->GetPlayer()->UnlockSpell(spell);
  10784. client->SendSpellUpdate(spell);
  10785. }
  10786. // cast spell here
  10787. if (!spell_tier)
  10788. spell_tier = 1;
  10789. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10790. if (spell) {
  10791. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10792. }
  10793. }
  10794. else {
  10795. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10796. }
  10797. master_aa_list.DisplayAA(client, 0, 0);
  10798. }
  10799. void Commands::Command_Editor(Client* client, Seperator* sep) {
  10800. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  10801. if (packet) {
  10802. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  10803. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  10804. char command[255];
  10805. url = "browser " + url;
  10806. int32 spawn_id = 0;
  10807. int32 zone_id = 0;
  10808. string type;
  10809. if (client->GetCurrentZone())
  10810. zone_id = client->GetCurrentZone()->GetZoneID();
  10811. if (client->GetPlayer()->GetTarget()) {
  10812. Spawn* target = client->GetPlayer()->GetTarget();
  10813. if (target->IsWidget())
  10814. type = "widgets";
  10815. else if (target->IsSign())
  10816. type = "signs";
  10817. else if (target->IsObject())
  10818. type = "objects";
  10819. else if (target->IsNPC())
  10820. type = "npcs";
  10821. else if (target->IsGroundSpawn())
  10822. type = "ground";
  10823. else
  10824. type = "spawn";
  10825. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10826. }
  10827. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  10828. packet->setDataByName("accept_command", command);
  10829. }
  10830. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  10831. char command[255];
  10832. url = "browser " + url;
  10833. if (client->GetPlayer()->GetTarget())
  10834. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  10835. packet->setDataByName("accept_command", command);
  10836. }
  10837. else {
  10838. string command = "browser " + url;
  10839. packet->setDataByName("accept_command", command.c_str());
  10840. }
  10841. packet->setDataByName("text", "Open the web editor?");
  10842. packet->setDataByName("accept_text", "Open");
  10843. packet->setDataByName("cancel_text", "Cancel");
  10844. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  10845. packet->setDataByName("unknown2", 50);
  10846. packet->setDataByName("unknown4", 1);
  10847. client->QueuePacket(packet->serialize());
  10848. safe_delete(packet);
  10849. }
  10850. }
  10851. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  10852. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10853. return;
  10854. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10855. if(client->GetCurrentRez()->active)
  10856. client->AcceptResurrection();
  10857. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10858. }
  10859. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  10860. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10861. return;
  10862. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10863. if(client->GetCurrentRez()->active)
  10864. client->GetCurrentRez()->should_delete = true;
  10865. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10866. }
  10867. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  10868. PrintSep(sep, "Switch_AA_Profile");
  10869. if (sep && sep->IsSet(0)) {
  10870. string type = sep->arg[0];
  10871. int8 newtemplate = atoul(sep->arg[1]);
  10872. master_aa_list.DisplayAA(client, newtemplate, 1);
  10873. }
  10874. }
  10875. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  10876. PrintSep(sep, "Get_AA_Xml");
  10877. if (sep && sep->IsSet(0)) {
  10878. string tabnum = sep->arg[0];
  10879. string spellid = sep->arg[1];
  10880. }
  10881. }
  10882. void Commands::Add_AA(Client* client, Seperator* sep) {
  10883. PrintSep(sep, "Add_AA");
  10884. if (sep && sep->IsSet(0)) {
  10885. int32 spell_id = atoul(sep->arg[1]);
  10886. int8 spell_tier = 0;
  10887. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10888. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10889. // addspellbookentry here
  10890. if(!data) {
  10891. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  10892. return;
  10893. }
  10894. if (spell_tier >= data->maxRank) {
  10895. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  10896. return;
  10897. }
  10898. if (!spell_tier) {
  10899. spell_tier = 1;
  10900. }
  10901. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10902. {
  10903. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10904. if(spell)
  10905. {
  10906. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10907. client->GetPlayer()->UnlockSpell(spell);
  10908. client->SendSpellUpdate(spell);
  10909. }
  10910. }
  10911. else
  10912. {
  10913. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10914. if(spell)
  10915. {
  10916. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10917. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10918. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10919. client->GetPlayer()->UnlockSpell(spell);
  10920. client->SendSpellUpdate(spell);
  10921. }
  10922. }
  10923. // cast spell here
  10924. if (!spell_tier)
  10925. spell_tier = 1;
  10926. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10927. if (spell) {
  10928. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10929. }
  10930. }
  10931. else {
  10932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10933. }
  10934. master_aa_list.DisplayAA(client, 0, 0);
  10935. }
  10936. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  10937. PrintSep(sep, "Commit_AA_Profile");
  10938. if (sep && sep->IsSet(0)) {
  10939. }
  10940. }
  10941. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  10942. PrintSep(sep, "Begin_AA_Profile");
  10943. if (sep && sep->IsSet(0)) {
  10944. master_aa_list.DisplayAA(client, 100, 2);
  10945. }
  10946. }
  10947. void Commands::Back_AA(Client* client, Seperator* sep) {
  10948. if (sep && sep->IsSet(0)) {
  10949. PrintSep(sep, "Back_AA");
  10950. }
  10951. }
  10952. void Commands::Remove_AA(Client* client, Seperator* sep) {
  10953. if (sep && sep->IsSet(0)) {
  10954. PrintSep(sep, "Remove_AA");
  10955. }
  10956. }
  10957. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  10958. MasterAAList master_aa_list;
  10959. PrintSep(sep, "Cancel_AA_Profile");
  10960. master_aa_list.DisplayAA(client, 0, 0);
  10961. }
  10962. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  10963. if (sep && sep->IsSet(0)) {
  10964. PrintSep(sep, "Save_AA_Profile");
  10965. }
  10966. }
  10967. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  10968. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  10969. if (!sep->IsNumber(0)) return;
  10970. int32 request_id = atoul(sep->arg[0]);
  10971. if (!sep->IsNumber(1)) return;
  10972. sint32 item_id = atoi(sep->arg[1]);
  10973. if (client->IsCurrentTransmuteID(request_id)) {
  10974. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  10975. }
  10976. else if (client->IsCurrentTransmuteID(item_id)) {
  10977. if (!sep->IsSet(2)) return;
  10978. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  10979. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  10980. }
  10981. }
  10982. }
  10983. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  10984. if(sep)
  10985. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  10986. }
  10987. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  10988. if(sep && sep->arg[0][0] && sep->arg[1][0])
  10989. {
  10990. char* name = sep->arg[0];
  10991. char* zoneName = sep->arg[1];
  10992. char query[256];
  10993. 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);
  10994. if (database.RunQuery(query, strnlen(query, 256)))
  10995. {
  10996. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  10997. }
  10998. else
  10999. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  11000. }
  11001. }
  11002. void Commands::Command_Mood(Client* client, Seperator* sep) {
  11003. Player* player = client->GetPlayer();
  11004. if( sep && sep->arg[0] )
  11005. {
  11006. const char* value = sep->arg[0];
  11007. InfoStruct* info = player->GetInfoStruct();
  11008. int32 cid = client->GetCharacterID();
  11009. char* characterName = database.GetCharacterName(cid);
  11010. char tmp[1024]; // our emote string "xyz appears zyx"
  11011. //char properties vals
  11012. char* pname = "mood";
  11013. char* pval; // mood value
  11014. bool pt; //used to verify return from DB.
  11015. //This should never be seen.
  11016. sprintf(tmp, " ");
  11017. if( strncasecmp(value, "angry", strlen(value)) == 0 )
  11018. {
  11019. sprintf(tmp, "%s appears angry", characterName);
  11020. pval = "11852";
  11021. player->SetMoodState(11852, 1);
  11022. info->set_mood(11852);
  11023. pt = database.insertCharacterProperty(client, pname, pval);
  11024. }
  11025. else if( strncasecmp(value, "afraid", strlen(value)) == 0 )
  11026. {
  11027. sprintf(tmp, "%s appears afraid", characterName);
  11028. pval = "11851";
  11029. player->SetMoodState(11851, 1);
  11030. info->set_mood(11851);
  11031. pt = database.insertCharacterProperty(client, pname, pval);
  11032. }
  11033. else if( strncasecmp(value, "happy", strlen(value)) == 0 )
  11034. {
  11035. sprintf(tmp, "%s appears happy", characterName);
  11036. pval = "11854";
  11037. player->SetMoodState(11854, 1);
  11038. info->set_mood(11854);
  11039. pt = database.insertCharacterProperty(client, pname, pval);
  11040. }
  11041. else if( strncasecmp(value, "sad", strlen(value)) == 0 ) {
  11042. sprintf(tmp, "%s appears sad", characterName);
  11043. pval = "11856";
  11044. player->SetMoodState(11856, 1);
  11045. info->set_mood(11856);
  11046. pt = database.insertCharacterProperty(client, pname, pval);
  11047. }
  11048. else if( strncasecmp(value, "tired", strlen(value)) == 0 )
  11049. {
  11050. sprintf(tmp, "%s appears tired", characterName);
  11051. pval = "11857";
  11052. player->SetMoodState(11857, 1);
  11053. info->set_mood(11857);
  11054. pt = database.insertCharacterProperty(client, pname, pval);
  11055. }
  11056. else if( strncasecmp(value, "none", strlen(value)) == 0 )
  11057. {
  11058. //using 11855 mood_idle for none, I assume thats what its for?
  11059. pval = "11855";
  11060. player->SetMoodState(11855, 1);
  11061. info->set_mood(11855);
  11062. pt = database.insertCharacterProperty(client, pname, pval);
  11063. //return since we have nothing left to do. No emote for none.
  11064. return;
  11065. }else{
  11066. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11067. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11068. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11069. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11070. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11071. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11072. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11073. return;
  11074. }
  11075. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, tmp);
  11076. return;
  11077. }
  11078. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11079. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11080. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11081. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11082. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11083. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11084. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11085. return;
  11086. }
  11087. /*
  11088. Function: Command_CancelEffect()
  11089. Purpose : Cancels (good) effect spells
  11090. Example : /cancel_effect spell_id - would cancel the spell with the <spell_id> value in spell effects list
  11091. */
  11092. void Commands::Command_CancelEffect(Client* client, Seperator* sep)
  11093. {
  11094. if (sep && sep->arg[0] && sep->IsNumber(0))
  11095. {
  11096. int32 spell_id = atoul(sep->arg[0]);
  11097. SpellEffects* effect = client->GetPlayer()->GetSpellEffect(spell_id);
  11098. if(!effect || effect->spell->spell->GetSpellData()->det_type) {
  11099. return;
  11100. }
  11101. MaintainedEffects* meffect = effect->caster->GetMaintainedSpell(spell_id);
  11102. if (!meffect || !meffect->spell || !meffect->spell->caster || !meffect->spell->caster->GetZone() ||
  11103. !meffect->spell->caster->GetZone()->GetSpellProcess()->DeleteCasterSpell(meffect->spell, "canceled", false, client->GetPlayer()))
  11104. client->Message(CHANNEL_COLOR_RED, "The spell effect could not be cancelled.");
  11105. }
  11106. }
  11107. /*
  11108. Function: Command_CurePlayer()
  11109. Purpose : Identifies spell to cast for cure based on type
  11110. Example : /cureplayer ??
  11111. https://eq2.fandom.com/wiki/Update:58
  11112. New command /cureplayer [playername|group or raid position][trauma|arcane|noxious|elemental|curse] optional [spell|potion]
  11113. Example: /cureplayer g0 noxious spell
  11114. Will attempt to cure yourself of a noxious detriment with only spells and without using potions (even if you have them).
  11115. Example: /cureplayer r4 noxious
  11116. Will attempt to cure the character in raid slot 4 of a noxious detriment using a spell or potion (whichever is available).
  11117. */
  11118. void Commands::Command_CurePlayer(Client* client, Seperator* sep)
  11119. {
  11120. Entity* target = nullptr;
  11121. bool use_spells = true;
  11122. bool use_potions = true;
  11123. if (sep && sep->arg[0] && sep->arg[1]) {
  11124. if(sep->arg[2]) {
  11125. std::string type(sep->arg[2]);
  11126. boost::algorithm::to_lower(type);
  11127. if(type == "potion")
  11128. use_spells = false;
  11129. else if(type == "spell")
  11130. use_potions = false;
  11131. }
  11132. if(strlen(sep->arg[0]) > 1 && isdigit(sep->arg[0][1])) {
  11133. int32 mapped_position = (int32)(sep->arg[0][1]) - 48;
  11134. // TODO: RAID Support ('r' argument)
  11135. if(sep->arg[0][0] == 'g' && !mapped_position) {
  11136. target = (Entity*)client->GetPlayer();
  11137. }
  11138. else {
  11139. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11140. if (gmi && gmi->group_id) {
  11141. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11142. if(group) {
  11143. target = group->GetGroupMemberByPosition(client->GetPlayer(), mapped_position);
  11144. }
  11145. }
  11146. }
  11147. }
  11148. else {
  11149. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11150. if(target_client && target_client->GetPlayer() && target_client->GetPlayer()->GetZone() == client->GetPlayer()->GetZone()) {
  11151. target = (Entity*)target_client->GetPlayer();
  11152. }
  11153. }
  11154. ItemEffectType type = EFFECT_CURE_TYPE_ALL;
  11155. bool successful_spell = false;
  11156. bool successful_potion = false;
  11157. if(target) {
  11158. SpellBookEntry* entry = nullptr;
  11159. std::string str(sep->arg[1]);
  11160. boost::algorithm::to_lower(str);
  11161. if(str == "arcane") {
  11162. type = EFFECT_CURE_TYPE_ARCANE;
  11163. // cure arcane spell missing in DB?
  11164. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()) {
  11165. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()); // cure noxious
  11166. }
  11167. }
  11168. else if(str == "trauma") {
  11169. type = EFFECT_CURE_TYPE_TRAUMA;
  11170. // cure trauma spell missing in DB?
  11171. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()) {
  11172. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()); // cure noxious
  11173. }
  11174. }
  11175. else if(str == "noxious") {
  11176. type = EFFECT_CURE_TYPE_NOXIOUS;
  11177. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()) {
  11178. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()); // cure noxious
  11179. }
  11180. }
  11181. else if(str == "curse") {
  11182. type = EFFECT_CURE_TYPE_CURSE;
  11183. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()) {
  11184. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()); // cure curse
  11185. }
  11186. }
  11187. else if(str == "magic") {
  11188. type = EFFECT_CURE_TYPE_MAGIC;
  11189. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()) {
  11190. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()); // cure magic
  11191. }
  11192. }
  11193. if(use_spells) {
  11194. // check if any of the specific cure types are available, if not then check the base cures
  11195. if(!entry && rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()) {
  11196. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()); // cure
  11197. }
  11198. if(entry && entry->spell_id) {
  11199. Spell* spell = master_spell_list.GetSpell(entry->spell_id, entry->tier);
  11200. target->GetZone()->ProcessSpell(spell, (Entity*)client->GetPlayer(), target, true, false);
  11201. successful_spell = true;
  11202. }
  11203. }
  11204. }
  11205. if(!successful_spell && use_potions && target && type != NO_EFFECT_TYPE) {
  11206. vector<Item*>* potential_items = client->GetItemsByEffectType(type, EFFECT_CURE_TYPE_ALL);
  11207. if (potential_items && potential_items->size() > 0) {
  11208. vector<Item*>::iterator itr;
  11209. for (itr = potential_items->begin(); itr != potential_items->end(); itr++)
  11210. {
  11211. Item* item = *itr;
  11212. if(client->UseItem(item, target)) {
  11213. successful_potion = true;
  11214. break;
  11215. }
  11216. }
  11217. }
  11218. safe_delete(potential_items);
  11219. }
  11220. }
  11221. }
  11222. /*
  11223. Function: Command_ShareQuest()
  11224. Purpose : Share quest with the group
  11225. Example : /share_quest [quest_id]
  11226. */
  11227. void Commands::Command_ShareQuest(Client* client, Seperator* sep)
  11228. {
  11229. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  11230. int32 quest_id = atoul(sep->arg[0]);
  11231. bool hasQuest = client->GetPlayer()->HasAnyQuest(quest_id);
  11232. if(hasQuest) {
  11233. Quest* quest = master_quest_list.GetQuest(quest_id, false);
  11234. if(quest) {
  11235. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11236. if (gmi && gmi->group_id) {
  11237. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11238. if (group) {
  11239. group->ShareQuestWithGroup(client, quest);
  11240. }
  11241. }
  11242. }
  11243. }
  11244. else {
  11245. client->SimpleMessage(CHANNEL_COLOR_RED, "Cannot find quest.");
  11246. }
  11247. }
  11248. }
  11249. /*
  11250. Function: Command_Yell()
  11251. Purpose : Yell to break an encounter
  11252. Example : /yell
  11253. * Uses self target, encounter target or no target
  11254. */
  11255. void Commands::Command_Yell(Client* client, Seperator* sep) {
  11256. Entity* player = (Entity*)client->GetPlayer();
  11257. Spawn* res = nullptr;
  11258. Spawn* prev = nullptr;
  11259. bool cycleAll = false;
  11260. if (player->GetTarget() == player) {
  11261. cycleAll = true; // self target breaks all encounters
  11262. }
  11263. else if (player->GetTarget()) {
  11264. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11265. }
  11266. if (res && !client->GetPlayer()->IsEngagedBySpawnID(res->GetID()))
  11267. return;
  11268. bool groupPermissionYell = true;
  11269. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11270. // If the player has a group and has a target
  11271. if (gmi) {
  11272. deque<GroupMemberInfo*>::iterator itr;
  11273. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  11274. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11275. if (group && !group->GetGroupOptions()->default_yell && !gmi->leader) { // default_yell_method = 0 means leader only
  11276. groupPermissionYell = false;
  11277. }
  11278. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  11279. }
  11280. if (!groupPermissionYell) {
  11281. LogWrite(COMMAND__ERROR, 0, "Command", "%s permission to yell denied due to group yell method set to leader only", client->GetPlayer()->GetName());
  11282. return;
  11283. }
  11284. bool alreadyYelled = false;
  11285. do {
  11286. if (!res && player->IsEngagedInEncounter(&res)) { // no target is set, dis-engage top of hated by list
  11287. }
  11288. if (!res || prev == res) {
  11289. return;
  11290. }
  11291. if (res->IsNPC() && ((NPC*)res)->Brain()) {
  11292. if (!alreadyYelled) {
  11293. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You yell for help!");
  11294. string yellMsg = std::string(client->GetPlayer()->GetName()) + " yelled for help!";
  11295. client->GetPlayer()->GetZone()->SimpleMessage(CHANNEL_COLOR_RED, yellMsg.c_str(), client->GetPlayer(), 35.0f, false);
  11296. client->GetPlayer()->GetZone()->SendYellPacket(client->GetPlayer());
  11297. }
  11298. alreadyYelled = true;
  11299. NPC* npc = (NPC*)res;
  11300. npc->Brain()->ClearEncounter();
  11301. npc->SetLockedNoLoot(ENCOUNTER_STATE_BROKEN);
  11302. npc->UpdateEncounterState(ENCOUNTER_STATE_BROKEN);
  11303. }
  11304. prev = res;
  11305. res = nullptr;
  11306. } while (cycleAll);
  11307. if (!player->IsEngagedInEncounter()) {
  11308. if (player->GetInfoStruct()->get_engaged_encounter()) {
  11309. player->GetInfoStruct()->set_engaged_encounter(0);
  11310. player->SetRegenValues((player->GetInfoStruct()->get_effective_level() > 0) ? player->GetInfoStruct()->get_effective_level() : player->GetLevel());
  11311. client->GetPlayer()->SetCharSheetChanged(true);
  11312. player->info_changed = true;
  11313. }
  11314. }
  11315. }
  11316. /*
  11317. Function: Command_SetAutoLootMode()
  11318. Purpose : Set player auto loot mode (0 = disabled, 1 = need/lotto, 2 = decline).
  11319. Example : /setautolootmode [mode]
  11320. */
  11321. void Commands::Command_SetAutoLootMode(Client* client, Seperator* sep) {
  11322. if (sep && sep->IsNumber(0)) {
  11323. int8 mode = atoul(sep->arg[0]);
  11324. switch (mode) {
  11325. case AutoLootMode::METHOD_DISABLED: {
  11326. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Disabled auto loot mode");
  11327. break;
  11328. }
  11329. case AutoLootMode::METHOD_ACCEPT: {
  11330. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Enabled auto loot mode for need and lotto.");
  11331. break;
  11332. }
  11333. default: {
  11334. mode = AutoLootMode::METHOD_DECLINE;
  11335. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Enabled auto loot mode to decline need and lotto.");
  11336. break;
  11337. }
  11338. }
  11339. client->GetPlayer()->GetInfoStruct()->set_group_auto_loot_method(mode);
  11340. database.insertCharacterProperty(client, CHAR_PROPERTY_AUTOLOOTMETHOD, (char*)std::to_string(mode).c_str());
  11341. client->SendDefaultGroupOptions();
  11342. }
  11343. }