9
3

Commands.cpp 450 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380
  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(int16 version){
  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->SetTotalHPBase(val);
  429. target->SetHP(val, send_update);
  430. break;
  431. }
  432. case SPAWN_SET_VALUE_POWER:{
  433. sprintf(tmp, "%i", target->GetPower());
  434. target->SetTotalPowerBase(val);
  435. target->SetPower(val, send_update);
  436. break;
  437. }
  438. case SPAWN_SET_VALUE_HEROIC:{
  439. sprintf(tmp, "%i", target->GetHeroic());
  440. target->SetHeroic(val, send_update);
  441. break;
  442. }
  443. case SPAWN_SET_VALUE_RESPAWN:{
  444. sprintf(tmp, "%u", target->GetRespawnTime());
  445. target->SetRespawnTime(val);
  446. break;
  447. }
  448. case SPAWN_SET_VALUE_X:{
  449. sprintf(tmp, "%f", target->GetX());
  450. target->SetX(atof(value), send_update);
  451. break;
  452. }
  453. case SPAWN_SET_VALUE_Y:{
  454. sprintf(tmp, "%f", target->GetY());
  455. target->SetY(atof(value), send_update);
  456. break;
  457. }
  458. case SPAWN_SET_VALUE_Z:{
  459. sprintf(tmp, "%f", target->GetZ());
  460. target->SetZ(atof(value), send_update);
  461. break;
  462. }
  463. case SPAWN_SET_VALUE_HEADING:{
  464. sprintf(tmp, "%f", target->GetHeading());
  465. target->SetHeading(atof(value) + 360, send_update);
  466. break;
  467. }
  468. case SPAWN_SET_VALUE_VISUAL_STATE:{
  469. sprintf(tmp, "%i", target->GetVisualState());
  470. target->SetVisualState(val, send_update);
  471. break;
  472. }
  473. case SPAWN_SET_VALUE_ACTION_STATE:{
  474. sprintf(tmp, "%i", target->GetActionState());
  475. target->SetActionState(val, send_update);
  476. break;
  477. }
  478. case SPAWN_SET_VALUE_MOOD_STATE:{
  479. sprintf(tmp, "%i", target->GetMoodState());
  480. target->SetMoodState(val, send_update);
  481. break;
  482. }
  483. case SPAWN_SET_VALUE_INITIAL_STATE:{
  484. sprintf(tmp, "%i", target->GetInitialState());
  485. target->SetInitialState(val, send_update);
  486. break;
  487. }
  488. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  489. sprintf(tmp, "%i", target->GetActivityStatus());
  490. target->SetActivityStatus(val, send_update);
  491. break;
  492. }
  493. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  494. sprintf(tmp, "%i", target->GetCollisionRadius());
  495. target->SetCollisionRadius(val, send_update);
  496. break;
  497. }
  498. case SPAWN_SET_VALUE_DEVICE_ID: {
  499. if (target->IsObject()) {
  500. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  501. ((Object*)target)->SetDeviceID(val);
  502. }
  503. break;
  504. }
  505. case SPAWN_SET_VALUE_PITCH: {
  506. sprintf(tmp, "%f", target->GetPitch());
  507. target->SetPitch(atof(value), send_update);
  508. break;
  509. }
  510. case SPAWN_SET_VALUE_ROLL: {
  511. sprintf(tmp, "%f", target->GetRoll());
  512. target->SetRoll(atof(value), send_update);
  513. break;
  514. }
  515. case SPAWN_SET_VALUE_HIDE_HOOD: {
  516. sprintf(tmp, "%i", target->appearance.hide_hood);
  517. target->SetHideHood(val);
  518. break;
  519. }
  520. case SPAWN_SET_VALUE_EMOTE_STATE: {
  521. sprintf(tmp, "%i", target->appearance.emote_state);
  522. target->SetEmoteState(val);
  523. break;
  524. }
  525. case SPAWN_SET_VALUE_ICON: {
  526. sprintf(tmp, "%i", target->GetIconValue());
  527. target->SetIcon(val);
  528. break;
  529. }
  530. case SPAWN_SET_VALUE_PREFIX: {
  531. sprintf(tmp, "%s", target->GetPrefixTitle());
  532. target->SetPrefixTitle(value);
  533. if(target->GetZone())
  534. target->GetZone()->SendUpdateTitles(target);
  535. break;
  536. }
  537. case SPAWN_SET_VALUE_SUFFIX: {
  538. sprintf(tmp, "%s", target->GetSuffixTitle());
  539. target->SetSuffixTitle(value);
  540. if(target->GetZone())
  541. target->GetZone()->SendUpdateTitles(target);
  542. break;
  543. }
  544. case SPAWN_SET_VALUE_LASTNAME: {
  545. sprintf(tmp, "%s", target->GetLastName());
  546. target->SetLastName(value);
  547. if(target->GetZone())
  548. target->GetZone()->SendUpdateTitles(target);
  549. break;
  550. }
  551. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  552. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  553. // nothing to do must reload spawns
  554. break;
  555. }
  556. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  557. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  558. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  559. break;
  560. }
  561. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  562. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  563. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  564. break;
  565. }
  566. case SPAWN_SET_VALUE_FACTION:{
  567. sprintf(tmp, "%i", target->faction_id);
  568. ZoneServer* zone = target->GetZone();
  569. if (!zone && client)
  570. zone = client->GetCurrentZone();
  571. target->faction_id = atoul(value);
  572. if(zone)
  573. {
  574. zone->RemoveDeadEnemyList(target);
  575. if(target->IsNPC())
  576. zone->AddEnemyList((NPC*)target);
  577. }
  578. break;
  579. }
  580. case SPAWN_SET_SKIN_COLOR:
  581. case SPAWN_SET_HAIR_COLOR1:
  582. case SPAWN_SET_HAIR_COLOR2:
  583. case SPAWN_SET_HAIR_TYPE_COLOR:
  584. case SPAWN_SET_HAIR_FACE_COLOR:
  585. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  586. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  587. case SPAWN_SET_HAIR_HIGHLIGHT:
  588. case SPAWN_SET_MODEL_COLOR:
  589. case SPAWN_SET_EYE_COLOR:
  590. case SPAWN_SET_SOGA_SKIN_COLOR:
  591. case SPAWN_SET_SOGA_HAIR_COLOR1:
  592. case SPAWN_SET_SOGA_HAIR_COLOR2:
  593. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  594. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  595. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  596. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  597. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  598. case SPAWN_SET_SOGA_MODEL_COLOR:
  599. case SPAWN_SET_SOGA_EYE_COLOR:
  600. {
  601. if (target->IsEntity())
  602. {
  603. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  604. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  605. {
  606. EQ2_Color clr;
  607. clr.red = atoul(skinsep->arg[0]);
  608. clr.green = atoul(skinsep->arg[1]);
  609. clr.blue = atoul(skinsep->arg[2]);
  610. switch(type)
  611. {
  612. case SPAWN_SET_SKIN_COLOR:
  613. ((Entity*)target)->SetSkinColor(clr);
  614. break;
  615. case SPAWN_SET_HAIR_COLOR1:
  616. ((Entity*)target)->SetHairColor1(clr);
  617. break;
  618. case SPAWN_SET_HAIR_COLOR2:
  619. ((Entity*)target)->SetHairColor2(clr);
  620. break;
  621. case SPAWN_SET_HAIR_TYPE_COLOR:
  622. ((Entity*)target)->SetHairColor(clr);
  623. break;
  624. case SPAWN_SET_HAIR_FACE_COLOR:
  625. ((Entity*)target)->SetFacialHairColor(clr);
  626. break;
  627. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  628. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  629. break;
  630. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  631. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  632. break;
  633. case SPAWN_SET_HAIR_HIGHLIGHT:
  634. ((Entity*)target)->SetHairHighlightColor(clr);
  635. break;
  636. case SPAWN_SET_MODEL_COLOR:
  637. ((Entity*)target)->SetModelColor(clr);
  638. break;
  639. case SPAWN_SET_EYE_COLOR:
  640. ((Entity*)target)->SetEyeColor(clr);
  641. break;
  642. case SPAWN_SET_SOGA_SKIN_COLOR:
  643. ((Entity*)target)->SetSogaSkinColor(clr);
  644. break;
  645. case SPAWN_SET_SOGA_HAIR_COLOR1:
  646. ((Entity*)target)->SetSogaHairColor1(clr);
  647. break;
  648. case SPAWN_SET_SOGA_HAIR_COLOR2:
  649. ((Entity*)target)->SetSogaHairColor2(clr);
  650. break;
  651. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  652. ((Entity*)target)->SetSogaHairColor(clr);
  653. break;
  654. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  655. ((Entity*)target)->SetSogaFacialHairColor(clr);
  656. break;
  657. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  658. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  659. break;
  660. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  661. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  662. break;
  663. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  664. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  665. break;
  666. case SPAWN_SET_SOGA_MODEL_COLOR:
  667. ((Entity*)target)->SetSogaModelColor(clr);
  668. break;
  669. case SPAWN_SET_SOGA_EYE_COLOR:
  670. ((Entity*)target)->SetSogaEyeColor(clr);
  671. break;
  672. }
  673. }
  674. safe_delete(skinsep);
  675. }
  676. break;
  677. }
  678. case SPAWN_SET_AAXP_REWARDS: {
  679. target->SetAAXPRewards(atoul(value));
  680. break;
  681. }
  682. case SPAWN_SET_CHEEK_TYPE:{
  683. if(target->IsEntity() && index < 3){
  684. sprintf(tmp, "%i", ((Entity*)target)->features.cheek_type[index]);
  685. sint8 new_value = atoi(value);
  686. ((Entity*)target)->features.cheek_type[index] = new_value;
  687. ((Entity*)target)->info_changed = true;
  688. }
  689. break;
  690. }
  691. case SPAWN_SET_CHIN_TYPE:{
  692. if(target->IsEntity() && index < 3){
  693. sprintf(tmp, "%i", ((Entity*)target)->features.chin_type[index]);
  694. sint8 new_value = atoi(value);
  695. ((Entity*)target)->features.chin_type[index] = new_value;
  696. ((Entity*)target)->info_changed = true;
  697. }
  698. break;
  699. }
  700. case SPAWN_SET_EAR_TYPE:{
  701. if(target->IsEntity() && index < 3){
  702. sprintf(tmp, "%i", ((Entity*)target)->features.ear_type[index]);
  703. sint8 new_value = atoi(value);
  704. ((Entity*)target)->features.ear_type[index] = new_value;
  705. ((Entity*)target)->info_changed = true;
  706. }
  707. break;
  708. }
  709. case SPAWN_SET_EYE_BROW_TYPE:{
  710. if(target->IsEntity() && index < 3){
  711. sprintf(tmp, "%i", ((Entity*)target)->features.eye_brow_type[index]);
  712. sint8 new_value = atoi(value);
  713. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  714. ((Entity*)target)->info_changed = true;
  715. }
  716. break;
  717. }
  718. case SPAWN_SET_EYE_TYPE:{
  719. if(target->IsEntity() && index < 3){
  720. sprintf(tmp, "%i", ((Entity*)target)->features.eye_type[index]);
  721. sint8 new_value = atoi(value);
  722. ((Entity*)target)->features.eye_type[index] = new_value;
  723. ((Entity*)target)->info_changed = true;
  724. }
  725. break;
  726. }
  727. case SPAWN_SET_LIP_TYPE:{
  728. if(target->IsEntity() && index < 3){
  729. sprintf(tmp, "%i", ((Entity*)target)->features.lip_type[index]);
  730. sint8 new_value = atoi(value);
  731. ((Entity*)target)->features.lip_type[index] = new_value;
  732. ((Entity*)target)->info_changed = true;
  733. }
  734. break;
  735. }
  736. case SPAWN_SET_NOSE_TYPE:{
  737. if(target->IsEntity() && index < 3){
  738. sprintf(tmp, "%i", ((Entity*)target)->features.nose_type[index]);
  739. sint8 new_value = atoi(value);
  740. ((Entity*)target)->features.nose_type[index] = new_value;
  741. ((Entity*)target)->info_changed = true;
  742. }
  743. break;
  744. }
  745. case SPAWN_SET_BODY_SIZE:{
  746. if(target->IsEntity()){
  747. sprintf(tmp, "%i", ((Entity*)target)->features.body_size);
  748. int8 new_value = atoul(value);
  749. ((Entity*)target)->features.body_size = new_value;
  750. ((Entity*)target)->info_changed = true;
  751. }
  752. break;
  753. }
  754. case SPAWN_SET_BODY_AGE:{
  755. if(target->IsEntity()){
  756. sprintf(tmp, "%i", ((Entity*)target)->features.body_age);
  757. int8 new_value = atoul(value);
  758. ((Entity*)target)->features.body_age = new_value;
  759. ((Entity*)target)->info_changed = true;
  760. }
  761. break;
  762. }
  763. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  764. if(target->IsEntity() && index < 3){
  765. sprintf(tmp, "%i", ((Entity*)target)->features.soga_cheek_type[index]);
  766. sint8 new_value = atoi(value);
  767. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  768. ((Entity*)target)->info_changed = true;
  769. }
  770. break;
  771. }
  772. case SPAWN_SET_SOGA_CHIN_TYPE:{
  773. if(target->IsEntity() && index < 3){
  774. sprintf(tmp, "%i", ((Entity*)target)->features.soga_chin_type[index]);
  775. sint8 new_value = atoi(value);
  776. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  777. ((Entity*)target)->info_changed = true;
  778. }
  779. break;
  780. }
  781. case SPAWN_SET_SOGA_EAR_TYPE:{
  782. if(target->IsEntity() && index < 3){
  783. sprintf(tmp, "%i", ((Entity*)target)->features.soga_ear_type[index]);
  784. sint8 new_value = atoi(value);
  785. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  786. ((Entity*)target)->info_changed = true;
  787. }
  788. break;
  789. }
  790. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  791. if(target->IsEntity() && index < 3){
  792. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_brow_type[index]);
  793. sint8 new_value = atoi(value);
  794. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  795. ((Entity*)target)->info_changed = true;
  796. }
  797. break;
  798. }
  799. case SPAWN_SET_SOGA_EYE_TYPE:{
  800. if(target->IsEntity() && index < 3){
  801. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_type[index]);
  802. sint8 new_value = atoi(value);
  803. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  804. ((Entity*)target)->info_changed = true;
  805. }
  806. break;
  807. }
  808. case SPAWN_SET_SOGA_LIP_TYPE:{
  809. if(target->IsEntity() && index < 3){
  810. sprintf(tmp, "%i", ((Entity*)target)->features.soga_lip_type[index]);
  811. sint8 new_value = atoi(value);
  812. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  813. ((Entity*)target)->info_changed = true;
  814. }
  815. break;
  816. }
  817. case SPAWN_SET_SOGA_BODY_SIZE:{
  818. if(target->IsEntity()){
  819. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_size);
  820. int8 new_value = atoul(value);
  821. ((Entity*)target)->features.soga_body_size = new_value;
  822. ((Entity*)target)->info_changed = true;
  823. }
  824. break;
  825. }
  826. case SPAWN_SET_SOGA_BODY_AGE:{
  827. if(target->IsEntity()){
  828. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_age);
  829. int8 new_value = atoul(value);
  830. ((Entity*)target)->features.soga_body_age = new_value;
  831. ((Entity*)target)->info_changed = true;
  832. }
  833. break;
  834. }
  835. case SPAWN_SET_ATTACK_TYPE:{
  836. if(target->IsEntity()){
  837. sprintf(tmp, "%u", ((Entity*)target)->GetInfoStruct()->get_attack_type());
  838. int8 new_value = atoul(value);
  839. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  840. }
  841. break;
  842. }
  843. case SPAWN_SET_RACE_TYPE:{
  844. if(target->GetModelType() > 0){
  845. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  846. if (tmpsep->IsNumber(0))
  847. {
  848. int16 race_type = atoul(value);
  849. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  850. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  851. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  852. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  853. if(client) {
  854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Race type added to memory, however not saved to database.");
  855. }
  856. }
  857. else if(client) {
  858. client->SimpleMessage(CHANNEL_COLOR_RED, "Model type already on the race_types_list, use spawn set database to override and update database.");
  859. }
  860. }
  861. safe_delete(tmpsep);
  862. }
  863. break;
  864. }
  865. case SPAWN_SET_LOOT_TIER:{
  866. if(target->IsEntity()){
  867. sprintf(tmp, "%u", target->GetLootTier());
  868. int32 new_value = atoul(value);
  869. target->SetLootTier(new_value);
  870. }
  871. break;
  872. }
  873. case SPAWN_SET_LOOT_DROP_TYPE:{
  874. if(target->IsEntity()){
  875. sprintf(tmp, "%u", target->GetLootDropType());
  876. int32 new_value = atoul(value);
  877. target->SetLootDropType(new_value);
  878. }
  879. break;
  880. }
  881. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  882. if(target->IsNPC()){
  883. sprintf(tmp, "%u", target->IsScaredByStrongPlayers());
  884. int32 new_value = atoul(value);
  885. target->SetScaredByStrongPlayers(new_value);
  886. }
  887. break;
  888. }
  889. if(temp_value)
  890. *temp_value = string(tmp);
  891. }
  892. }
  893. else{
  894. /**** NOT TEMPORARY ELSE STATEMENT ****/
  895. /**** MUST RE-DEFINE WHAT IS ALREADY IN THE IF TEMPORARY BLOCK HERE ****/
  896. switch(type){
  897. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  898. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  899. break;
  900. }
  901. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  902. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  903. break;
  904. }
  905. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  906. if (target->GetDatabaseID() > 0)
  907. {
  908. char query[256];
  909. snprintf(query, 256, "update spawn set expansion_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  910. if (database.RunQuery(query, strnlen(query, 256)))
  911. {
  912. if(client)
  913. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  914. }
  915. }
  916. break;
  917. }
  918. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  919. if (target->GetDatabaseID() > 0)
  920. {
  921. char query[256];
  922. snprintf(query, 256, "update spawn set holiday_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  923. if (database.RunQuery(query, strnlen(query, 256)))
  924. {
  925. if(client)
  926. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  927. }
  928. }
  929. break;
  930. }
  931. case SPAWN_SET_AAXP_REWARDS: {
  932. if (target->GetDatabaseID() > 0)
  933. {
  934. char query[256];
  935. snprintf(query, 256, "update spawn set aaxp_rewards=%u where id=%u", atoul(value), target->GetDatabaseID());
  936. if (database.RunQuery(query, strnlen(query, 256)))
  937. {
  938. if(client)
  939. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  940. }
  941. }
  942. break;
  943. }
  944. case SPAWN_SET_VALUE_NAME:{
  945. target->SetName(value);
  946. if(target->GetZone())
  947. target->GetZone()->SendUpdateTitles(target);
  948. break;
  949. }
  950. case SPAWN_SET_VALUE_SUB_TITLE: {
  951. target->SetSubTitle(value);
  952. if(target->GetZone())
  953. target->GetZone()->SendUpdateTitles(target);
  954. break;
  955. }
  956. case SPAWN_SET_VALUE_X_OFFSET:
  957. {
  958. target->SetXOffset(atof(value));
  959. break;
  960. }
  961. case SPAWN_SET_VALUE_Y_OFFSET:
  962. {
  963. target->SetYOffset(atof(value));
  964. break;
  965. }
  966. case SPAWN_SET_VALUE_Z_OFFSET:
  967. {
  968. target->SetZOffset(atof(value));
  969. break;
  970. }
  971. case SPAWN_SET_VALUE_EXPIRE: {
  972. target->SetExpireTime(val);
  973. break;
  974. }
  975. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  976. target->SetExpireOffsetTime(val);
  977. break;
  978. }
  979. case SPAWN_SET_VALUE_LEVEL:{
  980. target->SetLevel(val, send_update);
  981. break;
  982. }
  983. case SPAWN_SET_VALUE_DIFFICULTY:{
  984. target->SetDifficulty(val, send_update);
  985. break;
  986. }
  987. case SPAWN_SET_VALUE_MODEL_TYPE:{
  988. target->SetModelType(val, send_update);
  989. break;
  990. }
  991. case SPAWN_SET_VALUE_CLASS:{
  992. target->SetAdventureClass(val, send_update);
  993. break;
  994. }
  995. case SPAWN_SET_VALUE_GENDER:{
  996. target->SetGender(val, send_update);
  997. break;
  998. }
  999. case SPAWN_SET_VALUE_SHOW_NAME:{
  1000. target->SetShowName(val, send_update);
  1001. break;
  1002. }
  1003. case SPAWN_SET_VALUE_ATTACKABLE:{
  1004. target->SetAttackable(val, send_update);
  1005. break;
  1006. }
  1007. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  1008. target->SetShowLevel(val, send_update);
  1009. break;
  1010. }
  1011. case SPAWN_SET_VALUE_TARGETABLE:{
  1012. target->SetTargetable(val, send_update);
  1013. break;
  1014. }
  1015. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  1016. target->SetShowCommandIcon(val, send_update);
  1017. break;
  1018. }
  1019. case SPAWN_SET_VALUE_HAND_ICON:{
  1020. target->SetShowHandIcon(val, send_update);
  1021. break;
  1022. }
  1023. case SPAWN_SET_VALUE_HAIR_TYPE:{
  1024. if(target->IsEntity())
  1025. ((Entity*)target)->SetHairType(val, send_update);
  1026. break;
  1027. }
  1028. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  1029. if(target->IsEntity())
  1030. ((Entity*)target)->SetFacialHairType(val, send_update);
  1031. break;
  1032. }
  1033. case SPAWN_SET_VALUE_WING_TYPE:{
  1034. if(target->IsEntity())
  1035. ((Entity*)target)->SetWingType(val, send_update);
  1036. break;
  1037. }
  1038. case SPAWN_SET_VALUE_CHEST_TYPE:{
  1039. if(target->IsEntity())
  1040. ((Entity*)target)->SetChestType(val, send_update);
  1041. break;
  1042. }
  1043. case SPAWN_SET_VALUE_LEGS_TYPE:{
  1044. if(target->IsEntity())
  1045. ((Entity*)target)->SetLegsType(val, send_update);
  1046. break;
  1047. }
  1048. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  1049. if(target->IsEntity())
  1050. ((Entity*)target)->SetSogaHairType(val, send_update);
  1051. break;
  1052. }
  1053. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  1054. if(target->IsEntity())
  1055. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  1056. break;
  1057. }
  1058. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  1059. target->SetSogaModelType(val, send_update);
  1060. break;
  1061. }
  1062. case SPAWN_SET_VALUE_SIZE:{
  1063. target->SetSize(val, send_update);
  1064. break;
  1065. }
  1066. case SPAWN_SET_VALUE_HP:{
  1067. target->SetTotalHPBase(val);
  1068. target->SetHP(val, send_update);
  1069. break;
  1070. }
  1071. case SPAWN_SET_VALUE_POWER:{
  1072. target->SetTotalPowerBase(val);
  1073. target->SetPower(val, send_update);
  1074. break;
  1075. }
  1076. case SPAWN_SET_VALUE_HEROIC:{
  1077. target->SetHeroic(val, send_update);
  1078. break;
  1079. }
  1080. case SPAWN_SET_VALUE_RESPAWN:{
  1081. target->SetRespawnTime(val);
  1082. break;
  1083. }
  1084. case SPAWN_SET_VALUE_X:{
  1085. target->SetX(atof(value), send_update);
  1086. target->SetSpawnOrigX(target->GetX());
  1087. break;
  1088. }
  1089. case SPAWN_SET_VALUE_Y:{
  1090. target->SetY(atof(value), send_update);
  1091. target->SetSpawnOrigY(target->GetY());
  1092. break;
  1093. }
  1094. case SPAWN_SET_VALUE_Z:{
  1095. target->SetZ(atof(value), send_update);
  1096. target->SetSpawnOrigZ(target->GetZ());
  1097. break;
  1098. }
  1099. case SPAWN_SET_VALUE_HEADING:{
  1100. target->SetHeading(atof(value), send_update);
  1101. target->SetSpawnOrigHeading(target->GetHeading());
  1102. break;
  1103. }
  1104. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  1105. ZoneServer* zone = target->GetZone();
  1106. if (!zone && client)
  1107. zone = client->GetCurrentZone();
  1108. if(zone && zone->GetEntityCommandList(val))
  1109. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  1110. target->primary_command_list_id = val;
  1111. break;
  1112. }
  1113. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  1114. ZoneServer* zone = target->GetZone();
  1115. if (!zone && client)
  1116. zone = client->GetCurrentZone();
  1117. if (zone && zone->GetEntityCommandList(val))
  1118. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  1119. target->secondary_command_list_id = val;
  1120. break;
  1121. }
  1122. case SPAWN_SET_VALUE_VISUAL_STATE:{
  1123. target->SetVisualState(val, send_update);
  1124. break;
  1125. }
  1126. case SPAWN_SET_VALUE_ACTION_STATE:{
  1127. target->SetActionState(val, send_update);
  1128. break;
  1129. }
  1130. case SPAWN_SET_VALUE_MOOD_STATE:{
  1131. target->SetMoodState(val, send_update);
  1132. break;
  1133. }
  1134. case SPAWN_SET_VALUE_INITIAL_STATE:{
  1135. target->SetInitialState(val, send_update);
  1136. break;
  1137. }
  1138. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  1139. target->SetActivityStatus(val, send_update);
  1140. break;
  1141. }
  1142. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  1143. target->SetCollisionRadius(val, send_update);
  1144. break;
  1145. }
  1146. case SPAWN_SET_VALUE_FACTION:{
  1147. ZoneServer* zone = target->GetZone();
  1148. if (!zone && client)
  1149. zone = client->GetCurrentZone();
  1150. target->faction_id = val;
  1151. if(zone)
  1152. {
  1153. zone->RemoveDeadEnemyList(target);
  1154. if(target->IsNPC())
  1155. zone->AddEnemyList((NPC*)target);
  1156. }
  1157. break;
  1158. }
  1159. case SPAWN_SET_VALUE_DEVICE_ID:{
  1160. if (target->IsObject())
  1161. ((Object*)target)->SetDeviceID(val);
  1162. break;
  1163. }
  1164. case SPAWN_SET_VALUE_PITCH: {
  1165. target->SetPitch(atof(value), send_update);
  1166. target->SetSpawnOrigPitch(atof(value));
  1167. break;
  1168. }
  1169. case SPAWN_SET_VALUE_ROLL: {
  1170. target->SetRoll(atof(value), send_update);
  1171. target->SetSpawnOrigRoll(atof(value));
  1172. break;
  1173. }
  1174. case SPAWN_SET_VALUE_HIDE_HOOD: {
  1175. target->SetHideHood(val);
  1176. break;
  1177. }
  1178. case SPAWN_SET_VALUE_EMOTE_STATE: {
  1179. target->SetEmoteState(val);
  1180. break;
  1181. }
  1182. case SPAWN_SET_VALUE_ICON: {
  1183. target->SetIcon(val);
  1184. break;
  1185. }
  1186. case SPAWN_SET_VALUE_PREFIX: {
  1187. target->SetPrefixTitle(value);
  1188. if(target->GetZone())
  1189. target->GetZone()->SendUpdateTitles(target);
  1190. break;
  1191. }
  1192. case SPAWN_SET_VALUE_SUFFIX: {
  1193. target->SetSuffixTitle(value);
  1194. if(target->GetZone())
  1195. target->GetZone()->SendUpdateTitles(target);
  1196. break;
  1197. }
  1198. case SPAWN_SET_VALUE_LASTNAME: {
  1199. target->SetLastName(value);
  1200. if(target->GetZone())
  1201. target->GetZone()->SendUpdateTitles(target);
  1202. break;
  1203. }
  1204. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  1205. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1206. if(client){
  1207. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1208. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  1209. }
  1210. return false;
  1211. }
  1212. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  1213. return false;
  1214. else{
  1215. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  1216. target->SetSpawnScript(value);
  1217. }
  1218. break;
  1219. }
  1220. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  1221. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1222. if(client){
  1223. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1224. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  1225. }
  1226. return false;
  1227. }
  1228. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  1229. return false;
  1230. else{
  1231. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  1232. target->SetSpawnScript(value);
  1233. }
  1234. break;
  1235. }
  1236. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  1237. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1238. if(client){
  1239. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1240. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  1241. }
  1242. return false;
  1243. }
  1244. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  1245. return false;
  1246. else
  1247. target->SetSpawnScript(value);
  1248. break;
  1249. }
  1250. case SPAWN_SET_SKIN_COLOR:
  1251. case SPAWN_SET_HAIR_COLOR1:
  1252. case SPAWN_SET_HAIR_COLOR2:
  1253. case SPAWN_SET_HAIR_TYPE_COLOR:
  1254. case SPAWN_SET_HAIR_FACE_COLOR:
  1255. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1256. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1257. case SPAWN_SET_HAIR_HIGHLIGHT:
  1258. case SPAWN_SET_MODEL_COLOR:
  1259. case SPAWN_SET_EYE_COLOR:
  1260. case SPAWN_SET_SOGA_SKIN_COLOR:
  1261. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1262. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1263. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1264. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1265. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1266. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1267. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1268. case SPAWN_SET_SOGA_MODEL_COLOR:
  1269. case SPAWN_SET_SOGA_EYE_COLOR: {
  1270. if (target->IsNPC())
  1271. {
  1272. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  1273. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  1274. {
  1275. EQ2_Color clr;
  1276. clr.red = atoul(skinsep->arg[0]);
  1277. clr.green = atoul(skinsep->arg[1]);
  1278. clr.blue = atoul(skinsep->arg[2]);
  1279. Query replaceSkinQuery;
  1280. string fieldName("");
  1281. switch(type)
  1282. {
  1283. case SPAWN_SET_SKIN_COLOR:
  1284. ((Entity*)target)->SetSkinColor(clr);
  1285. fieldName.append("skin_color");
  1286. break;
  1287. case SPAWN_SET_HAIR_COLOR1:
  1288. ((Entity*)target)->SetHairColor1(clr);
  1289. fieldName.append("hair_color1");
  1290. break;
  1291. case SPAWN_SET_HAIR_COLOR2:
  1292. ((Entity*)target)->SetHairColor2(clr);
  1293. fieldName.append("hair_color2");
  1294. break;
  1295. case SPAWN_SET_HAIR_TYPE_COLOR:
  1296. ((Entity*)target)->SetHairColor(clr);
  1297. fieldName.append("hair_type_color");
  1298. break;
  1299. case SPAWN_SET_HAIR_FACE_COLOR:
  1300. ((Entity*)target)->SetFacialHairColor(clr);
  1301. fieldName.append("hair_face_color");
  1302. break;
  1303. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1304. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  1305. fieldName.append("hair_type_highlight_color");
  1306. break;
  1307. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1308. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  1309. fieldName.append("hair_face_highlight_color");
  1310. break;
  1311. case SPAWN_SET_HAIR_HIGHLIGHT:
  1312. ((Entity*)target)->SetHairHighlightColor(clr);
  1313. fieldName.append("hair_highlight");
  1314. break;
  1315. case SPAWN_SET_MODEL_COLOR:
  1316. ((Entity*)target)->SetModelColor(clr);
  1317. fieldName.append("model_color");
  1318. break;
  1319. case SPAWN_SET_EYE_COLOR:
  1320. ((Entity*)target)->SetEyeColor(clr);
  1321. fieldName.append("eye_color");
  1322. break;
  1323. case SPAWN_SET_SOGA_SKIN_COLOR:
  1324. ((Entity*)target)->SetSogaSkinColor(clr);
  1325. fieldName.append("soga_skin_color");
  1326. break;
  1327. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1328. ((Entity*)target)->SetSogaHairColor1(clr);
  1329. fieldName.append("soga_hair_color1");
  1330. break;
  1331. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1332. ((Entity*)target)->SetSogaHairColor2(clr);
  1333. fieldName.append("soga_hair_color2");
  1334. break;
  1335. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1336. ((Entity*)target)->SetSogaHairColor(clr);
  1337. fieldName.append("soga_hair_type_color");
  1338. break;
  1339. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1340. ((Entity*)target)->SetSogaFacialHairColor(clr);
  1341. fieldName.append("soga_hair_face_color");
  1342. break;
  1343. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1344. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  1345. fieldName.append("soga_hair_type_highlight_color");
  1346. break;
  1347. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1348. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  1349. fieldName.append("soga_hair_face_highlight_color");
  1350. break;
  1351. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1352. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  1353. fieldName.append("soga_hair_highlight");
  1354. break;
  1355. case SPAWN_SET_SOGA_MODEL_COLOR:
  1356. ((Entity*)target)->SetSogaModelColor(clr);
  1357. fieldName.append("soga_model_color");
  1358. break;
  1359. case SPAWN_SET_SOGA_EYE_COLOR:
  1360. ((Entity*)target)->SetSogaEyeColor(clr);
  1361. fieldName.append("soga_eye_color");
  1362. break;
  1363. }
  1364. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1365. 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);
  1366. }
  1367. safe_delete(skinsep);
  1368. }
  1369. break;
  1370. }
  1371. case SPAWN_SET_CHEEK_TYPE:{
  1372. if(target->IsEntity() && index < 3){
  1373. sint8 new_value = atoi(value);
  1374. ((Entity*)target)->features.cheek_type[index] = new_value;
  1375. UpdateDatabaseAppearance(client, target, "cheek_type", ((Entity*)target)->features.cheek_type[0], ((Entity*)target)->features.cheek_type[1], ((Entity*)target)->features.cheek_type[2]);
  1376. }
  1377. break;
  1378. }
  1379. case SPAWN_SET_CHIN_TYPE:{
  1380. if(target->IsEntity() && index < 3){
  1381. sint8 new_value = atoi(value);
  1382. ((Entity*)target)->features.chin_type[index] = new_value;
  1383. UpdateDatabaseAppearance(client, target, "chin_type", ((Entity*)target)->features.chin_type[0], ((Entity*)target)->features.chin_type[1], ((Entity*)target)->features.chin_type[2]);
  1384. }
  1385. break;
  1386. }
  1387. case SPAWN_SET_EAR_TYPE:{
  1388. if(target->IsEntity() && index < 3){
  1389. sint8 new_value = atoi(value);
  1390. ((Entity*)target)->features.ear_type[index] = new_value;
  1391. UpdateDatabaseAppearance(client, target, "ear_type", ((Entity*)target)->features.ear_type[0], ((Entity*)target)->features.ear_type[1], ((Entity*)target)->features.ear_type[2]);
  1392. }
  1393. break;
  1394. }
  1395. case SPAWN_SET_EYE_BROW_TYPE:{
  1396. if(target->IsEntity() && index < 3){
  1397. sint8 new_value = atoi(value);
  1398. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  1399. 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]);
  1400. }
  1401. break;
  1402. }
  1403. case SPAWN_SET_EYE_TYPE:{
  1404. if(target->IsEntity() && index < 3){
  1405. sint8 new_value = atoi(value);
  1406. ((Entity*)target)->features.eye_type[index] = new_value;
  1407. UpdateDatabaseAppearance(client, target, "eye_type", ((Entity*)target)->features.eye_type[0], ((Entity*)target)->features.eye_type[1], ((Entity*)target)->features.eye_type[2]);
  1408. }
  1409. break;
  1410. }
  1411. case SPAWN_SET_LIP_TYPE:{
  1412. if(target->IsEntity() && index < 3){
  1413. sint8 new_value = atoi(value);
  1414. ((Entity*)target)->features.lip_type[index] = new_value;
  1415. UpdateDatabaseAppearance(client, target, "lip_type", ((Entity*)target)->features.lip_type[0], ((Entity*)target)->features.lip_type[1], ((Entity*)target)->features.lip_type[2]);
  1416. }
  1417. break;
  1418. }
  1419. case SPAWN_SET_NOSE_TYPE:{
  1420. if(target->IsEntity() && index < 3){
  1421. sint8 new_value = atoi(value);
  1422. ((Entity*)target)->features.nose_type[index] = new_value;
  1423. UpdateDatabaseAppearance(client, target, "nose_type", ((Entity*)target)->features.nose_type[0], ((Entity*)target)->features.nose_type[1], ((Entity*)target)->features.nose_type[2]);
  1424. }
  1425. break;
  1426. }
  1427. case SPAWN_SET_BODY_SIZE:{
  1428. if(target->IsEntity()){
  1429. int8 new_value = atoul(value);
  1430. ((Entity*)target)->features.body_size = new_value;
  1431. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1432. }
  1433. break;
  1434. }
  1435. case SPAWN_SET_BODY_AGE:{
  1436. if(target->IsEntity()){
  1437. int8 new_value = atoul(value);
  1438. ((Entity*)target)->features.body_age = new_value;
  1439. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1440. }
  1441. break;
  1442. }
  1443. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  1444. if(target->IsEntity() && index < 3){
  1445. sint8 new_value = atoi(value);
  1446. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  1447. 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]);
  1448. }
  1449. break;
  1450. }
  1451. case SPAWN_SET_SOGA_CHIN_TYPE:{
  1452. if(target->IsEntity() && index < 3){
  1453. sint8 new_value = atoi(value);
  1454. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  1455. 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]);
  1456. }
  1457. break;
  1458. }
  1459. case SPAWN_SET_SOGA_EAR_TYPE:{
  1460. if(target->IsEntity() && index < 3){
  1461. sint8 new_value = atoi(value);
  1462. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  1463. 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]);
  1464. }
  1465. break;
  1466. }
  1467. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  1468. if(target->IsEntity() && index < 3){
  1469. sint8 new_value = atoi(value);
  1470. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  1471. 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]);
  1472. }
  1473. break;
  1474. }
  1475. case SPAWN_SET_SOGA_EYE_TYPE:{
  1476. if(target->IsEntity() && index < 3){
  1477. sint8 new_value = atoi(value);
  1478. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  1479. 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]);
  1480. }
  1481. break;
  1482. }
  1483. case SPAWN_SET_SOGA_LIP_TYPE:{
  1484. if(target->IsEntity() && index < 3){
  1485. sint8 new_value = atoi(value);
  1486. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  1487. 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]);
  1488. }
  1489. break;
  1490. }
  1491. case SPAWN_SET_SOGA_NOSE_TYPE:{
  1492. if(target->IsEntity() && index < 3){
  1493. sint8 new_value = atoi(value);
  1494. ((Entity*)target)->features.soga_nose_type[index] = new_value;
  1495. 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]);
  1496. }
  1497. break;
  1498. }
  1499. case SPAWN_SET_SOGA_BODY_SIZE:{
  1500. if(target->IsEntity()){
  1501. int8 new_value = atoul(value);
  1502. ((Entity*)target)->features.body_size = new_value;
  1503. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1504. }
  1505. break;
  1506. }
  1507. case SPAWN_SET_SOGA_BODY_AGE:{
  1508. if(target->IsEntity()){
  1509. int8 new_value = atoul(value);
  1510. ((Entity*)target)->features.body_age = new_value;
  1511. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1512. }
  1513. break;
  1514. }
  1515. case SPAWN_SET_ATTACK_TYPE:{
  1516. if(target->IsEntity()){
  1517. int8 new_value = atoul(value);
  1518. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  1519. if(target->IsNPC()) {
  1520. if(target->GetDatabaseID()) {
  1521. Query spawnNPCQuery;
  1522. spawnNPCQuery.AddQueryAsync(0, &database, Q_INSERT, "update spawn_npcs set attack_type=%u where id=%u", new_value, target->GetDatabaseID());
  1523. } else if(client) {
  1524. client->Message(CHANNEL_COLOR_RED, "Invalid spawn to update the database (NPC only) or no database id for the NPC present.");
  1525. }
  1526. }
  1527. }
  1528. break;
  1529. }
  1530. case SPAWN_SET_RACE_TYPE:{
  1531. if(target->GetModelType() > 0){
  1532. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  1533. if (tmpsep->IsNumber(0))
  1534. {
  1535. Query typequery;
  1536. int16 race_type = atoul(value);
  1537. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  1538. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  1539. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  1540. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  1541. if(client)
  1542. 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);
  1543. 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);
  1544. }
  1545. else {
  1546. if(client)
  1547. 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);
  1548. race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name, true);
  1549. 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());
  1550. }
  1551. }
  1552. safe_delete(tmpsep);
  1553. }
  1554. break;
  1555. }
  1556. case SPAWN_SET_LOOT_TIER:{
  1557. int32 new_value = atoul(value);
  1558. target->SetLootTier(new_value);
  1559. if (target->GetDatabaseID() > 0)
  1560. {
  1561. char query[256];
  1562. snprintf(query, 256, "update spawn set loot_tier=%u where id=%u", atoul(value), target->GetDatabaseID());
  1563. if (database.RunQuery(query, strnlen(query, 256)))
  1564. {
  1565. if(client)
  1566. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1567. }
  1568. }
  1569. break;
  1570. }
  1571. case SPAWN_SET_LOOT_DROP_TYPE:{
  1572. int32 new_value = atoul(value);
  1573. target->SetLootDropType(new_value);
  1574. if (target->GetDatabaseID() > 0)
  1575. {
  1576. char query[256];
  1577. snprintf(query, 256, "update spawn set loot_drop_type=%u where id=%u", atoul(value), target->GetDatabaseID());
  1578. if (database.RunQuery(query, strnlen(query, 256)))
  1579. {
  1580. if(client)
  1581. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1582. }
  1583. }
  1584. break;
  1585. }
  1586. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  1587. int32 new_value = atoul(value);
  1588. target->SetScaredByStrongPlayers(new_value);
  1589. if (target->GetDatabaseID() > 0)
  1590. {
  1591. char query[256];
  1592. snprintf(query, 256, "update spawn_npcs set scared_by_strong_players=%u where id=%u", atoul(value), target->GetDatabaseID());
  1593. if (database.RunQuery(query, strnlen(query, 256)))
  1594. {
  1595. if(client)
  1596. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1597. }
  1598. }
  1599. break;
  1600. }
  1601. }
  1602. }
  1603. return true;
  1604. }
  1605. void Commands::UpdateDatabaseAppearance(Client* client, Spawn* target, string fieldName, sint8 r, sint8 g, sint8 b)
  1606. {
  1607. Query replaceQuery;
  1608. if(target->IsBot())
  1609. {
  1610. Bot* bot = (Bot*)target;
  1611. if(bot->BotID)
  1612. database.SaveBotFloats(bot->BotID, fieldName.c_str(), r, g, b);
  1613. }
  1614. else if(target->IsPlayer())
  1615. {
  1616. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from char_colors where char_id=%u and type='%s'", ((Player*)target)->GetCharacterID(), fieldName.c_str());
  1617. 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);
  1618. }
  1619. else
  1620. {
  1621. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1622. 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);
  1623. }
  1624. ((Entity*)target)->changed = true;
  1625. ((Entity*)target)->info_changed = true;
  1626. if(target->GetZone())
  1627. target->GetZone()->AddChangedSpawn(target);
  1628. }
  1629. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  1630. the database fields always and also update the zone in memory if it's running. */
  1631. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  1632. if (client && zone_id > 0 && type > 0 && value) {
  1633. sint32 int_value = 0;
  1634. float float_value = 0;
  1635. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  1636. try {
  1637. float_value = atof(value);
  1638. }
  1639. catch (...) {
  1640. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  1641. return false;
  1642. }
  1643. }
  1644. 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) {
  1645. try {
  1646. int_value = atoi(value);
  1647. }
  1648. catch (...) {
  1649. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  1650. return false;
  1651. }
  1652. }
  1653. switch (type) {
  1654. case ZONE_SET_VALUE_EXPANSION_ID: {
  1655. break;
  1656. }
  1657. case ZONE_SET_VALUE_NAME: {
  1658. if (zone)
  1659. zone->SetZoneName(const_cast<char*>(value));
  1660. database.SaveZoneInfo(zone_id, "name", value);
  1661. break;
  1662. }
  1663. case ZONE_SET_VALUE_FILE: {
  1664. if (zone)
  1665. zone->SetZoneFile(const_cast<char*>(value));
  1666. database.SaveZoneInfo(zone_id, "file", value);
  1667. break;
  1668. }
  1669. case ZONE_SET_VALUE_DESCRIPTION: {
  1670. if (zone)
  1671. zone->SetZoneDescription(const_cast<char*>(value));
  1672. database.SaveZoneInfo(zone_id, "description", value);
  1673. break;
  1674. }
  1675. case ZONE_SET_VALUE_SAFE_X: {
  1676. if (zone)
  1677. zone->SetSafeX(float_value);
  1678. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  1679. break;
  1680. }
  1681. case ZONE_SET_VALUE_SAFE_Y: {
  1682. if (zone)
  1683. zone->SetSafeY(float_value);
  1684. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  1685. break;
  1686. }
  1687. case ZONE_SET_VALUE_SAFE_Z: {
  1688. if (zone)
  1689. zone->SetSafeZ(float_value);
  1690. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  1691. break;
  1692. }
  1693. case ZONE_SET_VALUE_UNDERWORLD: {
  1694. if (zone)
  1695. zone->SetUnderWorld(float_value);
  1696. database.SaveZoneInfo(zone_id, "underworld", float_value);
  1697. break;
  1698. }
  1699. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  1700. break;
  1701. }
  1702. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  1703. break;
  1704. }
  1705. case ZONE_SET_VALUE_ZONE_TYPE: {
  1706. break;
  1707. }
  1708. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  1709. if (zone)
  1710. zone->SetAlwaysLoaded(int_value == 1);
  1711. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  1712. break;
  1713. }
  1714. case ZONE_SET_VALUE_CITY_ZONE: {
  1715. if (zone)
  1716. zone->SetCityZone(int_value == 1);
  1717. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  1718. break;
  1719. }
  1720. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  1721. if (zone)
  1722. zone->SetWeatherAllowed(int_value == 1);
  1723. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  1724. break;
  1725. }
  1726. case ZONE_SET_VALUE_MIN_STATUS: {
  1727. if (zone)
  1728. zone->SetMinimumStatus(int_value);
  1729. database.SaveZoneInfo(zone_id, "min_status", int_value);
  1730. break;
  1731. }
  1732. case ZONE_SET_VALUE_MIN_LEVEL: {
  1733. if (zone)
  1734. zone->SetMinimumLevel(int_value);
  1735. database.SaveZoneInfo(zone_id, "min_level", int_value);
  1736. break;
  1737. }
  1738. case ZONE_SET_VALUE_MAX_LEVEL: {
  1739. if (zone)
  1740. zone->SetMaximumLevel(int_value);
  1741. database.SaveZoneInfo(zone_id, "max_level", int_value);
  1742. break;
  1743. }
  1744. case ZONE_SET_VALUE_START_ZONE: {
  1745. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  1746. break;
  1747. }
  1748. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  1749. if (zone)
  1750. zone->SetInstanceType(int_value);
  1751. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  1752. break;
  1753. }
  1754. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  1755. if (zone)
  1756. zone->SetDefaultReenterTime(int_value);
  1757. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  1758. break;
  1759. }
  1760. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  1761. if (zone)
  1762. zone->SetDefaultResetTime(int_value);
  1763. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  1764. break;
  1765. }
  1766. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1767. if (zone)
  1768. zone->SetDefaultLockoutTime(int_value);
  1769. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1770. break;
  1771. }
  1772. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1773. if (zone)
  1774. zone->SetForceGroupZoneOption(int_value);
  1775. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1776. break;
  1777. }
  1778. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1779. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1780. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1781. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1782. return false;
  1783. }
  1784. else {
  1785. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1786. database.SaveZoneInfo(zone_id, "lua_script", value);
  1787. }
  1788. break;
  1789. }
  1790. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1791. if (zone)
  1792. zone->SetShutdownTimer(int_value);
  1793. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1794. break;
  1795. }
  1796. case ZONE_SET_VALUE_ZONE_MOTD: {
  1797. if (zone)
  1798. zone->SetZoneMOTD(string(value));
  1799. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1800. break;
  1801. }
  1802. default: {
  1803. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1804. return false;
  1805. }
  1806. }
  1807. }
  1808. else {
  1809. if (client)
  1810. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1811. return false;
  1812. }
  1813. return true;
  1814. }
  1815. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1816. if (index >= remote_commands->commands.size()) {
  1817. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1818. return;
  1819. }
  1820. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1821. EQ2_RemoteCommandString* parent_command = 0;
  1822. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1823. Seperator* sep = 0;
  1824. if (command_parms->size > 0) {
  1825. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1826. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1827. parent_command = command;
  1828. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1829. safe_delete(sep);
  1830. if (command_parms->data.length() > (command->command.data.length() + 1))
  1831. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1832. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1833. }
  1834. else
  1835. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1836. }
  1837. int ndx = 0;
  1838. if (command->required_status > client->GetAdminStatus())
  1839. {
  1840. 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());
  1841. safe_delete(sep);
  1842. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1843. return;
  1844. }
  1845. Player* player = client->GetPlayer();
  1846. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1847. switch (command->handler) {
  1848. case COMMAND_RELOAD: {
  1849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1850. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells npc");
  1856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1863. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1864. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1865. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1866. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1867. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1868. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload voiceovers");
  1869. break;
  1870. }
  1871. case COMMAND_RELOADSTRUCTS: {
  1872. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1873. world.SetReloadingSubsystem("Structs");
  1874. configReader.ReloadStructs();
  1875. world.RemoveReloadingSubSystem("Structs");
  1876. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1877. break;
  1878. }
  1879. case COMMAND_RELOAD_QUESTS: {
  1880. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1881. world.SetReloadingSubsystem("Quests");
  1882. master_quest_list.Reload();
  1883. client_list.ReloadQuests();
  1884. zone_list.ReloadClientQuests();
  1885. world.RemoveReloadingSubSystem("Quests");
  1886. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1887. break;
  1888. }
  1889. case COMMAND_RELOAD_SPAWNS: {
  1890. client->GetCurrentZone()->ReloadSpawns();
  1891. break;
  1892. }
  1893. case COMMAND_RELOAD_SPELLS: {
  1894. if (sep && sep->arg[0] && strcmp(sep->arg[0], "npc") == 0) {
  1895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading NPC Spells Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1896. world.PurgeNPCSpells();
  1897. database.LoadNPCSpells();
  1898. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1899. }
  1900. else {
  1901. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells & NPC Spell Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1902. world.SetReloadingSubsystem("Spells");
  1903. zone_list.DeleteSpellProcess();
  1904. master_spell_list.Reload();
  1905. if (lua_interface)
  1906. lua_interface->ReloadSpells();
  1907. zone_list.LoadSpellProcess();
  1908. world.RemoveReloadingSubSystem("Spells");
  1909. world.PurgeNPCSpells();
  1910. database.LoadNPCSpells();
  1911. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1912. }
  1913. break;
  1914. }
  1915. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1916. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1917. world.SetReloadingSubsystem("GroundSpawns");
  1918. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1919. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1920. world.RemoveReloadingSubSystem("GroundSpawns");
  1921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1922. break;
  1923. }
  1924. case COMMAND_RELOAD_ZONESCRIPTS: {
  1925. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1926. world.SetReloadingSubsystem("ZoneScripts");
  1927. world.ResetZoneScripts();
  1928. database.LoadZoneScriptData();
  1929. if (lua_interface)
  1930. lua_interface->DestroyZoneScripts();
  1931. world.RemoveReloadingSubSystem("ZoneScripts");
  1932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1933. break;
  1934. }
  1935. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1937. world.SetReloadingSubsystem("EntityCommands");
  1938. client->GetCurrentZone()->ClearEntityCommands();
  1939. database.LoadEntityCommands(client->GetCurrentZone());
  1940. world.RemoveReloadingSubSystem("EntityCommands");
  1941. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1942. break;
  1943. }
  1944. case COMMAND_RELOAD_FACTIONS: {
  1945. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1946. world.SetReloadingSubsystem("Factions");
  1947. master_faction_list.Clear();
  1948. database.LoadFactionList();
  1949. world.RemoveReloadingSubSystem("Factions");
  1950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1951. break;
  1952. }
  1953. case COMMAND_RELOAD_MAIL: {
  1954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1955. zone_list.ReloadMail();
  1956. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1957. break;
  1958. }
  1959. case COMMAND_RELOAD_GUILDS: {
  1960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1961. world.ReloadGuilds();
  1962. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1963. break;
  1964. }
  1965. case COMMAND_RELOAD_LOCATIONS: {
  1966. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1967. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1968. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1970. break;
  1971. }
  1972. case COMMAND_RELOAD_RULES: {
  1973. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1974. database.LoadRuleSets(true);
  1975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1976. break;
  1977. }
  1978. case COMMAND_RELOAD_TRANSPORTERS: {
  1979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1980. database.LoadTransporters(client->GetCurrentZone());
  1981. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1982. break;
  1983. }
  1984. case COMMAND_RELOAD_STARTABILITIES: {
  1985. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1986. world.PurgeStartingLists();
  1987. world.LoadStartingLists();
  1988. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1989. break;
  1990. }
  1991. case COMMAND_RELOAD_VOICEOVERS: {
  1992. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Voiceovers...");
  1993. world.PurgeVoiceOvers();
  1994. world.LoadVoiceOvers();
  1995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1996. break;
  1997. }
  1998. case COMMAND_READ: {
  1999. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  2000. if (strcmp(sep->arg[0], "read") == 0) {
  2001. int32 item_index = atol(sep->arg[1]);
  2002. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  2003. if (item) {
  2004. Spawn* spawn = cmdTarget;
  2005. client->SendShowBook(client->GetPlayer(), item->name, item->book_language, item->book_pages);
  2006. break;
  2007. }
  2008. }
  2009. }
  2010. break;
  2011. }
  2012. case COMMAND_USEABILITY:{
  2013. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  2014. if (!client->GetPlayer()->Alive()) {
  2015. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  2016. }
  2017. else {
  2018. int32 spell_id = atoul(sep->arg[0]);
  2019. int8 spell_tier = 0;
  2020. if (sep->arg[1][0] && sep->IsNumber(1))
  2021. spell_tier = atoi(sep->arg[1]);
  2022. else
  2023. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  2024. if (!spell_tier)
  2025. spell_tier = 1;
  2026. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  2027. if (spell) {
  2028. 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)
  2029. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  2030. else
  2031. {
  2032. if (cmdTarget)
  2033. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  2034. else
  2035. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  2036. }
  2037. }
  2038. }
  2039. }
  2040. else if (cmdTarget && cmdTarget->IsWidget())
  2041. {
  2042. Widget* widget = (Widget*)cmdTarget;
  2043. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  2044. }
  2045. else
  2046. {
  2047. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  2048. }
  2049. break;
  2050. }
  2051. case COMMAND_INFO:{
  2052. bool check_self_trade = true;
  2053. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  2054. if(strcmp(sep->arg[0], "inventory") == 0){
  2055. int32 item_index = atol(sep->arg[1]);
  2056. LogWrite(COMMAND__DEBUG, 5, "Command", "/info inventory item original index %u", item_index);
  2057. if(client->GetVersion() <= 561) {
  2058. if(item_index <= 255) {
  2059. item_index = 255 - item_index;
  2060. }
  2061. else {
  2062. if(item_index == 256) { // first "new" item to inventory is assigned index 256 by client
  2063. item_index = client->GetPlayer()->item_list.GetFirstNewItem();
  2064. }
  2065. else {
  2066. // otherwise the slot has to be mapped out depending on the amount of new items + index sent in
  2067. item_index = client->GetPlayer()->item_list.GetNewItemByIndex((int16)item_index - 255);
  2068. }
  2069. }
  2070. }
  2071. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  2072. if(item){
  2073. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  2074. break;
  2075. EQ2Packet* app = 0;
  2076. if(client->GetVersion() <= 561) {
  2077. app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2078. }
  2079. else {
  2080. app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  2081. }
  2082. //DumpPacket(app);
  2083. client->QueuePacket(app);
  2084. if(item->GetItemScript() && lua_interface)
  2085. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2086. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  2087. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  2088. if(quest && client->GetPlayer()->HasQuestBeenCompleted(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->HasActiveQuest(item->generic_info.offers_quest_id) == 0)
  2089. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  2090. }
  2091. }
  2092. else
  2093. LogWrite(COMMAND__ERROR, 0, "Command", "/info inventory: Unknown Index: %u", item_index);
  2094. }
  2095. else if(strcmp(sep->arg[0], "equipment") == 0){
  2096. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2097. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  2098. if(item){
  2099. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2100. client->QueuePacket(app);
  2101. if(item->GetItemScript() && lua_interface)
  2102. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2103. }
  2104. else
  2105. LogWrite(COMMAND__ERROR, 0, "Command", "/info equipment: Unknown Index: %u", item_index);
  2106. }
  2107. else if(strcmp(sep->arg[0], "appearance") == 0){
  2108. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2109. Item* item = client->GetPlayer()->GetAppearanceEquipmentList()->GetItem(item_index);
  2110. if(item){
  2111. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2112. client->QueuePacket(app);
  2113. if(item->GetItemScript() && lua_interface)
  2114. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2115. }
  2116. else
  2117. LogWrite(COMMAND__ERROR, 0, "Command", "/info appearance: Unknown Index: %u", item_index);
  2118. }
  2119. 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){
  2120. int32 item_id = atoul(sep->arg[1]);
  2121. Item* item = master_item_list.GetItem(item_id);
  2122. if(item){
  2123. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2124. client->QueuePacket(app);
  2125. }
  2126. else
  2127. LogWrite(COMMAND__ERROR, 0, "Command", "/info item|merchant|store|buyback|consignment: Unknown Item ID: %u", item_id);
  2128. }
  2129. else if (strcmp(sep->arg[0], "spell") == 0) {
  2130. sint32 spell_id = atol(sep->arg[1]);
  2131. int8 tier = atoi(sep->arg[3]);
  2132. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  2133. if (outapp)
  2134. client->QueuePacket(outapp);
  2135. else
  2136. LogWrite(COMMAND__ERROR, 0, "Command", "/info spell: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2137. }
  2138. else if (strcmp(sep->arg[0], "achievement") == 0) {
  2139. sint32 spell_id = atol(sep->arg[2]);
  2140. int8 group = atoi(sep->arg[1]);
  2141. AltAdvanceData* data = 0;
  2142. SpellBookEntry* spellentry = 0;
  2143. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2144. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  2145. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  2146. if (outapp)
  2147. client->QueuePacket(outapp);
  2148. else
  2149. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  2150. }
  2151. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  2152. sint32 spell_id = atol(sep->arg[1]);
  2153. int32 tier = atoi(sep->arg[2]);
  2154. if (tier > 255) {
  2155. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  2156. if (ent)
  2157. tier = ent->tier;
  2158. }
  2159. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  2160. if (outapp)
  2161. client->QueuePacket(outapp);
  2162. else
  2163. LogWrite(COMMAND__ERROR, 0, "Command", "/info spellbook: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2164. }
  2165. else if (strcmp(sep->arg[0], "recipe") == 0) {
  2166. sint32 recipe_id = atol(sep->arg[1]);
  2167. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  2168. if(outapp)
  2169. client->QueuePacket(outapp);
  2170. else
  2171. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe: Unknown Recipe ID: %u", recipe_id);
  2172. }
  2173. else if (strcmp(sep->arg[0], "recipe_product") == 0) {
  2174. sint32 recipe_id = atol(sep->arg[1]);
  2175. PlayerRecipeList* prl = client->GetPlayer()->GetRecipeList();
  2176. Recipe* recipe = nullptr;
  2177. if ((recipe = prl->GetRecipe(recipe_id)) && recipe->GetProductID()) {
  2178. RecipeProducts* rp = recipe->products[1];
  2179. if (recipe->GetProductID() > 0) {
  2180. Item* item = master_item_list.GetItem(recipe->GetProductID());
  2181. if(item){
  2182. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2183. client->QueuePacket(app);
  2184. }
  2185. else
  2186. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: Unknown Item ID: %u", recipe->GetProductID());
  2187. }
  2188. else {
  2189. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: recipe->GetProductID() has value 0 for recipe id %u.", recipe_id);
  2190. }
  2191. }
  2192. else {
  2193. 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);
  2194. }
  2195. }
  2196. else if (strcmp(sep->arg[0], "maintained") ==0) {
  2197. int32 slot = atol(sep->arg[1]);
  2198. int32 spell_id = atol(sep->arg[2]);
  2199. LogWrite(COMMAND__DEBUG, 5, "Command", "/info maintained: Spell ID - Slot: %u unknown: %u", slot, spell_id);
  2200. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2201. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  2202. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  2203. if(outapp)
  2204. client->QueuePacket(outapp);
  2205. else
  2206. LogWrite(COMMAND__ERROR, 0, "Command", "/info maintained: Unknown Spell ID: %u", spell_id);
  2207. }
  2208. else if (strcmp(sep->arg[0], "effect") == 0) {
  2209. int32 spell_id = atol(sep->arg[1]);
  2210. LogWrite(COMMAND__DEBUG, 5, "Command", "/info effect: Spell ID: %u", spell_id);
  2211. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2212. int8 type = 0;
  2213. if (client->GetVersion() <= 561)
  2214. type = 1;
  2215. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  2216. if (outapp){
  2217. client->QueuePacket(outapp);
  2218. }
  2219. else
  2220. LogWrite(COMMAND__ERROR, 0, "Command", "/info effect: Unknown Spell ID: %u", spell_id);
  2221. }
  2222. else if(sep->IsNumber(1) && ((strncasecmp("your_trade", sep->arg[0], 10) == 0) ||
  2223. (strncasecmp("their_trade", sep->arg[0], 11) == 0)))
  2224. {
  2225. if(strncasecmp("t", sep->arg[0], 1) == 0) { // their_trade not self trade
  2226. check_self_trade = false;
  2227. }
  2228. int8 slot_id = atoul(sep->arg[1]);
  2229. if(client->GetPlayer()->trade) {
  2230. Entity* traderToCheck = client->GetPlayer();
  2231. if(!check_self_trade) {
  2232. traderToCheck = client->GetPlayer()->trade->GetTradee(client->GetPlayer());
  2233. }
  2234. Item* tradeItem = client->GetPlayer()->trade->GetTraderSlot(traderToCheck, slot_id);
  2235. if(tradeItem != nullptr) {
  2236. EQ2Packet* app = tradeItem->serialize(client->GetVersion(), true, client->GetPlayer(), true, 0, 0, client->GetVersion() > 561 ? true : false);
  2237. client->QueuePacket(app);
  2238. }
  2239. }
  2240. }
  2241. }
  2242. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  2243. Item* item = player->item_list.GetOverflowItem();
  2244. if(item) {
  2245. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2246. client->QueuePacket(app);
  2247. }
  2248. else
  2249. LogWrite(COMMAND__ERROR, 0,"Command", "/info overflow: Unable to retrieve an overflow item.");
  2250. }
  2251. else
  2252. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  2253. break;
  2254. }
  2255. case COMMAND_USE_EQUIPPED_ITEM:{
  2256. if (sep && sep->arg[0] && sep->IsNumber(0)){
  2257. int32 slot_id = atoul(sep->arg[0]);
  2258. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  2259. if (item && item->generic_info.usable && item->GetItemScript()) {
  2260. if(!item->CheckFlag2(INDESTRUCTABLE) && item->generic_info.condition == 0) {
  2261. client->SimpleMessage(CHANNEL_COLOR_RED, "This item is broken and must be repaired at a mender before it can be used");
  2262. }
  2263. else if (item->CheckFlag(EVIL_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_EVIL) {
  2264. client->Message(0, "%s requires an evil race.", item->name.c_str());
  2265. }
  2266. else if (item->CheckFlag(GOOD_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_GOOD) {
  2267. client->Message(0, "%s requires a good race.", item->name.c_str());
  2268. }
  2269. else {
  2270. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player, player->GetTarget());
  2271. }
  2272. }
  2273. }
  2274. break;
  2275. }
  2276. case COMMAND_USE_ITEM: {
  2277. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2278. int32 item_index = atoul(sep->arg[0]);
  2279. Item* item = player->item_list.GetItemFromIndex(item_index);
  2280. client->UseItem(item, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer());
  2281. }
  2282. break;
  2283. }
  2284. case COMMAND_SCRIBE_SCROLL_ITEM: {
  2285. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2286. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  2287. if (item) {
  2288. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  2289. if(item->generic_info.item_type == 6) {
  2290. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  2291. int8 old_slot = 0;
  2292. if (spell) {
  2293. if(!spell->ScribeAllowed(client->GetPlayer())) {
  2294. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not meet one of the requirements to scribe, due to class or level.");
  2295. break;
  2296. }
  2297. int16 tier_up = player->GetTierUp(spell->GetSpellTier());
  2298. if (rule_manager.GetGlobalRule(R_Spells, RequirePreviousTierScribe)->GetInt8() && !player->HasSpell(spell->GetSpellID(), tier_up, false, true))
  2299. client->SimpleMessage(CHANNEL_COLOR_RED, "You have not scribed the required previous version of this ability.");
  2300. else if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  2301. old_slot = player->GetSpellSlot(spell->GetSpellID());
  2302. player->RemoveSpellBookEntry(spell->GetSpellID());
  2303. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  2304. player->UnlockSpell(spell);
  2305. client->SendSpellUpdate(spell);
  2306. database.DeleteItem(client->GetCharacterID(), item, 0);
  2307. player->item_list.RemoveItem(item, true);
  2308. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  2309. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  2310. // force purge client cache and display updated spell for hover over
  2311. EQ2Packet* app = spell->SerializeSpell(client, false, false);
  2312. client->QueuePacket(app);
  2313. }
  2314. }
  2315. else
  2316. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  2317. }
  2318. else if(item->generic_info.item_type == 7){
  2319. if(item->recipebook_info) {
  2320. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->recipebook_info->recipe_id, player->GetName());
  2321. client->AddRecipeBookToPlayer(item->recipebook_info->recipe_id, item);
  2322. }
  2323. else {
  2324. 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);
  2325. 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());
  2326. }
  2327. }
  2328. else {
  2329. LogWrite(COMMAND__ERROR, 0, "Command", "Recipe Book Info is not set for item %s.", item->name.c_str());
  2330. }
  2331. }
  2332. else
  2333. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  2334. }
  2335. break;
  2336. }
  2337. case COMMAND_SUMMONITEM: {
  2338. if (sep && sep->IsNumber(0)) {
  2339. int32 item_id = atol(sep->arg[0]);
  2340. int32 quantity = 1;
  2341. if (sep->arg[1] && sep->IsNumber(1))
  2342. quantity = atoi(sep->arg[1]);
  2343. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  2344. client->AddItemToBank(item_id,quantity);
  2345. }
  2346. else {
  2347. client->AddItem(item_id, quantity);
  2348. }
  2349. }
  2350. else {
  2351. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  2352. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  2353. }
  2354. break;
  2355. }
  2356. case COMMAND_COLLECTION_ADDITEM: {
  2357. // takes 2 params: collection_id, slot
  2358. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2359. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  2360. if (item)
  2361. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  2362. else
  2363. 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]));
  2364. }
  2365. else
  2366. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  2367. break;
  2368. }
  2369. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  2370. // takes 1 param: slot
  2371. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  2372. int i = 0;
  2373. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  2374. printf("\t%u: %s\n", i, sep->arg[i]);
  2375. i++;
  2376. }
  2377. break;
  2378. }
  2379. case COMMAND_WAYPOINT: {
  2380. bool success = false;
  2381. client->ClearWaypoint();
  2382. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  2383. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  2384. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2385. }
  2386. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  2387. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  2388. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2389. }
  2390. else {
  2391. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  2392. }
  2393. break;
  2394. }
  2395. case COMMAND_WHO:{
  2396. const char* who = 0;
  2397. if(sep && sep->arg[0]){
  2398. //cout << "Who query: \n";
  2399. who = sep->argplus[0];
  2400. //cout << who << endl;
  2401. }
  2402. zone_list.ProcessWhoQuery(who, client);
  2403. break;
  2404. }
  2405. case COMMAND_SELECT_JUNCTION:{
  2406. // transporters (bells birds) use OP_SelectZoneTeleporterDestinatio / ProcessTeleportLocation(app)
  2407. // this is only used for revive it seems
  2408. int32 choice = 0;
  2409. if(sep && sep->arg[0] && sep->IsNumber(0))
  2410. choice = atoul(sep->arg[0]);
  2411. if(!client->GetPlayer()->Alive()){ //dead and this is a revive request
  2412. client->HandlePlayerRevive(choice);
  2413. }
  2414. break;
  2415. }
  2416. case COMMAND_SPAWN_MOVE: {
  2417. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  2418. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  2419. if (packet) {
  2420. float unknown2_3 = 0;
  2421. int8 placement_mode = 0;
  2422. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  2423. if (sep && sep->arg[0][0]) {
  2424. if (strcmp(sep->arg[0], "wall") == 0) {
  2425. placement_mode = 2;
  2426. unknown2_3 = 150;
  2427. }
  2428. else if (strcmp(sep->arg[0], "ceiling") == 0)
  2429. placement_mode = 1;
  2430. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  2431. {
  2432. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  2433. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  2434. }
  2435. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  2436. {
  2437. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  2438. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  2439. }
  2440. else if (strcmp(sep->arg[0], "myloc") == 0)
  2441. {
  2442. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  2443. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  2444. safe_delete(packet);
  2445. break;
  2446. }
  2447. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  2448. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  2449. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  2450. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  2451. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  2452. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  2453. safe_delete(packet);
  2454. break;
  2455. }
  2456. }
  2457. packet->setDataByName("placement_mode", placement_mode);
  2458. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  2459. packet->setDataByName("model_type", cmdTarget->GetModelType());
  2460. packet->setDataByName("unknown", 1); //size
  2461. packet->setDataByName("unknown2", 1); //size 2
  2462. packet->setDataByName("unknown2", .5, 1); //size 3
  2463. packet->setDataByName("unknown2", 3, 2);
  2464. packet->setDataByName("unknown2", unknown2_3, 3);
  2465. packet->setDataByName("max_distance", 500);
  2466. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  2467. client->QueuePacket(packet->serialize());
  2468. safe_delete(packet);
  2469. }
  2470. }
  2471. else {
  2472. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  2473. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  2474. }
  2475. break;
  2476. }
  2477. case COMMAND_HAIL:{
  2478. Spawn* spawn = cmdTarget;
  2479. if(spawn && spawn->GetTargetable())
  2480. {
  2481. char tmp[75] = {0};
  2482. sprintf(tmp, "Hail, %s", spawn->GetName());
  2483. bool show_bubble = true;
  2484. if (spawn->IsNPC())
  2485. show_bubble = false;
  2486. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble, client->GetPlayer()->GetCurrentLanguage());
  2487. if(spawn->IsPlayer() == false && spawn->Alive() && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetGlobalRule(R_Spawn, HailDistance)->GetInt32()){
  2488. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  2489. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  2490. else
  2491. {
  2492. bool pauseRunback = false;
  2493. // prime runback as the heading or anything can be altered when hailing succeeds
  2494. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  2495. {
  2496. ((NPC*)spawn)->StartRunback();
  2497. pauseRunback = true;
  2498. }
  2499. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  2500. spawn->PauseMovement(rule_manager.GetGlobalRule(R_Spawn, HailMovementPause)->GetInt32());
  2501. else if(spawn->IsNPC() && pauseRunback)
  2502. ((NPC*)spawn)->ClearRunback();
  2503. }
  2504. }
  2505. }
  2506. else {
  2507. string tmp = "Hail";
  2508. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2509. }
  2510. break;
  2511. }
  2512. case COMMAND_SAY:{
  2513. if (sep && sep->arg[0][0]) {
  2514. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2515. if (cmdTarget && !(cmdTarget->IsPlayer()))
  2516. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  2517. }
  2518. else
  2519. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  2520. break;
  2521. }
  2522. case COMMAND_TELL:{
  2523. if(sep && sep->arg[0] && sep->argplus[1]){
  2524. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1], 0, client->GetPlayer()->GetCurrentLanguage()))
  2525. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  2526. }else
  2527. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  2528. break;
  2529. }
  2530. case COMMAND_SHOUT:{
  2531. if(sep && sep->arg[0][0])
  2532. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2533. else
  2534. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  2535. break;
  2536. }
  2537. case COMMAND_AUCTION:{
  2538. if(sep && sep->arg[0][0])
  2539. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2540. else
  2541. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  2542. break;
  2543. }
  2544. case COMMAND_OOC:{
  2545. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2546. if(sep && sep->arg[0][0])
  2547. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0], 0, client->GetPlayer()->GetCurrentLanguage());
  2548. else
  2549. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2550. break;
  2551. }
  2552. case COMMAND_EMOTE:{
  2553. if(sep && sep->arg[0][0])
  2554. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2555. else
  2556. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2557. break;
  2558. }
  2559. case COMMAND_RACE:{
  2560. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2561. if(sep->arg[1][0] && sep->IsNumber(1)){
  2562. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2563. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2564. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2565. client->GetPlayer()->SetCharSheetChanged(true);
  2566. }
  2567. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2568. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2569. //client->QueuePacket(outapp);
  2570. }
  2571. else{
  2572. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2573. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2574. }
  2575. break;
  2576. }
  2577. case COMMAND_BANK_DEPOSIT:{
  2578. if(client->GetBanker() && sep && sep->arg[0]){
  2579. int64 amount = 0;
  2580. string deposit = string(sep->arg[0]);
  2581. amount = atoi64(deposit.c_str());
  2582. client->BankDeposit(amount);
  2583. }
  2584. break;
  2585. }
  2586. case COMMAND_BANK_WITHDRAWAL:{
  2587. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2588. int64 amount = 0;
  2589. string deposit = string(sep->arg[0]);
  2590. amount = atoi64(deposit.c_str());
  2591. client->BankWithdrawal(amount);
  2592. }
  2593. break;
  2594. }
  2595. case COMMAND_BANK_CANCEL:{
  2596. Spawn* banker = cmdTarget;
  2597. client->Bank(banker, true);
  2598. break;
  2599. }
  2600. case COMMAND_BANK:{
  2601. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2602. Spawn* banker = cmdTarget;
  2603. client->Bank(banker);
  2604. break;
  2605. }
  2606. case COMMAND_GUILD_BANK:{
  2607. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2608. //Spawn* banker = client->GetPlayer()->GetTarget();
  2609. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2610. break;
  2611. }
  2612. case COMMAND_START_MAIL: {
  2613. client->SetMailTransaction(cmdTarget);
  2614. client->SendMailList();
  2615. break;
  2616. }
  2617. case COMMAND_CANCEL_MAIL: {
  2618. client->SetMailTransaction(0);
  2619. break;
  2620. }
  2621. case COMMAND_GET_MAIL_MESSAGE: {
  2622. if (sep && sep->arg[0] && sep->IsNumber(0))
  2623. client->DisplayMailMessage(atoul(sep->arg[0]));
  2624. break;
  2625. }
  2626. case COMMAND_ADD_MAIL_PLAT: {
  2627. if (sep && sep->arg[0] && sep->IsNumber(0))
  2628. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2629. break;
  2630. }
  2631. case COMMAND_ADD_MAIL_GOLD: {
  2632. if (sep && sep->arg[0] && sep->IsNumber(0))
  2633. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2634. break;
  2635. }
  2636. case COMMAND_ADD_MAIL_SILVER: {
  2637. if (sep && sep->arg[0] && sep->IsNumber(0))
  2638. client->AddMailCoin(0, atoul(sep->arg[0]));
  2639. break;
  2640. }
  2641. case COMMAND_ADD_MAIL_COPPER: {
  2642. if (sep && sep->arg[0] && sep->IsNumber(0))
  2643. client->AddMailCoin(atoul(sep->arg[0]));
  2644. break;
  2645. }
  2646. case COMMAND_SET_MAIL_ITEM: {
  2647. if(sep && sep->IsNumber(0) && sep->IsNumber(1))
  2648. {
  2649. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2650. if(item)
  2651. {
  2652. int16 quantity = atoul(sep->arg[1]);
  2653. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2654. {
  2655. return;
  2656. }
  2657. if(item->IsBag())
  2658. {
  2659. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2660. if(bag_items && bag_items->size() > 0)
  2661. {
  2662. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2663. safe_delete(bag_items);
  2664. return;
  2665. }
  2666. safe_delete(bag_items);
  2667. }
  2668. Item* itemtoadd = item;
  2669. if(quantity > 0)
  2670. {
  2671. if(quantity > item->details.count)
  2672. return;
  2673. Item* tmpItem = new Item(item);
  2674. tmpItem->details.count = quantity;
  2675. itemtoadd = tmpItem;
  2676. }
  2677. if(client->AddMailItem(itemtoadd))
  2678. {
  2679. client->RemoveItem(item, quantity, true);
  2680. }
  2681. }
  2682. }
  2683. break;
  2684. }
  2685. case COMMAND_REMOVE_MAIL_PLAT: {
  2686. if (sep && sep->arg[0] && sep->IsNumber(0))
  2687. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2688. break;
  2689. }
  2690. case COMMAND_REMOVE_MAIL_GOLD: {
  2691. if (sep && sep->arg[0] && sep->IsNumber(0))
  2692. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2693. break;
  2694. }
  2695. case COMMAND_REMOVE_MAIL_SILVER: {
  2696. if (sep && sep->arg[0] && sep->IsNumber(0))
  2697. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2698. break;
  2699. }
  2700. case COMMAND_REMOVE_MAIL_COPPER: {
  2701. if (sep && sep->arg[0] && sep->IsNumber(0))
  2702. client->RemoveMailCoin(atoul(sep->arg[0]));
  2703. break;
  2704. }
  2705. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2706. if (sep && sep->arg[0] && sep->IsNumber(0))
  2707. client->TakeMailAttachments(atoul(sep->arg[0]));
  2708. break;
  2709. }
  2710. case COMMAND_CANCEL_SEND_MAIL: {
  2711. client->ResetSendMail();
  2712. break;
  2713. }
  2714. case COMMAND_DELETE_MAIL_MESSAGE: {
  2715. if (sep && sep->arg[0] && sep->IsNumber(0))
  2716. client->DeleteMail(atoul(sep->arg[0]), true);
  2717. break;
  2718. }
  2719. case COMMAND_REPORT_SPAM: {
  2720. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2721. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2722. break;
  2723. }
  2724. case COMMAND_KILL:{
  2725. Spawn* dead = 0;
  2726. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2727. dead=client->GetPlayer();
  2728. client->GetPlayer()->SetHP(0);
  2729. client->GetPlayer()->KillSpawn(dead);
  2730. }else{
  2731. dead= cmdTarget;
  2732. if(dead && dead->IsPlayer() == false){
  2733. if(dead->IsNPC() && ((NPC*)dead)->Brain()) {
  2734. client->GetPlayer()->CheckEncounterState((Entity*)dead);
  2735. ((NPC*)dead)->Brain()->AddToEncounter(client->GetPlayer());
  2736. ((NPC*)dead)->AddTargetToEncounter(client->GetPlayer());
  2737. ((NPC*)dead)->Brain()->AddHate(client->GetPlayer(), 1);
  2738. }
  2739. dead->SetHP(0);
  2740. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2741. client->GetCurrentZone()->RemoveSpawn(dead, true, true, true, true, true);
  2742. else
  2743. client->GetPlayer()->KillSpawn(dead);
  2744. }else{
  2745. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2746. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2747. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2748. }
  2749. }
  2750. break;
  2751. }
  2752. case COMMAND_LEVEL:{
  2753. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2754. int16 new_level = atoi(sep->arg[ndx]);
  2755. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2756. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2757. else {
  2758. if (new_level < 1)
  2759. new_level = 1;
  2760. if (new_level > 255)
  2761. new_level = 255;
  2762. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2763. }
  2764. }else
  2765. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2766. break;
  2767. }
  2768. case COMMAND_SIT: {
  2769. if(client->GetPlayer()->GetHP() > 0){
  2770. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2771. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2772. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2773. }
  2774. break;
  2775. }
  2776. case COMMAND_STAND: {
  2777. if(client->GetPlayer()->GetHP() > 0){
  2778. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2779. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2780. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2781. }
  2782. break;
  2783. }
  2784. case COMMAND_CLASS:{
  2785. if(sep && sep->arg[ndx][0]){
  2786. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2787. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2788. }else
  2789. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2790. break;
  2791. }
  2792. case COMMAND_FLYMODE:{
  2793. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2794. PrintSep(sep, "COMMAND_FLYMODE");
  2795. int8 val = atoul(sep->arg[0]);
  2796. ClientPacketFunctions::SendFlyMode(client, val);
  2797. }
  2798. else{
  2799. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode [1|2] 1 = fly, 2 = no clip");
  2800. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2801. }
  2802. break;
  2803. }
  2804. case COMMAND_LOOT_LIST:{
  2805. Spawn* spawn = cmdTarget;
  2806. if(spawn && spawn->IsEntity()){
  2807. if (sep && sep->arg[0]) {
  2808. if (!spawn->GetDatabaseID())
  2809. {
  2810. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "NOTE: Spawn has no database id to assign to loottables.");
  2811. }
  2812. if (!spawn->IsNPC())
  2813. {
  2814. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2815. break;
  2816. }
  2817. bool reloadLoot = false;
  2818. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2819. {
  2820. int32 loottable_id = atoul(sep->arg[1]);
  2821. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2822. {
  2823. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2824. reloadLoot = true;
  2825. }
  2826. else
  2827. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2828. }
  2829. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2830. {
  2831. int32 loottable_id = atoul(sep->arg[1]);
  2832. if (loottable_id > 0)
  2833. {
  2834. database.AddLootTableToSpawn(spawn, loottable_id);
  2835. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2836. reloadLoot = true;
  2837. }
  2838. else
  2839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2840. }
  2841. else if (!stricmp(sep->arg[0], "clearall"))
  2842. {
  2843. if (database.RemoveSpawnLootTable(spawn, 0))
  2844. {
  2845. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2846. reloadLoot = true;
  2847. }
  2848. else
  2849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2850. }
  2851. else if (!stricmp(sep->arg[0], "details"))
  2852. {
  2853. spawn->LockLoot();
  2854. client->SimpleMessage(CHANNEL_COMMANDS, "Loot Window List:");
  2855. if (spawn->GetLootWindowList()->size() > 0) {
  2856. std::map<int32, bool>::iterator itr;
  2857. for (itr = spawn->GetLootWindowList()->begin(); itr != spawn->GetLootWindowList()->end(); itr++) {
  2858. Spawn* looter = client->GetPlayer()->GetZone()->GetSpawnByID(itr->first);
  2859. if (looter) {
  2860. client->Message(CHANNEL_COLOR_YELLOW, "Looter: %s IsLootWindowOpen: %s, HasCompletedLootWindow: %s.", looter->GetName(), itr->second ? "NO" : "YES", spawn->HasSpawnLootWindowCompleted(itr->first) ? "YES" : "NO");
  2861. }
  2862. }
  2863. }
  2864. spawn->UnlockLoot();
  2865. }
  2866. else
  2867. {
  2868. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2871. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2872. break;
  2873. }
  2874. if (reloadLoot)
  2875. {
  2876. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2877. if (spawn->IsNPC())
  2878. {
  2879. Entity* ent = (Entity*)spawn;
  2880. ent->SetLootCoins(0);
  2881. ent->ClearLoot();
  2882. spawn->GetZone()->AddLoot((NPC*)spawn);
  2883. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2884. }
  2885. }
  2886. break; // nothing further this is the end of these sub commands
  2887. }
  2888. else
  2889. {
  2890. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()), spawn);
  2891. if (loot_list.size() > 0) {
  2892. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2893. vector<int32>::iterator list_itr;
  2894. LootTable* table = 0;
  2895. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2896. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2897. if (table)
  2898. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2899. }
  2900. }
  2901. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2902. vector<Item*>* items = spawn->GetLootItems();
  2903. if (items) {
  2904. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2905. vector<Item*>::iterator itr;
  2906. Item* item = 0;
  2907. for (itr = items->begin(); itr != items->end(); itr++) {
  2908. item = *itr;
  2909. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2910. }
  2911. }
  2912. else
  2913. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2914. }
  2915. }
  2916. break;
  2917. }
  2918. case COMMAND_LOOT_SETCOIN:{
  2919. Spawn* spawn = cmdTarget;
  2920. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2921. spawn->SetLootCoins(atoul(sep->arg[0]));
  2922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2923. }
  2924. else
  2925. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2926. break;
  2927. }
  2928. case COMMAND_LOOT_ADDITEM:{
  2929. Spawn* spawn = cmdTarget;
  2930. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2931. int16 charges = 1;
  2932. if(sep->arg[1] && sep->IsNumber(1))
  2933. charges = atoi(sep->arg[1]);
  2934. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2935. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2936. }
  2937. else
  2938. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2939. break;
  2940. }
  2941. case COMMAND_LOOT_REMOVEITEM:{
  2942. Spawn* spawn = cmdTarget;
  2943. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2944. Item* item = spawn->LootItem(atoul(sep->arg[0]));
  2945. lua_interface->SetLuaUserDataStale(item);
  2946. safe_delete(item);
  2947. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2948. }
  2949. else
  2950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2951. break;
  2952. }
  2953. case COMMAND_LOOT_CORPSE:
  2954. case COMMAND_DISARM:
  2955. case COMMAND_LOOT:{
  2956. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2957. {
  2958. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2959. break;
  2960. }
  2961. if(cmdTarget && cmdTarget->IsEntity()){
  2962. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2963. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2964. client->OpenChest(cmdTarget, true);
  2965. else
  2966. client->LootSpawnRequest(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2967. if (!(cmdTarget)->HasLoot()){
  2968. if (((Entity*)cmdTarget)->IsNPC())
  2969. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2970. }
  2971. }
  2972. else
  2973. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2974. }
  2975. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2976. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2977. break;
  2978. }
  2979. case COMMAND_RELOADSPAWNSCRIPTS:{
  2980. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2981. if (lua_interface)
  2982. lua_interface->SetLuaSystemReloading(true);
  2983. world.ResetSpawnScripts();
  2984. database.LoadSpawnScriptData();
  2985. if(lua_interface) {
  2986. lua_interface->DestroySpawnScripts();
  2987. lua_interface->SetLuaSystemReloading(false);
  2988. }
  2989. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2990. break;
  2991. }
  2992. case COMMAND_RELOADREGIONSCRIPTS:{
  2993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2994. if(lua_interface) {
  2995. lua_interface->DestroyRegionScripts();
  2996. }
  2997. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2998. break;
  2999. }
  3000. case COMMAND_RELOADLUASYSTEM:{
  3001. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  3002. world.SetReloadingSubsystem("LuaSystem");
  3003. if(lua_interface) {
  3004. lua_interface->SetLuaSystemReloading(true);
  3005. }
  3006. zone_list.DeleteSpellProcess();
  3007. master_spell_list.Reload();
  3008. if (lua_interface)
  3009. lua_interface->ReloadSpells();
  3010. zone_list.LoadSpellProcess();
  3011. if(lua_interface){
  3012. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  3013. map<Client*, int32>::iterator itr;
  3014. for(itr = debug_clients.begin(); itr != debug_clients.end(); itr++){
  3015. if(lua_interface)
  3016. lua_interface->UpdateDebugClients(itr->first);
  3017. }
  3018. }
  3019. world.ResetSpawnScripts();
  3020. database.LoadSpawnScriptData();
  3021. world.ResetZoneScripts();
  3022. database.LoadZoneScriptData();
  3023. if(lua_interface) {
  3024. lua_interface->DestroySpawnScripts();
  3025. lua_interface->DestroyRegionScripts();
  3026. lua_interface->DestroyQuests();
  3027. lua_interface->DestroyItemScripts();
  3028. lua_interface->DestroyZoneScripts();
  3029. }
  3030. int32 quest_count = database.LoadQuests();
  3031. int32 spell_count = 0;
  3032. if(lua_interface) {
  3033. spell_count = database.LoadSpellScriptData();
  3034. lua_interface->SetLuaSystemReloading(false);
  3035. }
  3036. world.RemoveReloadingSubSystem("LuaSystem");
  3037. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  3038. break;
  3039. }
  3040. case COMMAND_DECLINE_QUEST:{
  3041. int32 quest_id = 0;
  3042. if(sep && sep->arg[0] && sep->IsNumber(0))
  3043. quest_id = atoul(sep->arg[0]);
  3044. if(quest_id > 0){
  3045. client->RemovePendingQuest(quest_id);
  3046. }
  3047. break;
  3048. }
  3049. case COMMAND_DELETE_QUEST:{
  3050. int32 quest_id = 0;
  3051. if(sep && sep->arg[0] && sep->IsNumber(0))
  3052. quest_id = atoul(sep->arg[0]);
  3053. if(quest_id > 0){
  3054. client->GetPlayer()->MPlayerQuests.readlock(__FUNCTION__, __LINE__);
  3055. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  3056. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  3057. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3058. if (quest && quest->CanDeleteQuest()) {
  3059. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  3060. client->RemovePlayerQuest(quest_id);
  3061. client->GetCurrentZone()->SendQuestUpdates(client);
  3062. }
  3063. }
  3064. else {
  3065. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3066. }
  3067. }
  3068. break;
  3069. }
  3070. case COMMAND_ACCEPT_QUEST:{
  3071. int32 quest_id = 0;
  3072. if(sep && sep->arg[0] && sep->IsNumber(0))
  3073. quest_id = atoul(sep->arg[0]);
  3074. if(quest_id > 0){
  3075. client->AcceptQuest(quest_id);
  3076. }
  3077. break;
  3078. }
  3079. case COMMAND_NAME:{
  3080. if(sep && sep->arg[ndx][0]){
  3081. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  3082. client->GetPlayer()->SetCharSheetChanged(true);
  3083. }else
  3084. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  3085. break;
  3086. }
  3087. case COMMAND_GROUP: {
  3088. if(sep && sep->arg[0])
  3089. printf("Group: %s\n",sep->argplus[0]);
  3090. break;
  3091. }
  3092. case COMMAND_GROUPSAY:{
  3093. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3094. if(sep && sep->arg[0] && gmi)
  3095. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), client->GetPlayer()->GetCurrentLanguage(), sep->argplus[0]);
  3096. break;
  3097. }
  3098. case COMMAND_GROUPINVITE: {
  3099. Entity* target = 0;
  3100. Client* target_client = 0;
  3101. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3102. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  3103. return;
  3104. }
  3105. // name provided with command so it has to be a player, npc not supported here
  3106. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  3107. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  3108. if (target_client) {
  3109. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  3110. target = 0;
  3111. else
  3112. target = target_client->GetPlayer();
  3113. }
  3114. }
  3115. // if name was not provided use the players target, npc or player supported here
  3116. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  3117. target = (Entity*)client->GetPlayer()->GetTarget();
  3118. if (target->IsPlayer()) {
  3119. target_client = ((Player*)target)->GetClient();
  3120. }
  3121. }
  3122. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  3123. if (result == 0) {
  3124. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  3125. if (target_client) {
  3126. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  3127. if (packet) {
  3128. packet->setDataByName("type", 1);
  3129. packet->setDataByName("name", client->GetPlayer()->GetName());
  3130. packet->setDataByName("unknown2", 1);
  3131. target_client->QueuePacket(packet->serialize());
  3132. safe_delete(packet);
  3133. }
  3134. }
  3135. }
  3136. else if (result == 1)
  3137. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  3138. else if (result == 2)
  3139. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  3140. else if (result == 3)
  3141. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  3142. else if (result == 4)
  3143. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  3144. else if (result == 5)
  3145. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  3146. else if (result == 6)
  3147. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  3148. else
  3149. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  3150. break;
  3151. }
  3152. case COMMAND_GROUPDISBAND: {
  3153. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3154. if (gmi) { // TODO: Leader check
  3155. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  3156. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  3157. }
  3158. break;
  3159. }
  3160. case COMMAND_GROUP_LEAVE: {
  3161. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3162. if (gmi) {
  3163. int32 group_id = gmi->group_id;
  3164. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  3165. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  3166. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  3167. }
  3168. else {
  3169. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  3170. }
  3171. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  3172. }
  3173. break;
  3174. }
  3175. case COMMAND_FRIEND_ADD:{
  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. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3183. if(client->GetPlayer()->IsIgnored(name.c_str())){
  3184. client->GetPlayer()->RemoveIgnore(name.c_str());
  3185. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3186. client->SendChatRelationship(3, name.c_str());
  3187. }
  3188. client->GetPlayer()->AddFriend(name.c_str(), true);
  3189. client->SendChatRelationship(0, name.c_str());
  3190. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  3191. if(zone_list.GetClientByCharName(name))
  3192. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  3193. }
  3194. else
  3195. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  3196. }
  3197. else
  3198. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3199. break;
  3200. }
  3201. case COMMAND_FRIEND_REMOVE:{
  3202. string name = "";
  3203. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3204. name = database.GetPlayerName(sep->arg[0]);
  3205. else if(cmdTarget && cmdTarget->IsPlayer())
  3206. name = string(cmdTarget->GetName());
  3207. if(name.length() > 0){
  3208. client->GetPlayer()->RemoveFriend(name.c_str());
  3209. client->SendChatRelationship(1, name.c_str());
  3210. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3211. }
  3212. else
  3213. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3214. break;
  3215. }
  3216. case COMMAND_FRIENDS:{
  3217. break;
  3218. }
  3219. case COMMAND_IGNORE_ADD:{
  3220. string name = "";
  3221. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3222. name = database.GetPlayerName(sep->arg[0]);
  3223. else if(cmdTarget && cmdTarget->IsPlayer())
  3224. name = string(cmdTarget->GetName());
  3225. if(name.length() > 0){
  3226. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3227. if(client->GetPlayer()->IsFriend(name.c_str())){
  3228. client->GetPlayer()->RemoveFriend(name.c_str());
  3229. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3230. client->SendChatRelationship(1, name.c_str());
  3231. }
  3232. client->GetPlayer()->AddIgnore(name.c_str(), true);
  3233. client->SendChatRelationship(2, name.c_str());
  3234. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  3235. }
  3236. else
  3237. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  3238. }
  3239. else
  3240. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3241. break;
  3242. }
  3243. case COMMAND_IGNORE_REMOVE:{
  3244. string name = "";
  3245. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3246. name = database.GetPlayerName(sep->arg[0]);
  3247. else if(cmdTarget && cmdTarget->IsPlayer())
  3248. name = string(cmdTarget->GetName());
  3249. if(name.length() > 0){
  3250. client->GetPlayer()->RemoveIgnore(name.c_str());
  3251. client->SendChatRelationship(3, name.c_str());
  3252. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3253. }
  3254. break;
  3255. }
  3256. case COMMAND_IGNORES:{
  3257. break;
  3258. }
  3259. case COMMAND_GROUP_KICK:{
  3260. Entity* kicked = 0;
  3261. Client* kicked_client = 0;
  3262. int32 group_id = 0;
  3263. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  3264. return;
  3265. if (sep && sep->arg[0]) {
  3266. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  3267. if (kicked_client)
  3268. kicked = kicked_client->GetPlayer();
  3269. }
  3270. else if (cmdTarget && cmdTarget->IsEntity()) {
  3271. kicked = (Entity*)cmdTarget;
  3272. }
  3273. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  3274. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  3275. if (kicked)
  3276. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  3277. if(send_kicked_message)
  3278. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  3279. else
  3280. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  3281. if (kicked_client)
  3282. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  3283. break;
  3284. }
  3285. case COMMAND_GROUP_MAKE_LEADER:{
  3286. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3287. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  3288. return;
  3289. }
  3290. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  3291. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  3292. if (new_leader && new_leader->GetPlayer()->GetGroupMemberInfo() && new_leader->GetPlayer()->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3293. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  3294. if(world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer())) {
  3295. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", new_leader->GetPlayer()->GetName());
  3296. }
  3297. }
  3298. }
  3299. else
  3300. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  3301. }
  3302. else if (cmdTarget && cmdTarget->IsPlayer() && ((Player*)cmdTarget)->GetGroupMemberInfo() && ((Player*)cmdTarget)->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3303. if(client->GetPlayer()->IsGroupMember((Player*)cmdTarget) && world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget)) {
  3304. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", cmdTarget->GetName());
  3305. }
  3306. }
  3307. else
  3308. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  3309. break;
  3310. }
  3311. case COMMAND_GROUP_ACCEPT_INVITE: {
  3312. if((sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) || (!sep && client->GetVersion() <= 561)) {
  3313. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  3314. if (result == 0)
  3315. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  3316. else if (result == 1)
  3317. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  3318. else if (result == 2)
  3319. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  3320. else
  3321. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  3322. }
  3323. break;
  3324. }
  3325. case COMMAND_GROUP_DECLINE_INVITE: {
  3326. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  3327. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  3328. }
  3329. break;
  3330. }
  3331. case COMMAND_SUMMON:{
  3332. char* search_name = 0;
  3333. if(sep && sep->arg[0][0])
  3334. search_name = sep->arg[0];
  3335. if(!search_name && !cmdTarget){
  3336. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  3337. 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.");
  3338. }
  3339. else{
  3340. if(!client->Summon(search_name))
  3341. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3342. }
  3343. break;
  3344. }
  3345. case COMMAND_GOTO:{
  3346. const char* search_name = 0;
  3347. if(sep && sep->arg[0][0])
  3348. search_name = sep->argplus[0];
  3349. if(!search_name && !cmdTarget){
  3350. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  3351. 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.");
  3352. }
  3353. else{
  3354. if(!client->GotoSpawn(search_name))
  3355. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3356. }
  3357. break;
  3358. }
  3359. case COMMAND_MOVE:{
  3360. bool success = false;
  3361. try{
  3362. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  3363. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  3364. if(app){
  3365. client->QueuePacket(app);
  3366. success = true;
  3367. }
  3368. }
  3369. }
  3370. catch(...){}
  3371. if(!success){
  3372. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  3373. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  3374. }
  3375. break;
  3376. }
  3377. case COMMAND_SETTIME:{
  3378. if(sep && sep->arg[0]){
  3379. world.MWorldTime.writelock(__FUNCTION__, __LINE__);
  3380. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  3381. if(sep->arg[1] && sep->IsNumber(1))
  3382. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  3383. if(sep->arg[2] && sep->IsNumber(2))
  3384. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  3385. if(sep->arg[3] && sep->IsNumber(3))
  3386. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  3387. world.MWorldTime.releasewritelock(__FUNCTION__, __LINE__);
  3388. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  3389. }
  3390. else{
  3391. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  3392. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  3393. }
  3394. break;
  3395. }
  3396. case COMMAND_VERSION:{
  3397. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  3398. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  3399. auto [days, hours, minutes, seconds] = convertTimestampDuration((getCurrentTimestamp() - world.world_uptime));
  3400. client->Message(CHANNEL_COLOR_YELLOW,"Uptime %u day(s), %u hour(s), %u minute(s), %u second(s).", days, hours, minutes, seconds);
  3401. break;
  3402. }
  3403. case COMMAND_ZONE:{
  3404. int32 instanceID = 0;
  3405. string zone;
  3406. int32 zone_id = 0;
  3407. bool listSearch = false;
  3408. bool isInstance = false;
  3409. ZoneServer* zsZone = 0;
  3410. if(sep && sep->arg[0][0])
  3411. {
  3412. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  3413. listSearch = true;
  3414. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  3415. {
  3416. zone_list.SendZoneList(client);
  3417. break;
  3418. }
  3419. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  3420. {
  3421. if(sep->IsNumber(1))
  3422. instanceID = atol(sep->arg[1]);
  3423. }
  3424. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  3425. {
  3426. PrintSep(sep, "ZONE LOCK");
  3427. if(sep->IsNumber(1))
  3428. zsZone = zone_list.Get(atoul(sep->arg[1]), false, false, false);
  3429. else
  3430. zsZone = zone_list.Get(sep->arg[1], false, false, false);
  3431. if( zsZone )
  3432. {
  3433. zsZone->SetZoneLockState(true);
  3434. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3435. }
  3436. else
  3437. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  3438. break;
  3439. }
  3440. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  3441. {
  3442. PrintSep(sep, "ZONE UNLOCK");
  3443. if(sep->IsNumber(1))
  3444. zsZone = zone_list.Get(atoul(sep->arg[1]), false, false, false);
  3445. else
  3446. zsZone = zone_list.Get(sep->arg[1], false, false, false);
  3447. if( zsZone )
  3448. {
  3449. zsZone->SetZoneLockState(false);
  3450. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3451. }
  3452. else
  3453. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  3454. break;
  3455. }
  3456. else
  3457. {
  3458. if(sep->IsNumber(0))
  3459. {
  3460. zone_id = atoul(sep->arg[0]);
  3461. string zonename = database.GetZoneName(zone_id);
  3462. if(zonename.length() > 0)
  3463. zone = zonename;
  3464. }
  3465. else
  3466. zone = sep->arg[0];
  3467. }
  3468. if(instanceID > 0)
  3469. {
  3470. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  3471. if(zsInstance != NULL)
  3472. {
  3473. instanceID = zsInstance->GetInstanceID();
  3474. zone = zsInstance->GetZoneName();
  3475. zone_id = zsInstance->GetZoneID();
  3476. isInstance = true;
  3477. }
  3478. }
  3479. }
  3480. if(!listSearch)
  3481. {
  3482. if(zone.length() == 0)
  3483. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  3484. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  3485. zone_id != client->GetCurrentZone()->GetZoneID())
  3486. {
  3487. const char* zonestr = zone.c_str();
  3488. if(database.VerifyZone(zonestr))
  3489. {
  3490. if(client->CheckZoneAccess(zonestr))
  3491. {
  3492. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  3493. if(isInstance)
  3494. client->Zone(instanceID,true,true,false);
  3495. else
  3496. client->Zone(zonestr);
  3497. }
  3498. }
  3499. else
  3500. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  3501. }
  3502. else
  3503. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  3504. }
  3505. else
  3506. {
  3507. const char* name = 0;
  3508. if(sep && sep->arg[1][0])
  3509. {
  3510. map<int32, string>* zone_names;
  3511. name = sep->argplus[1];
  3512. sint16 status = client->GetAdminStatus();
  3513. if( status > 0 )
  3514. {
  3515. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  3516. zone_names = database.GetZoneList(name, true);
  3517. }
  3518. else
  3519. zone_names = database.GetZoneList(name);
  3520. if(!zone_names)
  3521. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  3522. else
  3523. {
  3524. map<int32, string>::iterator itr;
  3525. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  3526. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  3527. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  3528. safe_delete(zone_names);
  3529. }
  3530. }
  3531. else
  3532. {
  3533. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  3534. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  3535. }
  3536. }
  3537. break;
  3538. }
  3539. case COMMAND_USE: {
  3540. Spawn* target = cmdTarget;
  3541. if (target && target->IsWidget())
  3542. ((Widget*)target)->HandleUse(client, "use");
  3543. break;
  3544. }
  3545. case COMMAND_OPEN: {
  3546. Spawn* target = cmdTarget;
  3547. if (target && target->IsWidget())
  3548. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  3549. break;
  3550. }
  3551. case COMMAND_CASTSPELL: {
  3552. if (sep && sep->arg[0] && sep->IsNumber(0))
  3553. {
  3554. int8 tier = 1;
  3555. if (sep->arg[1] && sep->IsNumber(1))
  3556. tier = atoul(sep->arg[1]);
  3557. int8 self = 1;
  3558. if (sep->arg[1] && sep->IsNumber(2))
  3559. {
  3560. self = atoul(sep->arg[2]);
  3561. if(self != 1 && !cmdTarget->IsEntity())
  3562. {
  3563. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  3564. self = 1;
  3565. }
  3566. }
  3567. int32 spellid = atoul(sep->arg[0]);
  3568. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  3569. if (spell)
  3570. {
  3571. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3572. SpellProcess* spellProcess = 0;
  3573. // Get the current zones spell process
  3574. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3575. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3576. }
  3577. else
  3578. {
  3579. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3580. }
  3581. }
  3582. else if (sep && sep->arg[0])
  3583. {
  3584. database.FindSpell(client, (char*)sep->argplus[0]);
  3585. }
  3586. else
  3587. {
  3588. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3589. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3590. }
  3591. break;
  3592. }
  3593. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3594. if (sep && (client->GetVersion() <= 561 && sep->GetArgNumber() == 3) || sep->GetArgNumber() == 4)
  3595. {
  3596. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3597. // cannot sort the ability book in this client it is greyed out
  3598. if (client->GetVersion() <= 561 && book == SPELL_BOOK_TYPE_ABILITY)
  3599. break;
  3600. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3601. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3602. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3603. int32 maxlvlonly = 0;
  3604. if(client->GetVersion() > 561 && sep->arg[4][0]) {
  3605. maxlvlonly = atoul(sep->arg[4]); // checkbox for newer clients
  3606. }
  3607. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3608. ClientPacketFunctions::SendSkillSlotMappings(client);
  3609. }
  3610. else
  3611. {
  3612. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3613. }
  3614. break;
  3615. }
  3616. case COMMAND_MOVE_ITEM:
  3617. {
  3618. int32 id = 0;
  3619. if (sep && sep->IsNumber(0))
  3620. id = atoul(sep->arg[0]);
  3621. Spawn* spawn = 0;
  3622. if (id == 0)
  3623. {
  3624. spawn = cmdTarget;
  3625. }
  3626. else
  3627. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3628. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3629. break;
  3630. client->SendMoveObjectMode(spawn, 0);
  3631. break;
  3632. }
  3633. case COMMAND_PICKUP:
  3634. {
  3635. int32 id = 0;
  3636. if (sep && sep->IsNumber(0))
  3637. id = atoul(sep->arg[0]);
  3638. Spawn* spawn = 0;
  3639. if (id == 0)
  3640. {
  3641. spawn = cmdTarget;
  3642. }
  3643. else
  3644. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3645. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3646. break;
  3647. if(client->AddItem(spawn->GetPickupItemID(), 1)) {
  3648. Query query;
  3649. 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());
  3650. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3651. client->GetCurrentZone()->RemoveSpawn(spawn, true, true, true, true, true);
  3652. }
  3653. // we had a UI Window displayed, update the house items
  3654. if ( id > 0 )
  3655. client->GetCurrentZone()->SendHouseItems(client);
  3656. }
  3657. break;
  3658. }
  3659. case COMMAND_HOUSE_DEPOSIT:
  3660. {
  3661. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3662. // arg0 = spawn_id for DoF, could also be house_id for newer clients
  3663. // arg1 = coin (in copper)
  3664. // arg2 = status? (not implemented yet)
  3665. PlayerHouse* ph = nullptr;
  3666. int32 spawn_id = 0;
  3667. if(sep && sep->arg[0]) {
  3668. spawn_id = atoul(sep->arg[0]);
  3669. ph = world.GetPlayerHouse(client, spawn_id, client->GetVersion() > 561 ? spawn_id : 0, nullptr);
  3670. }
  3671. if(!ph) {
  3672. ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3673. }
  3674. if (ph && sep && sep->IsNumber(1))
  3675. {
  3676. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3677. int32 outValStatus = 0;
  3678. if(sep->IsNumber(2))
  3679. {
  3680. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3681. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3682. outValStatus = 0; // cheat check
  3683. }
  3684. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3685. {
  3686. if(outValStatus)
  3687. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3688. char query[256];
  3689. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3690. if (itr != ph->depositsMap.end())
  3691. {
  3692. 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());
  3693. }
  3694. else
  3695. 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);
  3696. if (database.RunQuery(query, strnlen(query, 256)))
  3697. {
  3698. ph->escrow_coins += outValCoin;
  3699. ph->escrow_status += outValStatus;
  3700. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3701. database.LoadDeposits(ph);
  3702. client->PlaySound("coin_cha_ching");
  3703. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3704. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 561 ? spawn_id : client->GetPlayer()->GetID());
  3705. }
  3706. else
  3707. {
  3708. if(outValCoin)
  3709. client->GetPlayer()->AddCoins(outValCoin);
  3710. if(outValStatus)
  3711. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3712. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3713. }
  3714. }
  3715. }
  3716. break;
  3717. }
  3718. case COMMAND_HOUSE:
  3719. {
  3720. int32 spawn_id = 0;
  3721. if (sep && sep->IsNumber(0))
  3722. {
  3723. PlayerHouse* ph = nullptr;
  3724. if(!ph && sep && sep->arg[0]) {
  3725. spawn_id = atoul(sep->arg[0]);
  3726. ph = world.GetPlayerHouse(client, spawn_id, spawn_id, nullptr);
  3727. }
  3728. HouseZone* hz = 0;
  3729. if (ph)
  3730. hz = world.GetHouseZone(ph->house_id);
  3731. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3732. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 561 ? spawn_id : client->GetPlayer()->GetID());
  3733. }
  3734. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3735. {
  3736. // inside a house or something? Send the access window
  3737. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3738. HouseZone* hz = 0;
  3739. if ( ph )
  3740. hz = world.GetHouseZone(ph->house_id);
  3741. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 561 ? spawn_id : client->GetPlayer()->GetID());
  3742. client->GetCurrentZone()->SendHouseItems(client);
  3743. }
  3744. break;
  3745. }
  3746. case COMMAND_HOUSE_UI:
  3747. {
  3748. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3749. {
  3750. int32 unique_id = atoi(sep->arg[0]);
  3751. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3752. HouseZone* hz = 0;
  3753. if ( ph )
  3754. hz = world.GetHouseZone(ph->house_id);
  3755. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3756. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3757. }
  3758. break;
  3759. }
  3760. case COMMAND_PLACE_HOUSE_ITEM: {
  3761. if (sep && sep->IsNumber(0))
  3762. {
  3763. int32 uniqueid = atoi(sep->arg[0]);
  3764. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3765. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3766. if (item && item->IsHouseItem())
  3767. {
  3768. if (!client->HasOwnerOrEditAccess())
  3769. {
  3770. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3771. break;
  3772. }
  3773. else if (!item->generic_info.appearance_id)
  3774. {
  3775. 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);
  3776. break;
  3777. }
  3778. else if(item->CheckFlag2(HOUSE_LORE) && client->GetCurrentZone()->HouseItemSpawnExists(item->details.item_id)) {
  3779. client->Message(CHANNEL_COLOR_RED, "Item %s is house lore and you cannot place another.", item->name.c_str());
  3780. break;
  3781. }
  3782. if (client->GetTempPlacementSpawn())
  3783. {
  3784. Spawn* tmp = client->GetTempPlacementSpawn();
  3785. client->GetCurrentZone()->RemoveSpawn(tmp, true, true, true, true, true);
  3786. client->SetTempPlacementSpawn(nullptr);
  3787. }
  3788. Object* obj = new Object();
  3789. Spawn* spawn = (Spawn*)obj;
  3790. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3791. strcpy(spawn->appearance.name, "temp");
  3792. spawn->SetX(client->GetPlayer()->GetX());
  3793. spawn->SetY(client->GetPlayer()->GetY());
  3794. spawn->SetZ(client->GetPlayer()->GetZ());
  3795. spawn->appearance.pos.collision_radius = 32;
  3796. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3797. spawn->SetSpawnOrigX(spawn->GetX());
  3798. spawn->SetSpawnOrigY(spawn->GetY());
  3799. spawn->SetSpawnOrigZ(spawn->GetZ());
  3800. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3801. spawn->appearance.targetable = 1;
  3802. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3803. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3804. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3805. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3806. spawn->SetZone(client->GetCurrentZone());
  3807. client->SetTempPlacementSpawn(spawn);
  3808. client->SetPlacementUniqueItemID(uniqueid);
  3809. client->GetCurrentZone()->AddSpawn(spawn);
  3810. }
  3811. }
  3812. break;
  3813. }
  3814. case COMMAND_GM:
  3815. {
  3816. if (sep && sep->arg[0] && sep->arg[1])
  3817. {
  3818. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3819. if (strcmp(sep->arg[0], "vision") == 0)
  3820. {
  3821. client->GetPlayer()->SetGMVision(onOff);
  3822. #if defined(__GNUC__)
  3823. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3824. #else
  3825. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3826. #endif
  3827. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3828. if (onOff)
  3829. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3830. else
  3831. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3832. }
  3833. else if (strcmp(sep->arg[0], "tag") == 0)
  3834. {
  3835. int32 value = 0;
  3836. int16 tag_icon = 0;
  3837. // groundspawn has special exception -1 argument so it needs to be handled here
  3838. if(sep->arg[2] && sep->arg[3] && ((tag_icon = atoul(sep->arg[3])) > 0) || (strncasecmp(sep->arg[1], "groundspawn", 11) == 0)) {
  3839. value = atoul(sep->arg[2]);
  3840. if(strncasecmp(sep->arg[1], "faction", 7) == 0){
  3841. if(!value) {
  3842. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid faction id.");
  3843. break;
  3844. }
  3845. if(!tag_icon) {
  3846. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3847. break;
  3848. }
  3849. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_FACTION, value, "", tag_icon);
  3850. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3851. client->Message(CHANNEL_COLOR_RED, "Adding faction id %u with tag icon %u.", value, tag_icon);
  3852. }
  3853. else if(strncasecmp(sep->arg[1], "spawngroup", 10) == 0){
  3854. if(value>0) {
  3855. value = 1;
  3856. }
  3857. if(!tag_icon) {
  3858. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3859. break;
  3860. }
  3861. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_SPAWNGROUP, value, "", tag_icon);
  3862. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3863. client->Message(CHANNEL_COLOR_RED, "Adding spawn group tag \"%s\" with tag icon %u.", (value == 1) ? "on" : "off", tag_icon);
  3864. }
  3865. else if(strncasecmp(sep->arg[1], "race", 4 == 0)){
  3866. if(!value) {
  3867. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid race id.");
  3868. break;
  3869. }
  3870. if(!tag_icon) {
  3871. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3872. break;
  3873. }
  3874. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_RACE, value, "", tag_icon);
  3875. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3876. client->Message(CHANNEL_COLOR_RED, "Adding race id %u with tag icon %u.", value, tag_icon);
  3877. }
  3878. else if(strncasecmp(sep->arg[1], "groundspawn", 11) == 0){
  3879. // one less argument value field not tag_icon for this one
  3880. if(!value) {
  3881. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3882. break;
  3883. }
  3884. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_GROUNDSPAWN, 1, "", value);
  3885. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3886. client->Message(CHANNEL_COLOR_RED, "Adding groundspawns with tag icon %u.", value);
  3887. }
  3888. }
  3889. else {
  3890. if(strncasecmp(sep->arg[1], "clear", 5) == 0){
  3891. client->GetPlayer()->ClearGMVisualFilters();
  3892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Tags Cleared!");
  3893. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3894. }
  3895. else {
  3896. client->SimpleMessage(CHANNEL_COLOR_RED, "GM Tagging Missing Arguments:");
  3897. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag [type] [value] [visual_icon_display]");
  3898. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag clear - Clears all GM visual tags");
  3899. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Type Options:");
  3900. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: faction, value: faction id of spawn(s)");
  3901. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: spawngroup, value: 1 to show grouped, 0 to show not grouped");
  3902. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: race, value: race id (either against base race or race id in spawn details)");
  3903. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: groundspawn, value: (not used)");
  3904. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Icon Options:");
  3905. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3906. "1 = skull, 2 = shield half dark blue / half light blue, 3 = purple? star, 4 = yellow sword, 5 = red X, 6 = green flame");
  3907. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3908. "7 = Number \"1\", 8 = Number \"2\", 9 = Number \"3\", 10 = Number \"4\", 11 = Number \"5\", 12 = Number \"6\"");
  3909. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3910. "25 = shield, 26 = green plus, 27 = crossed swords, 28 = bow with arrow in it, 29 = light blue lightning bolt");
  3911. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3912. "30 = bard instrument (hard to see), 31 = writ with shield, 32 = writ with green +, 33 = writ with crossed sword");
  3913. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3914. "34 = writ with bow, 35 = writ with light blue lightning bolt, 36 = same as 30, 37 = party with crossed sword, shield and lightning bolt");
  3915. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3916. "38 = shaking hands green background, 39 = shaking hands dark green background, unlocked keylock");
  3917. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3918. "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");
  3919. }
  3920. }
  3921. }
  3922. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3923. {
  3924. client->SetRegionDebug(onOff);
  3925. #if defined(__GNUC__)
  3926. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3927. #else
  3928. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3929. #endif
  3930. if (onOff)
  3931. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  3932. else
  3933. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  3934. }
  3935. else if (strcmp(sep->arg[0], "sight") == 0)
  3936. {
  3937. if(onOff && cmdTarget) {
  3938. client->SetPlayerPOVGhost(cmdTarget);
  3939. }
  3940. else
  3941. client->SetPlayerPOVGhost(nullptr);
  3942. }
  3943. else if (strcmp(sep->arg[0], "controleffects") == 0)
  3944. {
  3945. if(cmdTarget && cmdTarget->IsEntity()) {
  3946. ((Entity*)cmdTarget)->SendControlEffectDetailsToClient(client);
  3947. }
  3948. else {
  3949. client->GetPlayer()->SendControlEffectDetailsToClient(client);
  3950. }
  3951. }
  3952. else if (strcmp(sep->arg[0], "luadebug") == 0)
  3953. {
  3954. client->SetLuaDebugClient(onOff);
  3955. #if defined(__GNUC__)
  3956. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3957. #else
  3958. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  3959. #endif
  3960. if (onOff)
  3961. {
  3962. if (lua_interface)
  3963. lua_interface->UpdateDebugClients(client);
  3964. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3965. }
  3966. else
  3967. {
  3968. if (lua_interface)
  3969. lua_interface->RemoveDebugClients(client);
  3970. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3971. }
  3972. }
  3973. }
  3974. break;
  3975. }
  3976. case COMMAND_ATTACK:
  3977. case COMMAND_AUTO_ATTACK:{
  3978. Command_AutoAttack(client, sep);
  3979. break;
  3980. }
  3981. case COMMAND_DEPOP:{
  3982. bool allow_respawns = false;
  3983. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3984. if(atoi(sep->arg[0]) == 1)
  3985. allow_respawns = true;
  3986. }
  3987. client->GetCurrentZone()->Depop(allow_respawns);
  3988. break;
  3989. }
  3990. case COMMAND_REPOP:{
  3991. client->GetCurrentZone()->Depop(false, true);
  3992. break;
  3993. }
  3994. case COMMAND_BUYBACK:{
  3995. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3996. // 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
  3997. int64 id = atoi64(sep->arg[0]);
  3998. // get the first int32, the item id
  3999. //int32 item_id = (int32)id;
  4000. // get the second int32, the unique id
  4001. int32 unique_id = (int32)(id>>32);
  4002. int8 quantity = atoi(sep->arg[1]);
  4003. if(quantity == 255)
  4004. quantity = 1;
  4005. client->BuyBack(unique_id, quantity);
  4006. }
  4007. break;
  4008. }
  4009. case COMMAND_MERCHANT_BUY:{
  4010. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4011. int32 item_id = atoul(sep->arg[0]);
  4012. int8 quantity = atoi(sep->arg[1]);
  4013. client->BuyItem(item_id, quantity);
  4014. }
  4015. else
  4016. Command_SendMerchantWindow(client, sep);
  4017. break;
  4018. }
  4019. case COMMAND_MERCHANT_SELL:{
  4020. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4021. // 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
  4022. int64 id = atoi64(sep->arg[0]);
  4023. // get the first int32, the item id
  4024. int32 item_id = (int32)id;
  4025. // get the second int32, the unique id
  4026. int32 unique_id = (int32)(id>>32);
  4027. int8 quantity = atoi(sep->arg[1]);
  4028. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  4029. client->SellItem(item_id, quantity, unique_id);
  4030. }
  4031. break;
  4032. }
  4033. case COMMAND_MENDER_REPAIR: {
  4034. if (sep && sep->arg[0] && sep->IsNumber(0))
  4035. client->RepairItem(atoul(sep->arg[0]));
  4036. break;
  4037. }
  4038. case COMMAND_MENDER_REPAIR_ALL: {
  4039. client->RepairAllItems();
  4040. break;
  4041. }
  4042. case COMMAND_CANCEL_MERCHANT:{
  4043. client->SetMerchantTransaction(0);
  4044. break;
  4045. }
  4046. case COMMAND_START_MERCHANT:{
  4047. break;
  4048. }
  4049. case COMMAND_INVULNERABLE:{
  4050. sint8 val = -1;
  4051. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4052. val = atoi(sep->arg[0]);
  4053. //devn00b: Fix for linux builds
  4054. #if defined(__GNUC__)
  4055. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  4056. #else
  4057. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4058. #endif
  4059. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4060. client->GetPlayer()->SetInvulnerable(val==1);
  4061. if(client->GetPlayer()->GetInvulnerable())
  4062. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  4063. else
  4064. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  4065. }
  4066. if(val == -1)
  4067. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  4068. break;
  4069. }
  4070. case COMMAND_REPAIR: {
  4071. Spawn* spawn = cmdTarget;
  4072. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  4073. client->SendHailCommand(spawn);
  4074. client->SetMerchantTransaction(spawn);
  4075. client->SendRepairList();
  4076. }
  4077. break;
  4078. }
  4079. case COMMAND_LOTTO: {
  4080. Spawn* spawn = cmdTarget;
  4081. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  4082. client->SetMerchantTransaction(spawn);
  4083. client->ShowLottoWindow();
  4084. }
  4085. break;
  4086. }
  4087. case COMMAND_ACCEPT_REWARD:{
  4088. int32 unknown = 0;
  4089. int32 selectable_item_id = 0;
  4090. //Quest *quest = 0;
  4091. /* no idea what the first argument is for (faction maybe?)
  4092. if the reward has a selectable item reward, it's sent as the second argument
  4093. if neither of these are included in the reward, there is no sep
  4094. 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
  4095. only 1 quest or collection reward may be displayed at a time */
  4096. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  4097. unknown = atoul(sep->arg[0]);
  4098. selectable_item_id = atoul(sep->arg[1]);
  4099. }
  4100. /* 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
  4101. ** Otherwise it will likely be a DoF client scenario (pending item rewards, selectable item rewards) which is specifying an item id
  4102. ** 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
  4103. */
  4104. int32 item_id = 0;
  4105. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  4106. item_id = atoul(sep->arg[0]);
  4107. bool collectedItems = client->GetPlayer()->AcceptQuestReward(item_id, selectable_item_id);
  4108. if (collectedItems) {
  4109. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4110. if (outapp)
  4111. client->QueuePacket(outapp);
  4112. }
  4113. else
  4114. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  4115. break;
  4116. }
  4117. case COMMAND_BUY_FROM_BROKER:{
  4118. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4119. int32 item_id = atoul(sep->arg[0]);
  4120. int16 quantity = atoul(sep->arg[1]);
  4121. Item* item = master_item_list.GetItem(item_id);
  4122. if(item && item->generic_info.max_charges > 1)
  4123. quantity = item->generic_info.max_charges;
  4124. client->AddItem(item_id, quantity, AddItemType::BUY_FROM_BROKER);
  4125. }
  4126. break;
  4127. }
  4128. case COMMAND_SEARCH_STORES_PAGE:{
  4129. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4130. int32 page = atoul(sep->arg[0]);
  4131. client->SearchStore(page);
  4132. }
  4133. break;
  4134. }
  4135. case COMMAND_SEARCH_STORES:{
  4136. if(sep && sep->arg[0][0]){
  4137. const char* values = sep->argplus[0];
  4138. if(values){
  4139. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  4140. map<string, string> str_values = TranslateBrokerRequest(values);
  4141. vector<Item*>* items = master_item_list.GetItems(str_values, client);
  4142. if(items){
  4143. client->SetItemSearch(items);
  4144. client->SearchStore(0);
  4145. }
  4146. }
  4147. }
  4148. break;
  4149. }
  4150. case COMMAND_LUADEBUG:{
  4151. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  4152. client->SetLuaDebugClient(true);
  4153. if(lua_interface)
  4154. lua_interface->UpdateDebugClients(client);
  4155. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4156. }
  4157. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  4158. client->SetLuaDebugClient(false);
  4159. if(lua_interface)
  4160. lua_interface->RemoveDebugClients(client);
  4161. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4162. }
  4163. else{
  4164. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  4165. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  4166. }
  4167. break;
  4168. }
  4169. case COMMAND_SPAWN_GROUP:
  4170. {
  4171. Spawn* target = cmdTarget;
  4172. if(target && target->IsPlayer() == false)
  4173. {
  4174. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  4175. {
  4176. if(target->GetSpawnLocationPlacementID() > 0)
  4177. {
  4178. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  4179. {
  4180. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  4181. if(id > 0)
  4182. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  4183. else
  4184. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  4185. target->SetSpawnGroupID(id);
  4186. target->AddSpawnToGroup(target);
  4187. }
  4188. else
  4189. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  4190. }
  4191. else
  4192. 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.");
  4193. }
  4194. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  4195. {
  4196. if(sep->arg[1] && sep->IsNumber(1))
  4197. {
  4198. int32 group_id = atoul(sep->arg[1]);
  4199. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  4200. if(leader)
  4201. {
  4202. leader->AddSpawnToGroup(target);
  4203. target->SetSpawnGroupID(group_id);
  4204. if(database.SpawnGroupAddSpawn(target, group_id))
  4205. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  4206. else
  4207. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  4208. }
  4209. else
  4210. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  4211. }
  4212. else
  4213. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  4214. }
  4215. else if(target->GetSpawnGroupID() == 0)
  4216. {
  4217. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  4218. }
  4219. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  4220. {
  4221. int32 group_id = target->GetSpawnGroupID();
  4222. target->RemoveSpawnFromGroup();
  4223. if(database.SpawnGroupRemoveSpawn(target, group_id))
  4224. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  4225. else
  4226. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  4227. }
  4228. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  4229. {
  4230. int32 group_id = target->GetSpawnGroupID();
  4231. if(sep->arg[1] && sep->IsNumber(1))
  4232. {
  4233. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  4234. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  4235. else
  4236. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  4237. }
  4238. else
  4239. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  4240. }
  4241. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  4242. {
  4243. int32 group_id = target->GetSpawnGroupID();
  4244. if(sep->arg[1] && sep->IsNumber(1))
  4245. {
  4246. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  4247. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  4248. else
  4249. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  4250. }
  4251. else
  4252. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  4253. }
  4254. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  4255. {
  4256. if(sep->arg[1] && sep->IsNumber(1))
  4257. {
  4258. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  4259. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  4260. else
  4261. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  4262. }
  4263. else
  4264. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  4265. }
  4266. else
  4267. {
  4268. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  4269. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  4270. }
  4271. }
  4272. else
  4273. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  4274. break;
  4275. }
  4276. case COMMAND_SPAWN_COMBINE:{
  4277. Spawn* spawn = cmdTarget;
  4278. float radius = 0;
  4279. bool failed = true;
  4280. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  4281. failed = false;
  4282. if(spawn->GetSpawnGroupID() > 0){
  4283. 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.");
  4284. }
  4285. else if(sep->IsNumber(0)){
  4286. radius = atof(sep->arg[0]);
  4287. client->CombineSpawns(radius, spawn);
  4288. }
  4289. else{
  4290. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  4291. client->AddCombineSpawn(spawn);
  4292. }
  4293. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  4294. client->RemoveCombineSpawn(spawn);
  4295. }
  4296. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  4297. const char* name = 0;
  4298. if(sep->arg[1] && sep->arg[1][0])
  4299. name = sep->argplus[1];
  4300. client->SaveCombineSpawns(name);
  4301. }
  4302. else
  4303. failed = true;
  4304. }
  4305. }
  4306. if(failed){
  4307. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  4308. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  4309. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  4310. }
  4311. break;
  4312. }
  4313. case COMMAND_SPAWN_CREATE:{
  4314. Spawn* spawn = 0;
  4315. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4316. spawn = new Object();
  4317. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4318. }
  4319. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4320. spawn = new GroundSpawn();
  4321. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4322. }
  4323. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4324. spawn = new Sign();
  4325. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4326. }
  4327. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4328. spawn = new NPC();
  4329. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4330. spawn->appearance.pos.collision_radius = 32;
  4331. spawn->secondary_command_list_id = 0;
  4332. spawn->primary_command_list_id = 0;
  4333. spawn->appearance.display_name = 1;
  4334. spawn->appearance.show_level = 1;
  4335. spawn->appearance.attackable = 1;
  4336. }
  4337. else{
  4338. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  4339. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  4340. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  4341. break;
  4342. }
  4343. spawn->SetID(Spawn::NextID());
  4344. spawn->SetX(client->GetPlayer()->GetX());
  4345. spawn->SetY(client->GetPlayer()->GetY());
  4346. spawn->SetZ(client->GetPlayer()->GetZ());
  4347. spawn->SetHeading(client->GetPlayer()->GetHeading());
  4348. spawn->SetSpawnOrigX(spawn->GetX());
  4349. spawn->SetSpawnOrigY(spawn->GetY());
  4350. spawn->SetSpawnOrigZ(spawn->GetZ());
  4351. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4352. if(spawn->IsSign())
  4353. {
  4354. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  4355. ((Sign*)spawn)->SetSignDistance(20.0f);
  4356. ((Sign*)spawn)->SetIncludeLocation(1);
  4357. ((Sign*)spawn)->SetIncludeHeading(1);
  4358. ((Sign*)spawn)->SetInitialState(1);
  4359. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  4360. ((Sign*)spawn)->SetActivityStatus(64);
  4361. spawn->appearance.race = 0;
  4362. spawn->SetLevel(0);
  4363. spawn->SetHP(0);
  4364. spawn->SetTotalHP(0);
  4365. spawn->SetPower(0);
  4366. spawn->SetTotalPower(0);
  4367. spawn->SetDifficulty(0);
  4368. spawn->SetTargetable(0);
  4369. spawn->SetSogaModelType(0);
  4370. spawn->SetCollisionRadius(19);
  4371. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  4372. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  4373. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  4374. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4375. spawn->appearance.model_type = atoul(sep->arg[1]);
  4376. }
  4377. else
  4378. {
  4379. spawn->appearance.targetable = 1;
  4380. spawn->appearance.race = 255;
  4381. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4382. spawn->SetModelType(atoi(sep->arg[1]));
  4383. spawn->SetAdventureClass(atoi(sep->arg[2]));
  4384. spawn->SetLevel(atoi(sep->arg[3]));
  4385. spawn->SetName(sep->arg[4]);
  4386. if(sep->arg[5][0] && sep->IsNumber(5))
  4387. spawn->SetDifficulty(atoi(sep->arg[5]));
  4388. if(sep->arg[6][0] && sep->IsNumber(6))
  4389. spawn->size = atoi(sep->arg[6]);
  4390. if(spawn->GetTotalHP() == 0){
  4391. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  4392. spawn->SetHP(25*spawn->GetLevel() + 1);
  4393. }
  4394. if(spawn->GetTotalPower() == 0){
  4395. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  4396. spawn->SetPower(25*spawn->GetLevel() + 1);
  4397. }
  4398. }
  4399. client->GetCurrentZone()->AddSpawn(spawn);
  4400. break;
  4401. }
  4402. case COMMAND_SPAWN_EQUIPMENT:{
  4403. Spawn* spawn = cmdTarget;
  4404. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  4405. int8 slot = atoi(sep->arg[0]);
  4406. int16 type = atoi(sep->arg[1]);
  4407. int8 red = 0;
  4408. int8 green = 0;
  4409. int8 blue = 0;
  4410. int8 h_red = 0;
  4411. int8 h_green = 0;
  4412. int8 h_blue = 0;
  4413. if(sep->arg[2])
  4414. red = atoi(sep->arg[2]);
  4415. if(sep->arg[3])
  4416. green = atoi(sep->arg[3]);
  4417. if(sep->arg[4])
  4418. blue = atoi(sep->arg[4]);
  4419. if(sep->arg[5])
  4420. h_red = atoi(sep->arg[5]);
  4421. if(sep->arg[6])
  4422. h_green = atoi(sep->arg[6]);
  4423. if(sep->arg[7])
  4424. h_blue = atoi(sep->arg[7]);
  4425. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  4426. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  4427. }
  4428. else{
  4429. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  4430. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  4431. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  4432. }
  4433. break;
  4434. }
  4435. case COMMAND_SPAWN_DETAILS: {
  4436. Spawn* spawn = cmdTarget;
  4437. if (sep && sep->arg[0][0]) {
  4438. if (cmdTarget)
  4439. {
  4440. if (ToLower(string(sep->arg[0])) == "los")
  4441. {
  4442. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  4443. if (hasLOS)
  4444. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  4445. else
  4446. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  4447. break;
  4448. }
  4449. else if (ToLower(string(sep->arg[0])) == "bestz")
  4450. {
  4451. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  4452. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  4453. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  4454. break;
  4455. }
  4456. else if (ToLower(string(sep->arg[0])) == "inwater")
  4457. {
  4458. if (cmdTarget->GetRegionMap() == nullptr)
  4459. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  4460. else
  4461. {
  4462. bool inWater = cmdTarget->InWater();
  4463. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  4464. }
  4465. break;
  4466. }
  4467. else if (ToLower(string(sep->arg[0])) == "inlava")
  4468. {
  4469. if (cmdTarget->GetRegionMap() == nullptr)
  4470. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4471. else
  4472. {
  4473. bool inLava = cmdTarget->InLava();
  4474. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  4475. }
  4476. break;
  4477. }
  4478. else if (ToLower(string(sep->arg[0])) == "regions")
  4479. {
  4480. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  4481. if (cmdTarget->GetRegionMap() == nullptr)
  4482. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4483. else
  4484. {
  4485. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  4486. }
  4487. break;
  4488. }
  4489. else if (ToLower(string(sep->arg[0])) == "behind")
  4490. {
  4491. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  4492. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  4493. break;
  4494. }
  4495. else if (ToLower(string(sep->arg[0])) == "infront")
  4496. {
  4497. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  4498. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  4499. break;
  4500. }
  4501. else if (ToLower(string(sep->arg[0])) == "flank")
  4502. {
  4503. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  4504. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  4505. break;
  4506. }
  4507. else if (ToLower(string(sep->arg[0])) == "aggro")
  4508. {
  4509. if(cmdTarget->IsNPC() && ((NPC*)cmdTarget)->Brain()) {
  4510. ((NPC*)cmdTarget)->Brain()->SendEncounterList(client);
  4511. ((NPC*)cmdTarget)->Brain()->SendHateList(client);
  4512. }
  4513. else {
  4514. client->SimpleMessage(CHANNEL_COLOR_RED, "/spawn details aggro is for NPCs only!");
  4515. }
  4516. break;
  4517. }
  4518. else if (ToLower(string(sep->arg[0])) == "angle")
  4519. {
  4520. float spawnAngle = client->GetPlayer()->GetFaceTarget(cmdTarget->GetX(), cmdTarget->GetZ());
  4521. 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());
  4522. break;
  4523. }
  4524. }
  4525. if (sep->IsNumber(0))
  4526. {
  4527. float radius = atof(sep->arg[0]);
  4528. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  4529. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  4530. break;
  4531. }
  4532. }
  4533. if (spawn) {
  4534. const char* type = "NPC";
  4535. if (spawn->IsObject())
  4536. type = "Object";
  4537. else if (spawn->IsSign())
  4538. type = "Sign";
  4539. else if (spawn->IsWidget())
  4540. type = "Widget";
  4541. else if (spawn->IsGroundSpawn())
  4542. type = "GroundSpawn";
  4543. int16 race_type = race_types_list.GetRaceType(spawn->GetModelType());
  4544. int16 race_base_type = race_types_list.GetRaceBaseType(spawn->GetModelType());
  4545. char* category = race_types_list.GetRaceTypeCategory(spawn->GetModelType());
  4546. char* subcategory = race_types_list.GetRaceTypeSubCategory(spawn->GetModelType());
  4547. char* modelname = race_types_list.GetRaceTypeModelName(spawn->GetModelType());
  4548. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  4549. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  4550. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  4551. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  4552. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  4553. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  4554. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u / %u, Power: %u / %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetTotalHP(), spawn->GetPower(), spawn->GetTotalPower());
  4555. 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());
  4556. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetDifficulty(), spawn->GetHeroic());
  4557. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  4558. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  4559. if (spawn->IsEntity()) {
  4560. 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());
  4561. 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());
  4562. }
  4563. 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);
  4564. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  4565. 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());
  4566. 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);
  4567. if (spawn->IsNPC())
  4568. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  4569. if (spawn->IsNPC()){
  4570. client->Message(CHANNEL_COLOR_YELLOW, "Heat Resist/Base: %u/%u",((NPC*)spawn)->GetHeatResistance(), ((NPC*)spawn)->GetHeatResistanceBase());
  4571. client->Message(CHANNEL_COLOR_YELLOW, "Cold Resist/Base: %u/%u",((NPC*)spawn)->GetColdResistance(), ((NPC*)spawn)->GetColdResistanceBase());
  4572. client->Message(CHANNEL_COLOR_YELLOW, "Magic Resist/Base: %u/%u",((NPC*)spawn)->GetMagicResistance(), ((NPC*)spawn)->GetMagicResistanceBase());
  4573. client->Message(CHANNEL_COLOR_YELLOW, "Mental Resist/Base: %u/%u",((NPC*)spawn)->GetMentalResistance(), ((NPC*)spawn)->GetMentalResistanceBase());
  4574. client->Message(CHANNEL_COLOR_YELLOW, "Divine Resist/Base: %u/%u",((NPC*)spawn)->GetDivineResistance(), ((NPC*)spawn)->GetDivineResistanceBase());
  4575. client->Message(CHANNEL_COLOR_YELLOW, "Disease Resist/Base: %u/%u",((NPC*)spawn)->GetDiseaseResistance(), ((NPC*)spawn)->GetDiseaseResistanceBase());
  4576. client->Message(CHANNEL_COLOR_YELLOW, "Poison Resist/Base: %u/%u",((NPC*)spawn)->GetPoisonResistance(), ((NPC*)spawn)->GetPoisonResistanceBase());
  4577. }
  4578. string details;
  4579. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  4580. details += "Type: " + string(type) + "\n";
  4581. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  4582. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  4583. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  4584. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  4585. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  4586. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  4587. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  4588. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  4589. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  4590. details += "HP: " + to_string(spawn->GetHP()) + " / " + to_string(spawn->GetTotalHP()) + "(" + to_string(spawn->GetIntHPRatio()) + "%)\n";
  4591. details += "Power: " + to_string(spawn->GetPower()) + + " / " + to_string(spawn->GetTotalPower()) + "\n";
  4592. details += "Difficulty: " + to_string(spawn->GetDifficulty()) + "\n";
  4593. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  4594. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  4595. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  4596. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  4597. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  4598. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  4599. char x[16];
  4600. sprintf(x, "%.2f", spawn->GetX());
  4601. char y[16];
  4602. sprintf(y, "%.2f", spawn->GetY());
  4603. char z[16];
  4604. sprintf(z, "%.2f", spawn->GetZ());
  4605. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  4606. string details2;
  4607. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  4608. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  4609. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  4610. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  4611. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  4612. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  4613. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  4614. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  4615. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  4616. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  4617. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  4618. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  4619. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  4620. details2 += "Race Type: " + to_string(race_type) + "\n";
  4621. details2 += "Race Base Type: " + to_string(race_base_type) + "\n";
  4622. details2 += "Race Category (Sub Category): " + std::string(category) + " (" + std::string(subcategory) + ")\n";
  4623. details2 += "Model Name: " + std::string(modelname) + "\n";
  4624. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  4625. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  4626. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  4627. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  4628. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  4629. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  4630. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  4631. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  4632. string details3;
  4633. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  4634. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  4635. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  4636. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  4637. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  4638. if(spawn->IsSign()) {
  4639. details3 += "Sign Language: " + to_string(((Sign*)spawn)->GetLanguage()) + "\n";
  4640. }
  4641. if(spawn->IsEntity())
  4642. {
  4643. Entity* ent = (Entity*)spawn;
  4644. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  4645. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  4646. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  4647. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  4648. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  4649. }
  4650. string details4;
  4651. if (spawn->IsEntity()) {
  4652. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  4653. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4654. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4655. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4656. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4657. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4658. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4659. if (spawn->IsNPC()) {
  4660. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4661. }
  4662. }
  4663. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4664. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4665. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4666. client->SendShowBook(client->GetPlayer(), title, 0, 4, details, details2, details3, details4);
  4667. }
  4668. else {
  4669. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4670. 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.");
  4671. }
  4672. break;
  4673. }
  4674. case COMMAND_SPAWN_TARGET:{
  4675. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4676. int32 spawn_id = atoul(sep->arg[0]);
  4677. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4678. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4679. }
  4680. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4681. float distance = atof(sep->arg[1]);
  4682. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4683. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4684. }
  4685. else{
  4686. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4687. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4688. }
  4689. break;
  4690. }
  4691. case COMMAND_SPAWN_SET:
  4692. {
  4693. Spawn* spawn = cmdTarget;
  4694. sint16 set_type = -1;
  4695. string type_str;
  4696. if (spawn)
  4697. {
  4698. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4699. 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)
  4700. {
  4701. // set the type, which will be 0 if location or list or invalid
  4702. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4703. }
  4704. if(set_type > 0)
  4705. {
  4706. // check if spawn set is NOT a char update, or not location, or isn't a number
  4707. 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)
  4708. {
  4709. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4710. }
  4711. else
  4712. {
  4713. string name = string(spawn->GetName());
  4714. bool customSetSpawn = false;
  4715. if(set_type >= SPAWN_SET_CHEEK_TYPE && set_type <= SPAWN_SET_SOGA_NOSE_TYPE)
  4716. {
  4717. int8 index = sep->IsNumber(2) ? atoul(sep->arg[2]) : 0;
  4718. // override the standard setspawncommand, we pass arguments different!
  4719. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1], true, false, nullptr, index))
  4720. customSetSpawn = true;
  4721. }
  4722. if(customSetSpawn || SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4723. {
  4724. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4725. {
  4726. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4727. }
  4728. else if (set_type == SPAWN_SET_VALUE_NAME)
  4729. {
  4730. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4731. }
  4732. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4733. {
  4734. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4735. }
  4736. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4737. {
  4738. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4739. 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());
  4740. }
  4741. else
  4742. {
  4743. 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());
  4744. }
  4745. switch (set_type)
  4746. {
  4747. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4748. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4749. case SPAWN_SET_VALUE_FACTION:
  4750. case SPAWN_SET_AAXP_REWARDS:
  4751. case SPAWN_SET_CHEEK_TYPE:
  4752. case SPAWN_SET_CHIN_TYPE:
  4753. case SPAWN_SET_EAR_TYPE:
  4754. case SPAWN_SET_EYE_BROW_TYPE:
  4755. case SPAWN_SET_EYE_TYPE:
  4756. case SPAWN_SET_LIP_TYPE:
  4757. case SPAWN_SET_NOSE_TYPE:
  4758. case SPAWN_SET_BODY_SIZE:
  4759. case SPAWN_SET_BODY_AGE:
  4760. case SPAWN_SET_SOGA_CHEEK_TYPE:
  4761. case SPAWN_SET_SOGA_CHIN_TYPE:
  4762. case SPAWN_SET_SOGA_EAR_TYPE:
  4763. case SPAWN_SET_SOGA_EYE_BROW_TYPE:
  4764. case SPAWN_SET_SOGA_EYE_TYPE:
  4765. case SPAWN_SET_SOGA_LIP_TYPE:
  4766. case SPAWN_SET_SOGA_NOSE_TYPE:
  4767. case SPAWN_SET_SOGA_BODY_SIZE:
  4768. case SPAWN_SET_SOGA_BODY_AGE:
  4769. case SPAWN_SET_ATTACK_TYPE:
  4770. case SPAWN_SET_RACE_TYPE:
  4771. case SPAWN_SET_LOOT_TIER:
  4772. case SPAWN_SET_LOOT_DROP_TYPE:
  4773. case SPAWN_SET_SCARED_STRONG_PLAYERS:
  4774. {
  4775. // not applicable already ran db command
  4776. break;
  4777. }
  4778. default:
  4779. {
  4780. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4781. break;
  4782. }
  4783. }
  4784. 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))
  4785. {
  4786. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4787. {
  4788. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4789. }
  4790. else if(spawn->GetSpawnLocationID() > 0)
  4791. {
  4792. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4793. }
  4794. }
  4795. else
  4796. {
  4797. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4798. {
  4799. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4800. }
  4801. else if(spawn->GetDatabaseID() > 0)
  4802. {
  4803. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4804. }
  4805. }
  4806. }
  4807. }
  4808. }
  4809. else if(set_type == 0)
  4810. {
  4811. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4812. map<string, int8>::iterator itr;
  4813. int i=0;
  4814. string list;
  4815. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4816. {
  4817. if(i==10)
  4818. {
  4819. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4820. i = 0;
  4821. }
  4822. if(i>0)
  4823. {
  4824. list.append(", ").append(itr->first);
  4825. }
  4826. else
  4827. {
  4828. list = itr->first;
  4829. }
  4830. }
  4831. if(list.length() > 0)
  4832. {
  4833. // if 1 or more, display in client.
  4834. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4835. }
  4836. }
  4837. else
  4838. {
  4839. // syntax fail
  4840. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4842. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4843. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4844. }
  4845. }
  4846. break;
  4847. }
  4848. case COMMAND_SPAWN_REMOVE:{
  4849. Spawn* spawn = cmdTarget;
  4850. if(spawn && !spawn->IsPlayer()){
  4851. if(spawn->GetSpawnLocationID() > 0){
  4852. string name = string(spawn->GetName());
  4853. int32 dbid = spawn->GetDatabaseID();
  4854. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4855. client->GetCurrentZone()->RemoveSpawn(spawn, true, false, true, true, true);
  4856. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone for spawn '%s' (DBID: %u)", name.c_str(), dbid);
  4857. }
  4858. else
  4859. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4860. }
  4861. else
  4862. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4863. }
  4864. else{
  4865. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4866. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4867. }
  4868. break;
  4869. }
  4870. case COMMAND_SPAWN_LIST:{
  4871. if(sep && sep->arg[0][0]){
  4872. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4873. vector<string>::iterator itr;
  4874. if(results){
  4875. for(itr=results->begin();itr!=results->end();itr++){
  4876. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4877. }
  4878. safe_delete(results);
  4879. }
  4880. else
  4881. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4882. }
  4883. else{
  4884. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4885. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4886. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4887. }
  4888. break;
  4889. }
  4890. case COMMAND_SPAWN_ADD:{
  4891. Spawn* spawn = cmdTarget;
  4892. if(spawn && sep && ((sep->arg[1][0] && sep->IsNumber(0)) || (sep->arg[0][0] && strncasecmp(sep->arg[0], "new", 3) == 0))){
  4893. if(spawn->GetSpawnLocationID() > 0){
  4894. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4895. break;
  4896. }
  4897. if(spawn->GetDatabaseID() == 0){
  4898. if(database.SaveSpawnInfo(spawn)) {
  4899. char spawn_type[32];
  4900. memset(spawn_type, 0, sizeof(spawn_type));
  4901. if (spawn->IsNPC())
  4902. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4903. else if (spawn->IsObject())
  4904. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4905. else if (spawn->IsSign())
  4906. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4907. else if (spawn->IsGroundSpawn())
  4908. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4909. else
  4910. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4911. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4912. }
  4913. else
  4914. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4915. }
  4916. int32 spawn_group_id = 0;
  4917. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4918. spawn_group_id = database.GetNextSpawnLocation();
  4919. else
  4920. spawn_group_id = atol(sep->arg[0]);
  4921. int8 percent = 100;
  4922. if(sep->arg[2] && sep->IsNumber(2))
  4923. percent = atoi(sep->arg[2]);
  4924. spawn->SetSpawnLocationID(spawn_group_id);
  4925. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4926. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4927. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4928. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4929. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4930. else
  4931. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  4932. }
  4933. else{
  4934. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  4935. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  4936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  4937. }
  4938. break;
  4939. }
  4940. case COMMAND_SPAWN:{
  4941. int32 id = 0;
  4942. Spawn* spawn = 0;
  4943. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4944. id = atol(sep->arg[0]);
  4945. spawn = client->GetCurrentZone()->GetSpawn(id);
  4946. }
  4947. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  4948. id = 0;
  4949. if(!id || !spawn){
  4950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  4951. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  4952. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  4953. safe_delete(sep);
  4954. return;
  4955. }
  4956. if(sep && sep->arg[1][0]){
  4957. float x = atof(sep->arg[1]);
  4958. spawn->appearance.pos.X = x;
  4959. }
  4960. else
  4961. spawn->SetX(client->GetPlayer()->GetX(), false);
  4962. if(sep && sep->arg[2][0]){
  4963. float y = atof(sep->arg[2]);
  4964. spawn->appearance.pos.Y = y;
  4965. }
  4966. else
  4967. spawn->SetY(client->GetPlayer()->GetY(), false);
  4968. if(sep && sep->arg[3][0]){
  4969. float z = atof(sep->arg[3]);
  4970. spawn->appearance.pos.Z = z;
  4971. }
  4972. else
  4973. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  4974. if(sep && sep->arg[4][0]){
  4975. float heading = atof(sep->arg[4]);
  4976. spawn->SetHeading(heading);
  4977. }
  4978. else
  4979. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  4980. spawn->SetSpawnOrigX(spawn->GetX());
  4981. spawn->SetSpawnOrigY(spawn->GetY());
  4982. spawn->SetSpawnOrigZ(spawn->GetZ());
  4983. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4984. if(sep && sep->arg[5][0])
  4985. spawn->SetLocation(atoul(sep->arg[5]));
  4986. else
  4987. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4988. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  4989. spawn->SetTotalHP(spawn->GetLevel() * 15);
  4990. spawn->SetHP(spawn->GetTotalHP());
  4991. }
  4992. if(spawn->GetTotalPower() == 0){
  4993. spawn->SetTotalPower(spawn->GetLevel() * 15);
  4994. spawn->SetPower(spawn->GetTotalPower());
  4995. }
  4996. const char* script = world.GetSpawnScript(id);
  4997. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  4998. spawn->SetSpawnScript(string(script));
  4999. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  5000. client->GetCurrentZone()->AddSpawn(spawn);
  5001. if(spawn->IsNPC())
  5002. spawn->GetZone()->AddLoot((NPC*)spawn);
  5003. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  5004. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  5005. break;
  5006. }
  5007. case COMMAND_ADMINFLAG:
  5008. {
  5009. if(sep && sep->arg[0]){
  5010. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  5011. sint16 new_status = atoi(sep->arg[1]);
  5012. if(tmp_status == -10)
  5013. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  5014. else if(tmp_status >= client->GetAdminStatus())
  5015. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  5016. else if (new_status > client->GetAdminStatus())
  5017. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  5018. else{
  5019. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  5020. if (!client2)
  5021. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  5022. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  5023. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  5024. if (client2) {
  5025. client2->SetAdminStatus(new_status);
  5026. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  5027. }
  5028. }
  5029. else
  5030. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  5031. }
  5032. }else{
  5033. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  5034. if(status != client->GetAdminStatus())
  5035. {
  5036. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  5037. client->SetAdminStatus(status);
  5038. }
  5039. else
  5040. {
  5041. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  5042. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  5043. client->Message(CHANNEL_COLOR_YELLOW," Admin User: %i", status);
  5044. }
  5045. }
  5046. break;
  5047. }
  5048. case COMMAND_CANNEDEMOTE:{
  5049. client->GetCurrentZone()->HandleEmote(client->GetPlayer(), command_parms->data);
  5050. break;
  5051. }
  5052. case COMMAND_BROADCAST: {
  5053. if (sep && sep->arg[0])
  5054. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  5055. else
  5056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  5057. break;
  5058. }
  5059. case COMMAND_ANNOUNCE: {
  5060. if (sep && sep->arg[0])
  5061. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  5062. else
  5063. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  5064. break;
  5065. }
  5066. case COMMAND_RELOAD_ITEMS:{
  5067. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  5068. int32 item_id = (sep && sep->arg[0]) ? atoul(sep->arg[0]) : 0;
  5069. if(item_id > 0) {
  5070. client->Message(CHANNEL_COLOR_YELLOW, "Reloading item %u based on /reload items [item_id].", item_id);
  5071. }
  5072. else {
  5073. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  5074. }
  5075. database.ReloadItemList(item_id);
  5076. if(!item_id) {
  5077. database.LoadMerchantInformation(); // we skip if there is only a reload of single item not all items
  5078. }
  5079. if(item_id > 0) {
  5080. client->Message(CHANNEL_COLOR_YELLOW, "Reloaded item %u.", item_id);
  5081. }
  5082. else {
  5083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  5084. }
  5085. break;
  5086. }
  5087. case COMMAND_ENABLE_ABILITY_QUE:{
  5088. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  5089. if(app)
  5090. client->QueuePacket(app);
  5091. break;
  5092. }
  5093. case COMMAND_ITEMSEARCH:
  5094. case COMMAND_FROMBROKER:{
  5095. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  5096. if (packet) {
  5097. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  5098. //packet->setDataByName("unknown", 1);
  5099. packet->setDataByName("unknown2", 5, 0);
  5100. packet->setDataByName("unknown2", 20, 1);
  5101. packet->setDataByName("unknown2", 58, 3);
  5102. packet->setDataByName("unknown2", 40, 4);
  5103. client->QueuePacket(packet->serialize());
  5104. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  5105. if (packet2) {
  5106. packet2->setDataByName("char_id", client->GetCharacterID());
  5107. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  5108. safe_delete(packet2);
  5109. }
  5110. safe_delete(packet);
  5111. }
  5112. break;
  5113. }
  5114. case COMMAND_ANIMTEST:{
  5115. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  5116. if(command_packet){
  5117. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  5118. if (cmdTarget)
  5119. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  5120. command_packet->setDataByName ( "spawn_id" , id);
  5121. int animID = 1;
  5122. if(sep && sep->arg[0] && sep->IsNumber(0))
  5123. animID = atoi(sep->arg[0]);
  5124. VisualState* vs = NULL;
  5125. if(animID == 0)
  5126. {
  5127. vs = visual_states.FindVisualState(sep->arg[0]);
  5128. }
  5129. char msg[128];
  5130. sprintf(msg,"Animation Test ID: %i",animID);
  5131. command_packet->setMediumStringByName ( "emote_msg" , msg );
  5132. if(vs != NULL)
  5133. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  5134. else
  5135. command_packet->setDataByName ( "anim_type", animID );
  5136. command_packet->setDataByName ( "unknown0", 0 );
  5137. EQ2Packet* outapp = command_packet->serialize();
  5138. client->QueuePacket(outapp);
  5139. safe_delete(command_packet);
  5140. }
  5141. break;
  5142. }
  5143. case COMMAND_KICK:
  5144. {
  5145. if( sep == 0 || sep->arg[0] == 0)
  5146. {
  5147. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  5148. }
  5149. else
  5150. {
  5151. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  5152. if ( kickClient == client )
  5153. {
  5154. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  5155. break;
  5156. }
  5157. else if(kickClient != NULL)
  5158. {
  5159. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5160. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  5161. {
  5162. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5163. break;
  5164. }
  5165. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  5166. kickClient->Disconnect();
  5167. }
  5168. else
  5169. {
  5170. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5171. }
  5172. }
  5173. break;
  5174. }
  5175. case COMMAND_LOCK:
  5176. {
  5177. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  5178. int worldLocked = atoi(sep->arg[0]);
  5179. net.world_locked = worldLocked;
  5180. if ( worldLocked )
  5181. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  5182. else
  5183. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  5184. }
  5185. else
  5186. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  5187. break;
  5188. }
  5189. case COMMAND_BAN:{
  5190. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  5191. {
  5192. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  5193. }
  5194. else
  5195. {
  5196. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  5197. if ( kickClient == client )
  5198. {
  5199. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  5200. break;
  5201. }
  5202. else if(kickClient != NULL)
  5203. {
  5204. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5205. if ( maxStatus > client->GetAdminStatus( ) ||
  5206. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  5207. {
  5208. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5209. break;
  5210. }
  5211. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  5212. int perm = atol(sep->arg[1]);
  5213. if ( perm == 1 )
  5214. database.UpdateAdminStatus(sep->arg[0],-2);
  5215. else
  5216. database.UpdateAdminStatus(sep->arg[0],-1);
  5217. kickClient->Disconnect();
  5218. }
  5219. else
  5220. {
  5221. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5222. }
  5223. }
  5224. break;
  5225. }
  5226. case COMMAND_SET_COMBAT_VOICE:{
  5227. int32 value = 0;
  5228. if(sep && sep->arg[0] && sep->IsNumber(0))
  5229. value = atoi(sep->arg[0]);
  5230. client->GetPlayer()->SetCombatVoice(value);
  5231. break;
  5232. }
  5233. case COMMAND_SET_EMOTE_VOICE:{
  5234. int32 value = 0;
  5235. if(sep && sep->arg[0] && sep->IsNumber(0))
  5236. value = atoi(sep->arg[0]);
  5237. client->GetPlayer()->SetEmoteVoice(value);
  5238. break;
  5239. }
  5240. case COMMAND_GIVEITEM:{
  5241. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  5242. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  5243. if ( itemToClient == NULL )
  5244. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  5245. else
  5246. {
  5247. int32 item_id = atol(sep->arg[1]);
  5248. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  5249. itemToClient->AddItem(item_id);
  5250. }
  5251. }
  5252. else
  5253. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  5254. break;
  5255. }
  5256. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  5257. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  5258. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  5259. case COMMAND_SKILL :
  5260. case COMMAND_SKILL_ADD :
  5261. case COMMAND_SKILL_REMOVE :
  5262. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  5263. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  5264. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  5265. case COMMAND_ENTITYCOMMAND :
  5266. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  5267. case COMMAND_MERCHANT :
  5268. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  5269. case COMMAND_APPEARANCE :
  5270. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  5271. case COMMAND_TRACK : { Command_Track(client); break; }
  5272. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  5273. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  5274. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  5275. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  5276. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  5277. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  5278. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  5279. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  5280. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  5281. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  5282. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  5283. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  5284. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  5285. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  5286. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  5287. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  5288. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  5289. case COMMAND_LOCATION : { Command_Location(client); break; }
  5290. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  5291. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  5292. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  5293. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  5294. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  5295. case COMMAND_GRID : { Command_Grid(client, sep); break; }
  5296. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  5297. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  5298. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  5299. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  5300. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  5301. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  5302. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  5303. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  5304. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  5305. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  5306. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  5307. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  5308. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  5309. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  5310. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  5311. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  5312. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  5313. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  5314. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  5315. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  5316. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  5317. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  5318. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  5319. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  5320. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  5321. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  5322. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  5323. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  5324. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  5325. case COMMAND_MOTD : { Command_MOTD(client); break; }
  5326. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  5327. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  5328. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  5329. case COMMAND_TITLE : { Command_Title(client); break; }
  5330. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  5331. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  5332. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  5333. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  5334. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  5335. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  5336. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  5337. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  5338. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  5339. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  5340. case COMMAND_PET : { Command_Pet(client, sep); break; }
  5341. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  5342. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  5343. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  5344. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  5345. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  5346. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  5347. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  5348. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  5349. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  5350. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  5351. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  5352. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  5353. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  5354. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  5355. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  5356. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  5357. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  5358. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  5359. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  5360. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  5361. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  5362. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  5363. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  5364. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  5365. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  5366. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  5367. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  5368. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  5369. //devn00b
  5370. case COMMAND_MOOD : { Command_Mood(client, sep); break;}
  5371. case COMMAND_MODIFY : { Command_Modify(client); break; }
  5372. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  5373. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  5374. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  5375. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  5376. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  5377. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  5378. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  5379. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  5380. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  5381. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  5382. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  5383. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  5384. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  5385. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  5386. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  5387. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  5388. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  5389. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  5390. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  5391. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  5392. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  5393. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5394. case COMMAND_SET_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5395. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  5396. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  5397. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  5398. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  5399. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  5400. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  5401. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  5402. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  5403. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  5404. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  5405. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  5406. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  5407. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  5408. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  5409. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  5410. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  5411. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  5412. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  5413. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  5414. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  5415. case ADD_AA : { Add_AA(client, sep); break; }
  5416. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  5417. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  5418. case BACK_AA : { Back_AA(client, sep); break; }
  5419. case REMOVE_AA : { Remove_AA(client, sep); break; }
  5420. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  5421. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  5422. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  5423. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  5424. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  5425. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  5426. case COMMAND_CRAFTITEM: {
  5427. Item* item = 0;
  5428. if (sep && sep->IsNumber(0)) {
  5429. int32 item_id = atol(sep->arg[0]);
  5430. int32 quantity = 1;
  5431. if (sep->arg[1] && sep->IsNumber(1))
  5432. quantity = atoi(sep->arg[1]);
  5433. item = new Item(master_item_list.GetItem(item_id));
  5434. if (!item) {
  5435. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  5436. }
  5437. else {
  5438. item->details.count = quantity;
  5439. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  5440. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  5441. bool itemDeleted = false;
  5442. client->AddItem(item, &itemDeleted);
  5443. //Check for crafting quest updates
  5444. int8 update_amt = 0;
  5445. if (!itemDeleted && item->stack_count > 1)
  5446. update_amt = 1;
  5447. else
  5448. update_amt = quantity;
  5449. if(!itemDeleted)
  5450. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  5451. }
  5452. }
  5453. else {
  5454. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  5455. }
  5456. break;
  5457. }
  5458. case COMMAND_UNMENTOR:
  5459. case COMMAND_MENTOR: {
  5460. client->GetPlayer()->MentorTarget();
  5461. break;
  5462. }
  5463. case COMMAND_CANCEL_EFFECT: { Command_CancelEffect(client, sep); break; }
  5464. case COMMAND_CUREPLAYER: { Command_CurePlayer(client, sep); break; }
  5465. case COMMAND_SHARE_QUEST: { Command_ShareQuest(client, sep); break; }
  5466. case COMMAND_YELL: { Command_Yell(client, sep); break; }
  5467. case COMMAND_SETAUTOLOOTMODE: { Command_SetAutoLootMode(client, sep); break; }
  5468. case COMMAND_ASSIST: { Command_Assist(client, sep); break; }
  5469. case COMMAND_TARGET: { Command_Target(client, sep); break; }
  5470. case COMMAND_TARGET_PET: { Command_Target_Pet(client, sep); break; }
  5471. default:
  5472. {
  5473. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  5474. break;
  5475. }
  5476. }
  5477. safe_delete(sep);
  5478. }
  5479. /******************** New COMMAND Handler Functions ********************/
  5480. /*
  5481. Started breaking apart the huge switch() for commands into sepErate
  5482. functions so it is easier to locate the blocks of code by command
  5483. -- JA 2012.03.03
  5484. */
  5485. // sample function header
  5486. /*
  5487. Function:
  5488. Purpose :
  5489. Params :
  5490. Dev :
  5491. Example :
  5492. */
  5493. //void Commands::Command()
  5494. //{
  5495. //}
  5496. /*
  5497. Function: Command_AcceptAdvancement()
  5498. Purpose : Player accepts a new advancement option
  5499. Params : Spell ID
  5500. Dev : Jabantiz
  5501. */
  5502. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  5503. {
  5504. Player *player = client->GetPlayer();
  5505. if (sep && sep->IsSet(0)) {
  5506. int32 trait_id = atoul(sep->arg[0]);
  5507. TraitData* trait = nullptr;
  5508. if(client->GetVersion() <= 561) {
  5509. trait = master_trait_list.GetTraitByItemID(trait_id);
  5510. }
  5511. else {
  5512. trait = master_trait_list.GetTrait(trait_id);
  5513. }
  5514. if(!trait) {
  5515. LogWrite(COMMAND__ERROR, 0, "Command", "Invalid accept advancement of trait %u, no trait found.", trait_id);
  5516. return; // not valid lets not crash!
  5517. }
  5518. if(!master_trait_list.IsPlayerAllowedTrait(client, trait)) {
  5519. client->SimpleMessage(CHANNEL_COLOR_RED, "Not enough trait points to accept trait.");
  5520. return;
  5521. }
  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. if(spell) {
  5527. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5528. }
  5529. else {
  5530. client->Message(CHANNEL_COLOR_RED, "ERROR! Trait is not a valid spell id %u may be disabled.", trait->spellID);
  5531. }
  5532. }
  5533. else
  5534. {
  5535. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5536. if(spell) {
  5537. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  5538. player->RemoveSpellBookEntry(spell->GetSpellID());
  5539. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5540. player->UnlockSpell(spell);
  5541. client->SendSpellUpdate(spell);
  5542. }
  5543. else {
  5544. client->Message(CHANNEL_COLOR_RED, "ERROR! Trait is not a valid spell id %u may be disabled.", trait->spellID);
  5545. }
  5546. }
  5547. // Spell book update
  5548. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  5549. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  5550. if(client->GetVersion() <= 561) {
  5551. master_trait_list.ChooseNextTrait(client);
  5552. }
  5553. }
  5554. }
  5555. /*
  5556. Function:
  5557. Purpose :
  5558. Params :
  5559. Dev :
  5560. Example :
  5561. */
  5562. void Commands::Command_AFK(Client* client, Seperator* sep)
  5563. {
  5564. Player* player = client->GetPlayer();
  5565. player->toggle_character_flag(CF_AFK);
  5566. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  5567. if (player->get_character_flag(CF_AFK))
  5568. {
  5569. if (sep && sep->argplus[0])
  5570. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  5571. else
  5572. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  5573. string message = string(player->GetName()) + " is going afk.";
  5574. Spawn* target = player->GetTarget();
  5575. if (target && target != player)
  5576. {
  5577. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  5578. player->GetGender() == 1 ? message += "he" : message += "she";
  5579. message += " is going afk.";
  5580. }
  5581. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  5582. }
  5583. if (player->get_character_flag(CF_AFK))
  5584. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK);
  5585. else
  5586. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK);
  5587. }
  5588. /*
  5589. Function: Command_Appearance()
  5590. Purpose : Handles /appearance commands
  5591. Params : list
  5592. Dev : Scatman
  5593. Example : /appearance list
  5594. */
  5595. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  5596. {
  5597. if( handler == COMMAND_APPEARANCE )
  5598. {
  5599. // /appearance command by itself shows help (to be extended)
  5600. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5601. return;
  5602. }
  5603. else if( handler == COMMAND_APPEARANCE_LIST )
  5604. {
  5605. // /appearance list command expects "name" param
  5606. if (sep && sep->arg[0])
  5607. {
  5608. const char* appearance_name = sep->argplus[0];
  5609. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  5610. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  5611. if (appearances)
  5612. {
  5613. vector<int16>::iterator itr;
  5614. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  5615. {
  5616. int16 id = *itr;
  5617. string name = database.GetAppearanceName(id);
  5618. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  5619. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  5620. }
  5621. safe_delete(appearances);
  5622. }
  5623. }
  5624. else // no param
  5625. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5626. }
  5627. }
  5628. /*
  5629. Function: Command_Claim()
  5630. Purpose : Summon veteran rewards
  5631. Params : nothing = show claim window, any number claims that item.
  5632. Dev : devn00b
  5633. Example : /claim 0 (claims the 1st item added to the list claim[0])
  5634. */
  5635. void Commands::Command_Claim(Client* client, Seperator* sep)
  5636. {
  5637. //if we were passed a claim id
  5638. if (sep && sep->argplus[0] && sep->IsNumber(0))
  5639. {
  5640. int32 char_id = client->GetCharacterID();
  5641. int8 my_claim_id = atoi(sep->argplus[0]);
  5642. vector<ClaimItems> claim = database.LoadCharacterClaimItems(char_id);
  5643. Item* item = master_item_list.GetItem(claim[my_claim_id].item_id);
  5644. database.ClaimItem(char_id, item->details.item_id, client);
  5645. return;
  5646. }
  5647. else {
  5648. //if no arg just send the window.
  5649. client->ShowClaimWindow();
  5650. return;
  5651. }
  5652. return;
  5653. }
  5654. /*
  5655. Function: Command_ClearAllQueued()
  5656. Purpose :
  5657. Params :
  5658. Dev :
  5659. Example :
  5660. */
  5661. void Commands::Command_ClearAllQueued(Client* client)
  5662. {
  5663. ZoneServer* zone = client->GetPlayer()->GetZone();
  5664. if (zone && zone->GetSpellProcess())
  5665. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  5666. }
  5667. /*
  5668. Function: Command_CancelMaintained()
  5669. Purpose : Cancels maintained spells
  5670. Params : Maintained Spell Index
  5671. Dev : Zcoretri
  5672. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  5673. */
  5674. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  5675. {
  5676. if (sep && sep->arg[0] && sep->IsNumber(0))
  5677. {
  5678. int32 spell_index = atoul(sep->arg[0]);
  5679. if(spell_index > 29)
  5680. return;
  5681. client->GetPlayer()->MMaintainedSpells.readlock(__FUNCTION__, __LINE__);
  5682. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  5683. client->GetPlayer()->MMaintainedSpells.releasereadlock(__FUNCTION__, __LINE__);
  5684. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled", false))
  5685. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  5686. }
  5687. }
  5688. /*
  5689. Function: Command_Create()
  5690. Purpose : Handler for starting Tradeskilling table
  5691. Params :
  5692. Dev : Zcoretri
  5693. Example :
  5694. */
  5695. void Commands::Command_Create(Client* client, Seperator* sep)
  5696. {
  5697. PrintSep(sep, "COMMAND_CREATE");
  5698. client->ShowRecipeBook();
  5699. }
  5700. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  5701. {
  5702. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  5703. if (sep && sep->arg[0] && sep->IsNumber(0))
  5704. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  5705. }
  5706. /*
  5707. Function: Command_Distance()
  5708. Purpose : Displays distance from targeted spawn
  5709. Params :
  5710. Dev : Scatman
  5711. Example : /distance
  5712. */
  5713. void Commands::Command_Distance(Client* client)
  5714. {
  5715. Spawn* target = client->GetPlayer()->GetTarget();
  5716. if (target)
  5717. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  5718. else
  5719. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  5720. }
  5721. /*
  5722. Function: Command_Duel()
  5723. Purpose : Handle the /duel commands - not yet implemented
  5724. Params : unknown
  5725. Dev :
  5726. Example :
  5727. */
  5728. void Commands::Command_Duel(Client* client, Seperator* sep)
  5729. {
  5730. PrintSep(sep, "COMMAND_DUEL");
  5731. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  5732. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5733. }
  5734. /*
  5735. Function: Command_DuelBet()
  5736. Purpose : Handle the /duel commands - not yet implemented
  5737. Params : unknown
  5738. Dev :
  5739. Example :
  5740. */
  5741. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  5742. {
  5743. PrintSep(sep, "COMMAND_DUELBET");
  5744. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  5745. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5746. }
  5747. /*
  5748. Function: Command_DuelAccept()
  5749. Purpose : Handle the /duel commands - not yet implemented
  5750. Params : unknown
  5751. Dev :
  5752. Example :
  5753. */
  5754. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5755. {
  5756. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5757. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5758. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5759. }
  5760. /*
  5761. Function: Command_DuelDecline()
  5762. Purpose : Handle the /duel commands - not yet implemented
  5763. Params : unknown
  5764. Dev :
  5765. Example :
  5766. */
  5767. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5768. {
  5769. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5770. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5771. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5772. }
  5773. /*
  5774. Function: Command_DuelSurrender()
  5775. Purpose : Handle the /duel commands - not yet implemented
  5776. Params : unknown
  5777. Dev :
  5778. Example :
  5779. */
  5780. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5781. {
  5782. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5783. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5784. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5785. // JA, just messin around ;)
  5786. char surrender[64];
  5787. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5788. zone_list.HandleGlobalAnnouncement(surrender);
  5789. }
  5790. /*
  5791. Function: Command_DuelToggle()
  5792. Purpose : Handle the /duel commands - not yet implemented
  5793. Params : unknown
  5794. Dev :
  5795. Example :
  5796. */
  5797. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5798. {
  5799. PrintSep(sep, "COMMAND_DUEL");
  5800. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5801. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5802. }
  5803. /*
  5804. Function:
  5805. Purpose :
  5806. Params :
  5807. Dev :
  5808. Example :
  5809. */
  5810. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5811. {
  5812. if( handler == COMMAND_ENTITYCOMMAND )
  5813. {
  5814. // /entitycommand command by itself shows help (to be extended)
  5815. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5816. return;
  5817. }
  5818. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5819. {
  5820. // /entitycommand list command expects "name" param
  5821. if (sep && sep->arg[0])
  5822. {
  5823. const char* entity_command_name = sep->argplus[0];
  5824. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5825. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5826. map<int32, vector<EntityCommand*>*>::iterator itr;
  5827. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5828. {
  5829. vector<EntityCommand*>* entity_command_list = itr->second;
  5830. vector<EntityCommand*>::iterator itr2;
  5831. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5832. {
  5833. EntityCommand* entity_command = *itr2;
  5834. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5835. 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);
  5836. }
  5837. }
  5838. }
  5839. else // no command name
  5840. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5841. }
  5842. }
  5843. /*
  5844. Function: Command_Follow()
  5845. Purpose : Handle the /follow command - not yet implemented
  5846. Params :
  5847. Dev :
  5848. Example :
  5849. */
  5850. void Commands::Command_Follow(Client* client, Seperator* sep)
  5851. {
  5852. PrintSep(sep, "COMMAND_FOLLOW");
  5853. // flag to toggle if the players target is in the players group
  5854. bool targetInGroup = false;
  5855. // get a pointer to the players group
  5856. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5857. // If the player has a group and has a target
  5858. if (gmi && client->GetPlayer()->GetTarget()) {
  5859. deque<GroupMemberInfo*>::iterator itr;
  5860. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5861. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5862. if (group)
  5863. {
  5864. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5865. deque<GroupMemberInfo*>* members = group->GetMembers();
  5866. // Loop through the group members
  5867. for (itr = members->begin(); itr != members->end(); itr++) {
  5868. // If a group member matches a target
  5869. if ((*itr)->member && (*itr)->member == client->GetPlayer()->GetTarget()) {
  5870. // toggle the flag and break the loop
  5871. targetInGroup = true;
  5872. break;
  5873. }
  5874. }
  5875. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5876. }
  5877. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5878. }
  5879. if (targetInGroup) {
  5880. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5881. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5882. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5883. client->GetPlayer()->info_changed = true;
  5884. client->GetPlayer()->changed = true;
  5885. }
  5886. else
  5887. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5888. }
  5889. /*
  5890. Function: Command_StopFollow()
  5891. Purpose : Handle the /stop_follow command - not yet implemented
  5892. Params :
  5893. Dev :
  5894. Example :
  5895. */
  5896. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5897. {
  5898. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5899. if (client->GetPlayer()->GetFollowTarget()) {
  5900. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5901. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5902. client->GetPlayer()->SetFollowTarget(0);
  5903. client->GetPlayer()->info_changed = true;
  5904. client->GetPlayer()->changed = true;
  5905. }
  5906. }
  5907. /*
  5908. Function: Command_Grid()
  5909. Purpose : Show player's current Grid ID
  5910. Params :
  5911. Dev : Scatman
  5912. Example : /grid
  5913. */
  5914. void Commands::Command_Grid(Client* client, Seperator* sep)
  5915. {
  5916. if (client->GetPlayer()->GetMap() != nullptr) {
  5917. if(sep && sep->arg[0][0] && strncasecmp("spawns", sep->arg[0], 6) == 0) {
  5918. int32 grid = client->GetPlayer()->GetLocation();
  5919. if(sep->IsNumber(1))
  5920. grid = atoul(sep->arg[1]);
  5921. client->GetCurrentZone()->SendClientSpawnListInGrid(client, grid);
  5922. }
  5923. if(sep && sep->arg[0][0] && strncasecmp("boundary", sep->arg[0], 8) == 0) {
  5924. int32 grid = client->GetPlayer()->GetLocation();
  5925. if(sep->IsNumber(1))
  5926. grid = atoul(sep->arg[1]);
  5927. if(!client->GetPlayer()->GetMap()) {
  5928. client->Message(CHANNEL_COLOR_RED, "No map to check grid!");
  5929. return;
  5930. }
  5931. GridMapBorder* gmb = client->GetPlayer()->GetMap()->GetMapGridBorder(grid, false);
  5932. if(gmb) {
  5933. client->Message(CHANNEL_COLOR_YELLOW, "Grid %u border MinX %f MaxX %f, MinY %f MaxY %f, MinZ %f MaxZ %f", grid, gmb->m_MinX, gmb->m_MaxX, gmb->m_MinY, gmb->m_MaxY, gmb->m_MinZ, gmb->m_MaxZ);
  5934. }
  5935. else {
  5936. client->Message(CHANNEL_COLOR_RED, "Grid %u has no grid map border", grid);
  5937. }
  5938. }
  5939. else {
  5940. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->GetLocation());
  5941. auto loc = glm::vec3(client->GetPlayer()->GetX(), client->GetPlayer()->GetZ(), client->GetPlayer()->GetY());
  5942. uint32 GridID = 0;
  5943. uint32 WidgetID = 0;
  5944. float new_z = client->GetPlayer()->FindBestZ(loc, nullptr, &GridID, &WidgetID);
  5945. float minY = client->GetPlayer()->GetMap()->GetMinY();
  5946. float maxY = client->GetPlayer()->GetMap()->GetMaxY();
  5947. float minZ = client->GetPlayer()->GetMap()->GetMinZ();
  5948. float maxZ = client->GetPlayer()->GetMap()->GetMaxZ();
  5949. int32 grid_spawn_count = client->GetPlayer()->GetZone()->GetSpawnCountInGrid(GridID);
  5950. 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);
  5951. }
  5952. }
  5953. }
  5954. /*
  5955. Function: Command_Guild()
  5956. Purpose : Handler for all UI-related guild commands
  5957. Dev : Scatman
  5958. */
  5959. void Commands::Command_Guild(Client* client, Seperator* sep)
  5960. {
  5961. Guild* guild = client->GetPlayer()->GetGuild();
  5962. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  5963. {
  5964. const char* command = sep->arg[0];
  5965. int32 length = strlen(command);
  5966. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  5967. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  5968. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  5969. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5970. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5971. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5972. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5973. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  5974. guild->KickGuildMember(client, sep->arg[1]);
  5975. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  5976. guild->DemoteGuildMember(client, sep->arg[1]);
  5977. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  5978. guild->PromoteGuildMember(client, sep->arg[1]);
  5979. else if (strncmp(command, "points", length) == 0 && guild)
  5980. {
  5981. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  5982. {
  5983. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5984. {
  5985. float points = atof(sep->arg[2]);
  5986. const char* option = sep->arg[3];
  5987. const char* comment = sep->argplus[4];
  5988. if (strncmp(option, "all", strlen(option)) == 0)
  5989. guild->AddPointsToAll(client, points, comment);
  5990. else if (strncmp(option, "online", strlen(option)) == 0)
  5991. guild->AddPointsToAllOnline(client, points, comment);
  5992. else if (strncmp(option, "group", strlen(option)) == 0)
  5993. guild->AddPointsToGroup(client, points, comment);
  5994. else if (strncmp(option, "raid", strlen(option)) == 0)
  5995. guild->AddPointsToRaid(client, points, comment);
  5996. else
  5997. guild->AddPointsToGuildMember(client, points, option, comment);
  5998. }
  5999. }
  6000. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  6001. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  6002. else
  6003. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  6004. }
  6005. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  6006. guild->SetMOTD(sep->argplus[1]);
  6007. else if (strncmp(command, "recruiting", length) == 0 && guild)
  6008. {
  6009. if (sep->arg[1])
  6010. {
  6011. const char* option = sep->arg[1];
  6012. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  6013. guild->SetRecruitingShortDesc(sep->argplus[2]);
  6014. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  6015. guild->SetRecruitingFullDesc(sep->argplus[2]);
  6016. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  6017. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  6018. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  6019. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  6020. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  6021. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  6022. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  6023. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  6024. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  6025. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6026. else
  6027. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  6028. }
  6029. else
  6030. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  6031. }
  6032. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  6033. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6034. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  6035. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6036. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  6037. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  6038. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  6039. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  6040. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  6041. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  6042. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  6043. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  6044. else if (strncmp(command, "invite", length) == 0 && guild)
  6045. {
  6046. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6047. guild->InvitePlayer(client, sep->arg[1]);
  6048. else
  6049. {
  6050. Spawn* target = client->GetPlayer()->GetTarget();
  6051. if (target)
  6052. {
  6053. if (target->IsPlayer())
  6054. guild->InvitePlayer(client, target->GetName());
  6055. else
  6056. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  6057. }
  6058. }
  6059. }
  6060. else if (strncmp(command, "accept", length) == 0)
  6061. {
  6062. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  6063. if (pgi && pgi->guild && pgi->invited_by)
  6064. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  6065. client->SetPendingGuildInvite(0);
  6066. }
  6067. else if (strncmp(command, "decline", length) == 0)
  6068. {
  6069. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  6070. if (pgi && pgi->guild && pgi->invited_by && pgi->invited_by->IsPlayer())
  6071. {
  6072. Client* client_inviter = ((Player*)pgi->invited_by)->GetClient();
  6073. if (client_inviter) {
  6074. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  6075. }
  6076. }
  6077. client->SetPendingGuildInvite(0);
  6078. }
  6079. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  6080. {
  6081. const char* guild_name = sep->argplus[1];
  6082. if (!guild_list.GetGuild(guild_name))
  6083. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6084. else
  6085. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  6086. }
  6087. else if (strncmp(command, "search", length) == 0)
  6088. client->ShowGuildSearchWindow();
  6089. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6090. {
  6091. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6092. if (to_guild)
  6093. to_guild->SendGuildRecruitingDetails(client);
  6094. }
  6095. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6096. {
  6097. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6098. if (to_guild)
  6099. to_guild->SendGuildRecruitingImages(client);
  6100. }
  6101. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  6102. {
  6103. if (sep->arg[1])
  6104. {
  6105. const char* option = sep->arg[1];
  6106. if (strncmp(option, "toggle", strlen(option)) == 0)
  6107. guild->ToggleGuildRecruiterAdventureClass(client);
  6108. }
  6109. else
  6110. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  6111. }
  6112. else if (strncmp(command, "display_heraldry", length) == 0)
  6113. {
  6114. // JA: not sure this is right...
  6115. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  6116. client->GetPlayer()->SetCharSheetChanged(true);
  6117. }
  6118. else
  6119. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  6120. }
  6121. }
  6122. /*
  6123. Function: Command_GuildCreate()
  6124. Purpose : Display's in-game Guild Creation window
  6125. Dev : Scatman
  6126. */
  6127. void Commands::Command_CreateGuild(Client* client)
  6128. {
  6129. client->SendGuildCreateWindow();
  6130. }
  6131. /*
  6132. Function: Command_SetGuildOfficerNote()
  6133. Purpose :
  6134. Dev : Scatman
  6135. */
  6136. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  6137. {
  6138. if (sep && sep->arg[0] && sep->arg[1])
  6139. {
  6140. Guild* guild = client->GetPlayer()->GetGuild();
  6141. if (guild)
  6142. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  6143. }
  6144. }
  6145. /*
  6146. Function: Command_SetGuildMemberNote()
  6147. Purpose :
  6148. Dev : Scatman
  6149. */
  6150. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  6151. {
  6152. if (sep && sep->arg[0] && sep->arg[1])
  6153. {
  6154. Guild* guild = client->GetPlayer()->GetGuild();
  6155. if (guild)
  6156. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  6157. }
  6158. }
  6159. /*
  6160. Function: Command_GuildSay()
  6161. Purpose :
  6162. Dev : Scatman
  6163. */
  6164. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  6165. {
  6166. Guild* guild = client->GetPlayer()->GetGuild();
  6167. if (guild)
  6168. {
  6169. if (sep && sep->arg[0])
  6170. guild->HandleGuildSay(client, sep->argplus[0]);
  6171. }
  6172. else
  6173. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6174. }
  6175. /*
  6176. Function: Command_OfficerSay()
  6177. Purpose :
  6178. Dev : Scatman
  6179. */
  6180. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  6181. {
  6182. Guild* guild = client->GetPlayer()->GetGuild();
  6183. if (guild)
  6184. {
  6185. if (sep && sep->arg[0])
  6186. guild->HandleOfficerSay(client, sep->argplus[0]);
  6187. }
  6188. else
  6189. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6190. }
  6191. /*
  6192. Function: Command_Guilds()
  6193. Purpose : Shows help for /guild command
  6194. Params :
  6195. Dev : Scatman
  6196. Example :
  6197. */
  6198. void Commands::Command_Guilds(Client* client)
  6199. {
  6200. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  6201. }
  6202. /*
  6203. Function: Command_GuildsAdd()
  6204. Purpose : Add's players to a guild
  6205. Params : guild_name|guild_id, player name
  6206. Dev : Scatman
  6207. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  6208. */
  6209. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  6210. {
  6211. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6212. {
  6213. Guild* guild = 0;
  6214. bool found = true;
  6215. if (sep->IsNumber(0))
  6216. {
  6217. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6218. if (!guild)
  6219. {
  6220. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6221. found = false;
  6222. }
  6223. }
  6224. else
  6225. {
  6226. guild = guild_list.GetGuild(sep->arg[0]);
  6227. if (!guild)
  6228. {
  6229. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6230. found = false;
  6231. }
  6232. }
  6233. if (found)
  6234. {
  6235. Client* to_client = 0;
  6236. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6237. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6238. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6239. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6240. if (to_client)
  6241. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  6242. else
  6243. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6244. }
  6245. }
  6246. else
  6247. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  6248. }
  6249. /*
  6250. Function: Command_GuildsCreate()
  6251. Purpose : Creates a guild
  6252. Params : guild_name, player_name (optional)
  6253. Dev : Scatman
  6254. Example : /guilds create [guild name] (player name)
  6255. */
  6256. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  6257. {
  6258. if (sep && sep->arg[0])
  6259. {
  6260. const char* guild_name = sep->arg[0];
  6261. if (!guild_list.GetGuild(guild_name))
  6262. {
  6263. bool ret = false;
  6264. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6265. {
  6266. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6267. if (to_client)
  6268. {
  6269. world.CreateGuild(guild_name, to_client);
  6270. ret = true;
  6271. }
  6272. else
  6273. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  6274. }
  6275. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6276. {
  6277. Client* to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6278. if (to_client)
  6279. {
  6280. world.CreateGuild(guild_name, to_client);
  6281. ret = true;
  6282. }
  6283. }
  6284. else
  6285. {
  6286. world.CreateGuild(guild_name);
  6287. ret = true;
  6288. }
  6289. if (ret)
  6290. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  6291. else
  6292. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  6293. }
  6294. else
  6295. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  6296. }
  6297. else
  6298. 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.");
  6299. }
  6300. /*
  6301. Function: Command_GuildsDelete()
  6302. Purpose : Delete's a guild
  6303. Params : guild name
  6304. Dev : Scatman
  6305. Example : /guilds delete Test
  6306. */
  6307. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  6308. {
  6309. if (sep && sep->arg[0])
  6310. {
  6311. Guild* guild = 0;
  6312. bool found = true;
  6313. if (sep->IsNumber(0))
  6314. {
  6315. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6316. if (!guild)
  6317. {
  6318. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6319. found = false;
  6320. }
  6321. }
  6322. else
  6323. {
  6324. guild = guild_list.GetGuild(sep->arg[0]);
  6325. if (!guild)
  6326. {
  6327. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6328. found = false;
  6329. }
  6330. }
  6331. if (found)
  6332. {
  6333. guild->RemoveAllGuildMembers();
  6334. database.DeleteGuild(guild);
  6335. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  6336. guild_list.RemoveGuild(guild, true);
  6337. }
  6338. }
  6339. else
  6340. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  6341. }
  6342. /*
  6343. Function: Command_GuildsList()
  6344. Purpose : Lists current guilds on server
  6345. Params :
  6346. Dev : Scatman
  6347. Example : /guilds list
  6348. */
  6349. void Commands::Command_GuildsList(Client* client)
  6350. {
  6351. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  6352. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  6353. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  6354. if (guilds->size() == 0)
  6355. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  6356. else {
  6357. while (itr.Next()) {
  6358. Guild* guild = itr.second;
  6359. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  6360. }
  6361. }
  6362. }
  6363. /*
  6364. Function: Command_GuildsRemove()
  6365. Purpose : Removes a player from a guild
  6366. Params : guild name|guild id, player name
  6367. Dev : Scatman
  6368. Example : /guilds remove 1 Admin = removes Admin from guild 1
  6369. */
  6370. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  6371. {
  6372. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6373. {
  6374. Guild* guild = 0;
  6375. bool found = true;
  6376. if (sep->IsNumber(0))
  6377. {
  6378. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6379. if (!guild)
  6380. {
  6381. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6382. found = false;
  6383. }
  6384. }
  6385. else
  6386. {
  6387. guild = guild_list.GetGuild(sep->arg[0]);
  6388. if (!guild)
  6389. {
  6390. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6391. found = false;
  6392. }
  6393. }
  6394. if (found)
  6395. {
  6396. Client* to_client = 0;
  6397. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6398. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6399. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6400. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6401. if (to_client)
  6402. {
  6403. Player* to_player = to_client->GetPlayer();
  6404. if (to_player->GetGuild())
  6405. {
  6406. if (to_player->GetGuild() == guild)
  6407. {
  6408. guild->KickGuildMember(client, to_player->GetName());
  6409. }
  6410. else
  6411. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  6412. }
  6413. else
  6414. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  6415. }
  6416. else
  6417. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6418. }
  6419. }
  6420. else
  6421. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  6422. }
  6423. /*
  6424. Function: Command_InspectPlayer()
  6425. Purpose : Handle the Inspect functions
  6426. Params : Client to inspect
  6427. Dev : Scatman
  6428. Example : /inspect Scatman
  6429. */
  6430. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  6431. {
  6432. if (sep && sep->arg[0])
  6433. {
  6434. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  6435. if (inspect_client)
  6436. client->InspectPlayer(inspect_client->GetPlayer());
  6437. }
  6438. else
  6439. {
  6440. Spawn* target = client->GetPlayer()->GetTarget();
  6441. if (target && target->IsPlayer())
  6442. client->InspectPlayer((Player*)target);
  6443. }
  6444. }
  6445. /*
  6446. Function: Command_Inventory()
  6447. Purpose : Handle changes in player inventory
  6448. Params : <TBD>
  6449. Dev : All
  6450. Example : /inventory delete item_id
  6451. */
  6452. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  6453. {
  6454. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  6455. Player* player = client->GetPlayer();
  6456. if(sep && sep->arg[0][0])
  6457. {
  6458. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  6459. if(!client->GetPlayer()->Alive())
  6460. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  6461. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6462. {
  6463. int16 index = atoi(sep->arg[1]);
  6464. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6465. if(item)
  6466. {
  6467. if(item->details.item_locked) {
  6468. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item in use.");
  6469. return;
  6470. }
  6471. else if(item->IsBag() && item->details.equip_slot_id) {
  6472. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item, it is being used as quiver.");
  6473. return;
  6474. }
  6475. else if(item->CheckFlag(NO_DESTROY)) {
  6476. client->SimpleMessage(CHANNEL_COLOR_RED, "You can't destroy this item.");
  6477. return;
  6478. }
  6479. if(item->GetItemScript() && lua_interface)
  6480. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  6481. //reobtain item make sure it wasn't removed
  6482. item = player->item_list.GetItemFromIndex(index);
  6483. int32 bag_id = 0;
  6484. if(item){
  6485. bag_id = item->details.inv_slot_id;
  6486. database.DeleteItem(client->GetCharacterID(), item, 0);
  6487. }
  6488. client->GetPlayer()->item_list.DestroyItem(index);
  6489. client->GetPlayer()->UpdateInventory(bag_id);
  6490. client->GetPlayer()->CalculateApplyWeight();
  6491. }
  6492. }
  6493. 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))
  6494. {
  6495. int16 from_index = atoi(sep->arg[1]);
  6496. sint16 to_slot = atoi(sep->arg[2]); // don't convert slot since this is inventory not equipment
  6497. sint32 bag_id = atol(sep->arg[3]);
  6498. int8 charges = atoi(sep->arg[4]);
  6499. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  6500. if(!item) {
  6501. client->SimpleMessage(CHANNEL_COLOR_RED, "You have no item.");
  6502. return;
  6503. }
  6504. if(to_slot == item->details.slot_id && (bag_id < 0 || bag_id == item->details.inv_slot_id)) {
  6505. return;
  6506. }
  6507. if(item->details.item_locked)
  6508. {
  6509. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot move the item in use.");
  6510. return;
  6511. }
  6512. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  6513. {
  6514. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  6515. return;
  6516. }
  6517. sint32 old_inventory_id = 0;
  6518. if(item)
  6519. old_inventory_id = item->details.inv_slot_id;
  6520. //autobank
  6521. if (bag_id == -3 && to_slot == -1)
  6522. {
  6523. if (player->HasFreeBankSlot())
  6524. to_slot = player->FindFreeBankSlot();
  6525. else
  6526. {
  6527. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  6528. return;
  6529. }
  6530. }
  6531. //auto inventory
  6532. if (bag_id == 0 && to_slot == -1)
  6533. {
  6534. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6535. {
  6536. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  6537. return;
  6538. }
  6539. }
  6540. bool item_deleted = false;
  6541. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, &item_deleted, client->GetVersion());
  6542. client->QueuePacket(outapp);
  6543. if(item_deleted)
  6544. item = nullptr;
  6545. //removed from bag send update
  6546. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  6547. {
  6548. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  6549. if(outapp)
  6550. client->QueuePacket(outapp);
  6551. }
  6552. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  6553. {
  6554. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  6555. if(outapp)
  6556. client->QueuePacket(outapp);
  6557. }
  6558. }
  6559. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  6560. {
  6561. int16 index = atoi(sep->arg[1]);
  6562. int8 slot_id = 255;
  6563. int8 unk3 = 0;
  6564. int8 appearance_equip = 0;
  6565. if(sep->arg[2][0] && sep->IsNumber(2))
  6566. slot_id = player->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6567. if(sep->arg[3][0] && sep->IsNumber(3))
  6568. unk3 = atoul(sep->arg[3]);
  6569. if(sep->arg[4][0] && sep->IsNumber(4))
  6570. appearance_equip = atoul(sep->arg[4]);
  6571. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  6572. EQ2Packet* outapp = 0;
  6573. for(int32 i=0;i<packets.size();i++)
  6574. {
  6575. outapp = packets[i];
  6576. if(outapp)
  6577. client->QueuePacket(outapp);
  6578. }
  6579. client->GetPlayer()->UpdateWeapons();
  6580. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6581. client->QueuePacket(characterSheetPackets);
  6582. }
  6583. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6584. {
  6585. if (client->GetPlayer()->EngagedInCombat())
  6586. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  6587. else {
  6588. int16 index = atoi(sep->arg[1]);
  6589. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6590. if (item) {
  6591. if(item->details.item_locked)
  6592. {
  6593. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot unpack the item in use.");
  6594. return;
  6595. }
  6596. // client->GetPlayer()->item_list.DestroyItem(index);
  6597. if (item->item_sets.size() > 0) {
  6598. for (int32 i = 0; i < item->item_sets.size(); i++) {
  6599. ItemSet* set = item->item_sets[i];
  6600. if (set->item_stack_size == 0)
  6601. set->item_stack_size += 1;
  6602. client->AddItem(set->item_id, set->item_stack_size);
  6603. }
  6604. }
  6605. }
  6606. client->RemoveItem(item, 1);
  6607. }
  6608. }
  6609. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  6610. {
  6611. int16 index = player->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6612. sint32 bag_id = -999;
  6613. int8 to_slot = 255;
  6614. if(sep->arg[3][0])
  6615. {
  6616. if(sep->IsNumber(2))
  6617. bag_id = atol(sep->arg[2]);
  6618. if(sep->IsNumber(3))
  6619. to_slot = atoi(sep->arg[3]);
  6620. }
  6621. sint8 unk4 = 0;
  6622. int8 appearance_equip = 0;
  6623. if(sep->arg[4][0] && sep->IsNumber(4))
  6624. unk4 = atoi(sep->arg[4]);
  6625. if(sep->arg[5][0] && sep->IsNumber(5))
  6626. appearance_equip = atoul(sep->arg[5]);
  6627. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  6628. EQ2Packet* outapp = 0;
  6629. for(int32 i=0;i<packets.size();i++)
  6630. {
  6631. outapp = packets[i];
  6632. if(outapp)
  6633. client->QueuePacket(outapp);
  6634. }
  6635. client->UnequipItem(index, bag_id, to_slot, appearance_equip);
  6636. }
  6637. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6638. {
  6639. if(client->GetPlayer()->EngagedInCombat() && rule_manager.GetGlobalRule(R_Player, AllowPlayerEquipCombat)->GetInt8() == 0) {
  6640. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not swap items while in combat.");
  6641. }
  6642. else {
  6643. int16 index1 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6644. int16 index2 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6645. int8 type = 0;
  6646. if(sep->IsNumber(3))
  6647. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  6648. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  6649. if(outapp)
  6650. client->QueuePacket(outapp);
  6651. else
  6652. {
  6653. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  6654. return;
  6655. }
  6656. }
  6657. }
  6658. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6659. {
  6660. sint16 to_slot = atoi(sep->arg[1]);
  6661. sint32 bag_id = atoi(sep->arg[2]);
  6662. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  6663. if (item) {
  6664. //auto inventory
  6665. if (bag_id == 0 && to_slot == -1)
  6666. {
  6667. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6668. {
  6669. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  6670. return;
  6671. }
  6672. // Set the slot for the item
  6673. item->details.inv_slot_id = bag_id;
  6674. item->details.slot_id = to_slot;
  6675. // Flag the item so it gets saved in its new location
  6676. item->save_needed = true;
  6677. // Add the item to its new location
  6678. if(player->item_list.AddItem(item)) {
  6679. // Remove the item from the overflow list
  6680. player->item_list.RemoveOverflowItem(item);
  6681. }
  6682. // Send the inventory update packet
  6683. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6684. return;
  6685. }
  6686. else if (bag_id == -3 && to_slot == -1) {
  6687. // Auto Bank
  6688. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  6689. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  6690. return;
  6691. }
  6692. item->details.inv_slot_id = bag_id;
  6693. item->details.slot_id = to_slot;
  6694. item->save_needed = true;
  6695. if(player->item_list.AddItem(item)) {
  6696. player->item_list.RemoveOverflowItem(item);
  6697. }
  6698. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6699. }
  6700. else if (bag_id == -4) {
  6701. // Shared Bank
  6702. if (!player->item_list.SharedBankAddAllowed(item)) {
  6703. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  6704. return;
  6705. }
  6706. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  6707. if (tmp_item) {
  6708. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6709. return;
  6710. }
  6711. else {
  6712. item->details.inv_slot_id = bag_id;
  6713. item->details.slot_id = to_slot;
  6714. item->save_needed = true;
  6715. if(player->item_list.AddItem(item)) {
  6716. player->item_list.RemoveOverflowItem(item);
  6717. }
  6718. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6719. return;
  6720. }
  6721. }
  6722. else {
  6723. // Try to get an item from the given bag id and slot id
  6724. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  6725. // Check to see if we got an item, if we do send an error,
  6726. // if we don't put the overflow item into this slot
  6727. if (tmp_item) {
  6728. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6729. }
  6730. else {
  6731. item->details.inv_slot_id = bag_id;
  6732. item->details.slot_id = to_slot;
  6733. item->save_needed = true;
  6734. if(player->item_list.AddItem(item)) {
  6735. player->item_list.RemoveOverflowItem(item);
  6736. }
  6737. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6738. return;
  6739. }
  6740. }
  6741. }
  6742. }
  6743. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6744. {
  6745. sint64 data = strtoull(sep->arg[1], NULL, 0);
  6746. int32 character_item_id = (int32) (data >> 32);
  6747. int32 item_id = (int32) (data & 0xffffffffL);
  6748. int8 sale_setting = atoi(sep->arg[2]);
  6749. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  6750. if(item)
  6751. {
  6752. item->no_sale = sale_setting;
  6753. item->save_needed = true;
  6754. client->SendSellMerchantList();
  6755. }
  6756. }
  6757. }
  6758. else
  6759. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  6760. }
  6761. /*
  6762. Function: Command_Languages()
  6763. Purpose : Show's languages the player knows
  6764. Params :
  6765. Dev : Zcoretri
  6766. Example :
  6767. */
  6768. void Commands::Command_Languages(Client* client, Seperator* sep)
  6769. {
  6770. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6771. list<Language*>::iterator itr;
  6772. Language* language;
  6773. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6774. for(itr = languages->begin(); itr != languages->end(); itr++)
  6775. {
  6776. language = *itr;
  6777. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6778. }
  6779. }
  6780. /*
  6781. Function: Command_SetLanguage()
  6782. Purpose : Handles language commands
  6783. Params : Language ID
  6784. Dev : Zcoretri
  6785. Example :
  6786. */
  6787. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6788. {
  6789. Player* player = client->GetPlayer();
  6790. if (sep && sep->arg[0])
  6791. {
  6792. if(!sep->IsNumber(0))
  6793. {
  6794. //String passed in
  6795. const char* value = sep->arg[0];
  6796. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6797. {
  6798. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6799. client->SendLanguagesUpdate(0);
  6800. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6801. }
  6802. else
  6803. {
  6804. if(player->HasLanguage(value))
  6805. {
  6806. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6807. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6808. client->SendLanguagesUpdate(language->GetID());
  6809. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6810. }
  6811. else
  6812. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6813. }
  6814. }
  6815. else
  6816. {
  6817. //Number passed in
  6818. int32 id = atoul(sep->arg[0]);
  6819. if(player->HasLanguage(id))
  6820. {
  6821. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6822. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6823. client->SendLanguagesUpdate(id);
  6824. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6825. }
  6826. else
  6827. {
  6828. Language* language = master_languages_list.GetLanguage(id);
  6829. if(language)
  6830. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6831. }
  6832. }
  6833. }
  6834. else
  6835. {
  6836. //No value was passed in
  6837. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6838. if(id > 0)
  6839. {
  6840. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6841. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6842. }
  6843. else
  6844. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6845. }
  6846. }
  6847. /*
  6848. Function: Command_LastName()
  6849. Purpose : Sets player surname
  6850. Params : Name text
  6851. Dev : theFoof
  6852. Example :
  6853. */
  6854. void Commands::Command_LastName(Client* client, Seperator* sep)
  6855. {
  6856. if (!client)
  6857. return;
  6858. if (sep && sep->arg[0])
  6859. {
  6860. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6861. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6862. return;
  6863. }
  6864. client->RemovePendingLastName();
  6865. uchar* checkname = (uchar*)sep->arg[0];
  6866. bool valid_name = true;
  6867. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6868. if (!alpha_check(checkname[i])) {
  6869. valid_name = false;
  6870. break;
  6871. }
  6872. }
  6873. if (!valid_name) {
  6874. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6875. return;
  6876. }
  6877. string last_name = (string)sep->arg[0];
  6878. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6879. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6880. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6881. client->SetPendingLastName(last_name);
  6882. client->SendLastNameConfirmation();
  6883. }
  6884. else
  6885. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6886. }
  6887. }
  6888. /*
  6889. Function: Command_ConfirmLastName()
  6890. Purpose : Confirms setting of player surname
  6891. Params : Name text
  6892. Dev : theFoof
  6893. Example :
  6894. */
  6895. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6896. {
  6897. if (!client)
  6898. return;
  6899. string* name = client->GetPendingLastName();
  6900. if (name){
  6901. Player* player = client->GetPlayer();
  6902. player->SetLastName(name->c_str(), false);
  6903. client->SendTitleUpdate();
  6904. player->SetCharSheetChanged(true);
  6905. client->RemovePendingLastName();
  6906. }
  6907. }
  6908. /*
  6909. Function: Command_Location()
  6910. Purpose : Display's Help for /location commands
  6911. Params :
  6912. Dev : Scatman
  6913. Example : /location = show's help for command
  6914. */
  6915. void Commands::Command_Location(Client* client)
  6916. {
  6917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6918. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6919. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6920. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6923. }
  6924. /*
  6925. Function: Command_LocationAdd()
  6926. Purpose : Add's a location to an existing location config
  6927. Params : location_id
  6928. Dev : Scatman
  6929. Example : /location add {location_id}
  6930. */
  6931. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6932. {
  6933. if (sep && sep->arg[0] && sep->IsNumber(0))
  6934. {
  6935. int32 location_id = atoul(sep->arg[0]);
  6936. float x = client->GetPlayer()->GetX();
  6937. float y = client->GetPlayer()->GetY();
  6938. float z = client->GetPlayer()->GetZ();
  6939. if (database.AddLocationPoint(location_id, x, y, z))
  6940. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6941. else
  6942. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6943. }
  6944. else
  6945. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6946. }
  6947. /*
  6948. Function: Command_LocationCreate()
  6949. Purpose : Creates a new location config
  6950. Params : location name, 0/1 for include_y (optional)
  6951. Dev : Scatman
  6952. Example : /location create Test 1 = creates a new location named Test with include_y True
  6953. */
  6954. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6955. {
  6956. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6957. {
  6958. const char* name = sep->arg[0];
  6959. bool include_y = false;
  6960. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6961. include_y = true;
  6962. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->GetLocation(), name, include_y);
  6963. if (location_id > 0)
  6964. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6965. else
  6966. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6967. }
  6968. else
  6969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6970. }
  6971. /*
  6972. Function: Command_LocationDelete()
  6973. Purpose : Delete's a location config and all it's location points
  6974. Params : location_id
  6975. Dev : Scatman
  6976. Example : /location delete {location_id}
  6977. */
  6978. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6979. {
  6980. if (sep && sep->arg[0] && sep->IsNumber(0))
  6981. {
  6982. int32 location_id = atoul(sep->arg[0]);
  6983. if (database.DeleteLocation(location_id))
  6984. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6985. else
  6986. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6987. }
  6988. else
  6989. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6990. }
  6991. /*
  6992. Function: Command_LocationList()
  6993. Purpose : Display's a list of location points
  6994. Params : location_id
  6995. Dev : Scatman
  6996. Example : /location list {location_id}
  6997. */
  6998. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6999. {
  7000. if (sep && sep->arg[0])
  7001. {
  7002. const char* option = sep->arg[0];
  7003. if (strncmp(option, "locations", strlen(option)) == 0)
  7004. database.ListLocations(client);
  7005. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  7006. {
  7007. int32 location_id = atoul(sep->arg[1]);
  7008. database.ListLocationPoints(client, location_id);
  7009. }
  7010. else
  7011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  7012. }
  7013. else
  7014. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  7015. }
  7016. /*
  7017. Function: Command_LocationRemove()
  7018. Purpose : Removes a single location point from a location config
  7019. Params : location_point_id (gotten from /location list {id})
  7020. Dev : Scatman
  7021. Example : /location remove 1 = will remove location_point_id 1
  7022. */
  7023. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  7024. {
  7025. if (sep && sep->arg[0] && sep->IsNumber(0))
  7026. {
  7027. int32 location_point_id = atoul(sep->arg[0]);
  7028. if (database.DeleteLocationPoint(location_point_id))
  7029. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  7030. else
  7031. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  7032. }
  7033. else
  7034. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  7035. }
  7036. /*
  7037. Function: Command_Merchant()
  7038. Purpose : Handles Merchant commands
  7039. Params : list
  7040. Dev : Scatman
  7041. Example : /merchant list
  7042. */
  7043. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  7044. {
  7045. if( handler == COMMAND_MERCHANT )
  7046. {
  7047. // /merchant command by itself shows help (to be extended)
  7048. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  7049. return;
  7050. }
  7051. else if( handler == COMMAND_MERCHANT_LIST )
  7052. {
  7053. // /merchant list command expects "description" param
  7054. if (sep && sep->arg[0])
  7055. {
  7056. const char* merchant_description = sep->argplus[0];
  7057. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  7058. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  7059. map<int32, MerchantInfo*>::iterator itr;
  7060. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  7061. {
  7062. string description = database.GetMerchantDescription(itr->first);
  7063. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  7064. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  7065. }
  7066. }
  7067. else // no description
  7068. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  7069. }
  7070. }
  7071. /*
  7072. Function: Command_Modify()
  7073. Purpose : to replace our other "set" commands
  7074. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  7075. Dev : John Adams
  7076. Example : /modify spell set name "Aegolism III"
  7077. */
  7078. void Commands::Command_Modify(Client* client)
  7079. {
  7080. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  7081. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  7082. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  7083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  7084. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  7085. }
  7086. /*
  7087. Function: Command_ModifySpawn()
  7088. Purpose : replace "spawn set" commands
  7089. Params : Action : the action to perform (or special handler)
  7090. : Field : the DB field to change
  7091. : Value : what to set the value to
  7092. : Target : what object to change (my target, or spawn_id)
  7093. Dev : John Adams
  7094. Example : /modify spawn set name "Lady Vox"
  7095. :
  7096. Note : Special Handlers, like "zoneto" for Signs
  7097. : /modify spawn zoneto
  7098. : Will set a sign's zone x/y/z to my current coords
  7099. */
  7100. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  7101. {
  7102. PrintSep(sep, "COMMAND_MODIFY");
  7103. // need at least 2 args for a valid command
  7104. if( sep && sep->arg[1] )
  7105. {
  7106. // JA: just a quick implementation because I need it :)
  7107. if (strcmp(sep->arg[0], "zoneto") == 0)
  7108. {
  7109. if( sep->IsNumber(1) )
  7110. {
  7111. int32 spawn_id = atoul(sep->arg[1]);
  7112. float x_coord = client->GetPlayer()->GetX();
  7113. float y_coord = client->GetPlayer()->GetY();
  7114. float z_coord = client->GetPlayer()->GetZ();
  7115. float h_coord = client->GetPlayer()->GetHeading();
  7116. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  7117. }
  7118. else
  7119. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  7120. }
  7121. }
  7122. else
  7123. Command_Modify(client);
  7124. }
  7125. /*
  7126. Function: Command_ModifyCharacter()
  7127. Purpose : to replace our other "set" commands
  7128. Params : Action : Add, Remove
  7129. : Field : copper, silver, gold, plat
  7130. : Value : min 1, max unlimited
  7131. : Target : Self, Player
  7132. Dev : Cynnar
  7133. Example : /modify character add gold 50
  7134. : /modify character remove silver 25
  7135. */
  7136. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  7137. {
  7138. PrintSep(sep, "COMMAND_MODIFY");
  7139. int64 value = 0;
  7140. Player* player = client->GetPlayer();
  7141. Client* targetClient = client;
  7142. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7143. player = (Player*)player->GetTarget();
  7144. targetClient = player->GetClient();
  7145. }
  7146. // need at least 2 args for a valid command
  7147. if( sep && sep->arg[1] )
  7148. {
  7149. if (strcmp(sep->arg[0], "add") == 0)
  7150. {
  7151. if (strcmp(sep->arg[1], "copper") == 0)
  7152. {
  7153. value = atoi64(sep->arg[2]);
  7154. player->AddCoins(value);
  7155. if (client->GetPlayer() == player)
  7156. {
  7157. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  7158. }
  7159. else {
  7160. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7161. if(targetClient) {
  7162. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7163. }
  7164. }
  7165. }
  7166. else if (strcmp(sep->arg[1], "silver") == 0)
  7167. {
  7168. value = atoi64(sep->arg[2]) * 100;
  7169. player->AddCoins(value);
  7170. if (client->GetPlayer() == player)
  7171. {
  7172. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  7173. }
  7174. else {
  7175. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  7176. if(targetClient) {
  7177. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7178. }
  7179. }
  7180. }
  7181. else if (strcmp(sep->arg[1], "gold") == 0)
  7182. {
  7183. value = atoi64(sep->arg[2]) * 10000;
  7184. player->AddCoins(value);
  7185. if (client->GetPlayer() == player)
  7186. {
  7187. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  7188. }
  7189. else {
  7190. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7191. if(targetClient) {
  7192. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7193. }
  7194. }
  7195. }
  7196. else if (strcmp(sep->arg[1], "plat") == 0)
  7197. {
  7198. value = atoi64(sep->arg[2]) * 1000000;
  7199. player->AddCoins(value);
  7200. if (client->GetPlayer() == player)
  7201. {
  7202. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  7203. }
  7204. else {
  7205. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7206. if(targetClient) {
  7207. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7208. }
  7209. }
  7210. }
  7211. else
  7212. {
  7213. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7214. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7215. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7216. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  7217. }
  7218. }
  7219. else if (strcmp(sep->arg[0], "remove") == 0)
  7220. {
  7221. if (strcmp(sep->arg[1], "copper") == 0)
  7222. {
  7223. value = atoi64(sep->arg[2]);
  7224. player->RemoveCoins(value);
  7225. if (client->GetPlayer() == player)
  7226. {
  7227. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  7228. }
  7229. else {
  7230. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  7231. if(targetClient) {
  7232. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7233. }
  7234. }
  7235. }
  7236. else if (strcmp(sep->arg[1], "silver") == 0)
  7237. {
  7238. value = atoi64(sep->arg[2]) * 100;
  7239. player->RemoveCoins(value);
  7240. if (client->GetPlayer() == player)
  7241. {
  7242. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  7243. }
  7244. else {
  7245. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  7246. if(targetClient) {
  7247. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7248. }
  7249. }
  7250. }
  7251. else if (strcmp(sep->arg[1], "gold") == 0)
  7252. {
  7253. value = atoi64(sep->arg[2]) * 10000;
  7254. player->RemoveCoins(value);
  7255. if (client->GetPlayer() == player)
  7256. {
  7257. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  7258. }
  7259. else {
  7260. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  7261. if(targetClient) {
  7262. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7263. }
  7264. }
  7265. }
  7266. else if (strcmp(sep->arg[1], "plat") == 0)
  7267. {
  7268. value = atoi64(sep->arg[2]) * 1000000;
  7269. player->RemoveCoins(value);
  7270. if (client->GetPlayer() == player)
  7271. {
  7272. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  7273. }
  7274. else {
  7275. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  7276. if(targetClient) {
  7277. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7278. }
  7279. }
  7280. }
  7281. else
  7282. {
  7283. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7284. }
  7285. }
  7286. else if (strcmp(sep->arg[0], "set") == 0) {
  7287. if (strcmp(sep->arg[1], "tslevel") == 0) {
  7288. int8 level = atoi(sep->arg[2]);
  7289. if (level > 0 && level < 256) {
  7290. if (player) {
  7291. if (client->GetPlayer() == player)
  7292. client->ChangeTSLevel(player->GetTSLevel(), level);
  7293. else if(targetClient)
  7294. targetClient->ChangeTSLevel(player->GetTSLevel(), level);
  7295. }
  7296. }
  7297. else
  7298. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  7299. }
  7300. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  7301. int8 tsclass = atoi(sep->arg[2]);
  7302. player->SetTradeskillClass(tsclass);
  7303. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  7304. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  7305. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  7306. player->SetCharSheetChanged(true);
  7307. }
  7308. else if (strcmp(sep->arg[1], "gender") == 0) {
  7309. int8 gender = atoi(sep->arg[2]);
  7310. client->GetPlayer()->GetInfoStruct()->set_gender(gender);
  7311. client->GetPlayer()->SetCharSheetChanged(true);
  7312. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  7313. }
  7314. }
  7315. }
  7316. else
  7317. {
  7318. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7319. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7320. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7321. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7322. }
  7323. }
  7324. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  7325. {
  7326. PrintSep(sep, "COMMAND_MODIFY");
  7327. // need at least 2 args for a valid command
  7328. if( sep && sep->arg[1] )
  7329. {
  7330. }
  7331. else
  7332. Command_Modify(client);
  7333. }
  7334. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  7335. {
  7336. PrintSep(sep, "COMMAND_MODIFY");
  7337. // need at least 2 args for a valid command
  7338. if( sep && sep->arg[1] )
  7339. {
  7340. }
  7341. else
  7342. Command_Modify(client);
  7343. }
  7344. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  7345. {
  7346. PrintSep(sep, "COMMAND_MODIFY");
  7347. // need at least 2 args for a valid command
  7348. if( sep && sep->arg[1] )
  7349. {
  7350. }
  7351. else
  7352. Command_Modify(client);
  7353. }
  7354. /*
  7355. Function: Command_ModifyQuest()
  7356. Purpose : to list players quest and completed quests
  7357. Params : Action : list, completed
  7358. : Target : Self, Player
  7359. Dev : Cynnar
  7360. Example : /modify quest list
  7361. : /modify quest completed
  7362. */
  7363. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  7364. {
  7365. PrintSep(sep, "COMMAND_MODIFY");
  7366. int64 value = 0;
  7367. Player* player = client->GetPlayer();
  7368. Client* targetClient = client;
  7369. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7370. player = (Player*)player->GetTarget();
  7371. targetClient = player->GetClient();
  7372. }
  7373. // need at least 2 args for a valid command
  7374. if (sep && sep->arg[1])
  7375. {
  7376. if (strcmp(sep->arg[0], "list") == 0)
  7377. {
  7378. map<int32, Quest*>* quests = player->GetPlayerQuests();
  7379. map<int32, Quest*>::iterator itr;
  7380. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  7381. if (quests->size() == 0)
  7382. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  7383. else
  7384. {
  7385. for (itr = quests->begin(); itr != quests->end(); itr++)
  7386. {
  7387. Quest* quest = itr->second;
  7388. if(quest) {
  7389. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7390. }
  7391. }
  7392. }
  7393. }
  7394. else if (strcmp(sep->arg[0], "completed") == 0)
  7395. {
  7396. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  7397. map<int32, Quest*>::iterator itr;
  7398. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  7399. if (quests->size() == 0)
  7400. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  7401. else
  7402. {
  7403. for (itr = quests->begin(); itr != quests->end(); itr++)
  7404. {
  7405. Quest* quest = itr->second;
  7406. if(quest) {
  7407. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7408. }
  7409. }
  7410. }
  7411. }
  7412. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  7413. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  7414. else if (strcmp(sep->arg[0], "remove") == 0)
  7415. {
  7416. int32 quest_id = 0;
  7417. if (sep && sep->arg[1] && sep->IsNumber(1))
  7418. quest_id = atoul(sep->arg[1]);
  7419. if (quest_id > 0)
  7420. {
  7421. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  7422. {
  7423. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7424. if (quest)
  7425. if (client->GetPlayer() == player)
  7426. {
  7427. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  7428. }
  7429. else
  7430. {
  7431. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  7432. if(targetClient) {
  7433. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  7434. }
  7435. }
  7436. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  7437. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  7438. }
  7439. client->RemovePlayerQuest(quest_id);
  7440. client->GetCurrentZone()->SendQuestUpdates(client);
  7441. }
  7442. }
  7443. else if (strcmp(sep->arg[0], "advance") == 0)
  7444. {
  7445. int32 quest_id = 0;
  7446. int32 step = 0;
  7447. if (sep && sep->arg[1] && sep->IsNumber(1))
  7448. {
  7449. quest_id = atoul(sep->arg[1]);
  7450. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7451. if(!quest) {
  7452. client->Message(CHANNEL_COLOR_RED, "Quest not found!");
  7453. return;
  7454. }
  7455. if (sep && sep->arg[2] && sep->IsNumber(1))
  7456. {
  7457. step = atoul(sep->arg[2]);
  7458. if (quest_id > 0 && step > 0)
  7459. {
  7460. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  7461. {
  7462. if (client)
  7463. {
  7464. client->AddPendingQuestUpdate(quest_id, step);
  7465. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  7466. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  7467. }
  7468. }
  7469. }
  7470. else
  7471. {
  7472. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  7473. }
  7474. }
  7475. else
  7476. {
  7477. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  7478. }
  7479. }
  7480. else
  7481. {
  7482. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  7483. }
  7484. }
  7485. else
  7486. {
  7487. Command_Modify(client);
  7488. }
  7489. }
  7490. else
  7491. {
  7492. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  7493. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  7494. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  7495. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  7496. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  7497. }
  7498. }
  7499. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  7500. {
  7501. PrintSep(sep, "COMMAND_MODIFY");
  7502. // need at least 2 args for a valid command
  7503. if( sep && sep->arg[1] )
  7504. {
  7505. if (strcmp(sep->arg[0], "add") == 0) {
  7506. const char* skill_name = sep->argplus[1];
  7507. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7508. if (skill) {
  7509. Player* player = 0;
  7510. Client* to_client = 0;
  7511. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7512. player = (Player*)client->GetPlayer()->GetTarget();
  7513. to_client = player->GetClient();
  7514. }
  7515. else {
  7516. player = client->GetPlayer();
  7517. to_client = client;
  7518. }
  7519. if (player)
  7520. {
  7521. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7522. {
  7523. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7524. if (to_client == client) {
  7525. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  7526. }
  7527. else {
  7528. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7529. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7530. }
  7531. }
  7532. else
  7533. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  7534. }
  7535. }
  7536. else
  7537. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7538. }
  7539. else if (strcmp(sep->arg[0], "remove") == 0) {
  7540. const char* skill_name = sep->argplus[1];
  7541. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7542. if (skill) {
  7543. Player* player = 0;
  7544. Client* to_client = 0;
  7545. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7546. player = (Player*)client->GetPlayer()->GetTarget();
  7547. to_client = player->GetClient();
  7548. }
  7549. else {
  7550. player = client->GetPlayer();
  7551. to_client = client;
  7552. }
  7553. if (player)
  7554. {
  7555. if (player->GetSkills()->HasSkill(skill->skill_id))
  7556. {
  7557. player->RemoveSkillFromDB(skill, true);
  7558. if (client == to_client) {
  7559. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  7560. }
  7561. else {
  7562. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7563. if(to_client) {
  7564. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7565. }
  7566. }
  7567. }
  7568. else {
  7569. if (client == to_client)
  7570. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  7571. else
  7572. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7573. }
  7574. }
  7575. }
  7576. else
  7577. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7578. }
  7579. else if (strcmp(sep->arg[0], "set") == 0) {
  7580. if (!sep->IsNumber(2)) {
  7581. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  7582. return;
  7583. }
  7584. const char* skill_name = sep->arg[1];
  7585. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7586. if (skill) {
  7587. int16 val = atoi(sep->arg[2]);
  7588. Player* player = 0;
  7589. Client* to_client = 0;
  7590. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7591. player = (Player*)client->GetPlayer()->GetTarget();
  7592. to_client = player->GetClient();
  7593. }
  7594. else {
  7595. player = client->GetPlayer();
  7596. to_client = client;
  7597. }
  7598. if (player)
  7599. {
  7600. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  7601. player->GetSkills()->SetSkill(skill->skill_id, val);
  7602. if (client != to_client)
  7603. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  7604. if(to_client) {
  7605. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  7606. }
  7607. }
  7608. else {
  7609. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  7610. }
  7611. }
  7612. }
  7613. else {
  7614. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7615. }
  7616. }
  7617. else {
  7618. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7619. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7620. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7621. }
  7622. }
  7623. else {
  7624. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7625. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7626. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7627. }
  7628. }
  7629. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  7630. {
  7631. PrintSep(sep, "COMMAND_MODIFY");
  7632. // need at least 2 args for a valid command
  7633. if( sep && sep->arg[1] )
  7634. {
  7635. }
  7636. else
  7637. Command_Modify(client);
  7638. }
  7639. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  7640. {
  7641. PrintSep(sep, "COMMAND_MODIFY");
  7642. // need at least 2 args for a valid command
  7643. if( sep && sep->arg[1] )
  7644. {
  7645. }
  7646. else
  7647. Command_Modify(client);
  7648. }
  7649. /*
  7650. Function: Command_MOTD()
  7651. Purpose : Displays server MOTD
  7652. Params :
  7653. Dev : LethalEncounter
  7654. Example : /motd
  7655. */
  7656. void Commands::Command_MOTD(Client* client)
  7657. {
  7658. if (client)
  7659. ClientPacketFunctions::SendMOTD(client);
  7660. }
  7661. /*
  7662. Function: Command_Pet()
  7663. Purpose : Handle Pet {Command} commands
  7664. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  7665. Dev :
  7666. Example : /pet preserve_master
  7667. */
  7668. void Commands::Command_Pet(Client* client, Seperator* sep)
  7669. {
  7670. PrintSep(sep, "COMMAND_PET");
  7671. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  7672. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7673. if (!sep || !sep->arg[0])
  7674. return; // should have sep->arg[0] filled
  7675. if (strcmp(sep->arg[0], "hide") == 0) {
  7676. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  7677. Entity* pet = client->GetPlayer()->GetDeityPet();
  7678. if (pet) {
  7679. if (pet->IsPrivateSpawn())
  7680. client->GetPlayer()->HideDeityPet(false);
  7681. else
  7682. client->GetPlayer()->HideDeityPet(true);
  7683. }
  7684. pet = client->GetPlayer()->GetCosmeticPet();
  7685. if (pet) {
  7686. if (pet->IsPrivateSpawn())
  7687. client->GetPlayer()->HideCosmeticPet(false);
  7688. else
  7689. client->GetPlayer()->HideCosmeticPet(true);
  7690. }
  7691. return;
  7692. }
  7693. // below is for all combat pets
  7694. if (!client->GetPlayer()->HasPet()) {
  7695. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  7696. return;
  7697. }
  7698. if (strcmp(sep->arg[0], "stay") == 0 || strcmp(sep->arg[0], "stayhere") == 0) {
  7699. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  7700. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  7701. client->GetPlayer()->SetCharSheetChanged(true);
  7702. if (client->GetPlayer()->GetPet())
  7703. client->GetPlayer()->GetPet()->following = false;
  7704. if (client->GetPlayer()->GetCharmedPet())
  7705. client->GetPlayer()->GetCharmedPet()->following = false;
  7706. }
  7707. else if (strcmp(sep->arg[0], "follow") == 0 || strcmp(sep->arg[0], "followme") == 0) {
  7708. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  7709. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  7710. client->GetPlayer()->SetCharSheetChanged(true);
  7711. }
  7712. else if (strcmp(sep->arg[0], "preserve_master") == 0 || strcmp(sep->arg[0], "guardme") == 0) {
  7713. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  7714. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  7715. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  7716. }
  7717. else {
  7718. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  7719. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  7720. }
  7721. client->GetPlayer()->SetCharSheetChanged(true);
  7722. }
  7723. else if (strcmp(sep->arg[0], "preserve_self") == 0 || strcmp(sep->arg[0], "guardhere") == 0) { // guardhere might be accurate, diff logic
  7724. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  7725. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  7726. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  7727. }
  7728. else {
  7729. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  7730. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  7731. }
  7732. client->GetPlayer()->SetCharSheetChanged(true);
  7733. }
  7734. else if (strcmp(sep->arg[0], "backoff") == 0) {
  7735. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  7736. if (client->GetPlayer()->GetPet())
  7737. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  7738. if (client->GetPlayer()->GetCharmedPet())
  7739. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  7740. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  7741. client->GetPlayer()->SetCharSheetChanged(true);
  7742. }
  7743. else if (strcmp(sep->arg[0], "attack") == 0) {
  7744. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  7745. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  7746. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  7747. if (client->GetPlayer()->GetPet())
  7748. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7749. if (client->GetPlayer()->GetCharmedPet())
  7750. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7751. }
  7752. else
  7753. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  7754. }
  7755. else
  7756. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  7757. }
  7758. else if (strcmp(sep->arg[0], "getlost") == 0) {
  7759. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  7760. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  7761. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  7762. }
  7763. else
  7764. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command %s.", sep->arg[0]);
  7765. }
  7766. /*
  7767. Function: Command_PetName()
  7768. Purpose : Pet your name (???)
  7769. Params :
  7770. Dev :
  7771. Example :
  7772. */
  7773. void Commands::Command_PetName(Client* client, Seperator* sep)
  7774. {
  7775. if (sep && sep->arg[0]) {
  7776. const char* pet_name = sep->argplus[0];
  7777. client->SetPetName(pet_name);
  7778. }
  7779. else {
  7780. client->GetPlayer()->GetInfoStruct()->set_pet_name("");
  7781. }
  7782. }
  7783. /*
  7784. Function: Command_NamePet()
  7785. Purpose : Name your pet
  7786. Params :
  7787. Dev :
  7788. Example :
  7789. */
  7790. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7791. {
  7792. PrintSep(sep, "COMMAND_NAME_PET");
  7793. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7794. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7795. }
  7796. /*
  7797. Function: Command_Rename()
  7798. Purpose : Renames existing pet
  7799. Params :
  7800. Dev :
  7801. Example :
  7802. */
  7803. void Commands::Command_Rename(Client* client, Seperator* sep)
  7804. {
  7805. PrintSep(sep, "COMMAND_RENAME");
  7806. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7807. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7808. }
  7809. /*
  7810. Function: Command_ConfirmRename()
  7811. Purpose : Confirms renaming your pet
  7812. Params :
  7813. Dev :
  7814. Example :
  7815. */
  7816. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7817. {
  7818. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7819. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7820. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7821. }
  7822. /*
  7823. Function: Command_PetOptions()
  7824. Purpose : Sets various pet options
  7825. Params :
  7826. Dev :
  7827. Example :
  7828. */
  7829. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7830. {
  7831. PrintSep(sep, "COMMAND_PETOPTIONS");
  7832. Player* player = client->GetPlayer();
  7833. Spawn* target = player->GetTarget();
  7834. if (!target)
  7835. return;
  7836. if (target == player->GetPet())
  7837. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7838. else if (target == player->GetCharmedPet())
  7839. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7840. else if (target == player->GetCosmeticPet())
  7841. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7842. else if (target == player->GetDeityPet())
  7843. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7844. }
  7845. /*
  7846. Function: Command_Random()
  7847. Purpose : Handles /random dice roll in-game
  7848. Params : 1-100
  7849. Dev : Scatman
  7850. Example : /randon 1 100
  7851. */
  7852. void Commands::Command_Random(Client* client, Seperator* sep)
  7853. {
  7854. char message[256] = {0};
  7855. if (sep)
  7856. {
  7857. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7858. 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])));
  7859. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7860. 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])));
  7861. else
  7862. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7863. }
  7864. else
  7865. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7866. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7867. }
  7868. /*
  7869. Function: Command_Randomize()
  7870. Purpose : Sets randomize (appearance) values for NPCs
  7871. Params : Attrib Name
  7872. Dev : Scatman
  7873. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7874. */
  7875. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7876. {
  7877. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7878. if (target)
  7879. {
  7880. if (target->IsNPC())
  7881. {
  7882. if (sep && sep->arg[0] && !sep->IsNumber(0))
  7883. {
  7884. const char* value = sep->arg[0];
  7885. if (strncasecmp(value, "show", strlen(value)) == 0)
  7886. {
  7887. client->DisplayRandomizeFeatures(target->GetRandomize());
  7888. }
  7889. else
  7890. {
  7891. if (sep->arg[1] && sep->IsNumber(1))
  7892. {
  7893. int8 option = atoi(sep->arg[1]);
  7894. if (option == 0 || option == 1)
  7895. {
  7896. int32 feature = 0;
  7897. char feature_text[32] = {0};
  7898. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7899. feature = RANDOMIZE_GENDER;
  7900. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7901. }
  7902. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7903. feature = RANDOMIZE_RACE;
  7904. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7905. }
  7906. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7907. feature = RANDOMIZE_MODEL_TYPE;
  7908. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7909. }
  7910. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7911. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7912. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7913. }
  7914. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7915. feature = RANDOMIZE_HAIR_TYPE;
  7916. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7917. }
  7918. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7919. feature = RANDOMIZE_WING_TYPE;
  7920. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7921. }
  7922. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7923. feature = RANDOMIZE_CHEEK_TYPE;
  7924. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7925. }
  7926. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7927. feature = RANDOMIZE_CHIN_TYPE;
  7928. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7929. }
  7930. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7931. feature = RANDOMIZE_EAR_TYPE;
  7932. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7933. }
  7934. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7935. feature = RANDOMIZE_EYE_BROW_TYPE;
  7936. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7937. }
  7938. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7939. feature = RANDOMIZE_EYE_TYPE;
  7940. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7941. }
  7942. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7943. feature = RANDOMIZE_LIP_TYPE;
  7944. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7945. }
  7946. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7947. feature = RANDOMIZE_NOSE_TYPE;
  7948. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7949. }
  7950. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7951. feature = RANDOMIZE_EYE_COLOR;
  7952. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7953. }
  7954. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7955. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7956. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7957. }
  7958. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7959. feature = RANDOMIZE_HAIR_COLOR1;
  7960. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7961. }
  7962. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7963. feature = RANDOMIZE_HAIR_COLOR2;
  7964. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7965. }
  7966. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7967. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7968. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7969. }
  7970. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7971. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7972. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7973. }
  7974. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7975. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7976. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7977. }
  7978. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7979. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7980. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7981. }
  7982. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7983. feature = RANDOMIZE_SKIN_COLOR;
  7984. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7985. }
  7986. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7987. feature = RANDOMIZE_WING_COLOR1;
  7988. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7989. }
  7990. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7991. feature = RANDOMIZE_WING_COLOR2;
  7992. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7993. }
  7994. else {
  7995. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7996. 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'.");
  7997. }
  7998. if (feature > 0) {
  7999. if (option == 1) {
  8000. if (target->GetRandomize() & feature)
  8001. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  8002. else {
  8003. target->AddRandomize(feature);
  8004. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  8005. database.UpdateRandomize(target->GetDatabaseID(), feature);
  8006. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  8007. }
  8008. }
  8009. else {
  8010. if (target->GetRandomize() & feature) {
  8011. target->AddRandomize(-feature);
  8012. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  8013. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  8014. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  8015. }
  8016. else
  8017. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  8018. }
  8019. }
  8020. }
  8021. else
  8022. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  8023. }
  8024. else
  8025. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  8026. }
  8027. }
  8028. else {
  8029. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  8030. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  8031. 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'.");
  8032. }
  8033. }
  8034. else
  8035. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  8036. }
  8037. else
  8038. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  8039. }
  8040. /*
  8041. Function: Command_ShowCloak()
  8042. Purpose : Character Settings combo box for Show Cloak
  8043. Params : true/false
  8044. Dev : John Adams
  8045. Example :
  8046. */
  8047. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  8048. {
  8049. Player* player = client->GetPlayer();
  8050. if (sep && sep->arg[0])
  8051. {
  8052. const char* value = sep->arg[0];
  8053. if (strncasecmp(value, "true", strlen(value)) == 0)
  8054. {
  8055. player->set_character_flag(CF_SHOW_CLOAK);
  8056. player->reset_character_flag(CF2_SHOW_RANGED);
  8057. }
  8058. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8059. player->reset_character_flag(CF_SHOW_CLOAK);
  8060. else
  8061. {
  8062. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8063. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8064. }
  8065. }
  8066. }
  8067. /*
  8068. Function: Command_ShowHelm()
  8069. Purpose : Character Settings combo box for Show Helm
  8070. Params : true/false
  8071. Dev : John Adams
  8072. Example :
  8073. */
  8074. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  8075. {
  8076. Player* player = client->GetPlayer();
  8077. if(client->GetVersion() <= 561) {
  8078. return; // not allowed/supported
  8079. }
  8080. if (sep && sep->arg[0])
  8081. {
  8082. PrintSep(sep, "Command_ShowHelm");
  8083. const char* value = sep->arg[0];
  8084. if (strncasecmp(value, "true", strlen(value)) == 0)
  8085. {
  8086. player->toggle_character_flag(CF_HIDE_HELM);
  8087. player->toggle_character_flag(CF_HIDE_HOOD);
  8088. }
  8089. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8090. player->toggle_character_flag(CF_HIDE_HELM);
  8091. else
  8092. {
  8093. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8094. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8095. }
  8096. }
  8097. }
  8098. /*
  8099. Function: Command_ShowHood()
  8100. Purpose : Character Settings combo box for Show Hood
  8101. Params : true/false
  8102. Dev : John Adams
  8103. Example :
  8104. */
  8105. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  8106. {
  8107. Player* player = client->GetPlayer();
  8108. if (sep && sep->arg[0])
  8109. {
  8110. PrintSep(sep, "Command_ShowHood");
  8111. const char* value = sep->arg[0];
  8112. if (strncasecmp(value, "true", strlen(value)) == 0)
  8113. {
  8114. player->toggle_character_flag(CF_HIDE_HOOD);
  8115. if(client->GetVersion() > 561) { // no hide helm support in DoF
  8116. player->toggle_character_flag(CF_HIDE_HELM);
  8117. }
  8118. }
  8119. else if (strncasecmp(value, "false", strlen(value)) == 0) {
  8120. player->toggle_character_flag(CF_HIDE_HOOD);
  8121. }
  8122. else
  8123. {
  8124. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8125. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8126. }
  8127. }
  8128. }
  8129. /*
  8130. Function: Command_ShowHoodHelm()
  8131. Purpose : Character Settings combo box for Show Helm or Hood
  8132. Params : true/false
  8133. Dev : John Adams
  8134. Example :
  8135. */
  8136. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  8137. {
  8138. Player* player = client->GetPlayer();
  8139. if(client->GetVersion() <= 561) {
  8140. return; // not allowed/supported
  8141. }
  8142. if (sep && sep->arg[0])
  8143. {
  8144. PrintSep(sep, "Command_ShowHoodHelm");
  8145. const char* value = sep->arg[0];
  8146. if (strncasecmp(value, "true", strlen(value)) == 0)
  8147. {
  8148. player->toggle_character_flag(CF_HIDE_HOOD);
  8149. player->toggle_character_flag(CF_HIDE_HELM);
  8150. }
  8151. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8152. {
  8153. // don't think we ever wind up in here...
  8154. player->toggle_character_flag(CF_HIDE_HOOD);
  8155. player->toggle_character_flag(CF_HIDE_HELM);
  8156. }
  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: Command_ShowRanged()
  8166. Purpose : Character Settings combo box for Show Ranged weapon
  8167. Params : true/false
  8168. Dev : John Adams
  8169. Example :
  8170. */
  8171. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  8172. {
  8173. Player* player = client->GetPlayer();
  8174. if (sep && sep->arg[0])
  8175. {
  8176. const char* value = sep->arg[0];
  8177. if (strncasecmp(value, "true", strlen(value)) == 0)
  8178. {
  8179. player->set_character_flag(CF2_SHOW_RANGED);
  8180. player->reset_character_flag(CF_SHOW_CLOAK);
  8181. }
  8182. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8183. player->reset_character_flag(CF2_SHOW_RANGED);
  8184. else
  8185. {
  8186. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8187. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8188. }
  8189. }
  8190. }
  8191. /*
  8192. Function:
  8193. Purpose :
  8194. Params :
  8195. Dev :
  8196. Example :
  8197. */
  8198. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  8199. {
  8200. Player* player = 0;
  8201. Client* to_client = 0;
  8202. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  8203. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  8204. switch(handler)
  8205. {
  8206. case COMMAND_SKILL:
  8207. {
  8208. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  8209. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  8210. break;
  8211. }
  8212. case COMMAND_SKILL_ADD:
  8213. {
  8214. if (sep && sep->arg[0])
  8215. {
  8216. const char* skill_name = sep->argplus[0];
  8217. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8218. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  8219. {
  8220. player = to_client->GetPlayer();
  8221. if (player)
  8222. {
  8223. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8224. {
  8225. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8226. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  8227. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  8228. }
  8229. else
  8230. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  8231. }
  8232. }
  8233. else if (skill) // add skill to yourself
  8234. {
  8235. player = client->GetPlayer();
  8236. if (player)
  8237. {
  8238. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8239. {
  8240. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8241. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  8242. }
  8243. else
  8244. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  8245. }
  8246. }
  8247. else
  8248. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8249. }
  8250. else
  8251. {
  8252. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  8253. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8254. }
  8255. break;
  8256. }
  8257. case COMMAND_SKILL_REMOVE:
  8258. {
  8259. if (sep && sep->arg[0])
  8260. {
  8261. const char* skill_name = sep->argplus[0];
  8262. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8263. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  8264. {
  8265. player = to_client->GetPlayer();
  8266. if (player)
  8267. {
  8268. if (player->GetSkills()->HasSkill(skill->skill_id))
  8269. {
  8270. player->RemoveSkillFromDB(skill, true);
  8271. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  8272. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  8273. }
  8274. else
  8275. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  8276. }
  8277. }
  8278. else if(skill) // remove skill from yourself
  8279. {
  8280. Player* player = client->GetPlayer();
  8281. if (player)
  8282. {
  8283. if (player->GetSkills()->HasSkill(skill->skill_id))
  8284. {
  8285. player->RemoveSkillFromDB(skill, true);
  8286. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  8287. }
  8288. else
  8289. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  8290. }
  8291. }
  8292. else
  8293. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8294. }
  8295. else
  8296. {
  8297. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  8298. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8299. }
  8300. break;
  8301. }
  8302. case COMMAND_SKILL_LIST:
  8303. {
  8304. if (sep && sep->arg[0])
  8305. {
  8306. const char* skill_name = sep->argplus[0];
  8307. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  8308. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  8309. map<int32, Skill*>::iterator itr;
  8310. if (skills && skills->size() > 0)
  8311. {
  8312. for (itr = skills->begin(); itr != skills->end(); itr++)
  8313. {
  8314. Skill* skill = itr->second;
  8315. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  8316. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  8317. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  8318. }
  8319. }
  8320. }
  8321. else
  8322. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  8323. break;
  8324. }
  8325. }
  8326. }
  8327. /*
  8328. Function: Command_SpawnTemplate()
  8329. Purpose : Create or Use defined Spawn Templates
  8330. Params : create, save, rempve, list
  8331. Dev : John Adams
  8332. Example : /spawn template create "Test"
  8333. */
  8334. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  8335. {
  8336. if (sep == NULL || sep->arg[0] == NULL)
  8337. {
  8338. 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.");
  8339. return;
  8340. }
  8341. // got params, continue
  8342. const char * template_cmd = sep->arg[0];
  8343. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  8344. {
  8345. if (!sep->IsSet(1))
  8346. {
  8347. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  8348. 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.");
  8349. return;
  8350. }
  8351. map<int32, string>* template_names = 0;
  8352. if (sep->IsNumber(1))
  8353. {
  8354. int32 location_id = 0;
  8355. location_id = atoi(sep->arg[1]);
  8356. template_names = database.GetSpawnTemplateListByID(location_id);
  8357. }
  8358. else
  8359. {
  8360. const char* name = 0;
  8361. name = sep->argplus[1];
  8362. template_names = database.GetSpawnTemplateListByName(name);
  8363. }
  8364. if(!template_names)
  8365. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  8366. else
  8367. {
  8368. map<int32, string>::iterator itr;
  8369. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  8370. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  8371. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  8372. safe_delete(template_names);
  8373. }
  8374. }
  8375. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  8376. {
  8377. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8378. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  8379. {
  8380. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  8381. {
  8382. // first, lookup to see if template name already exists
  8383. const char* name = 0;
  8384. name = sep->argplus[1];
  8385. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  8386. if(!template_names)
  8387. {
  8388. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  8389. if( new_template_id > 0 )
  8390. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  8391. else
  8392. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  8393. }
  8394. else
  8395. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  8396. }
  8397. else
  8398. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  8399. }
  8400. else
  8401. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  8402. }
  8403. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  8404. {
  8405. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  8406. {
  8407. int32 template_id = 0;
  8408. template_id = atoi(sep->arg[1]);
  8409. if (database.RemoveSpawnTemplate(template_id))
  8410. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  8411. else
  8412. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  8413. }
  8414. else
  8415. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  8416. }
  8417. // Renamed create to spawn
  8418. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  8419. {
  8420. if (sep && sep->arg[1][0])
  8421. {
  8422. int32 new_location = 0;
  8423. if (sep->IsNumber(1))
  8424. {
  8425. int32 template_id = 0;
  8426. template_id = atoi(sep->arg[1]);
  8427. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  8428. if( new_location > 0 )
  8429. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  8430. else
  8431. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  8432. }
  8433. else
  8434. {
  8435. const char* name = 0;
  8436. name = sep->argplus[1];
  8437. new_location = database.CreateSpawnFromTemplateByName(client, name);
  8438. if( new_location > 0 )
  8439. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  8440. else
  8441. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  8442. }
  8443. }
  8444. else
  8445. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  8446. }
  8447. else
  8448. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  8449. }
  8450. void Commands::Command_Speed(Client* client, Seperator* sep) {
  8451. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  8452. float new_speed = atof(sep->arg[0]);
  8453. if (new_speed > 0.0f)
  8454. {
  8455. client->GetPlayer()->SetSpeed(new_speed, true);
  8456. client->GetPlayer()->SetCharSheetChanged(true);
  8457. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  8458. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  8459. }
  8460. else
  8461. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  8462. }
  8463. else{
  8464. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  8465. }
  8466. }
  8467. /*
  8468. Function: Command_StationMarketPlace()
  8469. Purpose : just trying to eat the console spam for now
  8470. Params :
  8471. Dev : John
  8472. */
  8473. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  8474. {
  8475. PrintSep(sep, "COMMAND_SMP");
  8476. // This will reduce the spam from once every 10 sec to once every 30 sec,
  8477. // can't seem to reduce it any more get rid of it completely...
  8478. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  8479. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  8480. if (packet) {
  8481. packet->setDataByName("account_id", client->GetAccountID());
  8482. packet->setDataByName("character_id", client->GetCharacterID());
  8483. packet->setDataByName("unknown1", 1, 5);
  8484. packet->setDataByName("unknown1", 26, 6);
  8485. packet->setDataByName("unknown2", 0xFFFFFFFF);
  8486. packet->setDataByName("unknown3", 248, 1);
  8487. client->QueuePacket(packet->serialize());
  8488. }
  8489. safe_delete(packet);
  8490. }
  8491. }
  8492. /*
  8493. Function: Command_StopDrinking()
  8494. Purpose : Stops player from auto-consuming drink
  8495. Params :
  8496. Dev : Zcoretri
  8497. Example : /stopdrinking
  8498. */
  8499. void Commands::Command_StopDrinking(Client* client)
  8500. {
  8501. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  8502. client->GetPlayer()->SetActiveDrinkUniqueID(0);
  8503. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  8504. }
  8505. /*
  8506. Function: Command_StopEating()
  8507. Purpose : Stops player from auto-consuming food
  8508. Params :
  8509. Dev : Zcoretri
  8510. Example : /stopeating
  8511. */
  8512. void Commands::Command_StopEating(Client* client)
  8513. {
  8514. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  8515. client->GetPlayer()->SetActiveFoodUniqueID(0);
  8516. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  8517. }
  8518. /*
  8519. Function: Command_Title()
  8520. Purpose : Help for /title command
  8521. Params : n/a
  8522. Dev : Zcoretri
  8523. Example : /title
  8524. */
  8525. void Commands::Command_Title(Client* client)
  8526. {
  8527. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  8528. }
  8529. /*
  8530. Function: Command_TitleList()
  8531. Purpose : List available titles for player
  8532. Params : n/a
  8533. Dev : Zcoretri
  8534. Example : /title list
  8535. */
  8536. void Commands::Command_TitleList(Client* client)
  8537. {
  8538. // must call release read lock before leaving function on GetPlayerTitles
  8539. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  8540. vector<Title*>::iterator itr;
  8541. Title* title;
  8542. sint32 i = 0;
  8543. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  8544. for(itr = titles->begin(); itr != titles->end(); itr++)
  8545. {
  8546. title = *itr;
  8547. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  8548. i++;
  8549. }
  8550. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  8551. }
  8552. /*
  8553. Function: Command_TitleSetPrefix()
  8554. Purpose : Set Prefix title for player
  8555. Params : Title ID
  8556. Dev : Zcoretri
  8557. Example : /title setprefix 1
  8558. */
  8559. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  8560. {
  8561. if (sep && sep->arg[0] && sep->IsNumber(0))
  8562. {
  8563. sint32 index = atoul(sep->arg[0]);
  8564. if(index > -1)
  8565. {
  8566. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8567. if(!title)
  8568. {
  8569. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8570. return;
  8571. }
  8572. else if(!title->GetPrefix())
  8573. {
  8574. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  8575. return;
  8576. }
  8577. }
  8578. else // make sure client doesn't pass some bogus negative index
  8579. index = -1;
  8580. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  8581. client->SendTitleUpdate();
  8582. }
  8583. }
  8584. /*
  8585. Function: Command_TitleSetSuffix()
  8586. Purpose : Set Suffix title for player
  8587. Params : Title ID
  8588. Dev : Zcoretri
  8589. Example : /title setsuffix 1
  8590. */
  8591. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  8592. {
  8593. if (sep && sep->arg[0] && sep->IsNumber(0))
  8594. {
  8595. sint32 index = atoul(sep->arg[0]);
  8596. if(index > -1)
  8597. {
  8598. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8599. if(!title)
  8600. {
  8601. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8602. return;
  8603. }
  8604. else if(title->GetPrefix())
  8605. {
  8606. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  8607. return;
  8608. }
  8609. }
  8610. else // make sure client doesn't pass some bogus negative index
  8611. index = -1;
  8612. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  8613. client->SendTitleUpdate();
  8614. }
  8615. }
  8616. /*
  8617. Function: Command_TitleFix()
  8618. Purpose : Fix title for player (???)
  8619. Params :
  8620. Dev : Zcoretri
  8621. Example :
  8622. */
  8623. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  8624. {
  8625. PrintSep(sep, "COMMAND_TITLE_FIX");
  8626. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  8627. }
  8628. /*
  8629. Function: Command_Toggle_Anonymous()
  8630. Purpose : Toggles player Anonymous
  8631. Params :
  8632. Dev : paulgh
  8633. Example : /anon
  8634. */
  8635. void Commands::Command_Toggle_Anonymous(Client* client)
  8636. {
  8637. Player* player = client->GetPlayer();
  8638. player->toggle_character_flag(CF_ANONYMOUS);
  8639. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  8640. if (player->get_character_flag(CF_ANONYMOUS))
  8641. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  8642. else
  8643. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  8644. }
  8645. /*
  8646. Function: Command_Toggle_AutoConsume()
  8647. Purpose : Toggles player food/drink auto consume
  8648. Params : unknown
  8649. Dev : paulgh
  8650. Example : /set_auto_consume
  8651. */
  8652. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  8653. {
  8654. Player* player = client->GetPlayer();
  8655. if (sep && sep->arg[0])
  8656. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  8657. if (sep && sep->arg[0] && sep->IsNumber(0))
  8658. {
  8659. int8 slot = atoi(sep->arg[0]);
  8660. int8 flag = atoi(sep->arg[1]);
  8661. if (client->GetVersion() <= 373) {
  8662. slot += 4;
  8663. }
  8664. else if (client->GetVersion() <= 561) {
  8665. slot += 2;
  8666. }
  8667. if (slot == EQ2_FOOD_SLOT)
  8668. {
  8669. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  8670. player->SetCharSheetChanged(true);
  8671. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8672. if (flag == 1)
  8673. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  8674. else
  8675. {
  8676. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  8677. return;
  8678. }
  8679. }
  8680. else
  8681. {
  8682. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  8683. player->SetCharSheetChanged(true);
  8684. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8685. if (flag == 1)
  8686. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  8687. else
  8688. {
  8689. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  8690. return;
  8691. }
  8692. }
  8693. if(!client->CheckConsumptionAllowed(slot, false))
  8694. return;
  8695. Item* item = player->GetEquipmentList()->GetItem(slot);
  8696. if(item)
  8697. client->ConsumeFoodDrink(item, slot);
  8698. }
  8699. }
  8700. /*
  8701. Function: Command_Toggle_BonusXP()
  8702. Purpose : Toggles player Bonus XP
  8703. Params :
  8704. Dev : John Adams
  8705. Example : /disable_char_bonus_exp
  8706. */
  8707. void Commands::Command_Toggle_BonusXP(Client* client)
  8708. {
  8709. Player* player = client->GetPlayer();
  8710. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  8711. player->SetCharSheetChanged(true);
  8712. }
  8713. /*
  8714. Function: Command_Toggle_CombatXP()
  8715. Purpose : Toggles player Adventure XP
  8716. Params :
  8717. Dev : John Adams
  8718. Example : /disable_combat_exp
  8719. */
  8720. void Commands::Command_Toggle_CombatXP(Client* client)
  8721. {
  8722. Player* player = client->GetPlayer();
  8723. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  8724. player->SetCharSheetChanged(true);
  8725. }
  8726. /*
  8727. Function: Command_Toggle_GMHide()
  8728. Purpose : Toggles hiding player GM status
  8729. Params :
  8730. Dev : Scatman
  8731. Example : /gm_hide
  8732. */
  8733. void Commands::Command_Toggle_GMHide(Client* client)
  8734. {
  8735. Player* player = client->GetPlayer();
  8736. player->toggle_character_flag(CF_HIDE_STATUS);
  8737. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  8738. }
  8739. /*
  8740. Function: Command_Toggle_GMVanish()
  8741. Purpose : Toggles hiding GM players from /who searches
  8742. Params :
  8743. Dev : Scatman
  8744. Example : /gm_vanish
  8745. */
  8746. void Commands::Command_Toggle_GMVanish(Client* client)
  8747. {
  8748. Player* player = client->GetPlayer();
  8749. player->toggle_character_flag(CF_GM_HIDDEN);
  8750. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  8751. }
  8752. /*
  8753. Function: Command_Toggle_Illusions()
  8754. Purpose : Toggles player illusion form
  8755. Params : not sure sep is needed, testing
  8756. Dev : paulgh
  8757. Example : /hide_illusions
  8758. */
  8759. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  8760. {
  8761. if (sep && sep->arg[0])
  8762. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  8763. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  8764. }
  8765. /*
  8766. Function: Command_Toggle_LFG()
  8767. Purpose : Toggles player LFG Flag
  8768. Params :
  8769. Dev : paulgh
  8770. Example : /lfg
  8771. */
  8772. void Commands::Command_Toggle_LFG(Client* client)
  8773. {
  8774. Player* player = client->GetPlayer();
  8775. player->toggle_character_flag(CF_LFG);
  8776. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  8777. if (player->get_character_flag(CF_LFG))
  8778. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  8779. else
  8780. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  8781. }
  8782. /*
  8783. Function: Command_Toggle_LFW()
  8784. Purpose : Toggles player LFW Flag
  8785. Params :
  8786. Dev : paulgh
  8787. Example : /lfw
  8788. */
  8789. void Commands::Command_Toggle_LFW(Client* client)
  8790. {
  8791. Player* player = client->GetPlayer();
  8792. player->toggle_character_flag(CF_LFW);
  8793. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8794. if (player->get_character_flag(CF_LFW))
  8795. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8796. else
  8797. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8798. }
  8799. /*
  8800. Function: Command_Toggle_QuestXP()
  8801. Purpose : Toggles player Quest XP
  8802. Params :
  8803. Dev : John Adams
  8804. Example : /disable_quest_exp
  8805. */
  8806. void Commands::Command_Toggle_QuestXP(Client* client)
  8807. {
  8808. Player* player = client->GetPlayer();
  8809. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8810. player->SetCharSheetChanged(true);
  8811. }
  8812. /*
  8813. Function: Command_Toggle_Roleplaying()
  8814. Purpose : Toggles player Roleplaying flag
  8815. Params :
  8816. Dev : paulgh
  8817. Example : /role
  8818. */
  8819. void Commands::Command_Toggle_Roleplaying(Client* client)
  8820. {
  8821. Player* player = client->GetPlayer();
  8822. player->toggle_character_flag(CF_ROLEPLAYING);
  8823. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8824. if (player->get_character_flag(CF_ROLEPLAYING))
  8825. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8826. else
  8827. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8828. }
  8829. void Commands::Command_Toggle_Duels(Client* client)
  8830. {
  8831. Player* player = client->GetPlayer();
  8832. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8833. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8834. }
  8835. void Commands::Command_Toggle_Trades(Client* client)
  8836. {
  8837. Player* player = client->GetPlayer();
  8838. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8839. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8840. }
  8841. void Commands::Command_Toggle_Guilds(Client* client)
  8842. {
  8843. Player* player = client->GetPlayer();
  8844. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8845. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8846. }
  8847. void Commands::Command_Toggle_Groups(Client* client)
  8848. {
  8849. Player* player = client->GetPlayer();
  8850. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8851. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8852. }
  8853. void Commands::Command_Toggle_Raids(Client* client)
  8854. {
  8855. Player* player = client->GetPlayer();
  8856. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8857. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8858. }
  8859. void Commands::Command_Toggle_LON(Client* client)
  8860. {
  8861. Player* player = client->GetPlayer();
  8862. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8863. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8864. }
  8865. void Commands::Command_Toggle_VoiceChat(Client* client)
  8866. {
  8867. Player* player = client->GetPlayer();
  8868. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8869. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8870. }
  8871. /*
  8872. Function: Command_TradeStart()
  8873. Purpose : Starts item/coin trade between players
  8874. Params :
  8875. Dev :
  8876. Example :
  8877. */
  8878. #include "../Trade.h"
  8879. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  8880. {
  8881. PrintSep(sep, "COMMAND_START_TRADE");
  8882. Entity* trader = client->GetPlayer();
  8883. Entity* trader2 = 0;
  8884. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8885. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  8886. if (spawn) {
  8887. if (spawn->IsEntity())
  8888. trader2 = (Entity*)spawn;
  8889. }
  8890. }
  8891. else if (client->GetPlayer()->GetTarget()) {
  8892. if (client->GetPlayer()->GetTarget()->IsEntity())
  8893. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  8894. }
  8895. // can only trade with player or bots
  8896. if (trader && trader2) {
  8897. if (trader == trader2) {
  8898. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  8899. }
  8900. else if (trader2->IsPlayer() || trader2->IsBot()) {
  8901. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  8902. if (trader->trade)
  8903. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  8904. else if (trader2->trade)
  8905. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  8906. else {
  8907. Trade* trade = new Trade(trader, trader2);
  8908. trader->trade = trade;
  8909. trader2->trade = trade;
  8910. }
  8911. }
  8912. else {
  8913. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8914. }
  8915. }
  8916. else
  8917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8918. }
  8919. /*
  8920. Function: Command_Track()
  8921. Purpose : Starts/Stops Tracking for a player
  8922. Params :
  8923. Dev : Scatman
  8924. Example : /track
  8925. */
  8926. void Commands::Command_Track(Client* client)
  8927. {
  8928. if (!client->GetPlayer()->GetIsTracking())
  8929. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8930. else
  8931. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8932. }
  8933. /*
  8934. Function: Command_TradeAccept()
  8935. Purpose : Accepts item/coin trade between players
  8936. Params :
  8937. Dev :
  8938. Example :
  8939. */
  8940. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8941. {
  8942. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8943. Trade* trade = client->GetPlayer()->trade;
  8944. if (trade) {
  8945. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8946. if (trade_complete)
  8947. safe_delete(trade);
  8948. }
  8949. else
  8950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8951. }
  8952. /*
  8953. Function: Command_TradeReject()
  8954. Purpose : Rejects item/coin trade between players
  8955. Params :
  8956. Dev :
  8957. Example :
  8958. */
  8959. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8960. {
  8961. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8962. Command_TradeCancel(client, sep);
  8963. }
  8964. /*
  8965. Function: Command_TradeCancel()
  8966. Purpose : Cancels item/coin trade between players
  8967. Params :
  8968. Dev :
  8969. Example :
  8970. */
  8971. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8972. {
  8973. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8974. Trade* trade = client->GetPlayer()->trade;
  8975. if (trade) {
  8976. trade->CancelTrade(client->GetPlayer());
  8977. safe_delete(trade);
  8978. }
  8979. else
  8980. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8981. }
  8982. /*
  8983. Function: Command_TradeSetCoin()
  8984. Purpose : Sets coin trade between players
  8985. Params :
  8986. Dev :
  8987. Example :
  8988. */
  8989. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8990. {
  8991. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8992. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8993. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8994. }
  8995. /*
  8996. Function: Command_TradeAddCoin()
  8997. Purpose : Adds coin to trade between players
  8998. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8999. Dev :
  9000. Example :
  9001. */
  9002. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  9003. {
  9004. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  9005. Trade* trade = client->GetPlayer()->trade;
  9006. if (trade) {
  9007. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9008. int32 amount = atoi(sep->arg[0]);
  9009. int64 val = 0;
  9010. switch (handler) {
  9011. case COMMAND_ADD_TRADE_COPPER:
  9012. {
  9013. val = amount;
  9014. trade->AddCoinToTrade(client->GetPlayer(), val);
  9015. break;
  9016. }
  9017. case COMMAND_ADD_TRADE_SILVER:
  9018. {
  9019. val = amount * 100;
  9020. trade->AddCoinToTrade(client->GetPlayer(), val);
  9021. break;
  9022. }
  9023. case COMMAND_ADD_TRADE_GOLD:
  9024. {
  9025. val = amount * 10000;
  9026. trade->AddCoinToTrade(client->GetPlayer(), val);
  9027. break;
  9028. }
  9029. case COMMAND_ADD_TRADE_PLAT:
  9030. {
  9031. val = amount * 1000000;
  9032. trade->AddCoinToTrade(client->GetPlayer(), val);
  9033. break;
  9034. }
  9035. default:
  9036. {
  9037. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  9038. break;
  9039. }
  9040. }
  9041. }
  9042. else
  9043. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  9044. }
  9045. else
  9046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9047. }
  9048. /*
  9049. Function: Command_TradeRemoveCoin()
  9050. Purpose : Removes coin from trade between players
  9051. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  9052. Dev :
  9053. Example :
  9054. */
  9055. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  9056. {
  9057. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  9058. Trade* trade = client->GetPlayer()->trade;
  9059. if (trade) {
  9060. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9061. int32 amount = atoi(sep->arg[0]);
  9062. int64 val = 0;
  9063. switch (handler) {
  9064. case COMMAND_REMOVE_TRADE_COPPER:
  9065. {
  9066. val = amount;
  9067. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9068. break;
  9069. }
  9070. case COMMAND_REMOVE_TRADE_SILVER:
  9071. {
  9072. val = amount * 100;
  9073. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9074. break;
  9075. }
  9076. case COMMAND_REMOVE_TRADE_GOLD:
  9077. {
  9078. val = amount * 10000;
  9079. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9080. break;
  9081. }
  9082. case COMMAND_REMOVE_TRADE_PLAT:
  9083. {
  9084. val = amount * 1000000;
  9085. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9086. break;
  9087. }
  9088. default:
  9089. {
  9090. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  9091. break;
  9092. }
  9093. }
  9094. }
  9095. else
  9096. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  9097. }
  9098. else
  9099. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9100. }
  9101. /*
  9102. Function: Command_TradeAddItem()
  9103. Purpose : Adds item to trade between players
  9104. Params :
  9105. Dev :
  9106. Example :
  9107. */
  9108. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  9109. {
  9110. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  9111. /*
  9112. arg[0] = item index
  9113. arg[1] = slot
  9114. arg[2] = quantity
  9115. */
  9116. if (!client->GetPlayer()->trade) {
  9117. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  9118. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9119. return;
  9120. }
  9121. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  9122. Item* item = 0;
  9123. int32 index = atoi(sep->arg[0]);
  9124. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  9125. if (item) {
  9126. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  9127. if (result == 1)
  9128. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  9129. else if (result == 2)
  9130. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  9131. else if (result == 3)
  9132. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  9133. else if (result == 254)
  9134. client->Message(CHANNEL_COLOR_YELLOW, "You are trading with an older client with a %u trade slot restriction...", client->GetPlayer()->trade->MaxSlots());
  9135. else if (result == 255)
  9136. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  9137. }
  9138. else {
  9139. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  9140. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  9141. }
  9142. }
  9143. else
  9144. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9145. }
  9146. /*
  9147. Function: Command_TradeRemoveItem()
  9148. Purpose : Removes item from trade between players
  9149. Params :
  9150. Dev :
  9151. Example :
  9152. */
  9153. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  9154. {
  9155. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  9156. /*
  9157. arg[0] = trade window slot
  9158. */
  9159. Trade* trade = client->GetPlayer()->trade;
  9160. if (trade) {
  9161. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9162. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  9163. }
  9164. else
  9165. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9166. }
  9167. else
  9168. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9169. }
  9170. void Commands::Command_TryOn(Client* client, Seperator* sep)
  9171. {
  9172. Item *item = 0;
  9173. sint32 crc;
  9174. if (sep) {
  9175. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  9176. if (client->GetVersion() < 1096) {
  9177. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  9178. {
  9179. item = master_item_list.GetItem(atoul(sep->arg[1]));
  9180. crc = atol(sep->arg[2]);
  9181. }
  9182. }
  9183. else {
  9184. // From the broker and links in chat
  9185. if (strcmp(sep->arg[0], "crc") == 0) {
  9186. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  9187. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9188. crc = atol(sep->arg[3]);
  9189. }
  9190. }
  9191. // From inventory
  9192. if (strcmp(sep->arg[0], "dbid") == 0) {
  9193. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  9194. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9195. crc = atol(sep->arg[4]);
  9196. }
  9197. }
  9198. }
  9199. if (item)
  9200. client->ShowDressingRoom(item, crc);
  9201. }
  9202. }
  9203. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  9204. const char *channel_name, *password = NULL;
  9205. if (sep == NULL || !sep->IsSet(0)) {
  9206. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  9207. return;
  9208. }
  9209. channel_name = sep->arg[0];
  9210. if (sep->IsSet(1))
  9211. password = sep->arg[1];
  9212. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  9213. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  9214. return;
  9215. }
  9216. if (chat.IsInChannel(client, channel_name)) {
  9217. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  9218. return;
  9219. }
  9220. if (chat.HasPassword(channel_name)) {
  9221. if (password == NULL) {
  9222. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  9223. return;
  9224. }
  9225. if (!chat.PasswordMatches(channel_name, password)) {
  9226. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  9227. return;
  9228. }
  9229. }
  9230. if (!chat.JoinChannel(client, channel_name))
  9231. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  9232. }
  9233. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  9234. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  9235. Command_JoinChannel(client, sep);
  9236. }
  9237. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  9238. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  9239. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  9240. PrintSep(sep, "tellchannel");
  9241. return;
  9242. }
  9243. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  9244. }
  9245. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  9246. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9247. if (sep->IsSet(0)) {
  9248. if (atoi(sep->arg[0]) == 1) {
  9249. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  9250. if (packet2) {
  9251. packet2->setDataByName("spell_type", 2);
  9252. packet2->setDataByName("spell_id", 8308);
  9253. packet2->setDataByName("spell_name", "Sprint");
  9254. packet2->setDataByName("add_silently", 0);
  9255. packet2->setDataByName("tier", 1);
  9256. packet2->setDataByName("blah1", 1);
  9257. packet2->setDataByName("blah2", 1);
  9258. EQ2Packet* outapp = packet2->serialize();
  9259. DumpPacket(outapp);
  9260. client->QueuePacket(outapp);
  9261. safe_delete(packet2);
  9262. }
  9263. }
  9264. else if (atoi(sep->arg[0]) == 2) {
  9265. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  9266. if (packet2) {
  9267. packet2->setDataByName("guild_name", "Test");
  9268. packet2->setDataByName("guild_motd", "Test MOTD");
  9269. packet2->setDataByName("guild_id", 1234);
  9270. packet2->setDataByName("guild_level", 1);
  9271. packet2->setDataByName("unknown", 2);
  9272. packet2->setDataByName("unknown2", 3);
  9273. packet2->setDataByName("exp_current", 1);
  9274. packet2->setDataByName("exp_to_next_level", 4);
  9275. EQ2Packet* outapp = packet2->serialize();
  9276. DumpPacket(outapp);
  9277. client->QueuePacket(outapp);
  9278. safe_delete(packet2);
  9279. }
  9280. }
  9281. else if (atoi(sep->arg[0]) == 3) {
  9282. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  9283. if (packet2) {
  9284. packet2->setDataByName("guild_id", 1234);
  9285. packet2->setDataByName("character_id", 1);
  9286. packet2->setDataByName("account_id", 2);
  9287. packet2->setDataByName("guild_level", 1);
  9288. packet2->setDataByName("name", "Test");
  9289. packet2->setDataByName("unknown2", 0);
  9290. packet2->setDataByName("unknown3", 1);
  9291. packet2->setDataByName("adventure_class", 6);
  9292. packet2->setDataByName("adventure_level", 7);
  9293. packet2->setDataByName("tradeskill_class", 4);
  9294. packet2->setDataByName("tradeskill_level", 5);
  9295. packet2->setDataByName("rank", 0);
  9296. packet2->setDataByName("member_flags", 2);
  9297. packet2->setDataByName("join_date", 1591112273);
  9298. packet2->setDataByName("guild_status", 2);
  9299. packet2->setDataByName("last_login", 1591132273);
  9300. packet2->setDataByName("recruiter_id", 1);
  9301. packet2->setDataByName("points", 2345);
  9302. packet2->setDataByName("note", "note");
  9303. packet2->setMediumStringByName("officer_note", "O note");
  9304. packet2->setMediumStringByName("zone", "Blah");
  9305. EQ2Packet* outapp = packet2->serialize();
  9306. DumpPacket(outapp);
  9307. client->QueuePacket(outapp);
  9308. safe_delete(packet2);
  9309. }
  9310. }
  9311. else if (atoi(sep->arg[0]) == 5) {
  9312. int16 offset = atoi(sep->arg[1]);
  9313. int32 value1 = atol(sep->arg[2]);
  9314. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  9315. client->QueuePacket(outapp);
  9316. }
  9317. else if (atoi(sep->arg[0]) == 6) {
  9318. Spawn* spawn = client->GetPlayer()->GetTarget();
  9319. if (!spawn)
  9320. spawn = client->GetPlayer();
  9321. else if (spawn->IsEntity())
  9322. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  9323. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  9324. }
  9325. else if (atoi(sep->arg[0]) == 7) {
  9326. int32 id = 0;
  9327. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  9328. if (spawn) {
  9329. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9330. spawn->SetY(client->GetPlayer()->GetY(), false);
  9331. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9332. float heading = client->GetPlayer()->GetHeading() + 180;
  9333. if (heading > 360)
  9334. heading -= 360;
  9335. spawn->SetLevel(5);
  9336. spawn->SetAdventureClass(4);
  9337. spawn->SetHeading(heading, false);
  9338. spawn->SetSpawnOrigX(spawn->GetX());
  9339. spawn->SetSpawnOrigY(spawn->GetY());
  9340. spawn->SetSpawnOrigZ(spawn->GetZ());
  9341. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9342. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9343. spawn->appearance.targetable = 1;
  9344. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9345. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9346. spawn->SetHP(spawn->GetTotalHP());
  9347. }
  9348. if (spawn->GetTotalPower() == 0) {
  9349. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9350. spawn->SetPower(spawn->GetTotalPower());
  9351. }
  9352. int16 offset = atoi(sep->arg[1]);
  9353. int32 value1 = atol(sep->arg[2]);
  9354. sprintf(spawn->appearance.name, "Offset %i", offset);
  9355. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  9356. DumpPacket(ret);
  9357. client->QueuePacket(ret);
  9358. }
  9359. }
  9360. else if (atoi(sep->arg[0]) == 8) {
  9361. int32 id = atoi(sep->arg[1]);
  9362. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  9363. if (spawn) {
  9364. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9365. spawn->SetY(client->GetPlayer()->GetY(), false);
  9366. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9367. float heading = client->GetPlayer()->GetHeading() + 180;
  9368. if (heading > 360)
  9369. heading -= 360;
  9370. spawn->SetLevel(5);
  9371. spawn->SetAdventureClass(4);
  9372. spawn->SetHeading(heading, false);
  9373. spawn->SetSpawnOrigX(spawn->GetX());
  9374. spawn->SetSpawnOrigY(spawn->GetY());
  9375. spawn->SetSpawnOrigZ(spawn->GetZ());
  9376. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9377. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9378. spawn->appearance.targetable = 1;
  9379. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9380. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9381. spawn->SetHP(spawn->GetTotalHP());
  9382. }
  9383. if (spawn->GetTotalPower() == 0) {
  9384. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9385. spawn->SetPower(spawn->GetTotalPower());
  9386. }
  9387. int16 offset = atoi(sep->arg[2]);
  9388. int16 offset2 = atoi(sep->arg[3]);
  9389. int32 value1 = atol(sep->arg[4]);
  9390. int16 offset3 = 0;
  9391. int16 offset4 = 0;
  9392. int32 value2 = 0;
  9393. if (sep->IsSet(7)) {
  9394. offset3 = atoi(sep->arg[5]);
  9395. offset4 = atoi(sep->arg[6]);
  9396. value2 = atol(sep->arg[7]);
  9397. }
  9398. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  9399. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  9400. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  9401. DumpPacket(ret);
  9402. client->QueuePacket(ret);
  9403. }
  9404. }
  9405. else if (atoi(sep->arg[0]) == 9) {
  9406. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  9407. if (packet2) {
  9408. packet2->setArrayLengthByName("location_count", 1);
  9409. packet2->setArrayDataByName("location_ida", 1234);
  9410. packet2->setArrayDataByName("unknown2a", 3);
  9411. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  9412. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  9413. packet2->setArrayDataByName("distance", 134);
  9414. EQ2Packet* app = packet2->serialize();
  9415. if (sep->IsSet(2)) {
  9416. int8 offset = atoi(sep->arg[1]);
  9417. uchar* ptr2 = app->pBuffer;
  9418. ptr2 += offset;
  9419. if (sep->IsNumber(2)) {
  9420. int32 value1 = atol(sep->arg[2]);
  9421. if (value1 > 0xFFFF)
  9422. memcpy(ptr2, (uchar*)&value1, 4);
  9423. else if (value1 > 0xFF)
  9424. memcpy(ptr2, (uchar*)&value1, 2);
  9425. else
  9426. memcpy(ptr2, (uchar*)&value1, 1);
  9427. }
  9428. else {
  9429. int8 len = strlen(sep->arg[2]);
  9430. memcpy(ptr2, (uchar*)&len, 1);
  9431. ptr2 += 1;
  9432. memcpy(ptr2, sep->arg[2], len);
  9433. }
  9434. }
  9435. DumpPacket(app);
  9436. client->QueuePacket(app);
  9437. safe_delete(packet2);
  9438. }
  9439. }
  9440. else if (atoi(sep->arg[0]) == 10) {
  9441. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  9442. if (packet2) {
  9443. packet2->setArrayLengthByName("num_quests", 1);
  9444. packet2->setArrayDataByName("active", 1);
  9445. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  9446. packet2->setArrayDataByName("quest_type", "Hallmark");
  9447. packet2->setArrayDataByName("quest_zone", "Hallmark");
  9448. packet2->setArrayDataByName("journal_updated", 1);
  9449. packet2->setArrayDataByName("quest_id", 524);
  9450. packet2->setArrayDataByName("day", 19);
  9451. packet2->setArrayDataByName("month", 6);
  9452. packet2->setArrayDataByName("year", 20);
  9453. packet2->setArrayDataByName("level", 2);
  9454. packet2->setArrayDataByName("encounter_level", 4);
  9455. packet2->setArrayDataByName("difficulty", 3);
  9456. packet2->setArrayDataByName("visible", 1);
  9457. packet2->setDataByName("visible_quest_id", 524);
  9458. packet2->setDataByName("player_crc", 2900677088);
  9459. packet2->setDataByName("player_name", "LethalEncounter");
  9460. EQ2Packet* app = packet2->serialize();
  9461. if (sep->IsSet(2)) {
  9462. int8 offset = atoi(sep->arg[1]);
  9463. uchar* ptr2 = app->pBuffer;
  9464. ptr2 += offset;
  9465. if (sep->IsNumber(2)) {
  9466. int32 value1 = atol(sep->arg[2]);
  9467. if (value1 > 0xFFFF)
  9468. memcpy(ptr2, (uchar*)&value1, 4);
  9469. else if (value1 > 0xFF)
  9470. memcpy(ptr2, (uchar*)&value1, 2);
  9471. else
  9472. memcpy(ptr2, (uchar*)&value1, 1);
  9473. }
  9474. else {
  9475. int8 len = strlen(sep->arg[2]);
  9476. memcpy(ptr2, (uchar*)&len, 1);
  9477. ptr2 += 1;
  9478. memcpy(ptr2, sep->arg[2], len);
  9479. }
  9480. }
  9481. DumpPacket(app);
  9482. client->QueuePacket(app);
  9483. safe_delete(packet2);
  9484. }
  9485. }
  9486. else if (atoi(sep->arg[0]) == 11) {
  9487. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9488. if (packet2) {
  9489. packet2->setDataByName("quest_id", 524);
  9490. packet2->setDataByName("player_crc", 2900677088);
  9491. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  9492. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  9493. packet2->setDataByName("type", "Hallmark");
  9494. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9495. packet2->setDataByName("day", 19);
  9496. packet2->setDataByName("month", 6);
  9497. packet2->setDataByName("year", 20);
  9498. packet2->setDataByName("level", 1);
  9499. packet2->setDataByName("encounter_level", 1);
  9500. packet2->setDataByName("difficulty", 1);
  9501. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9502. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9503. //packet2->setDataByName("timer_duration", 300);
  9504. //packet2->setDataByName("timer_running", 1);
  9505. packet2->setArrayLengthByName("task_groups_completed", 9);
  9506. packet2->setArrayLengthByName("num_task_groups", 10);
  9507. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  9508. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  9509. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  9510. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  9511. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  9512. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  9513. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  9514. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  9515. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  9516. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  9517. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  9518. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9519. packet2->setSubArrayLengthByName("num_updates", 1);
  9520. packet2->setSubArrayDataByName("update_currentval", 0);
  9521. packet2->setSubArrayDataByName("update_maxval", 1);
  9522. packet2->setSubArrayDataByName("icon", 11);
  9523. */
  9524. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9525. packet2->setDataByName("journal_updated", 1);
  9526. packet2->setDataByName("bullets", 1);
  9527. EQ2Packet* app = packet2->serialize();
  9528. if (sep->IsSet(2)) {
  9529. int16 offset = atoi(sep->arg[1]);
  9530. uchar* ptr2 = app->pBuffer;
  9531. ptr2 += offset;
  9532. if (sep->IsNumber(2)) {
  9533. int32 value1 = atol(sep->arg[2]);
  9534. if (value1 > 0xFFFF)
  9535. memcpy(ptr2, (uchar*)&value1, 4);
  9536. else if (value1 > 0xFF)
  9537. memcpy(ptr2, (uchar*)&value1, 2);
  9538. else
  9539. memcpy(ptr2, (uchar*)&value1, 1);
  9540. }
  9541. else {
  9542. int16 len = strlen(sep->arg[2]);
  9543. memcpy(ptr2, (uchar*)&len, 2);
  9544. ptr2 += 2;
  9545. memcpy(ptr2, sep->arg[2], len);
  9546. }
  9547. }
  9548. DumpPacket(app);
  9549. client->QueuePacket(app);
  9550. safe_delete(packet2);
  9551. }
  9552. }
  9553. else if (atoi(sep->arg[0]) == 12) {
  9554. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9555. if (packet2) {
  9556. packet2->setDataByName("quest_id", 5725);
  9557. packet2->setDataByName("player_crc", 2900677088);
  9558. packet2->setDataByName("name", "Archetype Selection");
  9559. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  9560. packet2->setDataByName("type", "Hallmark");
  9561. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9562. packet2->setDataByName("day", 19);
  9563. packet2->setDataByName("month", 6);
  9564. packet2->setDataByName("year", 20);
  9565. packet2->setDataByName("level", 2);
  9566. packet2->setDataByName("encounter_level", 4);
  9567. packet2->setDataByName("difficulty", 3);
  9568. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9569. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9570. packet2->setDataByName("timer_duration", 300);
  9571. packet2->setDataByName("timer_running", 1);
  9572. packet2->setArrayLengthByName("task_groups_completed", 0);
  9573. packet2->setArrayLengthByName("num_task_groups", 1);
  9574. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  9575. packet2->setSubArrayLengthByName("num_tasks", 1);
  9576. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9577. packet2->setSubArrayLengthByName("num_updates", 1);
  9578. packet2->setSubArrayDataByName("update_currentval", 0);
  9579. packet2->setSubArrayDataByName("update_maxval", 1);
  9580. packet2->setSubArrayDataByName("icon", 11);
  9581. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9582. packet2->setDataByName("journal_updated", 1);
  9583. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9584. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9585. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  9586. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9587. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9588. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9589. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9590. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  9591. Item* item = master_item_list.GetItem(152755);
  9592. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9593. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  9594. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  9595. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  9596. packet2->setSubstructDataByName("item", "icon", 0xe7);
  9597. packet2->setSubstructDataByName("item", "tier", 4);
  9598. packet2->setSubstructDataByName("item", "flags", 0x60);
  9599. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  9600. packet2->setSubstructDataByName("item", "stat_type", 1);
  9601. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  9602. packet2->setSubstructDataByName("item", "value", 3);
  9603. packet2->setSubstructDataByName("item", "condition", 100);
  9604. packet2->setSubstructDataByName("item", "weight", 1);
  9605. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  9606. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  9607. packet2->setSubstructDataByName("item", "skill_min", 1);
  9608. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  9609. packet2->setSubstructDataByName("item", "adventure_class", 1);
  9610. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  9611. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  9612. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  9613. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  9614. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  9615. packet2->setSubstructDataByName("item", "level", 0x1e);
  9616. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  9617. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  9618. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  9619. //packet2->PrintPacket();
  9620. EQ2Packet* app = packet2->serialize();
  9621. if (sep->IsSet(2)) {
  9622. int16 offset = atoi(sep->arg[1]);
  9623. uchar* ptr2 = app->pBuffer;
  9624. ptr2 += offset;
  9625. if (sep->IsNumber(2)) {
  9626. int32 value1 = atol(sep->arg[2]);
  9627. if (value1 > 0xFFFF)
  9628. memcpy(ptr2, (uchar*)&value1, 4);
  9629. else if (value1 > 0xFF)
  9630. memcpy(ptr2, (uchar*)&value1, 2);
  9631. else
  9632. memcpy(ptr2, (uchar*)&value1, 1);
  9633. }
  9634. else {
  9635. int16 len = strlen(sep->arg[2]);
  9636. memcpy(ptr2, (uchar*)&len, 2);
  9637. ptr2 += 2;
  9638. memcpy(ptr2, sep->arg[2], len);
  9639. }
  9640. }
  9641. DumpPacket(app);
  9642. client->QueuePacket(app);
  9643. safe_delete(packet2);
  9644. }
  9645. }
  9646. else if (atoi(sep->arg[0]) == 13) {
  9647. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  9648. if (packet2 && sep->IsSet(7)) {
  9649. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  9650. char blah[128];
  9651. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  9652. packet2->setDataByName("text", blah);
  9653. packet2->setDataByName("message_type", sep->arg[3]);
  9654. packet2->setDataByName("size", atof(sep->arg[4]));
  9655. packet2->setDataByName("red", atoi(sep->arg[5]));
  9656. packet2->setDataByName("green", atoi(sep->arg[6]));
  9657. packet2->setDataByName("blue", atoi(sep->arg[7]));
  9658. EQ2Packet* app = packet2->serialize();
  9659. DumpPacket(app);
  9660. client->QueuePacket(app);
  9661. safe_delete(packet2);
  9662. }
  9663. }
  9664. else if (atoi(sep->arg[0]) == 14) {
  9665. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  9666. if (packet2 && sep->IsSet(3)) {
  9667. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  9668. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  9669. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  9670. 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.");
  9671. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  9672. packet2->setArrayLengthByName("num_goals", 1);
  9673. //packet2->setArrayDataByName("goal_text", )
  9674. packet2->setSubArrayLengthByName("num_tasks", 1);
  9675. packet2->setSubArrayDataByName("task_text", "continue");
  9676. packet2->setDataByName("complete_sound", "click");
  9677. packet2->setDataByName("signal", "introduction");
  9678. packet2->setDataByName("voice_key1", 0xcda65173);
  9679. packet2->setDataByName("voice_key2", 0x984bfc6d);
  9680. EQ2Packet* app = packet2->serialize();
  9681. DumpPacket(app);
  9682. client->QueuePacket(app);
  9683. safe_delete(packet2);
  9684. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  9685. packet2->setDataByName("window", "MainHUD.StartMenu");
  9686. packet2->setDataByName("show", 1);
  9687. app = packet2->serialize();
  9688. DumpPacket(app);
  9689. client->QueuePacket(app);
  9690. safe_delete(packet2);
  9691. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  9692. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  9693. packet2->setDataByName("flash_seconds", 10);
  9694. app = packet2->serialize();
  9695. DumpPacket(app);
  9696. client->QueuePacket(app);
  9697. safe_delete(packet2);
  9698. }
  9699. }
  9700. else if (atoi(sep->arg[0]) == 15) {
  9701. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9702. if (packet2) {
  9703. packet2->setArrayLengthByName("loot_count", 1);
  9704. packet2->setArrayDataByName("name", "Test");
  9705. packet2->setArrayDataByName("item_id", 1234);
  9706. packet2->setArrayDataByName("count", 1);
  9707. packet2->setArrayDataByName("icon", 258);
  9708. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  9709. Spawn* spawn = client->GetPlayer()->GetTarget();
  9710. if (spawn)
  9711. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9712. packet2->setDataByName("display", 1);
  9713. packet2->setDataByName("loot_type", 1);
  9714. packet2->setDataByName("lotto_timeout", 60);
  9715. EQ2Packet* app = packet2->serialize();
  9716. DumpPacket(app);
  9717. client->QueuePacket(app);
  9718. safe_delete(packet2);
  9719. }
  9720. }
  9721. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  9722. char blah[32];
  9723. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  9724. client->SimpleMessage(atoi(sep->arg[1]), blah);
  9725. }
  9726. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  9727. if (sep->IsSet(2)) {
  9728. int16 offset = atoi(sep->arg[1]);
  9729. if (sep->IsNumber(2)) {
  9730. int32 value1 = atol(sep->arg[2]);
  9731. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  9732. cout << "Sent" << endl;
  9733. }
  9734. }
  9735. }
  9736. else if (atoi(sep->arg[0]) == 18) {
  9737. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  9738. if (packet2) {
  9739. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9740. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9741. packet2->setSubstructDataByName("reward_data", "max_coin", 0);
  9742. packet2->setSubstructDataByName("reward_data", "text", "Some custom text to mess things up?");
  9743. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9744. //packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9745. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9746. Item* item = new Item(master_item_list.GetItem(9357));
  9747. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9748. //item->stack_count = 20;
  9749. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  9750. safe_delete(item);
  9751. /*item = new Item(master_item_list.GetItem(36685));
  9752. item->stack_count = 20;
  9753. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9754. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  9755. safe_delete(item);
  9756. item = master_item_list.GetItem(1414);
  9757. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9758. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  9759. item = master_item_list.GetItem(75057);
  9760. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9761. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);*/
  9762. EQ2Packet* app = packet2->serialize();
  9763. if (sep->IsSet(2)) {
  9764. int16 offset = atoi(sep->arg[1]);
  9765. uchar* ptr2 = app->pBuffer;
  9766. ptr2 += offset;
  9767. if (sep->IsNumber(2)) {
  9768. int32 value1 = atol(sep->arg[2]);
  9769. if (value1 > 0xFFFF)
  9770. memcpy(ptr2, (uchar*)&value1, 4);
  9771. else if (value1 > 0xFF)
  9772. memcpy(ptr2, (uchar*)&value1, 2);
  9773. else
  9774. memcpy(ptr2, (uchar*)&value1, 1);
  9775. }
  9776. else {
  9777. int16 len = strlen(sep->arg[2]);
  9778. memcpy(ptr2, (uchar*)&len, 2);
  9779. ptr2 += 2;
  9780. memcpy(ptr2, sep->arg[2], len);
  9781. }
  9782. }
  9783. DumpPacket(app);
  9784. client->QueuePacket(app);
  9785. safe_delete(packet2);
  9786. }
  9787. }
  9788. else if (atoi(sep->arg[0]) == 19) {
  9789. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9790. Spawn* spawn = client->GetPlayer()->GetTarget();
  9791. if (packet2 && spawn) {
  9792. Item* item = master_item_list.GetItem(130053);
  9793. packet2->setArrayLengthByName("loot_count", 1);
  9794. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9795. packet2->setArrayDataByName("unknown2", 1);
  9796. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9797. packet2->setDataByName("display", 1);
  9798. packet2->setDataByName("unknown2b", 1);
  9799. packet2->setDataByName("unknown3", 0x3c);
  9800. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9801. packet2->PrintPacket();
  9802. EQ2Packet* app = packet2->serialize();
  9803. if (sep->IsSet(2)) {
  9804. int16 offset = atoi(sep->arg[1]);
  9805. int16 offset2 = 0;
  9806. int32 value1 = 0;
  9807. if (sep->IsSet(3)) {
  9808. offset2 = atoi(sep->arg[2]);
  9809. value1 = atol(sep->arg[3]);
  9810. }
  9811. else
  9812. value1 = atol(sep->arg[2]);
  9813. int16 offset3 = 0;
  9814. int16 offset4 = 0;
  9815. int32 value2 = 0;
  9816. if (sep->IsSet(6)) {
  9817. offset3 = atoi(sep->arg[4]);
  9818. offset4 = atoi(sep->arg[5]);
  9819. value2 = atol(sep->arg[6]);
  9820. }
  9821. offset--;
  9822. if (offset2 > 0 && offset2 >= offset) {
  9823. offset2--;
  9824. uchar* ptr2 = app->pBuffer;
  9825. ptr2 += offset;
  9826. for (int i = offset; i <= offset2; i++) {
  9827. if (value1 > 0xFFFF) {
  9828. memcpy(ptr2, (uchar*)&value1, 4);
  9829. i += 3;
  9830. ptr2 += 3;
  9831. }
  9832. else if (value1 > 0xFF) {
  9833. memcpy(ptr2, (uchar*)&value1, 2);
  9834. i++;
  9835. ptr2++;
  9836. }
  9837. else
  9838. memcpy(ptr2, (uchar*)&value1, 1);
  9839. ptr2++;
  9840. }
  9841. }
  9842. if (offset4 > 0 && offset4 >= offset3) {
  9843. offset3--;
  9844. offset4--;
  9845. uchar* ptr2 = app->pBuffer;
  9846. ptr2 += offset3;
  9847. for (int i = offset3; i <= offset4; i++) {
  9848. if (value2 > 0xFFFF) {
  9849. memcpy(ptr2, (uchar*)&value2, 4);
  9850. i += 3;
  9851. ptr2 += 3;
  9852. }
  9853. else if (value2 > 0xFF) {
  9854. memcpy(ptr2, (uchar*)&value2, 2);
  9855. i++;
  9856. ptr2++;
  9857. }
  9858. else
  9859. memcpy(ptr2, (uchar*)&value2, 1);
  9860. ptr2++;
  9861. }
  9862. }
  9863. }
  9864. DumpPacket(app);
  9865. client->QueuePacket(app);
  9866. safe_delete(packet2);
  9867. }
  9868. }
  9869. else if (atoi(sep->arg[0]) == 21) {
  9870. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9871. if (packet2) {
  9872. packet2->setDataByName("unknown0", 255);
  9873. packet2->setDataByName("reward", "New Quest");
  9874. packet2->setDataByName("title", "Title");
  9875. packet2->setDataByName("description", "description");
  9876. packet2->setDataByName("quest_difficulty", 3);
  9877. packet2->setDataByName("unknown1", 5);
  9878. packet2->setDataByName("level", 3);
  9879. packet2->setDataByName("coin", 150);
  9880. packet2->setDataByName("status_points", 5);
  9881. packet2->setDataByName("exp_bonus", 10);
  9882. packet2->setArrayLengthByName("num_rewards", 1);
  9883. Item* item = new Item(master_item_list.GetItem(36212));
  9884. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9885. item->stack_count = 20;
  9886. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  9887. safe_delete(item);
  9888. char accept[35] = { 0 };
  9889. char decline[35] = { 0 };
  9890. sprintf(accept, "q_accept_pending_quest %u", 0);
  9891. sprintf(decline, "q_deny_pending_quest %u", 0);
  9892. packet2->setDataByName("accept_command", accept);
  9893. packet2->setDataByName("decline_command", decline);
  9894. EQ2Packet* app = packet2->serialize();
  9895. if (sep->IsSet(2)) {
  9896. int16 offset = atoi(sep->arg[1]);
  9897. uchar* ptr2 = app->pBuffer;
  9898. ptr2 += offset;
  9899. if (sep->IsNumber(2)) {
  9900. int32 value1 = atol(sep->arg[2]);
  9901. if (value1 > 0xFFFF)
  9902. memcpy(ptr2, (uchar*)&value1, 4);
  9903. else if (value1 > 0xFF)
  9904. memcpy(ptr2, (uchar*)&value1, 2);
  9905. else
  9906. memcpy(ptr2, (uchar*)&value1, 1);
  9907. }
  9908. DumpPacket(app);
  9909. client->QueuePacket(app);
  9910. safe_delete(packet2);
  9911. }
  9912. }
  9913. }
  9914. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9915. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9916. if (packet2) {
  9917. packet2->setDataByName("unknown0", 255);
  9918. packet2->setDataByName("reward", "New Quest");
  9919. packet2->setDataByName("title", "Title");
  9920. packet2->setDataByName("description", "description");
  9921. packet2->setDataByName("quest_difficulty", 3);
  9922. packet2->setDataByName("unknown1", 5);
  9923. packet2->setDataByName("level", 3);
  9924. packet2->setDataByName("coin", 150);
  9925. packet2->setDataByName("status_points", 5);
  9926. packet2->setDataByName("exp_bonus", 10);
  9927. packet2->setArrayLengthByName("num_rewards", 1);
  9928. Item* item = new Item(master_item_list.GetItem(36212));
  9929. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9930. item->stack_count = 20;
  9931. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  9932. safe_delete(item);
  9933. char accept[35] = { 0 };
  9934. char decline[35] = { 0 };
  9935. sprintf(accept, "q_accept_pending_quest %u", 0);
  9936. sprintf(decline, "q_deny_pending_quest %u", 0);
  9937. packet2->setDataByName("accept_command", accept);
  9938. packet2->setDataByName("decline_command", decline);
  9939. EQ2Packet* app = packet2->serialize();
  9940. if (sep->IsSet(2)) {
  9941. int16 offset = atoi(sep->arg[1]);
  9942. uchar* ptr2 = app->pBuffer;
  9943. ptr2 += offset;
  9944. if (sep->IsNumber(2)) {
  9945. int32 value1 = atol(sep->arg[2]);
  9946. if (value1 > 0xFFFF)
  9947. memcpy(ptr2, (uchar*)&value1, 4);
  9948. else if (value1 > 0xFF)
  9949. memcpy(ptr2, (uchar*)&value1, 2);
  9950. else
  9951. memcpy(ptr2, (uchar*)&value1, 1);
  9952. }
  9953. else {
  9954. int8 len = strlen(sep->arg[2]);
  9955. memcpy(ptr2, (uchar*)&len, 1);
  9956. ptr2 += 1;
  9957. memcpy(ptr2, sep->arg[2], len);
  9958. }
  9959. }
  9960. DumpPacket(app);
  9961. client->QueuePacket(app);
  9962. safe_delete(packet2);
  9963. }
  9964. }
  9965. else if (atoi(sep->arg[0]) == 23) {
  9966. if (client->GetPlayer()->GetTarget()) {
  9967. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9968. if (packet2) {
  9969. Spawn* target = client->GetPlayer()->GetTarget();
  9970. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9971. Item* item = new Item(master_item_list.GetItem(12565));
  9972. int8 i = 0;
  9973. packet2->setArrayLengthByName("num_items", 1);
  9974. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9975. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9976. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9977. packet2->setArrayDataByName("icon", item->GetIcon(client->GetVersion()), i);
  9978. int8 tmp_level = 0;
  9979. if (item->generic_info.adventure_default_level > 0)
  9980. tmp_level = item->generic_info.adventure_default_level;
  9981. else
  9982. tmp_level = item->generic_info.tradeskill_default_level;
  9983. packet2->setArrayDataByName("level", tmp_level, i);
  9984. packet2->setArrayDataByName("tier", item->details.tier, i);
  9985. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9986. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9987. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9988. item_difficulty = ARROW_COLOR_WHITE;
  9989. item_difficulty -= 6;
  9990. if (item_difficulty < 0)
  9991. item_difficulty *= -1;
  9992. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9993. packet2->setArrayDataByName("quantity", 2, i);
  9994. packet2->setArrayDataByName("unknown5", 255, i);
  9995. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9996. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9997. packet2->setDataByName("type", 2);
  9998. EQ2Packet* app = packet2->serialize();
  9999. if (sep->IsSet(2)) {
  10000. int16 offset = atoi(sep->arg[1]);
  10001. uchar* ptr2 = app->pBuffer;
  10002. ptr2 += offset;
  10003. if (sep->IsNumber(2)) {
  10004. int32 value1 = atol(sep->arg[2]);
  10005. if (value1 > 0xFFFF)
  10006. memcpy(ptr2, (uchar*)&value1, 4);
  10007. else if (value1 > 0xFF)
  10008. memcpy(ptr2, (uchar*)&value1, 2);
  10009. else
  10010. memcpy(ptr2, (uchar*)&value1, 1);
  10011. }
  10012. else {
  10013. int8 len = strlen(sep->arg[2]);
  10014. memcpy(ptr2, (uchar*)&len, 1);
  10015. ptr2 += 1;
  10016. memcpy(ptr2, sep->arg[2], len);
  10017. }
  10018. }
  10019. DumpPacket(app);
  10020. client->QueuePacket(app);
  10021. safe_delete(packet2);
  10022. }
  10023. }
  10024. }
  10025. else if (atoi(sep->arg[0]) == 24) {
  10026. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  10027. if (packet2) {
  10028. if (sep->IsSet(2)) {
  10029. packet2->setDataByName("event_name", sep->arg[1]);
  10030. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  10031. EQ2Packet* app = packet2->serialize();
  10032. DumpPacket(app);
  10033. client->QueuePacket(app);
  10034. safe_delete(packet2);
  10035. }
  10036. }
  10037. }
  10038. else if (atoi(sep->arg[0]) == 25) {
  10039. if (sep->IsSet(1)) {
  10040. Widget* new_spawn = new Widget();
  10041. int32 id = atoul(sep->arg[1]);
  10042. new_spawn->SetWidgetID(id);
  10043. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  10044. client->QueuePacket(ret);
  10045. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  10046. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  10047. if (packet2) {
  10048. packet2->setDataByName("spawn_index", index);
  10049. packet2->setDataByName("delete", 1);
  10050. EQ2Packet* app = packet2->serialize();
  10051. client->QueuePacket(app);
  10052. safe_delete(packet2);
  10053. }
  10054. }
  10055. }
  10056. else if (atoi(sep->arg[0]) == 26) {
  10057. if (sep->IsSet(4)) {
  10058. Widget* new_spawn = new Widget();
  10059. int32 id = atoul(sep->arg[1]);
  10060. new_spawn->SetWidgetID(id);
  10061. float x = atof(sep->arg[2]);
  10062. float y = atof(sep->arg[3]);
  10063. float z = atof(sep->arg[4]);
  10064. new_spawn->SetLocation(client->GetPlayer()->GetLocation());
  10065. new_spawn->SetWidgetX(x);
  10066. new_spawn->SetWidgetY(y);
  10067. new_spawn->SetWidgetZ(z);
  10068. new_spawn->SetX(x);
  10069. new_spawn->SetY(y);
  10070. new_spawn->SetZ(z);
  10071. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  10072. client->QueuePacket(ret);
  10073. }
  10074. }
  10075. else if (atoi(sep->arg[0]) == 27) {
  10076. Spawn* target = client->GetPlayer()->GetTarget();
  10077. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  10078. if (packet2 && target && sep->IsSet(4)) {
  10079. 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] : "");
  10080. }
  10081. }
  10082. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  10083. World::newValue = strtoull(sep->arg[1], NULL, 0);
  10084. }
  10085. else if (atoi(sep->arg[0]) == 29 && sep->IsNumber(1)) {
  10086. client->SendHearCast(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10087. strtoull(sep->arg[1], NULL, 0), atoul(sep->arg[2]));
  10088. }
  10089. else if (atoi(sep->arg[0]) == 30) {
  10090. PacketStruct* packet = configReader.getStruct("WS_UpdateSkillBook", client->GetVersion());
  10091. if (packet) {
  10092. packet->setDataByName("unknown", World::newValue);
  10093. EQ2Packet* outapp = packet->serialize();
  10094. DumpPacket(outapp);
  10095. client->QueuePacket(outapp);
  10096. safe_delete(packet);
  10097. }
  10098. }
  10099. else if (atoi(sep->arg[0]) == 31) {
  10100. client->SendRecipeList();
  10101. }
  10102. else if (atoi(sep->arg[0]) == 32 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10103. if(client->GetVersion() <= 561) {
  10104. int32 param = atoul(sep->arg[1]);
  10105. int32 paramvalue = atoul(sep->arg[2]);
  10106. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param %u param value %u", param, paramvalue);
  10107. ClientPacketFunctions::SendServerControlFlagsClassic(client, param, paramvalue);
  10108. }
  10109. else if(sep->IsNumber(3)) {
  10110. int8 param1 = atoul(sep->arg[1]);
  10111. int8 param2 = atoul(sep->arg[2]);
  10112. int8 paramval = atoul(sep->arg[3]);
  10113. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param1 %u param2 %u param value %u", param1, param2, paramval);
  10114. ClientPacketFunctions::SendServerControlFlags(client, param1, param2, paramval);
  10115. }
  10116. }
  10117. else if (atoi(sep->arg[0]) == 33 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10118. client->GetCurrentZone()->SendHealPacket(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10119. atoul(sep->arg[1]), atoul(sep->arg[2]), "TestSpell");
  10120. }
  10121. else if(atoi(sep->arg[0]) == 34 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10122. PacketStruct* packet = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  10123. packet->setSubstructDataByName("reward_data", "unknown1", atoi(sep->arg[1]));
  10124. Item* item = master_item_list.GetItem(atoul(sep->arg[2]));
  10125. if(item) {
  10126. packet->setSubstructArrayLengthByName("reward_data", "num_select_rewards", 1);
  10127. packet->setArrayDataByName("select_reward_id", item->details.item_id, 0);
  10128. packet->setItemArrayDataByName("select_item", item, client->GetPlayer(), 0, 0, World::newValue - 2);
  10129. }
  10130. client->QueuePacket(packet->serialize());
  10131. safe_delete(packet);
  10132. }
  10133. }
  10134. else {
  10135. PacketStruct* packet2 = configReader.getStruct("WS_ExaminePartialSpellInfo", client->GetVersion());
  10136. if (packet2) {
  10137. packet2->setSubstructDataByName("info_header", "show_name", 1);
  10138. packet2->setSubstructDataByName("info_header", "unknown", 7);
  10139. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  10140. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  10141. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  10142. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  10143. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  10144. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  10145. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  10146. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  10147. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  10148. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  10149. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  10150. packet2->setSubstructDataByName("info_header", "packettype", 3);
  10151. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  10152. packet2->setSubstructDataByName("spell_info", "level", 19);
  10153. packet2->setSubstructDataByName("spell_info", "tier", 1);
  10154. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  10155. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  10156. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  10157. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  10158. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  10159. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  10160. packet2->setSubstructDataByName("spell_info", "recast", 280);
  10161. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  10162. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  10163. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  10164. packet2->setSubstructDataByName("spell_info", "quality", 3);
  10165. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  10166. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  10167. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  10168. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  10169. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  10170. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  10171. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  10172. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  10173. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  10174. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  10175. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  10176. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  10177. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  10178. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  10179. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  10180. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  10181. packet2->setArrayDataByName("reagent", "Alcohol");
  10182. packet2->setArrayDataByName("consumed", "123");
  10183. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  10184. packet2->setSubstructDataByName("spell_info", "id", 8308);
  10185. packet2->setSubstructDataByName("spell_info", "icon", 303);
  10186. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  10187. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  10188. packet2->setSubstructDataByName("spell_info", "type", 2);
  10189. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  10190. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  10191. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  10192. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  10193. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  10194. EQ2Packet* outapp = packet2->serialize();
  10195. DumpPacket(outapp);
  10196. client->QueuePacket(outapp);
  10197. safe_delete(packet2);
  10198. }
  10199. }
  10200. return;
  10201. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  10202. if (!p) return;
  10203. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10204. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  10205. //}
  10206. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10207. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  10208. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  10209. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  10210. if (packet) {
  10211. client->QueuePacket(packet->serialize());
  10212. safe_delete(packet);
  10213. }
  10214. }*/
  10215. /*if (client->GetCurrentZone()->Grid != nullptr) {
  10216. int32 numFaces = 0;
  10217. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  10218. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  10219. map<int32, vector<Face*> >::iterator itr;
  10220. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  10221. numFaces += (*itr).second.size();
  10222. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  10223. }*/
  10224. //uchar blah[] = {
  10225. // 1208 - OP_EQUpdateStoreCmd
  10226. // /*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
  10227. // /*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
  10228. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  10229. // /*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
  10230. /*};
  10231. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10232. int8 val = 0;
  10233. int16 pos = 0;
  10234. int idx = 0;
  10235. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  10236. pos = atoi(sep2->arg[idx]);
  10237. val = atoi(sep2->arg[idx+1]);
  10238. memset(blah+pos, val, 1);
  10239. idx+=2;
  10240. }
  10241. DumpPacket(blah, sizeof(blah));
  10242. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  10243. if (client->GetPlayer()->GetTarget()) {
  10244. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  10245. if (packet) {
  10246. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10247. packet->setDataByName("size", 0);
  10248. packet->setDataByName("unknown2", 0);
  10249. EQ2Packet* app = packet->serialize();
  10250. client->QueuePacket(app);
  10251. safe_delete(packet);
  10252. }
  10253. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  10254. if (set_pov) {
  10255. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10256. EQ2Packet* app_pov = set_pov->serialize();
  10257. client->QueuePacket(app_pov);
  10258. safe_delete(set_pov);
  10259. }
  10260. }
  10261. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10262. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  10263. if (packet) {
  10264. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  10265. packet->setDataByName("Type", atoi(sep2->arg[0]));
  10266. else
  10267. packet->setDataByName("Type", 2);
  10268. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  10269. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  10270. else
  10271. packet->setDataByName("race_id", 0);
  10272. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  10273. packet->setDataByName("gender", atoi(sep2->arg[2]));
  10274. else
  10275. packet->setDataByName("gender", 2);
  10276. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  10277. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  10278. else
  10279. packet->setDataByName("unknown", 0, 0);
  10280. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  10281. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  10282. else
  10283. packet->setDataByName("unknown", 0, 1);
  10284. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  10285. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  10286. else
  10287. packet->setDataByName("unknown", 0, 2);
  10288. client->QueuePacket(packet->serialize());
  10289. }
  10290. safe_delete(packet);
  10291. safe_delete(sep2);
  10292. }
  10293. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  10294. const char *channel_name;
  10295. if (sep == NULL || !sep->IsSet(0)) {
  10296. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  10297. PrintSep(sep);
  10298. return;
  10299. }
  10300. channel_name = sep->arg[0];
  10301. if (!chat.IsInChannel(client, channel_name))
  10302. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  10303. else if (!chat.LeaveChannel(client, channel_name))
  10304. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  10305. }
  10306. /*
  10307. Function:
  10308. Purpose :
  10309. Params :
  10310. Dev :
  10311. Example :
  10312. */
  10313. void Commands::Command_WeaponStats(Client* client)
  10314. {
  10315. Player* player = client->GetPlayer();
  10316. Spawn* target = player->GetTarget();
  10317. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10318. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10319. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10320. const char* charName = player->GetName();
  10321. if(target && target->IsEntity()) {
  10322. primary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10323. secondary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10324. ranged = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10325. charName = target->GetName();
  10326. }
  10327. else {
  10328. target = nullptr;
  10329. }
  10330. client->Message(0, "WeaponStats for %s", charName);
  10331. client->SimpleMessage(0, "Primary:");
  10332. if (primary) {
  10333. client->Message(0, "Name: %s", primary->name.c_str());
  10334. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  10335. client->Message(0, "Mastery Damage: %u - %u", primary->weapon_info->damage_low2, primary->weapon_info->damage_high2);
  10336. client->Message(0, "Damage: %u - %u", primary->weapon_info->damage_low1, primary->weapon_info->damage_high1);
  10337. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10338. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10339. client->Message(0, "Actual Delay: %u", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay());
  10340. client->Message(0, "Proc Percent: %d%%", 0);
  10341. client->Message(0, "Procs Per Minute: %d", 0);
  10342. }
  10343. else {
  10344. client->SimpleMessage(0, "Name: fist");
  10345. client->Message(0, "Base Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10346. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10347. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10348. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10349. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay() * 0.1);
  10350. client->Message(0, "Proc Percent: %d%%", 0);
  10351. client->Message(0, "Procs Per Minute: %d", 0);
  10352. }
  10353. client->SimpleMessage(0, " ");
  10354. client->SimpleMessage(0, " ");
  10355. if (secondary) {
  10356. client->SimpleMessage(0, "Secondary:");
  10357. client->Message(0, "Name: %s", secondary->name.c_str());
  10358. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  10359. client->Message(0, "Mastery Damage: %u - %u", secondary->weapon_info->damage_low2, secondary->weapon_info->damage_high2);
  10360. client->Message(0, "Damage: %u - %u", secondary->weapon_info->damage_low1, secondary->weapon_info->damage_high1);
  10361. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetSecondaryWeaponMinDamage() : player->GetSecondaryWeaponMinDamage(),
  10362. target ? ((Entity*)target)->GetSecondaryWeaponMaxDamage() : player->GetSecondaryWeaponMaxDamage());
  10363. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetSecondaryWeaponDelay() : player->GetSecondaryWeaponDelay() * 0.1);
  10364. client->Message(0, "Proc Percent: %d%%", 0);
  10365. client->Message(0, "Procs Per Minute: %d", 0);
  10366. client->SimpleMessage(0, " ");
  10367. client->SimpleMessage(0, " ");
  10368. }
  10369. client->SimpleMessage(0, "Ranged:");
  10370. if (ranged) {
  10371. client->Message(0, "Name: %s", ranged->name.c_str());
  10372. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  10373. client->Message(0, "Mastery Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low2, ranged->ranged_info->weapon_info.damage_high2);
  10374. client->Message(0, "Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low1, ranged->ranged_info->weapon_info.damage_high1);
  10375. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetRangedWeaponMinDamage() : player->GetRangedWeaponMinDamage(),
  10376. target ? ((Entity*)target)->GetRangedWeaponMaxDamage() : player->GetRangedWeaponMaxDamage());
  10377. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetRangeWeaponDelay() : player->GetRangeWeaponDelay() * 0.1);
  10378. client->Message(0, "Proc Percent: %d%%", 0);
  10379. client->Message(0, "Procs Per Minute: %d", 0);
  10380. }
  10381. else
  10382. client->SimpleMessage(0, "None");
  10383. }
  10384. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  10385. const char *channel_name;
  10386. if (sep == NULL || !sep->IsSet(0)) {
  10387. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  10388. return;
  10389. }
  10390. channel_name = sep->arg[0];
  10391. if (!chat.ChannelExists(channel_name))
  10392. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  10393. else
  10394. chat.SendChannelUserList(client, channel_name);
  10395. }
  10396. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  10397. {
  10398. ZoneServer* zone = 0;
  10399. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  10400. if (zone_id > 0)
  10401. {
  10402. zone = zone_list.Get(zone_id, false, false, false);
  10403. if (zone)
  10404. {
  10405. zone->SetSafeX(client->GetPlayer()->GetX());
  10406. zone->SetSafeY(client->GetPlayer()->GetY());
  10407. zone->SetSafeZ(client->GetPlayer()->GetZ());
  10408. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  10409. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  10410. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  10411. else
  10412. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  10413. }
  10414. }
  10415. }
  10416. /*
  10417. Function:
  10418. Purpose :
  10419. Params :
  10420. Dev :
  10421. Example :
  10422. */
  10423. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  10424. {
  10425. ZoneInfo* zone_info = new ZoneInfo;
  10426. if (sep && sep->arg[0])
  10427. {
  10428. if (sep->IsNumber(0))
  10429. zone_info->id = atoi(sep->arg[0]);
  10430. else
  10431. zone_info->id = database.GetZoneID(sep->arg[0]);
  10432. if (zone_info->id > 0)
  10433. {
  10434. database.LoadZoneInfo(zone_info);
  10435. 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);
  10436. 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);
  10437. 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);
  10438. 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);
  10439. 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);
  10440. 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);
  10441. 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);
  10442. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  10443. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  10444. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  10445. }
  10446. else
  10447. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10448. }
  10449. else
  10450. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  10451. safe_delete(zone_info);
  10452. }
  10453. /*
  10454. Function:
  10455. Purpose :
  10456. Params :
  10457. Dev :
  10458. Example :
  10459. */
  10460. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  10461. {
  10462. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  10463. {
  10464. ZoneServer* zone = 0;
  10465. int32 zone_id = 0;
  10466. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  10467. {
  10468. zone_id = atoi(sep->arg[0]);
  10469. zone = zone_list.Get(atoi(sep->arg[0]), false, false, false);
  10470. }
  10471. else
  10472. {
  10473. zone_id = database.GetZoneID(sep->arg[0]);
  10474. if (zone_id > 0)
  10475. zone = zone_list.Get(sep->arg[0], false, false, false);
  10476. }
  10477. if (zone_id > 0)
  10478. {
  10479. if (zone_set_values.count(string(sep->arg[1])) > 0)
  10480. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  10481. else
  10482. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  10483. }
  10484. else
  10485. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10486. }
  10487. else
  10488. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  10489. }
  10490. void Commands::Command_Rain(Client* client, Seperator* sep) {
  10491. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10492. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  10493. return;
  10494. }
  10495. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  10496. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  10497. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  10498. }
  10499. void Commands::Command_Wind(Client* client, Seperator* sep) {
  10500. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10501. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  10502. return;
  10503. }
  10504. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  10505. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  10506. }
  10507. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  10508. Spawn* spawn = client->GetPlayer()->GetTarget();
  10509. if(client->GetVersion() < 561) {
  10510. sell = false; // doesn't support in the same way as AoM just open the normal buy/sell window
  10511. }
  10512. if(spawn) {
  10513. client->SetMerchantTransaction(spawn);
  10514. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  10515. client->SendHailCommand(spawn);
  10516. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  10517. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  10518. client->SendBuyMerchantList(sell);
  10519. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  10520. client->SendSellMerchantList(sell);
  10521. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  10522. client->SendBuyBackList(sell);
  10523. if(client->GetVersion() > 561) {
  10524. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10525. if (packet) {
  10526. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  10527. packet->setDataByName("type", 16);
  10528. EQ2Packet* outapp = packet->serialize();
  10529. if (outapp)
  10530. client->QueuePacket(outapp);
  10531. safe_delete(packet);
  10532. }
  10533. }
  10534. }
  10535. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  10536. client->SendRepairList();
  10537. }
  10538. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  10539. }
  10540. void Commands::Command_Weather(Client* client, Seperator* sep)
  10541. {
  10542. //PrintSep(sep, "Weather");
  10543. if( sep && sep->arg[0] )
  10544. {
  10545. ZoneServer* zsZone = client->GetCurrentZone();
  10546. const char* value = sep->arg[0];
  10547. // process single-param commands first
  10548. if( strncasecmp(value, "details", strlen(value)) == 0 )
  10549. {
  10550. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  10551. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  10552. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  10553. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  10554. }
  10555. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  10556. {
  10557. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10558. zsZone->ProcessWeather();
  10559. }
  10560. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  10561. {
  10562. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  10563. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  10564. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  10565. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  10566. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  10567. zsZone->SetWeatherPattern(1);
  10568. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  10569. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  10570. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  10571. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10572. zsZone->ProcessWeather();
  10573. }
  10574. // process commands with params
  10575. if( sep->arg[1] )
  10576. {
  10577. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  10578. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  10579. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  10580. zsZone->SetWeatherType(atoi(sep->arg[1]));
  10581. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  10582. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  10583. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  10584. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  10585. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  10586. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  10587. }
  10588. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  10589. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  10590. zsZone->SetRain(zsZone->GetCurrentWeather());
  10591. }
  10592. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  10593. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  10594. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  10595. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  10596. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10597. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  10598. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10599. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  10600. }
  10601. }
  10602. else
  10603. {
  10604. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  10605. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  10606. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  10607. return;
  10608. }
  10609. }
  10610. void Commands::Command_Select(Client* client, Seperator* sep) {
  10611. if (sep && sep->arg[1]) {
  10612. Spawn* spawn = client->GetPlayer()->GetTarget();
  10613. if (spawn && strlen(sep->arg[1]) > 0)
  10614. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  10615. }
  10616. }
  10617. /*
  10618. Function: Command_ConsumeFood()
  10619. Purpose : Consume Food/Drink and apply mods
  10620. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  10621. Dev : Zcoretri
  10622. Example : /consume_food 22
  10623. */
  10624. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  10625. if (sep && sep->arg[0] && sep->IsNumber(0))
  10626. {
  10627. Player* player = client->GetPlayer();
  10628. int32 slot = atoul(sep->arg[0]);
  10629. if (client->GetVersion() <= 373) {
  10630. if(client->GetVersion() <= 561) {
  10631. if(slot <= 255) {
  10632. slot = 255 - slot;
  10633. }
  10634. else {
  10635. if(slot == 256) { // first "new" item to inventory is assigned index 256 by client
  10636. slot = client->GetPlayer()->item_list.GetFirstNewItem();
  10637. }
  10638. else {
  10639. // otherwise the slot has to be mapped out depending on the amount of new items + index sent in
  10640. slot = client->GetPlayer()->item_list.GetNewItemByIndex((int16)slot - 255);
  10641. }
  10642. }
  10643. }
  10644. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(slot);
  10645. if(item && item->IsFood()) {
  10646. if(client->CheckConsumptionAllowed(slot)) {
  10647. if(item->IsFoodFood())
  10648. slot = EQ2_FOOD_SLOT;
  10649. else if(item->IsFoodDrink())
  10650. slot = EQ2_DRINK_SLOT;
  10651. else
  10652. return; // not valid item
  10653. client->ConsumeFoodDrink(item, slot);
  10654. }
  10655. }
  10656. }
  10657. else {
  10658. if (client->GetVersion() > 373 && client->GetVersion() <= 561) {
  10659. slot += 2;
  10660. }
  10661. Item* item = player->GetEquipmentList()->GetItem(slot);
  10662. if(client->CheckConsumptionAllowed(slot)) {
  10663. client->ConsumeFoodDrink(item, slot);
  10664. }
  10665. }
  10666. }
  10667. }
  10668. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  10669. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10670. if (atoi(sep->arg[0]) == 1) {
  10671. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  10672. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  10673. client->GetPlayer()->SetCharSheetChanged(true);
  10674. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  10675. }
  10676. else {
  10677. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  10678. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  10679. client->GetPlayer()->SetCharSheetChanged(true);
  10680. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  10681. }
  10682. }
  10683. else
  10684. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  10685. }
  10686. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  10687. {
  10688. if(sep)
  10689. {
  10690. string data;
  10691. if(sep->arg[0]){
  10692. data = string(sep->arg[0]);
  10693. }
  10694. for(int i=1;i<sep->GetMaxArgNum();i++){
  10695. if(sep->arg[i])
  10696. data.append(" ").append(sep->arg[i]);
  10697. }
  10698. if(!sep->IsSet(7)){
  10699. data.append(" ").append(std::to_string(client->GetVersion())).append("\a");
  10700. }
  10701. const char* target_name = 0;
  10702. int32 spawn_id = 0;
  10703. if(client->GetPlayer()->GetTarget())
  10704. {
  10705. target_name = client->GetPlayer()->GetTarget()->GetName();
  10706. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10707. }
  10708. else
  10709. target_name = "N/A";
  10710. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  10711. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  10712. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  10713. else
  10714. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  10715. }
  10716. }
  10717. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  10718. PrintSep(sep, "Command_Attune_Inv");
  10719. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10720. // Get the item index from the first parameter
  10721. int16 index = atoi(sep->arg[0]);
  10722. // Check to see if this is a valid item index for the player, if not exit out of the function
  10723. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  10724. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  10725. return;
  10726. }
  10727. // Get the item
  10728. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  10729. if(item) {
  10730. // Valid item lets check to make sure this item is attunable, if not return out
  10731. if (!item->CheckFlag(ATTUNEABLE)) {
  10732. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  10733. return;
  10734. }
  10735. // Remove the attunable flag
  10736. item->generic_info.item_flags -= ATTUNEABLE;
  10737. // Set the attuned flag
  10738. item->generic_info.item_flags += ATTUNED;
  10739. // Flag this item for saving
  10740. item->save_needed = true;
  10741. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  10742. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  10743. EQ2Packet* outapp = 0;
  10744. for (int32 i=0;i<packets.size();i++) {
  10745. outapp = packets[i];
  10746. if(outapp)
  10747. client->QueuePacket(outapp);
  10748. }
  10749. }
  10750. }
  10751. }
  10752. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  10753. PrintSep(sep, "Command_Reset_Zone_Timer");
  10754. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10755. int32 db_id = atoul(sep->arg[0]);
  10756. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  10757. if (data) {
  10758. // TODO: add a check to timers to ensure it can be reset
  10759. // Delete the character from the instance
  10760. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  10761. data->instance_id = 0;
  10762. // Update the success time and set to 0 so the player can enter it again
  10763. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  10764. data->last_success_timestamp = 0;
  10765. }
  10766. }*/
  10767. }
  10768. void Commands::Command_Player(Client* client, Seperator* sep) {
  10769. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  10770. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  10771. }
  10772. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  10773. // /player coins add 10
  10774. // /player coins add plat 10
  10775. Player* player = client->GetPlayer();
  10776. Client* targetClient = client;
  10777. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  10778. player = (Player*)player->GetTarget();
  10779. targetClient = player->GetClient();
  10780. }
  10781. if (sep && sep->arg[0] && sep->arg[1]) {
  10782. const char* action = sep->arg[0];
  10783. int64 value = 0;
  10784. if (strncasecmp(action, "add", strlen(action)) == 0) {
  10785. if (sep->IsNumber(1)) {
  10786. value = atoi64(sep->arg[1]);
  10787. player->AddCoins(value);
  10788. if (client->GetPlayer() == player)
  10789. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10790. else {
  10791. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10792. if(targetClient) {
  10793. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10794. }
  10795. }
  10796. return;
  10797. }
  10798. else if (sep->arg[2] && sep->IsNumber(2)) {
  10799. const char* type = sep->arg[1];
  10800. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  10801. value = atoi64(sep->arg[2]);
  10802. }
  10803. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  10804. value = atoi64(sep->arg[2]) * 100;
  10805. }
  10806. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  10807. value = atoi64(sep->arg[2]) * 10000;
  10808. }
  10809. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  10810. value = atoi64(sep->arg[2]) * 1000000;
  10811. }
  10812. player->AddCoins(value);
  10813. if (client->GetPlayer() == player)
  10814. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10815. else {
  10816. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10817. if(targetClient) {
  10818. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10819. }
  10820. }
  10821. return;
  10822. }
  10823. }
  10824. }
  10825. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  10826. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  10827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  10828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  10829. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  10830. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  10831. }
  10832. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  10833. PrintSep(sep, "ACHIEVEMENT_ADD");
  10834. if (sep && sep->IsSet(0)) {
  10835. int32 spell_id = atoul(sep->arg[1]);
  10836. int8 spell_tier = 0;
  10837. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10838. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10839. // addspellbookentry here
  10840. if (spell_tier >= data->maxRank) {
  10841. return;
  10842. }
  10843. if (!spell_tier) {
  10844. spell_tier = 1;
  10845. }
  10846. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10847. {
  10848. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10849. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10850. client->GetPlayer()->UnlockSpell(spell);
  10851. client->SendSpellUpdate(spell);
  10852. }
  10853. else
  10854. {
  10855. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  10856. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10857. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10858. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10859. client->GetPlayer()->UnlockSpell(spell);
  10860. client->SendSpellUpdate(spell);
  10861. }
  10862. // cast spell here
  10863. if (!spell_tier)
  10864. spell_tier = 1;
  10865. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10866. if (spell) {
  10867. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10868. }
  10869. }
  10870. else {
  10871. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10872. }
  10873. if(client->GetVersion() > 561)
  10874. master_aa_list.DisplayAA(client, 0, 0);
  10875. }
  10876. void Commands::Command_Editor(Client* client, Seperator* sep) {
  10877. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  10878. if (packet) {
  10879. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  10880. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  10881. char command[255];
  10882. url = "browser " + url;
  10883. int32 spawn_id = 0;
  10884. int32 zone_id = 0;
  10885. string type;
  10886. if (client->GetCurrentZone())
  10887. zone_id = client->GetCurrentZone()->GetZoneID();
  10888. if (client->GetPlayer()->GetTarget()) {
  10889. Spawn* target = client->GetPlayer()->GetTarget();
  10890. if (target->IsWidget())
  10891. type = "widgets";
  10892. else if (target->IsSign())
  10893. type = "signs";
  10894. else if (target->IsObject())
  10895. type = "objects";
  10896. else if (target->IsNPC())
  10897. type = "npcs";
  10898. else if (target->IsGroundSpawn())
  10899. type = "ground";
  10900. else
  10901. type = "spawn";
  10902. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10903. }
  10904. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  10905. packet->setDataByName("accept_command", command);
  10906. }
  10907. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  10908. char command[255];
  10909. url = "browser " + url;
  10910. if (client->GetPlayer()->GetTarget())
  10911. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  10912. packet->setDataByName("accept_command", command);
  10913. }
  10914. else {
  10915. string command = "browser " + url;
  10916. packet->setDataByName("accept_command", command.c_str());
  10917. }
  10918. packet->setDataByName("text", "Open the web editor?");
  10919. packet->setDataByName("accept_text", "Open");
  10920. packet->setDataByName("cancel_text", "Cancel");
  10921. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  10922. packet->setDataByName("unknown2", 50);
  10923. packet->setDataByName("unknown4", 1);
  10924. client->QueuePacket(packet->serialize());
  10925. safe_delete(packet);
  10926. }
  10927. }
  10928. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  10929. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10930. return;
  10931. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10932. if(client->GetCurrentRez()->active)
  10933. client->AcceptResurrection();
  10934. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10935. }
  10936. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  10937. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10938. return;
  10939. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10940. if(client->GetCurrentRez()->active)
  10941. client->GetCurrentRez()->should_delete = true;
  10942. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10943. }
  10944. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  10945. PrintSep(sep, "Switch_AA_Profile");
  10946. if (sep && sep->IsSet(0)) {
  10947. string type = sep->arg[0];
  10948. int8 newtemplate = atoul(sep->arg[1]);
  10949. if(client->GetVersion() > 561)
  10950. master_aa_list.DisplayAA(client, newtemplate, 1);
  10951. }
  10952. }
  10953. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  10954. PrintSep(sep, "Get_AA_Xml");
  10955. if (sep && sep->IsSet(0)) {
  10956. string tabnum = sep->arg[0];
  10957. string spellid = sep->arg[1];
  10958. }
  10959. }
  10960. void Commands::Add_AA(Client* client, Seperator* sep) {
  10961. PrintSep(sep, "Add_AA");
  10962. if (sep && sep->IsSet(0)) {
  10963. int32 spell_id = atoul(sep->arg[1]);
  10964. int8 spell_tier = 0;
  10965. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10966. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10967. // addspellbookentry here
  10968. if(!data) {
  10969. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  10970. return;
  10971. }
  10972. if (spell_tier >= data->maxRank) {
  10973. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  10974. return;
  10975. }
  10976. if (!spell_tier) {
  10977. spell_tier = 1;
  10978. }
  10979. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10980. {
  10981. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10982. if(spell)
  10983. {
  10984. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10985. client->GetPlayer()->UnlockSpell(spell);
  10986. client->SendSpellUpdate(spell);
  10987. }
  10988. }
  10989. else
  10990. {
  10991. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10992. if(spell)
  10993. {
  10994. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10995. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10996. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10997. client->GetPlayer()->UnlockSpell(spell);
  10998. client->SendSpellUpdate(spell);
  10999. }
  11000. }
  11001. // cast spell here
  11002. if (!spell_tier)
  11003. spell_tier = 1;
  11004. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  11005. if (spell) {
  11006. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  11007. }
  11008. }
  11009. else {
  11010. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  11011. }
  11012. if(client->GetVersion() > 561)
  11013. master_aa_list.DisplayAA(client, 0, 0);
  11014. }
  11015. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  11016. PrintSep(sep, "Commit_AA_Profile");
  11017. if (sep && sep->IsSet(0)) {
  11018. }
  11019. }
  11020. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  11021. PrintSep(sep, "Begin_AA_Profile");
  11022. if (sep && sep->IsSet(0)) {
  11023. if(client->GetVersion() > 561)
  11024. master_aa_list.DisplayAA(client, 100, 2);
  11025. }
  11026. }
  11027. void Commands::Back_AA(Client* client, Seperator* sep) {
  11028. if (sep && sep->IsSet(0)) {
  11029. PrintSep(sep, "Back_AA");
  11030. }
  11031. }
  11032. void Commands::Remove_AA(Client* client, Seperator* sep) {
  11033. if (sep && sep->IsSet(0)) {
  11034. PrintSep(sep, "Remove_AA");
  11035. }
  11036. }
  11037. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  11038. MasterAAList master_aa_list;
  11039. PrintSep(sep, "Cancel_AA_Profile");
  11040. if(client->GetVersion() > 561)
  11041. master_aa_list.DisplayAA(client, 0, 0);
  11042. }
  11043. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  11044. if (sep && sep->IsSet(0)) {
  11045. PrintSep(sep, "Save_AA_Profile");
  11046. }
  11047. }
  11048. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  11049. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  11050. if (!sep->IsNumber(0)) return;
  11051. int32 request_id = atoul(sep->arg[0]);
  11052. if (!sep->IsNumber(1)) return;
  11053. sint32 item_id = atoi(sep->arg[1]);
  11054. if (client->IsCurrentTransmuteID(request_id)) {
  11055. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  11056. }
  11057. else if (client->IsCurrentTransmuteID(item_id)) {
  11058. if (!sep->IsSet(2)) return;
  11059. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  11060. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  11061. }
  11062. }
  11063. }
  11064. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  11065. if(sep)
  11066. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  11067. }
  11068. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  11069. if(sep && sep->arg[0][0] && sep->arg[1][0])
  11070. {
  11071. char* name = sep->arg[0];
  11072. char* zoneName = sep->arg[1];
  11073. char query[256];
  11074. 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);
  11075. if (database.RunQuery(query, strnlen(query, 256)))
  11076. {
  11077. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  11078. }
  11079. else
  11080. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  11081. }
  11082. }
  11083. void Commands::Command_Mood(Client* client, Seperator* sep) {
  11084. Player* player = client->GetPlayer();
  11085. if( sep && sep->arg[0] )
  11086. {
  11087. const char* value = sep->arg[0];
  11088. InfoStruct* info = player->GetInfoStruct();
  11089. int32 cid = client->GetCharacterID();
  11090. char* characterName = database.GetCharacterName(cid);
  11091. char tmp[1024]; // our emote string "xyz appears zyx"
  11092. //char properties vals
  11093. char* pname = "mood";
  11094. char* pval; // mood value
  11095. bool pt; //used to verify return from DB.
  11096. //This should never be seen.
  11097. sprintf(tmp, " ");
  11098. if( strncasecmp(value, "angry", strlen(value)) == 0 )
  11099. {
  11100. sprintf(tmp, "%s appears angry", characterName);
  11101. pval = "11852";
  11102. player->SetMoodState(11852, 1);
  11103. info->set_mood(11852);
  11104. pt = database.insertCharacterProperty(client, pname, pval);
  11105. }
  11106. else if( strncasecmp(value, "afraid", strlen(value)) == 0 )
  11107. {
  11108. sprintf(tmp, "%s appears afraid", characterName);
  11109. pval = "11851";
  11110. player->SetMoodState(11851, 1);
  11111. info->set_mood(11851);
  11112. pt = database.insertCharacterProperty(client, pname, pval);
  11113. }
  11114. else if( strncasecmp(value, "happy", strlen(value)) == 0 )
  11115. {
  11116. sprintf(tmp, "%s appears happy", characterName);
  11117. pval = "11854";
  11118. player->SetMoodState(11854, 1);
  11119. info->set_mood(11854);
  11120. pt = database.insertCharacterProperty(client, pname, pval);
  11121. }
  11122. else if( strncasecmp(value, "sad", strlen(value)) == 0 ) {
  11123. sprintf(tmp, "%s appears sad", characterName);
  11124. pval = "11856";
  11125. player->SetMoodState(11856, 1);
  11126. info->set_mood(11856);
  11127. pt = database.insertCharacterProperty(client, pname, pval);
  11128. }
  11129. else if( strncasecmp(value, "tired", strlen(value)) == 0 )
  11130. {
  11131. sprintf(tmp, "%s appears tired", characterName);
  11132. pval = "11857";
  11133. player->SetMoodState(11857, 1);
  11134. info->set_mood(11857);
  11135. pt = database.insertCharacterProperty(client, pname, pval);
  11136. }
  11137. else if( strncasecmp(value, "none", strlen(value)) == 0 )
  11138. {
  11139. //using 11855 mood_idle for none, I assume thats what its for?
  11140. pval = "11855";
  11141. player->SetMoodState(11855, 1);
  11142. info->set_mood(11855);
  11143. pt = database.insertCharacterProperty(client, pname, pval);
  11144. //return since we have nothing left to do. No emote for none.
  11145. return;
  11146. }else{
  11147. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11148. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11149. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11150. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11151. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11152. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11153. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11154. return;
  11155. }
  11156. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, tmp);
  11157. return;
  11158. }
  11159. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11160. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11161. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11162. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11163. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11164. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11165. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11166. return;
  11167. }
  11168. /*
  11169. Function: Command_CancelEffect()
  11170. Purpose : Cancels (good) effect spells
  11171. Example : /cancel_effect spell_id - would cancel the spell with the <spell_id> value in spell effects list
  11172. */
  11173. void Commands::Command_CancelEffect(Client* client, Seperator* sep)
  11174. {
  11175. if (sep && sep->arg[0] && sep->IsNumber(0))
  11176. {
  11177. int32 spell_id = atoul(sep->arg[0]);
  11178. SpellEffects* effect = client->GetPlayer()->GetSpellEffect(spell_id);
  11179. if(!effect || effect->spell->spell->GetSpellData()->det_type) {
  11180. return;
  11181. }
  11182. MaintainedEffects* meffect = effect->caster->GetMaintainedSpell(spell_id);
  11183. if (!meffect || !meffect->spell || !meffect->spell->caster || !meffect->spell->caster->GetZone() ||
  11184. !meffect->spell->caster->GetZone()->GetSpellProcess()->DeleteCasterSpell(meffect->spell, "canceled", false, client->GetPlayer()))
  11185. client->Message(CHANNEL_COLOR_RED, "The spell effect could not be cancelled.");
  11186. }
  11187. }
  11188. /*
  11189. Function: Command_CurePlayer()
  11190. Purpose : Identifies spell to cast for cure based on type
  11191. Example : /cureplayer ??
  11192. https://eq2.fandom.com/wiki/Update:58
  11193. New command /cureplayer [playername|group or raid position][trauma|arcane|noxious|elemental|curse] optional [spell|potion]
  11194. Example: /cureplayer g0 noxious spell
  11195. Will attempt to cure yourself of a noxious detriment with only spells and without using potions (even if you have them).
  11196. Example: /cureplayer r4 noxious
  11197. Will attempt to cure the character in raid slot 4 of a noxious detriment using a spell or potion (whichever is available).
  11198. */
  11199. void Commands::Command_CurePlayer(Client* client, Seperator* sep)
  11200. {
  11201. Entity* target = nullptr;
  11202. bool use_spells = true;
  11203. bool use_potions = true;
  11204. if (sep && sep->arg[0] && sep->arg[1]) {
  11205. if(sep->arg[2]) {
  11206. std::string type(sep->arg[2]);
  11207. boost::algorithm::to_lower(type);
  11208. if(type == "potion")
  11209. use_spells = false;
  11210. else if(type == "spell")
  11211. use_potions = false;
  11212. }
  11213. if(strlen(sep->arg[0]) > 1 && isdigit(sep->arg[0][1])) {
  11214. int32 mapped_position = (int32)(sep->arg[0][1]) - 48;
  11215. // TODO: RAID Support ('r' argument)
  11216. if(sep->arg[0][0] == 'g' && !mapped_position) {
  11217. target = (Entity*)client->GetPlayer();
  11218. }
  11219. else {
  11220. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11221. if (gmi && gmi->group_id) {
  11222. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11223. if(group) {
  11224. target = group->GetGroupMemberByPosition(client->GetPlayer(), mapped_position);
  11225. }
  11226. }
  11227. }
  11228. }
  11229. else {
  11230. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11231. if(target_client && target_client->GetPlayer() && target_client->GetPlayer()->GetZone() == client->GetPlayer()->GetZone()) {
  11232. target = (Entity*)target_client->GetPlayer();
  11233. }
  11234. }
  11235. ItemEffectType type = EFFECT_CURE_TYPE_ALL;
  11236. bool successful_spell = false;
  11237. bool successful_potion = false;
  11238. if(target) {
  11239. SpellBookEntry* entry = nullptr;
  11240. std::string str(sep->arg[1]);
  11241. boost::algorithm::to_lower(str);
  11242. if(str == "arcane") {
  11243. type = EFFECT_CURE_TYPE_ARCANE;
  11244. // cure arcane spell missing in DB?
  11245. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()) {
  11246. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()); // cure noxious
  11247. }
  11248. }
  11249. else if(str == "trauma") {
  11250. type = EFFECT_CURE_TYPE_TRAUMA;
  11251. // cure trauma spell missing in DB?
  11252. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()) {
  11253. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()); // cure noxious
  11254. }
  11255. }
  11256. else if(str == "noxious") {
  11257. type = EFFECT_CURE_TYPE_NOXIOUS;
  11258. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()) {
  11259. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()); // cure noxious
  11260. }
  11261. }
  11262. else if(str == "curse") {
  11263. type = EFFECT_CURE_TYPE_CURSE;
  11264. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()) {
  11265. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()); // cure curse
  11266. }
  11267. }
  11268. else if(str == "magic") {
  11269. type = EFFECT_CURE_TYPE_MAGIC;
  11270. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()) {
  11271. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()); // cure magic
  11272. }
  11273. }
  11274. if(use_spells) {
  11275. // check if any of the specific cure types are available, if not then check the base cures
  11276. if(!entry && rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()) {
  11277. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()); // cure
  11278. }
  11279. if(entry && entry->spell_id) {
  11280. Spell* spell = master_spell_list.GetSpell(entry->spell_id, entry->tier);
  11281. target->GetZone()->ProcessSpell(spell, (Entity*)client->GetPlayer(), target, true, false);
  11282. successful_spell = true;
  11283. }
  11284. }
  11285. }
  11286. if(!successful_spell && use_potions && target && type != NO_EFFECT_TYPE) {
  11287. vector<Item*>* potential_items = client->GetItemsByEffectType(type, EFFECT_CURE_TYPE_ALL);
  11288. if (potential_items && potential_items->size() > 0) {
  11289. vector<Item*>::iterator itr;
  11290. for (itr = potential_items->begin(); itr != potential_items->end(); itr++)
  11291. {
  11292. Item* item = *itr;
  11293. if(client->UseItem(item, target)) {
  11294. successful_potion = true;
  11295. break;
  11296. }
  11297. }
  11298. }
  11299. safe_delete(potential_items);
  11300. }
  11301. }
  11302. }
  11303. /*
  11304. Function: Command_ShareQuest()
  11305. Purpose : Share quest with the group
  11306. Example : /share_quest [quest_id]
  11307. */
  11308. void Commands::Command_ShareQuest(Client* client, Seperator* sep)
  11309. {
  11310. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  11311. int32 quest_id = atoul(sep->arg[0]);
  11312. bool hasQuest = client->GetPlayer()->HasAnyQuest(quest_id);
  11313. if(hasQuest) {
  11314. Quest* quest = master_quest_list.GetQuest(quest_id, false);
  11315. if(quest) {
  11316. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11317. if (gmi && gmi->group_id) {
  11318. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11319. if (group) {
  11320. group->ShareQuestWithGroup(client, quest);
  11321. }
  11322. }
  11323. }
  11324. }
  11325. else {
  11326. client->SimpleMessage(CHANNEL_COLOR_RED, "Cannot find quest.");
  11327. }
  11328. }
  11329. }
  11330. /*
  11331. Function: Command_Yell()
  11332. Purpose : Yell to break an encounter
  11333. Example : /yell
  11334. * Uses self target, encounter target or no target
  11335. */
  11336. void Commands::Command_Yell(Client* client, Seperator* sep) {
  11337. Entity* player = (Entity*)client->GetPlayer();
  11338. Spawn* res = nullptr;
  11339. Spawn* prev = nullptr;
  11340. bool cycleAll = false;
  11341. if (player->GetTarget() == player) {
  11342. cycleAll = true; // self target breaks all encounters
  11343. }
  11344. else if (player->GetTarget()) {
  11345. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11346. }
  11347. if (res && !client->GetPlayer()->IsEngagedBySpawnID(res->GetID()))
  11348. return;
  11349. bool groupPermissionYell = true;
  11350. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11351. // If the player has a group and has a target
  11352. if (gmi) {
  11353. deque<GroupMemberInfo*>::iterator itr;
  11354. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  11355. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11356. if (group && !group->GetGroupOptions()->default_yell && !gmi->leader) { // default_yell_method = 0 means leader only
  11357. groupPermissionYell = false;
  11358. }
  11359. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  11360. }
  11361. if (!groupPermissionYell) {
  11362. LogWrite(COMMAND__ERROR, 0, "Command", "%s permission to yell denied due to group yell method set to leader only", client->GetPlayer()->GetName());
  11363. return;
  11364. }
  11365. bool alreadyYelled = false;
  11366. do {
  11367. if (!res && player->IsEngagedInEncounter(&res)) { // no target is set, dis-engage top of hated by list
  11368. }
  11369. if (!res || prev == res) {
  11370. return;
  11371. }
  11372. if (res->IsNPC() && ((NPC*)res)->Brain()) {
  11373. if (!alreadyYelled) {
  11374. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You yell for help!");
  11375. string yellMsg = std::string(client->GetPlayer()->GetName()) + " yelled for help!";
  11376. client->GetPlayer()->GetZone()->SimpleMessage(CHANNEL_COLOR_RED, yellMsg.c_str(), client->GetPlayer(), 35.0f, false);
  11377. client->GetPlayer()->GetZone()->SendYellPacket(client->GetPlayer());
  11378. }
  11379. alreadyYelled = true;
  11380. NPC* npc = (NPC*)res;
  11381. npc->Brain()->ClearEncounter();
  11382. npc->SetLockedNoLoot(ENCOUNTER_STATE_BROKEN);
  11383. npc->UpdateEncounterState(ENCOUNTER_STATE_BROKEN);
  11384. }
  11385. prev = res;
  11386. res = nullptr;
  11387. } while (cycleAll);
  11388. if (!player->IsEngagedInEncounter()) {
  11389. if (player->GetInfoStruct()->get_engaged_encounter()) {
  11390. player->GetInfoStruct()->set_engaged_encounter(0);
  11391. player->SetRegenValues((player->GetInfoStruct()->get_effective_level() > 0) ? player->GetInfoStruct()->get_effective_level() : player->GetLevel());
  11392. client->GetPlayer()->SetCharSheetChanged(true);
  11393. player->info_changed = true;
  11394. }
  11395. }
  11396. }
  11397. /*
  11398. Function: Command_SetAutoLootMode()
  11399. Purpose : Set player auto loot mode (0 = disabled, 1 = need/lotto, 2 = decline).
  11400. Example : /setautolootmode [mode]
  11401. */
  11402. void Commands::Command_SetAutoLootMode(Client* client, Seperator* sep) {
  11403. if (sep && sep->IsNumber(0)) {
  11404. int8 mode = atoul(sep->arg[0]);
  11405. switch (mode) {
  11406. case AutoLootMode::METHOD_DISABLED: {
  11407. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Disabled auto loot mode");
  11408. break;
  11409. }
  11410. case AutoLootMode::METHOD_ACCEPT: {
  11411. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Enabled auto loot mode for need and lotto.");
  11412. break;
  11413. }
  11414. default: {
  11415. mode = AutoLootMode::METHOD_DECLINE;
  11416. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Enabled auto loot mode to decline need and lotto.");
  11417. break;
  11418. }
  11419. }
  11420. client->GetPlayer()->GetInfoStruct()->set_group_auto_loot_method(mode);
  11421. database.insertCharacterProperty(client, CHAR_PROPERTY_AUTOLOOTMETHOD, (char*)std::to_string(mode).c_str());
  11422. client->SendDefaultGroupOptions();
  11423. }
  11424. }
  11425. /*
  11426. Function: Command_AutoAttack()
  11427. Purpose : Attack / Auto Attack
  11428. Example : /attack, /autoattack type
  11429. */
  11430. void Commands::Command_AutoAttack(Client* client, Seperator* sep) {
  11431. int8 type = 1;
  11432. bool update = false;
  11433. Player* player = client->GetPlayer();
  11434. if(!player)
  11435. return;
  11436. bool incombat = player->EngagedInCombat();
  11437. if(sep && sep->arg[0] && sep->IsNumber(0))
  11438. type = atoi(sep->arg[0]);
  11439. if(!client->GetPlayer()->Alive()){
  11440. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  11441. return;
  11442. }
  11443. if(type == 0){
  11444. if(incombat)
  11445. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  11446. player->StopCombat(type);
  11447. update = true;
  11448. }
  11449. else {
  11450. if(type == 2){
  11451. player->InCombat(false);
  11452. if(incombat && player->GetRangeAttack()){
  11453. player->StopCombat(type);
  11454. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  11455. update = true;
  11456. }
  11457. else{
  11458. player->SetRangeAttack(true);
  11459. player->InCombat(true, true);
  11460. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  11461. update = true;
  11462. }
  11463. }
  11464. else {
  11465. player->InCombat(false, true);
  11466. player->SetRangeAttack(false);
  11467. player->InCombat(true);
  11468. if(!incombat) {
  11469. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  11470. update = true;
  11471. }
  11472. }
  11473. /*else
  11474. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  11475. }
  11476. if(update) {
  11477. player->SetCharSheetChanged(true);
  11478. }
  11479. }
  11480. /*
  11481. Function: Command_Assist()
  11482. Purpose : Assist target
  11483. Example : /assist [name]
  11484. * Uses target or character name
  11485. */
  11486. void Commands::Command_Assist(Client* client, Seperator* sep) {
  11487. Entity* player = (Entity*)client->GetPlayer();
  11488. Spawn* res = nullptr;
  11489. if(sep && sep->arg[0]) {
  11490. if(!stricmp(sep->arg[0], "on")) {
  11491. database.insertCharacterProperty(client, CHAR_PROPERTY_ASSISTAUTOATTACK, "1");
  11492. return;
  11493. }
  11494. else if(!stricmp(sep->arg[0], "off")) {
  11495. database.insertCharacterProperty(client, CHAR_PROPERTY_ASSISTAUTOATTACK, "0");
  11496. return;
  11497. }
  11498. Client* otherClient = client->GetPlayer()->GetZone()->GetClientByName(sep->arg[0]);
  11499. if(otherClient) {
  11500. res = otherClient->GetPlayer();
  11501. }
  11502. }
  11503. if (player->GetTarget()) {
  11504. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11505. }
  11506. if(res && res->GetTarget()) {
  11507. res = res->GetTarget();
  11508. }
  11509. if(res) {
  11510. client->TargetSpawn(res);
  11511. if(client->GetPlayer()->GetInfoStruct()->get_assist_auto_attack() && !player->EngagedInCombat()) {
  11512. Command_AutoAttack(client, nullptr);
  11513. }
  11514. }
  11515. }
  11516. /*
  11517. Function: Command_Target()
  11518. Purpose : Target spawn/player
  11519. Example : /target [name]
  11520. * Uses target or character name
  11521. */
  11522. void Commands::Command_Target(Client* client, Seperator* sep) {
  11523. Entity* player = (Entity*)client->GetPlayer();
  11524. Spawn* res = nullptr;
  11525. if(sep && sep->arg[0] && player->GetZone()) {
  11526. float max_distance = rule_manager.GetGlobalRule(R_Player, MaxTargetCommandDistance)->GetFloat();
  11527. if(max_distance < 1.0f) {
  11528. max_distance = 10.0f;
  11529. }
  11530. player->GetZone()->SetPlayerTargetByName(client, (char*)sep->argplus[0], max_distance);
  11531. }
  11532. }
  11533. /*
  11534. Function: Command_Target_Pet()
  11535. Purpose : Target pet
  11536. Example : /target_pet
  11537. * Use to target pet
  11538. */
  11539. void Commands::Command_Target_Pet(Client* client, Seperator* sep) {
  11540. Entity* player = (Entity*)client->GetPlayer();
  11541. Spawn* res = client->GetPlayer()->GetPet();
  11542. if(res) {
  11543. client->TargetSpawn(res);
  11544. }
  11545. }