Commands.cpp 411 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include "Commands.h"
  18. #include "../ClientPacketFunctions.h"
  19. #include "../../common/version.h"
  20. #include "../../common/seperator.h"
  21. #include "../../common/servertalk.h"
  22. #include "../WorldDatabase.h"
  23. #include "../World.h"
  24. #include "../../common/ConfigReader.h"
  25. #include "../VisualStates.h"
  26. #include "../../common/debug.h"
  27. #include "../LuaInterface.h"
  28. #include "../Quests.h"
  29. #include "../client.h"
  30. #include "../NPC.h"
  31. #include "../Guilds/Guild.h"
  32. #include "../SpellProcess.h"
  33. #include "../Tradeskills/Tradeskills.h"
  34. #include "../../common/Log.h"
  35. #include "../../common/MiscFunctions.h"
  36. #include "../Languages.h"
  37. #include "../IRC/IRC.h"
  38. #include "../Traits/Traits.h"
  39. #include "../Chat/Chat.h"
  40. #include "../Rules/Rules.h"
  41. #include "../AltAdvancement/AltAdvancement.h"
  42. #include "../RaceTypes/RaceTypes.h"
  43. #include "../classes.h"
  44. #include "../Transmute.h"
  45. #include "../Zone/SPGrid.h"
  46. #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 IRC irc;
  65. extern Chat chat;
  66. extern RuleManager rule_manager;
  67. extern MasterAAList master_aa_list;
  68. extern MasterRaceTypeList race_types_list;
  69. extern Classes classes;
  70. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  71. #if defined(__GNUC__)
  72. #define stricmp strcasecmp
  73. #define strnicmp strncasecmp
  74. #endif
  75. EQ2Packet* RemoteCommands::serialize(){
  76. buffer.clear();
  77. vector<EQ2_RemoteCommandString>::iterator command_list;
  78. buffer.append((char*)&num_commands, sizeof(int16));
  79. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  80. AddDataCommand(&(*command_list));
  81. }
  82. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  83. return app;
  84. }
  85. Commands::Commands(){
  86. remote_commands = new RemoteCommands();
  87. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  88. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  89. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  90. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  91. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  92. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  93. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  94. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  95. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  96. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  97. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  98. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  99. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  100. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  101. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  102. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  103. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  104. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  105. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  106. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  107. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  108. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  109. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  110. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  111. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  112. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  113. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  114. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  115. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  116. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  117. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  118. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  119. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  120. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  121. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  122. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  123. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  124. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  125. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  126. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  127. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  128. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  129. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  130. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  131. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  132. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  133. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  134. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  135. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  136. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  137. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  138. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  139. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  140. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  141. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  142. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  143. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  144. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  145. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  146. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  147. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  148. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  149. spawn_set_values["skin_color"] = SPAWN_SET_SKIN_COLOR;
  150. spawn_set_values["aaxp_rewards"] = SPAWN_SET_AAXP_REWARDS;
  151. spawn_set_values["hair_color1"] = SPAWN_SET_HAIR_COLOR1;
  152. spawn_set_values["hair_color2"] = SPAWN_SET_HAIR_COLOR2;
  153. spawn_set_values["hair_type_color"] = SPAWN_SET_HAIR_TYPE_COLOR;
  154. spawn_set_values["hair_face_color"] = SPAWN_SET_HAIR_FACE_COLOR;
  155. spawn_set_values["hair_type_highlight_color"] = SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR;
  156. spawn_set_values["face_hairlight_color"] = SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR;
  157. spawn_set_values["hair_highlight"] = SPAWN_SET_HAIR_HIGHLIGHT;
  158. spawn_set_values["model_color"] = SPAWN_SET_MODEL_COLOR;
  159. spawn_set_values["eye_color"] = SPAWN_SET_EYE_COLOR;
  160. spawn_set_values["soga_skin_color"] = SPAWN_SET_SOGA_SKIN_COLOR;
  161. spawn_set_values["soga_hair_color1"] = SPAWN_SET_SOGA_HAIR_COLOR1;
  162. spawn_set_values["soga_hair_color2"] = SPAWN_SET_SOGA_HAIR_COLOR2;
  163. spawn_set_values["soga_hair_type_color"] = SPAWN_SET_SOGA_HAIR_TYPE_COLOR;
  164. spawn_set_values["soga_hair_face_color"] = SPAWN_SET_SOGA_HAIR_FACE_COLOR;
  165. spawn_set_values["soga_hair_type_highlight_color"] = SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR;
  166. spawn_set_values["soga_face_hairlight_color"] = SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR;
  167. spawn_set_values["soga_hair_highlight"] = SPAWN_SET_SOGA_HAIR_HIGHLIGHT;
  168. spawn_set_values["soga_model_color"] = SPAWN_SET_SOGA_MODEL_COLOR;
  169. spawn_set_values["soga_eye_color"] = SPAWN_SET_SOGA_EYE_COLOR;
  170. spawn_set_values["cheek_type"] = SPAWN_SET_CHEEK_TYPE;
  171. spawn_set_values["chin_type"] = SPAWN_SET_CHIN_TYPE;
  172. spawn_set_values["ear_type"] = SPAWN_SET_EAR_TYPE;
  173. spawn_set_values["eye_brow_type"] = SPAWN_SET_EYE_BROW_TYPE;
  174. spawn_set_values["eye_type"] = SPAWN_SET_EYE_TYPE;
  175. spawn_set_values["lip_type"] = SPAWN_SET_LIP_TYPE;
  176. spawn_set_values["nose_type"] = SPAWN_SET_NOSE_TYPE;
  177. spawn_set_values["body_size"] = SPAWN_SET_BODY_SIZE;
  178. spawn_set_values["body_age"] = SPAWN_SET_BODY_AGE;
  179. spawn_set_values["soga_cheek_type"] = SPAWN_SET_SOGA_CHEEK_TYPE;
  180. spawn_set_values["soga_chin_type"] = SPAWN_SET_SOGA_CHIN_TYPE;
  181. spawn_set_values["soga_ear_type"] = SPAWN_SET_SOGA_EAR_TYPE;
  182. spawn_set_values["soga_eye_brow_type"] = SPAWN_SET_SOGA_EYE_BROW_TYPE;
  183. spawn_set_values["soga_eye_type"] = SPAWN_SET_SOGA_EYE_TYPE;
  184. spawn_set_values["soga_lip_type"] = SPAWN_SET_SOGA_LIP_TYPE;
  185. spawn_set_values["soga_nose_type"] = SPAWN_SET_SOGA_NOSE_TYPE;
  186. spawn_set_values["soga_body_size"] = SPAWN_SET_SOGA_BODY_SIZE;
  187. spawn_set_values["soga_body_age"] = SPAWN_SET_SOGA_BODY_AGE;
  188. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  189. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  190. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  191. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  192. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  193. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  194. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  195. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  196. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  197. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  198. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  199. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  200. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  201. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  202. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  203. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  204. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  205. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  206. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  207. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  208. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  209. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  210. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  211. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  212. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  213. }
  214. Commands::~Commands() {
  215. safe_delete(remote_commands);
  216. }
  217. int32 Commands::GetSpawnSetType(string val){
  218. if(spawn_set_values.count(val) > 0)
  219. return spawn_set_values[val];
  220. return 0xFFFFFFFF;
  221. }
  222. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value, int8 index){
  223. if(!target)
  224. return false;
  225. int32 val = 0;
  226. try{
  227. if(type != SPAWN_SET_VALUE_NAME &&
  228. !(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))
  229. {
  230. switch(type)
  231. {
  232. case SPAWN_SET_SKIN_COLOR:
  233. case SPAWN_SET_HAIR_COLOR1:
  234. case SPAWN_SET_HAIR_COLOR2:
  235. case SPAWN_SET_HAIR_TYPE_COLOR:
  236. case SPAWN_SET_HAIR_FACE_COLOR:
  237. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  238. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  239. case SPAWN_SET_HAIR_HIGHLIGHT:
  240. case SPAWN_SET_EYE_COLOR:
  241. case SPAWN_SET_SOGA_SKIN_COLOR:
  242. case SPAWN_SET_SOGA_HAIR_COLOR1:
  243. case SPAWN_SET_SOGA_HAIR_COLOR2:
  244. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  245. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  246. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  247. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  248. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  249. case SPAWN_SET_SOGA_EYE_COLOR:
  250. // ignore these are colors can't pass as a integer value
  251. break;
  252. default:
  253. val = atoul(value);
  254. }
  255. }
  256. }
  257. catch(...){
  258. if(client)
  259. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  260. return false;
  261. }
  262. if(temporary){
  263. char tmp[128] = {0};
  264. switch(type){
  265. case SPAWN_SET_VALUE_NAME:{
  266. sprintf(tmp, "%s", target->GetName());
  267. target->SetName(value);
  268. if(target->GetZone())
  269. target->GetZone()->SendUpdateTitles(target);
  270. break;
  271. }
  272. case SPAWN_SET_VALUE_X_OFFSET:
  273. {
  274. sprintf(tmp, "%f", target->GetXOffset());
  275. target->SetXOffset(float(val));
  276. break;
  277. }
  278. case SPAWN_SET_VALUE_Y_OFFSET:
  279. {
  280. sprintf(tmp, "%f", target->GetYOffset());
  281. target->SetYOffset(float(val));
  282. break;
  283. }
  284. case SPAWN_SET_VALUE_Z_OFFSET:
  285. {
  286. sprintf(tmp, "%f", target->GetZOffset());
  287. target->SetZOffset(float(val));
  288. break;
  289. }
  290. case SPAWN_SET_VALUE_EXPIRE: {
  291. sprintf(tmp, "%u", target->GetExpireTime());
  292. target->SetExpireTime(val);
  293. break;
  294. }
  295. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  296. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  297. target->SetExpireOffsetTime(val);
  298. break;
  299. }
  300. case SPAWN_SET_VALUE_SUB_TITLE: {
  301. sprintf(tmp, "%s", target->GetSubTitle());
  302. target->SetSubTitle(value);
  303. if(target->GetZone())
  304. target->GetZone()->SendUpdateTitles(target);
  305. break;
  306. }
  307. case SPAWN_SET_VALUE_LEVEL:{
  308. sprintf(tmp, "%i", target->GetLevel());
  309. target->SetLevel(val, send_update);
  310. break;
  311. }
  312. case SPAWN_SET_VALUE_DIFFICULTY:{
  313. sprintf(tmp, "%i", target->GetEncounterLevel());
  314. target->SetEncounterLevel(val, send_update);
  315. break;
  316. }
  317. case SPAWN_SET_VALUE_MODEL_TYPE:{
  318. sprintf(tmp, "%i", target->GetModelType());
  319. target->SetModelType(val, send_update);
  320. break;
  321. }
  322. case SPAWN_SET_VALUE_CLASS:{
  323. sprintf(tmp, "%i", target->GetAdventureClass());
  324. target->SetAdventureClass(val, send_update);
  325. break;
  326. }
  327. case SPAWN_SET_VALUE_GENDER:{
  328. sprintf(tmp, "%i", target->GetGender());
  329. target->SetGender(val, send_update);
  330. break;
  331. }
  332. case SPAWN_SET_VALUE_SHOW_NAME:{
  333. sprintf(tmp, "%i", target->GetShowName());
  334. target->SetShowName(val, send_update);
  335. break;
  336. }
  337. case SPAWN_SET_VALUE_ATTACKABLE:{
  338. sprintf(tmp, "%i", target->GetAttackable());
  339. target->SetAttackable(val, send_update);
  340. break;
  341. }
  342. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  343. sprintf(tmp, "%i", target->GetShowLevel());
  344. target->SetShowLevel(val, send_update);
  345. break;
  346. }
  347. case SPAWN_SET_VALUE_TARGETABLE:{
  348. sprintf(tmp, "%i", target->GetTargetable());
  349. target->SetTargetable(val, send_update);
  350. break;
  351. }
  352. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  353. sprintf(tmp, "%i", target->GetShowCommandIcon());
  354. target->SetShowCommandIcon(val, send_update);
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_HAND_ICON:{
  358. sprintf(tmp, "%i", target->GetShowHandIcon());
  359. target->SetShowHandIcon(val, send_update);
  360. break;
  361. }
  362. case SPAWN_SET_VALUE_HAIR_TYPE:{
  363. if(target->IsEntity()){
  364. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  365. ((Entity*)target)->SetHairType(val, send_update);
  366. }
  367. break;
  368. }
  369. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  370. if(target->IsEntity()){
  371. sprintf(tmp, "%i", ((Entity*)target)->GetFacialHairType());
  372. ((Entity*)target)->SetFacialHairType(val, send_update);
  373. }
  374. break;
  375. }
  376. case SPAWN_SET_VALUE_WING_TYPE:{
  377. if(target->IsEntity()){
  378. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  379. ((Entity*)target)->SetWingType(val, send_update);
  380. }
  381. break;
  382. }
  383. case SPAWN_SET_VALUE_CHEST_TYPE:{
  384. if(target->IsEntity()){
  385. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  386. ((Entity*)target)->SetChestType(val, send_update);
  387. }
  388. break;
  389. }
  390. case SPAWN_SET_VALUE_LEGS_TYPE:{
  391. if(target->IsEntity()){
  392. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  393. ((Entity*)target)->SetLegsType(val, send_update);
  394. }
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  398. if(target->IsEntity()){
  399. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  400. ((Entity*)target)->SetSogaHairType(val, send_update);
  401. }
  402. break;
  403. }
  404. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  405. if(target->IsEntity()){
  406. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  407. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  408. }
  409. break;
  410. }
  411. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  412. sprintf(tmp, "%i", target->GetSogaModelType());
  413. target->SetSogaModelType(val, send_update);
  414. break;
  415. }
  416. case SPAWN_SET_VALUE_SIZE:{
  417. sprintf(tmp, "%i", target->GetSize());
  418. target->SetSize(val, send_update);
  419. break;
  420. }
  421. case SPAWN_SET_VALUE_HP:{
  422. sprintf(tmp, "%i", target->GetHP());
  423. target->SetHP(val, send_update);
  424. break;
  425. }
  426. case SPAWN_SET_VALUE_POWER:{
  427. sprintf(tmp, "%i", target->GetPower());
  428. target->SetPower(val, send_update);
  429. break;
  430. }
  431. case SPAWN_SET_VALUE_HEROIC:{
  432. sprintf(tmp, "%i", target->GetHeroic());
  433. target->SetHeroic(val, send_update);
  434. break;
  435. }
  436. case SPAWN_SET_VALUE_RESPAWN:{
  437. sprintf(tmp, "%u", target->GetRespawnTime());
  438. target->SetRespawnTime(val);
  439. break;
  440. }
  441. case SPAWN_SET_VALUE_X:{
  442. sprintf(tmp, "%f", target->GetX());
  443. target->SetX(atof(value), send_update);
  444. break;
  445. }
  446. case SPAWN_SET_VALUE_Y:{
  447. sprintf(tmp, "%f", target->GetY());
  448. target->SetY(atof(value), send_update);
  449. break;
  450. }
  451. case SPAWN_SET_VALUE_Z:{
  452. sprintf(tmp, "%f", target->GetZ());
  453. target->SetZ(atof(value), send_update);
  454. break;
  455. }
  456. case SPAWN_SET_VALUE_HEADING:{
  457. sprintf(tmp, "%f", target->GetHeading());
  458. target->SetHeading(atof(value) + 360, send_update);
  459. break;
  460. }
  461. case SPAWN_SET_VALUE_VISUAL_STATE:{
  462. sprintf(tmp, "%i", target->GetVisualState());
  463. target->SetVisualState(val, send_update);
  464. break;
  465. }
  466. case SPAWN_SET_VALUE_ACTION_STATE:{
  467. sprintf(tmp, "%i", target->GetActionState());
  468. target->SetActionState(val, send_update);
  469. break;
  470. }
  471. case SPAWN_SET_VALUE_MOOD_STATE:{
  472. sprintf(tmp, "%i", target->GetMoodState());
  473. target->SetMoodState(val, send_update);
  474. break;
  475. }
  476. case SPAWN_SET_VALUE_INITIAL_STATE:{
  477. sprintf(tmp, "%i", target->GetInitialState());
  478. target->SetInitialState(val, send_update);
  479. break;
  480. }
  481. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  482. sprintf(tmp, "%i", target->GetActivityStatus());
  483. target->SetActivityStatus(val, send_update);
  484. break;
  485. }
  486. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  487. sprintf(tmp, "%i", target->GetCollisionRadius());
  488. target->SetCollisionRadius(val, send_update);
  489. break;
  490. }
  491. case SPAWN_SET_VALUE_DEVICE_ID: {
  492. if (target->IsObject()) {
  493. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  494. ((Object*)target)->SetDeviceID(val);
  495. }
  496. break;
  497. }
  498. case SPAWN_SET_VALUE_PITCH: {
  499. sprintf(tmp, "%f", target->GetPitch());
  500. target->SetPitch(atof(value), send_update);
  501. break;
  502. }
  503. case SPAWN_SET_VALUE_ROLL: {
  504. sprintf(tmp, "%f", target->GetRoll());
  505. target->SetRoll(atof(value), send_update);
  506. break;
  507. }
  508. case SPAWN_SET_VALUE_HIDE_HOOD: {
  509. sprintf(tmp, "%i", target->appearance.hide_hood);
  510. target->SetHideHood(val);
  511. break;
  512. }
  513. case SPAWN_SET_VALUE_EMOTE_STATE: {
  514. sprintf(tmp, "%i", target->appearance.emote_state);
  515. target->SetEmoteState(val);
  516. break;
  517. }
  518. case SPAWN_SET_VALUE_ICON: {
  519. sprintf(tmp, "%i", target->GetIconValue());
  520. target->SetIcon(val);
  521. break;
  522. }
  523. case SPAWN_SET_VALUE_PREFIX: {
  524. sprintf(tmp, "%s", target->GetPrefixTitle());
  525. target->SetPrefixTitle(value);
  526. if(target->GetZone())
  527. target->GetZone()->SendUpdateTitles(target);
  528. break;
  529. }
  530. case SPAWN_SET_VALUE_SUFFIX: {
  531. sprintf(tmp, "%s", target->GetSuffixTitle());
  532. target->SetSuffixTitle(value);
  533. if(target->GetZone())
  534. target->GetZone()->SendUpdateTitles(target);
  535. break;
  536. }
  537. case SPAWN_SET_VALUE_LASTNAME: {
  538. sprintf(tmp, "%s", target->GetLastName());
  539. target->SetLastName(value);
  540. if(target->GetZone())
  541. target->GetZone()->SendUpdateTitles(target);
  542. break;
  543. }
  544. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  545. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  546. // nothing to do must reload spawns
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  550. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  551. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  552. break;
  553. }
  554. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  555. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  556. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  557. break;
  558. }
  559. case SPAWN_SET_VALUE_FACTION:{
  560. sprintf(tmp, "%i", target->faction_id);
  561. ZoneServer* zone = target->GetZone();
  562. if (!zone && client)
  563. zone = client->GetCurrentZone();
  564. target->faction_id = atoul(value);
  565. if(zone)
  566. {
  567. zone->RemoveDeadEnemyList(target);
  568. if(target->IsNPC())
  569. zone->AddEnemyList((NPC*)target);
  570. }
  571. break;
  572. }
  573. case SPAWN_SET_SKIN_COLOR:
  574. case SPAWN_SET_HAIR_COLOR1:
  575. case SPAWN_SET_HAIR_COLOR2:
  576. case SPAWN_SET_HAIR_TYPE_COLOR:
  577. case SPAWN_SET_HAIR_FACE_COLOR:
  578. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  579. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  580. case SPAWN_SET_HAIR_HIGHLIGHT:
  581. case SPAWN_SET_MODEL_COLOR:
  582. case SPAWN_SET_EYE_COLOR:
  583. case SPAWN_SET_SOGA_SKIN_COLOR:
  584. case SPAWN_SET_SOGA_HAIR_COLOR1:
  585. case SPAWN_SET_SOGA_HAIR_COLOR2:
  586. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  587. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  588. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  589. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  590. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  591. case SPAWN_SET_SOGA_MODEL_COLOR:
  592. case SPAWN_SET_SOGA_EYE_COLOR:
  593. {
  594. if (target->IsEntity())
  595. {
  596. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  597. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  598. {
  599. EQ2_Color clr;
  600. clr.red = atoul(skinsep->arg[0]);
  601. clr.green = atoul(skinsep->arg[1]);
  602. clr.blue = atoul(skinsep->arg[2]);
  603. switch(type)
  604. {
  605. case SPAWN_SET_SKIN_COLOR:
  606. ((Entity*)target)->SetSkinColor(clr);
  607. break;
  608. case SPAWN_SET_HAIR_COLOR1:
  609. ((Entity*)target)->SetHairColor1(clr);
  610. break;
  611. case SPAWN_SET_HAIR_COLOR2:
  612. ((Entity*)target)->SetHairColor2(clr);
  613. break;
  614. case SPAWN_SET_HAIR_TYPE_COLOR:
  615. ((Entity*)target)->SetHairColor(clr);
  616. break;
  617. case SPAWN_SET_HAIR_FACE_COLOR:
  618. ((Entity*)target)->SetFacialHairColor(clr);
  619. break;
  620. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  621. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  622. break;
  623. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  624. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  625. break;
  626. case SPAWN_SET_HAIR_HIGHLIGHT:
  627. ((Entity*)target)->SetHairHighlightColor(clr);
  628. break;
  629. case SPAWN_SET_MODEL_COLOR:
  630. ((Entity*)target)->SetModelColor(clr);
  631. break;
  632. case SPAWN_SET_EYE_COLOR:
  633. ((Entity*)target)->SetEyeColor(clr);
  634. break;
  635. case SPAWN_SET_SOGA_SKIN_COLOR:
  636. ((Entity*)target)->SetSogaSkinColor(clr);
  637. break;
  638. case SPAWN_SET_SOGA_HAIR_COLOR1:
  639. ((Entity*)target)->SetSogaHairColor1(clr);
  640. break;
  641. case SPAWN_SET_SOGA_HAIR_COLOR2:
  642. ((Entity*)target)->SetSogaHairColor2(clr);
  643. break;
  644. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  645. ((Entity*)target)->SetSogaHairColor(clr);
  646. break;
  647. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  648. ((Entity*)target)->SetSogaFacialHairColor(clr);
  649. break;
  650. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  651. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  652. break;
  653. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  654. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  655. break;
  656. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  657. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  658. break;
  659. case SPAWN_SET_SOGA_MODEL_COLOR:
  660. ((Entity*)target)->SetSogaModelColor(clr);
  661. break;
  662. case SPAWN_SET_SOGA_EYE_COLOR:
  663. ((Entity*)target)->SetSogaEyeColor(clr);
  664. break;
  665. }
  666. }
  667. safe_delete(skinsep);
  668. }
  669. break;
  670. }
  671. case SPAWN_SET_AAXP_REWARDS: {
  672. target->SetAAXPRewards(atoul(value));
  673. break;
  674. }
  675. case SPAWN_SET_CHEEK_TYPE:{
  676. if(target->IsEntity() && index < 3){
  677. sprintf(tmp, "%i", ((Entity*)target)->features.cheek_type[index]);
  678. sint8 new_value = atoi(value);
  679. ((Entity*)target)->features.cheek_type[index] = new_value;
  680. ((Entity*)target)->info_changed = true;
  681. }
  682. break;
  683. }
  684. case SPAWN_SET_CHIN_TYPE:{
  685. if(target->IsEntity() && index < 3){
  686. sprintf(tmp, "%i", ((Entity*)target)->features.chin_type[index]);
  687. sint8 new_value = atoi(value);
  688. ((Entity*)target)->features.chin_type[index] = new_value;
  689. ((Entity*)target)->info_changed = true;
  690. }
  691. break;
  692. }
  693. case SPAWN_SET_EAR_TYPE:{
  694. if(target->IsEntity() && index < 3){
  695. sprintf(tmp, "%i", ((Entity*)target)->features.ear_type[index]);
  696. sint8 new_value = atoi(value);
  697. ((Entity*)target)->features.ear_type[index] = new_value;
  698. ((Entity*)target)->info_changed = true;
  699. }
  700. break;
  701. }
  702. case SPAWN_SET_EYE_BROW_TYPE:{
  703. if(target->IsEntity() && index < 3){
  704. sprintf(tmp, "%i", ((Entity*)target)->features.eye_brow_type[index]);
  705. sint8 new_value = atoi(value);
  706. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  707. ((Entity*)target)->info_changed = true;
  708. }
  709. break;
  710. }
  711. case SPAWN_SET_EYE_TYPE:{
  712. if(target->IsEntity() && index < 3){
  713. sprintf(tmp, "%i", ((Entity*)target)->features.eye_type[index]);
  714. sint8 new_value = atoi(value);
  715. ((Entity*)target)->features.eye_type[index] = new_value;
  716. ((Entity*)target)->info_changed = true;
  717. }
  718. break;
  719. }
  720. case SPAWN_SET_LIP_TYPE:{
  721. if(target->IsEntity() && index < 3){
  722. sprintf(tmp, "%i", ((Entity*)target)->features.lip_type[index]);
  723. sint8 new_value = atoi(value);
  724. ((Entity*)target)->features.lip_type[index] = new_value;
  725. ((Entity*)target)->info_changed = true;
  726. }
  727. break;
  728. }
  729. case SPAWN_SET_NOSE_TYPE:{
  730. if(target->IsEntity() && index < 3){
  731. sprintf(tmp, "%i", ((Entity*)target)->features.nose_type[index]);
  732. sint8 new_value = atoi(value);
  733. ((Entity*)target)->features.nose_type[index] = new_value;
  734. ((Entity*)target)->info_changed = true;
  735. }
  736. break;
  737. }
  738. case SPAWN_SET_BODY_SIZE:{
  739. if(target->IsEntity()){
  740. sprintf(tmp, "%i", ((Entity*)target)->features.body_size);
  741. int8 new_value = atoul(value);
  742. ((Entity*)target)->features.body_size = new_value;
  743. ((Entity*)target)->info_changed = true;
  744. }
  745. break;
  746. }
  747. case SPAWN_SET_BODY_AGE:{
  748. if(target->IsEntity()){
  749. sprintf(tmp, "%i", ((Entity*)target)->features.body_age);
  750. int8 new_value = atoul(value);
  751. ((Entity*)target)->features.body_age = new_value;
  752. ((Entity*)target)->info_changed = true;
  753. }
  754. break;
  755. }
  756. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  757. if(target->IsEntity() && index < 3){
  758. sprintf(tmp, "%i", ((Entity*)target)->features.soga_cheek_type[index]);
  759. sint8 new_value = atoi(value);
  760. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  761. ((Entity*)target)->info_changed = true;
  762. }
  763. break;
  764. }
  765. case SPAWN_SET_SOGA_CHIN_TYPE:{
  766. if(target->IsEntity() && index < 3){
  767. sprintf(tmp, "%i", ((Entity*)target)->features.soga_chin_type[index]);
  768. sint8 new_value = atoi(value);
  769. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  770. ((Entity*)target)->info_changed = true;
  771. }
  772. break;
  773. }
  774. case SPAWN_SET_SOGA_EAR_TYPE:{
  775. if(target->IsEntity() && index < 3){
  776. sprintf(tmp, "%i", ((Entity*)target)->features.soga_ear_type[index]);
  777. sint8 new_value = atoi(value);
  778. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  779. ((Entity*)target)->info_changed = true;
  780. }
  781. break;
  782. }
  783. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  784. if(target->IsEntity() && index < 3){
  785. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_brow_type[index]);
  786. sint8 new_value = atoi(value);
  787. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  788. ((Entity*)target)->info_changed = true;
  789. }
  790. break;
  791. }
  792. case SPAWN_SET_SOGA_EYE_TYPE:{
  793. if(target->IsEntity() && index < 3){
  794. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_type[index]);
  795. sint8 new_value = atoi(value);
  796. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  797. ((Entity*)target)->info_changed = true;
  798. }
  799. break;
  800. }
  801. case SPAWN_SET_SOGA_LIP_TYPE:{
  802. if(target->IsEntity() && index < 3){
  803. sprintf(tmp, "%i", ((Entity*)target)->features.soga_lip_type[index]);
  804. sint8 new_value = atoi(value);
  805. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  806. ((Entity*)target)->info_changed = true;
  807. }
  808. break;
  809. }
  810. case SPAWN_SET_SOGA_BODY_SIZE:{
  811. if(target->IsEntity()){
  812. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_size);
  813. int8 new_value = atoul(value);
  814. ((Entity*)target)->features.soga_body_size = new_value;
  815. ((Entity*)target)->info_changed = true;
  816. }
  817. break;
  818. }
  819. case SPAWN_SET_SOGA_BODY_AGE:{
  820. if(target->IsEntity()){
  821. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_age);
  822. int8 new_value = atoul(value);
  823. ((Entity*)target)->features.soga_body_age = new_value;
  824. ((Entity*)target)->info_changed = true;
  825. }
  826. break;
  827. }
  828. if(temp_value)
  829. *temp_value = string(tmp);
  830. }
  831. }
  832. else{
  833. /**** NOT TEMPORARY ELSE STATEMENT ****/
  834. /**** MUST RE-DEFINE WHAT IS ALREADY IN THE IF TEMPORARY BLOCK HERE ****/
  835. switch(type){
  836. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  837. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  838. break;
  839. }
  840. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  841. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  842. break;
  843. }
  844. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  845. if (target->GetDatabaseID() > 0)
  846. {
  847. char query[256];
  848. snprintf(query, 256, "update spawn set expansion_flag=%u where id=%i", atoul(value), target->GetDatabaseID());
  849. if (database.RunQuery(query, strnlen(query, 256)))
  850. {
  851. if(client)
  852. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  853. }
  854. }
  855. break;
  856. }
  857. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  858. if (target->GetDatabaseID() > 0)
  859. {
  860. char query[256];
  861. snprintf(query, 256, "update spawn set holiday_flag=%u where id=%i", atoul(value), target->GetDatabaseID());
  862. if (database.RunQuery(query, strnlen(query, 256)))
  863. {
  864. if(client)
  865. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  866. }
  867. }
  868. break;
  869. }
  870. case SPAWN_SET_AAXP_REWARDS: {
  871. if (target->GetDatabaseID() > 0)
  872. {
  873. char query[256];
  874. snprintf(query, 256, "update spawn set aaxp_rewards=%u where id=%i", atoul(value), target->GetDatabaseID());
  875. if (database.RunQuery(query, strnlen(query, 256)))
  876. {
  877. if(client)
  878. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  879. }
  880. }
  881. break;
  882. }
  883. case SPAWN_SET_VALUE_NAME:{
  884. target->SetName(value);
  885. if(target->GetZone())
  886. target->GetZone()->SendUpdateTitles(target);
  887. break;
  888. }
  889. case SPAWN_SET_VALUE_SUB_TITLE: {
  890. target->SetSubTitle(value);
  891. if(target->GetZone())
  892. target->GetZone()->SendUpdateTitles(target);
  893. break;
  894. }
  895. case SPAWN_SET_VALUE_X_OFFSET:
  896. {
  897. target->SetXOffset(atof(value));
  898. break;
  899. }
  900. case SPAWN_SET_VALUE_Y_OFFSET:
  901. {
  902. target->SetYOffset(atof(value));
  903. break;
  904. }
  905. case SPAWN_SET_VALUE_Z_OFFSET:
  906. {
  907. target->SetZOffset(atof(value));
  908. break;
  909. }
  910. case SPAWN_SET_VALUE_EXPIRE: {
  911. target->SetExpireTime(val);
  912. break;
  913. }
  914. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  915. target->SetExpireOffsetTime(val);
  916. break;
  917. }
  918. case SPAWN_SET_VALUE_LEVEL:{
  919. target->SetLevel(val, send_update);
  920. break;
  921. }
  922. case SPAWN_SET_VALUE_DIFFICULTY:{
  923. target->SetEncounterLevel(val, send_update);
  924. break;
  925. }
  926. case SPAWN_SET_VALUE_MODEL_TYPE:{
  927. target->SetModelType(val, send_update);
  928. break;
  929. }
  930. case SPAWN_SET_VALUE_CLASS:{
  931. target->SetAdventureClass(val, send_update);
  932. break;
  933. }
  934. case SPAWN_SET_VALUE_GENDER:{
  935. target->SetGender(val, send_update);
  936. break;
  937. }
  938. case SPAWN_SET_VALUE_SHOW_NAME:{
  939. target->SetShowName(val, send_update);
  940. break;
  941. }
  942. case SPAWN_SET_VALUE_ATTACKABLE:{
  943. target->SetAttackable(val, send_update);
  944. break;
  945. }
  946. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  947. target->SetShowLevel(val, send_update);
  948. break;
  949. }
  950. case SPAWN_SET_VALUE_TARGETABLE:{
  951. target->SetTargetable(val, send_update);
  952. break;
  953. }
  954. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  955. target->SetShowCommandIcon(val, send_update);
  956. break;
  957. }
  958. case SPAWN_SET_VALUE_HAND_ICON:{
  959. target->SetShowHandIcon(val, send_update);
  960. break;
  961. }
  962. case SPAWN_SET_VALUE_HAIR_TYPE:{
  963. if(target->IsEntity())
  964. ((Entity*)target)->SetHairType(val, send_update);
  965. break;
  966. }
  967. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  968. if(target->IsEntity())
  969. ((Entity*)target)->SetFacialHairType(val, send_update);
  970. break;
  971. }
  972. case SPAWN_SET_VALUE_WING_TYPE:{
  973. if(target->IsEntity())
  974. ((Entity*)target)->SetWingType(val, send_update);
  975. break;
  976. }
  977. case SPAWN_SET_VALUE_CHEST_TYPE:{
  978. if(target->IsEntity())
  979. ((Entity*)target)->SetChestType(val, send_update);
  980. break;
  981. }
  982. case SPAWN_SET_VALUE_LEGS_TYPE:{
  983. if(target->IsEntity())
  984. ((Entity*)target)->SetLegsType(val, send_update);
  985. break;
  986. }
  987. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  988. if(target->IsEntity())
  989. ((Entity*)target)->SetSogaHairType(val, send_update);
  990. break;
  991. }
  992. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  993. if(target->IsEntity())
  994. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  995. break;
  996. }
  997. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  998. target->SetSogaModelType(val, send_update);
  999. break;
  1000. }
  1001. case SPAWN_SET_VALUE_SIZE:{
  1002. target->SetSize(val, send_update);
  1003. break;
  1004. }
  1005. case SPAWN_SET_VALUE_HP:{
  1006. target->SetHP(val, send_update);
  1007. break;
  1008. }
  1009. case SPAWN_SET_VALUE_POWER:{
  1010. target->SetPower(val, send_update);
  1011. break;
  1012. }
  1013. case SPAWN_SET_VALUE_HEROIC:{
  1014. target->SetHeroic(val, send_update);
  1015. break;
  1016. }
  1017. case SPAWN_SET_VALUE_RESPAWN:{
  1018. target->SetRespawnTime(val);
  1019. break;
  1020. }
  1021. case SPAWN_SET_VALUE_X:{
  1022. target->SetX(atof(value), send_update);
  1023. target->SetSpawnOrigX(target->GetX());
  1024. break;
  1025. }
  1026. case SPAWN_SET_VALUE_Y:{
  1027. target->SetY(atof(value), send_update);
  1028. target->SetSpawnOrigY(target->GetY());
  1029. break;
  1030. }
  1031. case SPAWN_SET_VALUE_Z:{
  1032. target->SetZ(atof(value), send_update);
  1033. target->SetSpawnOrigZ(target->GetZ());
  1034. break;
  1035. }
  1036. case SPAWN_SET_VALUE_HEADING:{
  1037. target->SetHeading(atof(value), send_update);
  1038. target->SetSpawnOrigHeading(target->GetHeading());
  1039. break;
  1040. }
  1041. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  1042. ZoneServer* zone = target->GetZone();
  1043. if (!zone && client)
  1044. zone = client->GetCurrentZone();
  1045. if(zone && zone->GetEntityCommandList(val))
  1046. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  1047. target->primary_command_list_id = val;
  1048. break;
  1049. }
  1050. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  1051. ZoneServer* zone = target->GetZone();
  1052. if (!zone && client)
  1053. zone = client->GetCurrentZone();
  1054. if (zone && zone->GetEntityCommandList(val))
  1055. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  1056. target->secondary_command_list_id = val;
  1057. break;
  1058. }
  1059. case SPAWN_SET_VALUE_VISUAL_STATE:{
  1060. target->SetVisualState(val, send_update);
  1061. break;
  1062. }
  1063. case SPAWN_SET_VALUE_ACTION_STATE:{
  1064. target->SetActionState(val, send_update);
  1065. break;
  1066. }
  1067. case SPAWN_SET_VALUE_MOOD_STATE:{
  1068. target->SetMoodState(val, send_update);
  1069. break;
  1070. }
  1071. case SPAWN_SET_VALUE_INITIAL_STATE:{
  1072. target->SetInitialState(val, send_update);
  1073. break;
  1074. }
  1075. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  1076. target->SetActivityStatus(val, send_update);
  1077. break;
  1078. }
  1079. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  1080. target->SetCollisionRadius(val, send_update);
  1081. break;
  1082. }
  1083. case SPAWN_SET_VALUE_FACTION:{
  1084. ZoneServer* zone = target->GetZone();
  1085. if (!zone && client)
  1086. zone = client->GetCurrentZone();
  1087. target->faction_id = val;
  1088. if(zone)
  1089. {
  1090. zone->RemoveDeadEnemyList(target);
  1091. if(target->IsNPC())
  1092. zone->AddEnemyList((NPC*)target);
  1093. }
  1094. break;
  1095. }
  1096. case SPAWN_SET_VALUE_DEVICE_ID:{
  1097. if (target->IsObject())
  1098. ((Object*)target)->SetDeviceID(val);
  1099. break;
  1100. }
  1101. case SPAWN_SET_VALUE_PITCH: {
  1102. target->SetPitch(atof(value), send_update);
  1103. target->SetSpawnOrigPitch(atof(value));
  1104. break;
  1105. }
  1106. case SPAWN_SET_VALUE_ROLL: {
  1107. target->SetRoll(atof(value), send_update);
  1108. target->SetSpawnOrigRoll(atof(value));
  1109. break;
  1110. }
  1111. case SPAWN_SET_VALUE_HIDE_HOOD: {
  1112. target->SetHideHood(val);
  1113. break;
  1114. }
  1115. case SPAWN_SET_VALUE_EMOTE_STATE: {
  1116. target->SetEmoteState(val);
  1117. break;
  1118. }
  1119. case SPAWN_SET_VALUE_ICON: {
  1120. target->SetIcon(val);
  1121. break;
  1122. }
  1123. case SPAWN_SET_VALUE_PREFIX: {
  1124. target->SetPrefixTitle(value);
  1125. if(target->GetZone())
  1126. target->GetZone()->SendUpdateTitles(target);
  1127. break;
  1128. }
  1129. case SPAWN_SET_VALUE_SUFFIX: {
  1130. target->SetSuffixTitle(value);
  1131. if(target->GetZone())
  1132. target->GetZone()->SendUpdateTitles(target);
  1133. break;
  1134. }
  1135. case SPAWN_SET_VALUE_LASTNAME: {
  1136. target->SetLastName(value);
  1137. if(target->GetZone())
  1138. target->GetZone()->SendUpdateTitles(target);
  1139. break;
  1140. }
  1141. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  1142. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1143. if(client){
  1144. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1145. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  1146. }
  1147. return false;
  1148. }
  1149. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  1150. return false;
  1151. else{
  1152. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  1153. target->SetSpawnScript(value);
  1154. }
  1155. break;
  1156. }
  1157. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  1158. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1159. if(client){
  1160. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1161. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  1162. }
  1163. return false;
  1164. }
  1165. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  1166. return false;
  1167. else{
  1168. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  1169. target->SetSpawnScript(value);
  1170. }
  1171. break;
  1172. }
  1173. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  1174. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1175. if(client){
  1176. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1177. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  1178. }
  1179. return false;
  1180. }
  1181. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  1182. return false;
  1183. else
  1184. target->SetSpawnScript(value);
  1185. break;
  1186. }
  1187. case SPAWN_SET_SKIN_COLOR:
  1188. case SPAWN_SET_HAIR_COLOR1:
  1189. case SPAWN_SET_HAIR_COLOR2:
  1190. case SPAWN_SET_HAIR_TYPE_COLOR:
  1191. case SPAWN_SET_HAIR_FACE_COLOR:
  1192. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1193. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1194. case SPAWN_SET_HAIR_HIGHLIGHT:
  1195. case SPAWN_SET_MODEL_COLOR:
  1196. case SPAWN_SET_EYE_COLOR:
  1197. case SPAWN_SET_SOGA_SKIN_COLOR:
  1198. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1199. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1200. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1201. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1202. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1203. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1204. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1205. case SPAWN_SET_SOGA_MODEL_COLOR:
  1206. case SPAWN_SET_SOGA_EYE_COLOR: {
  1207. if (target->IsNPC())
  1208. {
  1209. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  1210. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  1211. {
  1212. EQ2_Color clr;
  1213. clr.red = atoul(skinsep->arg[0]);
  1214. clr.green = atoul(skinsep->arg[1]);
  1215. clr.blue = atoul(skinsep->arg[2]);
  1216. Query replaceSkinQuery;
  1217. string fieldName("");
  1218. switch(type)
  1219. {
  1220. case SPAWN_SET_SKIN_COLOR:
  1221. ((Entity*)target)->SetSkinColor(clr);
  1222. fieldName.append("skin_color");
  1223. break;
  1224. case SPAWN_SET_HAIR_COLOR1:
  1225. ((Entity*)target)->SetHairColor1(clr);
  1226. fieldName.append("hair_color1");
  1227. break;
  1228. case SPAWN_SET_HAIR_COLOR2:
  1229. ((Entity*)target)->SetHairColor2(clr);
  1230. fieldName.append("hair_color2");
  1231. break;
  1232. case SPAWN_SET_HAIR_TYPE_COLOR:
  1233. ((Entity*)target)->SetHairColor(clr);
  1234. fieldName.append("hair_type_color");
  1235. break;
  1236. case SPAWN_SET_HAIR_FACE_COLOR:
  1237. ((Entity*)target)->SetFacialHairColor(clr);
  1238. fieldName.append("hair_face_color");
  1239. break;
  1240. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1241. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  1242. fieldName.append("hair_type_highlight_color");
  1243. break;
  1244. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1245. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  1246. fieldName.append("hair_face_highlight_color");
  1247. break;
  1248. case SPAWN_SET_HAIR_HIGHLIGHT:
  1249. ((Entity*)target)->SetHairHighlightColor(clr);
  1250. fieldName.append("hair_highlight");
  1251. break;
  1252. case SPAWN_SET_MODEL_COLOR:
  1253. ((Entity*)target)->SetModelColor(clr);
  1254. fieldName.append("model_color");
  1255. break;
  1256. case SPAWN_SET_EYE_COLOR:
  1257. ((Entity*)target)->SetEyeColor(clr);
  1258. fieldName.append("eye_color");
  1259. break;
  1260. case SPAWN_SET_SOGA_SKIN_COLOR:
  1261. ((Entity*)target)->SetSogaSkinColor(clr);
  1262. fieldName.append("soga_skin_color");
  1263. break;
  1264. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1265. ((Entity*)target)->SetSogaHairColor1(clr);
  1266. fieldName.append("soga_hair_color1");
  1267. break;
  1268. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1269. ((Entity*)target)->SetSogaHairColor2(clr);
  1270. fieldName.append("soga_hair_color2");
  1271. break;
  1272. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1273. ((Entity*)target)->SetSogaHairColor(clr);
  1274. fieldName.append("soga_hair_type_color");
  1275. break;
  1276. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1277. ((Entity*)target)->SetSogaFacialHairColor(clr);
  1278. fieldName.append("soga_hair_face_color");
  1279. break;
  1280. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1281. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  1282. fieldName.append("soga_hair_type_highlight_color");
  1283. break;
  1284. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1285. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  1286. fieldName.append("soga_hair_face_highlight_color");
  1287. break;
  1288. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1289. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  1290. fieldName.append("soga_hair_highlight");
  1291. break;
  1292. case SPAWN_SET_SOGA_MODEL_COLOR:
  1293. ((Entity*)target)->SetSogaModelColor(clr);
  1294. fieldName.append("soga_model_color");
  1295. break;
  1296. case SPAWN_SET_SOGA_EYE_COLOR:
  1297. ((Entity*)target)->SetSogaEyeColor(clr);
  1298. fieldName.append("soga_eye_color");
  1299. break;
  1300. }
  1301. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1302. 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);
  1303. }
  1304. safe_delete(skinsep);
  1305. }
  1306. break;
  1307. }
  1308. case SPAWN_SET_CHEEK_TYPE:{
  1309. if(target->IsEntity() && index < 3){
  1310. sint8 new_value = atoi(value);
  1311. ((Entity*)target)->features.cheek_type[index] = new_value;
  1312. UpdateDatabaseAppearance(client, target, "cheek_type", ((Entity*)target)->features.cheek_type[0], ((Entity*)target)->features.cheek_type[1], ((Entity*)target)->features.cheek_type[2]);
  1313. }
  1314. break;
  1315. }
  1316. case SPAWN_SET_CHIN_TYPE:{
  1317. if(target->IsEntity() && index < 3){
  1318. sint8 new_value = atoi(value);
  1319. ((Entity*)target)->features.chin_type[index] = new_value;
  1320. UpdateDatabaseAppearance(client, target, "chin_type", ((Entity*)target)->features.chin_type[0], ((Entity*)target)->features.chin_type[1], ((Entity*)target)->features.chin_type[2]);
  1321. }
  1322. break;
  1323. }
  1324. case SPAWN_SET_EAR_TYPE:{
  1325. if(target->IsEntity() && index < 3){
  1326. sint8 new_value = atoi(value);
  1327. ((Entity*)target)->features.ear_type[index] = new_value;
  1328. UpdateDatabaseAppearance(client, target, "ear_type", ((Entity*)target)->features.ear_type[0], ((Entity*)target)->features.ear_type[1], ((Entity*)target)->features.ear_type[2]);
  1329. }
  1330. break;
  1331. }
  1332. case SPAWN_SET_EYE_BROW_TYPE:{
  1333. if(target->IsEntity() && index < 3){
  1334. sint8 new_value = atoi(value);
  1335. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  1336. 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]);
  1337. }
  1338. break;
  1339. }
  1340. case SPAWN_SET_EYE_TYPE:{
  1341. if(target->IsEntity() && index < 3){
  1342. sint8 new_value = atoi(value);
  1343. ((Entity*)target)->features.eye_type[index] = new_value;
  1344. UpdateDatabaseAppearance(client, target, "eye_type", ((Entity*)target)->features.eye_type[0], ((Entity*)target)->features.eye_type[1], ((Entity*)target)->features.eye_type[2]);
  1345. }
  1346. break;
  1347. }
  1348. case SPAWN_SET_LIP_TYPE:{
  1349. if(target->IsEntity() && index < 3){
  1350. sint8 new_value = atoi(value);
  1351. ((Entity*)target)->features.lip_type[index] = new_value;
  1352. UpdateDatabaseAppearance(client, target, "lip_type", ((Entity*)target)->features.lip_type[0], ((Entity*)target)->features.lip_type[1], ((Entity*)target)->features.lip_type[2]);
  1353. }
  1354. break;
  1355. }
  1356. case SPAWN_SET_NOSE_TYPE:{
  1357. if(target->IsEntity() && index < 3){
  1358. sint8 new_value = atoi(value);
  1359. ((Entity*)target)->features.nose_type[index] = new_value;
  1360. UpdateDatabaseAppearance(client, target, "nose_type", ((Entity*)target)->features.nose_type[0], ((Entity*)target)->features.nose_type[1], ((Entity*)target)->features.nose_type[2]);
  1361. }
  1362. break;
  1363. }
  1364. case SPAWN_SET_BODY_SIZE:{
  1365. if(target->IsEntity()){
  1366. int8 new_value = atoul(value);
  1367. ((Entity*)target)->features.body_size = new_value;
  1368. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1369. }
  1370. break;
  1371. }
  1372. case SPAWN_SET_BODY_AGE:{
  1373. if(target->IsEntity()){
  1374. int8 new_value = atoul(value);
  1375. ((Entity*)target)->features.body_age = new_value;
  1376. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1377. }
  1378. break;
  1379. }
  1380. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  1381. if(target->IsEntity() && index < 3){
  1382. sint8 new_value = atoi(value);
  1383. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  1384. 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]);
  1385. }
  1386. break;
  1387. }
  1388. case SPAWN_SET_SOGA_CHIN_TYPE:{
  1389. if(target->IsEntity() && index < 3){
  1390. sint8 new_value = atoi(value);
  1391. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  1392. 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]);
  1393. }
  1394. break;
  1395. }
  1396. case SPAWN_SET_SOGA_EAR_TYPE:{
  1397. if(target->IsEntity() && index < 3){
  1398. sint8 new_value = atoi(value);
  1399. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  1400. 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]);
  1401. }
  1402. break;
  1403. }
  1404. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  1405. if(target->IsEntity() && index < 3){
  1406. sint8 new_value = atoi(value);
  1407. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  1408. 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]);
  1409. }
  1410. break;
  1411. }
  1412. case SPAWN_SET_SOGA_EYE_TYPE:{
  1413. if(target->IsEntity() && index < 3){
  1414. sint8 new_value = atoi(value);
  1415. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  1416. 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]);
  1417. }
  1418. break;
  1419. }
  1420. case SPAWN_SET_SOGA_LIP_TYPE:{
  1421. if(target->IsEntity() && index < 3){
  1422. sint8 new_value = atoi(value);
  1423. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  1424. 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]);
  1425. }
  1426. break;
  1427. }
  1428. case SPAWN_SET_SOGA_NOSE_TYPE:{
  1429. if(target->IsEntity() && index < 3){
  1430. sint8 new_value = atoi(value);
  1431. ((Entity*)target)->features.soga_nose_type[index] = new_value;
  1432. 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]);
  1433. }
  1434. break;
  1435. }
  1436. case SPAWN_SET_SOGA_BODY_SIZE:{
  1437. if(target->IsEntity()){
  1438. int8 new_value = atoul(value);
  1439. ((Entity*)target)->features.body_size = new_value;
  1440. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1441. }
  1442. break;
  1443. }
  1444. case SPAWN_SET_SOGA_BODY_AGE:{
  1445. if(target->IsEntity()){
  1446. int8 new_value = atoul(value);
  1447. ((Entity*)target)->features.body_age = new_value;
  1448. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1449. }
  1450. break;
  1451. }
  1452. }
  1453. }
  1454. return true;
  1455. }
  1456. void Commands::UpdateDatabaseAppearance(Client* client, Spawn* target, string fieldName, sint8 r, sint8 g, sint8 b)
  1457. {
  1458. Query replaceQuery;
  1459. if(target->IsBot())
  1460. {
  1461. Bot* bot = (Bot*)target;
  1462. if(bot->BotID)
  1463. database.SaveBotFloats(bot->BotID, fieldName.c_str(), r, g, b);
  1464. }
  1465. else if(target->IsPlayer())
  1466. {
  1467. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from char_colors where char_id=%u and type='%s'", ((Player*)target)->GetCharacterID(), fieldName.c_str());
  1468. 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);
  1469. }
  1470. else
  1471. {
  1472. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1473. 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);
  1474. }
  1475. ((Entity*)target)->changed = true;
  1476. ((Entity*)target)->info_changed = true;
  1477. if(target->GetZone())
  1478. target->GetZone()->AddChangedSpawn(target);
  1479. }
  1480. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  1481. the database fields always and also update the zone in memory if it's running. */
  1482. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  1483. if (client && zone_id > 0 && type > 0 && value) {
  1484. sint32 int_value = 0;
  1485. float float_value = 0;
  1486. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  1487. try {
  1488. float_value = atof(value);
  1489. }
  1490. catch (...) {
  1491. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  1492. return false;
  1493. }
  1494. }
  1495. 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) {
  1496. try {
  1497. int_value = atoi(value);
  1498. }
  1499. catch (...) {
  1500. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  1501. return false;
  1502. }
  1503. }
  1504. switch (type) {
  1505. case ZONE_SET_VALUE_EXPANSION_ID: {
  1506. break;
  1507. }
  1508. case ZONE_SET_VALUE_NAME: {
  1509. if (zone)
  1510. zone->SetZoneName(const_cast<char*>(value));
  1511. database.SaveZoneInfo(zone_id, "name", value);
  1512. break;
  1513. }
  1514. case ZONE_SET_VALUE_FILE: {
  1515. if (zone)
  1516. zone->SetZoneFile(const_cast<char*>(value));
  1517. database.SaveZoneInfo(zone_id, "file", value);
  1518. break;
  1519. }
  1520. case ZONE_SET_VALUE_DESCRIPTION: {
  1521. if (zone)
  1522. zone->SetZoneDescription(const_cast<char*>(value));
  1523. database.SaveZoneInfo(zone_id, "description", value);
  1524. break;
  1525. }
  1526. case ZONE_SET_VALUE_SAFE_X: {
  1527. if (zone)
  1528. zone->SetSafeX(float_value);
  1529. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  1530. break;
  1531. }
  1532. case ZONE_SET_VALUE_SAFE_Y: {
  1533. if (zone)
  1534. zone->SetSafeY(float_value);
  1535. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  1536. break;
  1537. }
  1538. case ZONE_SET_VALUE_SAFE_Z: {
  1539. if (zone)
  1540. zone->SetSafeZ(float_value);
  1541. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  1542. break;
  1543. }
  1544. case ZONE_SET_VALUE_UNDERWORLD: {
  1545. if (zone)
  1546. zone->SetUnderWorld(float_value);
  1547. database.SaveZoneInfo(zone_id, "underworld", float_value);
  1548. break;
  1549. }
  1550. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  1551. break;
  1552. }
  1553. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  1554. break;
  1555. }
  1556. case ZONE_SET_VALUE_ZONE_TYPE: {
  1557. break;
  1558. }
  1559. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  1560. if (zone)
  1561. zone->SetAlwaysLoaded(int_value == 1);
  1562. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  1563. break;
  1564. }
  1565. case ZONE_SET_VALUE_CITY_ZONE: {
  1566. if (zone)
  1567. zone->SetCityZone(int_value == 1);
  1568. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  1569. break;
  1570. }
  1571. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  1572. if (zone)
  1573. zone->SetWeatherAllowed(int_value == 1);
  1574. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  1575. break;
  1576. }
  1577. case ZONE_SET_VALUE_MIN_STATUS: {
  1578. if (zone)
  1579. zone->SetMinimumStatus(int_value);
  1580. database.SaveZoneInfo(zone_id, "min_status", int_value);
  1581. break;
  1582. }
  1583. case ZONE_SET_VALUE_MIN_LEVEL: {
  1584. if (zone)
  1585. zone->SetMinimumLevel(int_value);
  1586. database.SaveZoneInfo(zone_id, "min_level", int_value);
  1587. break;
  1588. }
  1589. case ZONE_SET_VALUE_MAX_LEVEL: {
  1590. if (zone)
  1591. zone->SetMaximumLevel(int_value);
  1592. database.SaveZoneInfo(zone_id, "max_level", int_value);
  1593. break;
  1594. }
  1595. case ZONE_SET_VALUE_START_ZONE: {
  1596. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  1597. break;
  1598. }
  1599. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  1600. if (zone)
  1601. zone->SetInstanceType(int_value);
  1602. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  1603. break;
  1604. }
  1605. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  1606. if (zone)
  1607. zone->SetDefaultReenterTime(int_value);
  1608. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  1609. break;
  1610. }
  1611. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  1612. if (zone)
  1613. zone->SetDefaultResetTime(int_value);
  1614. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  1615. break;
  1616. }
  1617. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1618. if (zone)
  1619. zone->SetDefaultLockoutTime(int_value);
  1620. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1621. break;
  1622. }
  1623. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1624. if (zone)
  1625. zone->SetForceGroupZoneOption(int_value);
  1626. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1627. break;
  1628. }
  1629. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1630. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1631. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1632. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1633. return false;
  1634. }
  1635. else {
  1636. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1637. database.SaveZoneInfo(zone_id, "lua_script", value);
  1638. }
  1639. break;
  1640. }
  1641. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1642. if (zone)
  1643. zone->SetShutdownTimer(int_value);
  1644. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1645. break;
  1646. }
  1647. case ZONE_SET_VALUE_ZONE_MOTD: {
  1648. if (zone)
  1649. zone->SetZoneMOTD(string(value));
  1650. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1651. break;
  1652. }
  1653. default: {
  1654. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1655. return false;
  1656. }
  1657. }
  1658. }
  1659. else {
  1660. if (client)
  1661. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1662. return false;
  1663. }
  1664. return true;
  1665. }
  1666. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1667. if (index >= remote_commands->commands.size()) {
  1668. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1669. return;
  1670. }
  1671. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1672. EQ2_RemoteCommandString* parent_command = 0;
  1673. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1674. Seperator* sep = 0;
  1675. if (command_parms->size > 0) {
  1676. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1677. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1678. parent_command = command;
  1679. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1680. safe_delete(sep);
  1681. if (command_parms->data.length() > (command->command.data.length() + 1))
  1682. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1683. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1684. }
  1685. else
  1686. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1687. }
  1688. int ndx = 0;
  1689. if (command->required_status > client->GetAdminStatus())
  1690. {
  1691. 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());
  1692. safe_delete(sep);
  1693. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1694. return;
  1695. }
  1696. Player* player = client->GetPlayer();
  1697. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1698. switch (command->handler) {
  1699. case COMMAND_RELOAD: {
  1700. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1701. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1702. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1703. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1704. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1705. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1706. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1707. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1708. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1709. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1710. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1711. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1712. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1713. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1714. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1715. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1716. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1717. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1718. break;
  1719. }
  1720. case COMMAND_RELOADSTRUCTS: {
  1721. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1722. world.SetReloadingSubsystem("Structs");
  1723. configReader.ReloadStructs();
  1724. world.RemoveReloadingSubSystem("Structs");
  1725. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1726. break;
  1727. }
  1728. case COMMAND_RELOAD_QUESTS: {
  1729. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1730. world.SetReloadingSubsystem("Quests");
  1731. master_quest_list.Reload();
  1732. client_list.ReloadQuests();
  1733. zone_list.ReloadClientQuests();
  1734. world.RemoveReloadingSubSystem("Quests");
  1735. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1736. break;
  1737. }
  1738. case COMMAND_RELOAD_SPAWNS: {
  1739. client->GetCurrentZone()->ReloadSpawns();
  1740. break;
  1741. }
  1742. case COMMAND_RELOAD_SPELLS: {
  1743. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1744. world.SetReloadingSubsystem("Spells");
  1745. zone_list.DeleteSpellProcess();
  1746. master_spell_list.Reload();
  1747. if (lua_interface)
  1748. lua_interface->ReloadSpells();
  1749. zone_list.LoadSpellProcess();
  1750. world.RemoveReloadingSubSystem("Spells");
  1751. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1752. break;
  1753. }
  1754. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1755. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1756. world.SetReloadingSubsystem("GroundSpawns");
  1757. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1758. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1759. world.RemoveReloadingSubSystem("GroundSpawns");
  1760. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1761. break;
  1762. }
  1763. case COMMAND_RELOAD_ZONESCRIPTS: {
  1764. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1765. world.SetReloadingSubsystem("ZoneScripts");
  1766. world.ResetZoneScripts();
  1767. database.LoadZoneScriptData();
  1768. if (lua_interface)
  1769. lua_interface->DestroyZoneScripts();
  1770. world.RemoveReloadingSubSystem("ZoneScripts");
  1771. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1772. break;
  1773. }
  1774. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1775. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1776. world.SetReloadingSubsystem("EntityCommands");
  1777. client->GetCurrentZone()->ClearEntityCommands();
  1778. database.LoadEntityCommands(client->GetCurrentZone());
  1779. world.RemoveReloadingSubSystem("EntityCommands");
  1780. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1781. break;
  1782. }
  1783. case COMMAND_RELOAD_FACTIONS: {
  1784. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1785. world.SetReloadingSubsystem("Factions");
  1786. master_faction_list.Clear();
  1787. database.LoadFactionList();
  1788. world.RemoveReloadingSubSystem("Factions");
  1789. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1790. break;
  1791. }
  1792. case COMMAND_RELOAD_MAIL: {
  1793. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1794. zone_list.ReloadMail();
  1795. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1796. break;
  1797. }
  1798. case COMMAND_RELOAD_GUILDS: {
  1799. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1800. world.ReloadGuilds();
  1801. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1802. break;
  1803. }
  1804. case COMMAND_RELOAD_LOCATIONS: {
  1805. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1806. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1807. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1808. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1809. break;
  1810. }
  1811. case COMMAND_RELOAD_RULES: {
  1812. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1813. database.LoadRuleSets(true);
  1814. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1815. break;
  1816. }
  1817. case COMMAND_RELOAD_TRANSPORTERS: {
  1818. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1819. database.LoadTransporters(client->GetCurrentZone());
  1820. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1821. break;
  1822. }
  1823. case COMMAND_RELOAD_STARTABILITIES: {
  1824. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1825. world.PurgeStartingLists();
  1826. world.LoadStartingLists();
  1827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1828. break;
  1829. }
  1830. case COMMAND_READ: {
  1831. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1832. if (strcmp(sep->arg[0], "read") == 0) {
  1833. int32 item_index = atol(sep->arg[1]);
  1834. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1835. if (item) {
  1836. Spawn* spawn = cmdTarget;
  1837. client->SendShowBook(client->GetPlayer(), item->name, item->book_pages);
  1838. break;
  1839. }
  1840. }
  1841. }
  1842. break;
  1843. }
  1844. case COMMAND_USEABILITY:{
  1845. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1846. if (client->GetPlayer()->GetHP() == 0) {
  1847. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1848. }
  1849. else {
  1850. int32 spell_id = atoul(sep->arg[0]);
  1851. int8 spell_tier = 0;
  1852. if (sep->arg[1][0] && sep->IsNumber(1))
  1853. spell_tier = atoi(sep->arg[1]);
  1854. else
  1855. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1856. if (!spell_tier)
  1857. spell_tier = 1;
  1858. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1859. if (spell) {
  1860. 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)
  1861. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1862. else
  1863. {
  1864. if (cmdTarget)
  1865. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1866. else
  1867. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1868. }
  1869. }
  1870. }
  1871. }
  1872. else if (cmdTarget && cmdTarget->IsWidget())
  1873. {
  1874. Widget* widget = (Widget*)cmdTarget;
  1875. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1876. }
  1877. else
  1878. {
  1879. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1880. }
  1881. break;
  1882. }
  1883. case COMMAND_INFO:{
  1884. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1885. if(strcmp(sep->arg[0], "inventory") == 0){
  1886. int32 item_index = atol(sep->arg[1]);
  1887. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1888. if(item){
  1889. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1890. break;
  1891. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1892. //DumpPacket(app);
  1893. client->QueuePacket(app);
  1894. if(item->GetItemScript() && lua_interface)
  1895. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1896. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1897. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  1898. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1899. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  1900. }
  1901. }
  1902. else
  1903. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1904. }
  1905. else if(strcmp(sep->arg[0], "equipment") == 0){
  1906. int32 item_index = atol(sep->arg[1]);
  1907. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1908. if(item){
  1909. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1910. client->QueuePacket(app);
  1911. if(item->GetItemScript() && lua_interface)
  1912. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1913. }
  1914. else
  1915. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1916. }
  1917. else if(strcmp(sep->arg[0], "appearance") == 0){
  1918. int32 item_index = atol(sep->arg[1]);
  1919. Item* item = client->GetPlayer()->GetAppearanceEquipmentList()->GetItem(item_index);
  1920. if(item){
  1921. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1922. client->QueuePacket(app);
  1923. if(item->GetItemScript() && lua_interface)
  1924. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1925. }
  1926. else
  1927. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1928. }
  1929. 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){
  1930. int32 item_id = atoul(sep->arg[1]);
  1931. Item* item = master_item_list.GetItem(item_id);
  1932. if(item){
  1933. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1934. client->QueuePacket(app);
  1935. }
  1936. else
  1937. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1938. }
  1939. else if (strcmp(sep->arg[0], "spell") == 0) {
  1940. sint32 spell_id = atol(sep->arg[1]);
  1941. int8 tier = atoi(sep->arg[3]);
  1942. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1943. if (outapp)
  1944. client->QueuePacket(outapp);
  1945. else
  1946. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1947. }
  1948. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1949. sint32 spell_id = atol(sep->arg[2]);
  1950. int8 group = atoi(sep->arg[1]);
  1951. AltAdvanceData* data = 0;
  1952. SpellBookEntry* spellentry = 0;
  1953. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1954. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1955. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1956. if (outapp)
  1957. client->QueuePacket(outapp);
  1958. else
  1959. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1960. }
  1961. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1962. sint32 spell_id = atol(sep->arg[1]);
  1963. int32 tier = atoi(sep->arg[2]);
  1964. if (tier > 255) {
  1965. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  1966. if (ent)
  1967. tier = ent->tier;
  1968. }
  1969. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  1970. if (outapp)
  1971. client->QueuePacket(outapp);
  1972. else
  1973. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1974. }
  1975. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1976. sint32 recipe_id = atol(sep->arg[1]);
  1977. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1978. if(outapp)
  1979. client->QueuePacket(outapp);
  1980. else
  1981. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1982. }
  1983. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1984. int32 slot = atol(sep->arg[1]);
  1985. int32 spell_id = atol(sep->arg[2]);
  1986. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1987. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1988. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1989. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1990. if(outapp)
  1991. client->QueuePacket(outapp);
  1992. else
  1993. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1994. }
  1995. else if (strcmp(sep->arg[0], "effect") == 0) {
  1996. int32 spell_id = atol(sep->arg[1]);
  1997. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1998. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1999. int8 type = 0;
  2000. if (client->GetVersion() <= 546)
  2001. type = 1;
  2002. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  2003. if (outapp){
  2004. client->QueuePacket(outapp);
  2005. }
  2006. else
  2007. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  2008. }
  2009. }
  2010. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  2011. Item* item = player->item_list.GetOverflowItem();
  2012. if(item) {
  2013. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2014. client->QueuePacket(app);
  2015. }
  2016. else
  2017. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  2018. }
  2019. else
  2020. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  2021. break;
  2022. }
  2023. case COMMAND_USE_EQUIPPED_ITEM:{
  2024. if (sep && sep->arg[0] && sep->IsNumber(0)){
  2025. int32 slot_id = atoul(sep->arg[0]);
  2026. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  2027. if (item && item->generic_info.usable && item->GetItemScript())
  2028. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  2029. }
  2030. break;
  2031. }
  2032. case COMMAND_USE_ITEM: {
  2033. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2034. int32 item_index = atoul(sep->arg[0]);
  2035. Item* item = player->item_list.GetItemFromIndex(item_index);
  2036. if (item && item->GetItemScript()) {
  2037. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  2038. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  2039. else {
  2040. if (item->details.count > 0) {
  2041. std::string itemName = string(item->name);
  2042. int32 item_id = item->details.item_id;
  2043. sint64 flags = 0;
  2044. if(lua_interface->RunItemScript(item->GetItemScript(), "used", item, player, &flags) && flags >= 0)
  2045. {
  2046. //reobtain item make sure it wasn't removed
  2047. item = player->item_list.GetItemFromIndex(item_index);
  2048. if(!item)
  2049. LogWrite(PLAYER__WARNING, 0, "Command", "%s: Item %s (%i) was used, however after the item looks to be removed.", client->GetPlayer()->GetName(), itemName.c_str(), item_id);
  2050. else if(!item->generic_info.display_charges && item->generic_info.max_charges == 1) {
  2051. client->Message(CHANNEL_NARRATIVE, "%s is out of charges. It has been removed.", item->name.c_str());
  2052. client->RemoveItem(item, 1); // end of a set of charges OR an item that uses a stack count of actual item quantity
  2053. }
  2054. else
  2055. {
  2056. item->details.count--; // charges
  2057. item->save_needed = true;
  2058. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  2059. if(!item->details.count) {
  2060. client->Message(CHANNEL_NARRATIVE, "%s is out of charges. It has been removed.", item->name.c_str());
  2061. client->RemoveItem(item, 1); // end of a set of charges OR an item that uses a stack count of actual item quantity
  2062. }
  2063. }
  2064. }
  2065. else
  2066. LogWrite(PLAYER__WARNING, 0, "Command", "%s: Item %s (%i) was used, after it returned %i, bypassing any removal/update of items.", client->GetPlayer()->GetName(), itemName.c_str(), item_id, flags);
  2067. }
  2068. else
  2069. {
  2070. //reobtain item make sure it wasn't removed
  2071. item = player->item_list.GetItemFromIndex(item_index);
  2072. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is out of charges.");
  2073. if(item) {
  2074. LogWrite(PLAYER__ERROR, 0, "Command", "%s: Item %s (%i) attempted to be used, however details.count is 0.", client->GetPlayer()->GetName(), item->name.c_str(), item->details.item_id);
  2075. }
  2076. }
  2077. }
  2078. }
  2079. }
  2080. break;
  2081. }
  2082. case COMMAND_SCRIBE_SCROLL_ITEM: {
  2083. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2084. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  2085. if (item) {
  2086. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  2087. if(item->generic_info.item_type == 6) {
  2088. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  2089. int8 old_slot = 0;
  2090. if (spell) {
  2091. int16 tier_up = player->GetTierUp(spell->GetSpellTier());
  2092. if (rule_manager.GetGlobalRule(R_Spells, RequirePreviousTierScribe)->GetInt8() && !player->HasSpell(spell->GetSpellID(), tier_up, false, true))
  2093. client->SimpleMessage(CHANNEL_COLOR_RED, "You have not scribed the required previous version of this ability.");
  2094. else if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  2095. old_slot = player->GetSpellSlot(spell->GetSpellID());
  2096. player->RemoveSpellBookEntry(spell->GetSpellID());
  2097. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  2098. player->UnlockSpell(spell);
  2099. client->SendSpellUpdate(spell);
  2100. database.DeleteItem(client->GetCharacterID(), item, 0);
  2101. player->item_list.RemoveItem(item, true);
  2102. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  2103. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  2104. // force purge client cache and display updated spell for hover over
  2105. EQ2Packet* app = spell->SerializeSpell(client, false, false);
  2106. client->QueuePacket(app);
  2107. }
  2108. }
  2109. else
  2110. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  2111. }
  2112. else if(item->generic_info.item_type == 7){
  2113. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  2114. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  2115. // if valid recipe book and the player doesn't have it
  2116. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  2117. client->Message(CHANNEL_NARRATIVE, "Your tradeskill level is not high enough to scribe this book.");
  2118. safe_delete(recipe_book);
  2119. }
  2120. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  2121. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  2122. // Add recipe book to the players list
  2123. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  2124. // Get a list of all recipes this book contains
  2125. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  2126. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  2127. // Create the packet to send to update the players recipe list
  2128. PacketStruct* packet = 0;
  2129. if (client->GetRecipeListSent()) {
  2130. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  2131. if (packet)
  2132. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  2133. }
  2134. // loop through the list
  2135. vector<Recipe*>::iterator itr;
  2136. int16 i = 0;
  2137. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  2138. // check to see if the player already has this recipe some how
  2139. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  2140. // Player doesn't already have this recipe so lets add it
  2141. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  2142. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  2143. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  2144. client->Message(CHANNEL_NARRATIVE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  2145. if (packet && client->GetRecipeListSent()) {
  2146. packet->setArrayDataByName("id", recipe->GetID(), i);
  2147. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  2148. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  2149. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  2150. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  2151. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  2152. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  2153. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  2154. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  2155. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  2156. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  2157. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  2158. i++;
  2159. }
  2160. }
  2161. }
  2162. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  2163. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  2164. database.DeleteItem(client->GetCharacterID(), item, 0);
  2165. client->GetPlayer()->item_list.RemoveItem(item, true);
  2166. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  2167. if (packet && client->GetRecipeListSent())
  2168. client->QueuePacket(packet->serialize());
  2169. safe_delete(packet);
  2170. }
  2171. else {
  2172. if (recipe_book)
  2173. client->Message(CHANNEL_NARRATIVE, "You have already learned all you can from this item.");
  2174. safe_delete(recipe_book);
  2175. }
  2176. }
  2177. }
  2178. else
  2179. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  2180. }
  2181. break;
  2182. }
  2183. case COMMAND_SUMMONITEM: {
  2184. if (sep && sep->IsNumber(0)) {
  2185. int32 item_id = atol(sep->arg[0]);
  2186. int32 quantity = 1;
  2187. if (sep->arg[1] && sep->IsNumber(1))
  2188. quantity = atoi(sep->arg[1]);
  2189. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  2190. client->AddItemToBank(item_id,quantity);
  2191. }
  2192. else {
  2193. client->AddItem(item_id, quantity);
  2194. }
  2195. }
  2196. else {
  2197. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  2198. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  2199. }
  2200. break;
  2201. }
  2202. case COMMAND_COLLECTION_ADDITEM: {
  2203. // takes 2 params: collection_id, slot
  2204. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2205. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  2206. if (item)
  2207. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  2208. else
  2209. 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]));
  2210. }
  2211. else
  2212. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  2213. break;
  2214. }
  2215. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  2216. // takes 1 param: slot
  2217. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  2218. int i = 0;
  2219. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  2220. printf("\t%u: %s\n", i, sep->arg[i]);
  2221. i++;
  2222. }
  2223. break;
  2224. }
  2225. case COMMAND_WAYPOINT: {
  2226. bool success = false;
  2227. client->ClearWaypoint();
  2228. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  2229. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  2230. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2231. }
  2232. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  2233. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  2234. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2235. }
  2236. else {
  2237. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  2238. }
  2239. break;
  2240. }
  2241. case COMMAND_WHO:{
  2242. const char* who = 0;
  2243. if(sep && sep->arg[0]){
  2244. //cout << "Who query: \n";
  2245. who = sep->argplus[0];
  2246. //cout << who << endl;
  2247. }
  2248. zone_list.ProcessWhoQuery(who, client);
  2249. break;
  2250. }
  2251. case COMMAND_SELECT_JUNCTION:{
  2252. LogWrite(MISC__TODO, 1, "TODO", "For access/travel selections (i.e. Mariner Bells, Player Death Window, etc.)\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2253. int32 choice = 0;
  2254. if(sep && sep->arg[0] && sep->IsNumber(0))
  2255. choice = atoul(sep->arg[0]);
  2256. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  2257. client->HandlePlayerRevive(choice);
  2258. }
  2259. break;
  2260. }
  2261. case COMMAND_SPAWN_MOVE: {
  2262. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  2263. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  2264. if (packet) {
  2265. float unknown2_3 = 0;
  2266. int8 placement_mode = 0;
  2267. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  2268. if (sep && sep->arg[0][0]) {
  2269. if (strcmp(sep->arg[0], "wall") == 0) {
  2270. placement_mode = 2;
  2271. unknown2_3 = 150;
  2272. }
  2273. else if (strcmp(sep->arg[0], "ceiling") == 0)
  2274. placement_mode = 1;
  2275. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  2276. {
  2277. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  2278. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  2279. }
  2280. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  2281. {
  2282. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  2283. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  2284. }
  2285. else if (strcmp(sep->arg[0], "myloc") == 0)
  2286. {
  2287. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  2288. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  2289. safe_delete(packet);
  2290. break;
  2291. }
  2292. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  2293. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  2294. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  2295. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  2296. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  2297. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  2298. safe_delete(packet);
  2299. break;
  2300. }
  2301. }
  2302. packet->setDataByName("placement_mode", placement_mode);
  2303. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  2304. packet->setDataByName("model_type", cmdTarget->GetModelType());
  2305. packet->setDataByName("unknown", 1); //size
  2306. packet->setDataByName("unknown2", 1); //size 2
  2307. packet->setDataByName("unknown2", .5, 1); //size 3
  2308. packet->setDataByName("unknown2", 3, 2);
  2309. packet->setDataByName("unknown2", unknown2_3, 3);
  2310. packet->setDataByName("max_distance", 500);
  2311. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  2312. client->QueuePacket(packet->serialize());
  2313. safe_delete(packet);
  2314. }
  2315. }
  2316. else {
  2317. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  2318. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  2319. }
  2320. break;
  2321. }
  2322. case COMMAND_HAIL:{
  2323. Spawn* spawn = cmdTarget;
  2324. if(spawn && spawn->GetTargetable())
  2325. {
  2326. char tmp[75] = {0};
  2327. sprintf(tmp, "Hail, %s", spawn->GetName());
  2328. bool show_bubble = true;
  2329. if (spawn->IsNPC())
  2330. show_bubble = false;
  2331. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  2332. if(spawn->IsPlayer() == false && spawn->Alive() && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetGlobalRule(R_Spawn, HailDistance)->GetInt32()){
  2333. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  2334. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  2335. else
  2336. {
  2337. bool pauseRunback = false;
  2338. // prime runback as the heading or anything can be altered when hailing succeeds
  2339. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  2340. {
  2341. ((NPC*)spawn)->StartRunback();
  2342. pauseRunback = true;
  2343. }
  2344. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  2345. spawn->PauseMovement(rule_manager.GetGlobalRule(R_Spawn, HailMovementPause)->GetInt32());
  2346. else if(spawn->IsNPC() && pauseRunback)
  2347. ((NPC*)spawn)->ClearRunback();
  2348. }
  2349. }
  2350. }
  2351. else {
  2352. string tmp = "Hail";
  2353. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  2354. }
  2355. break;
  2356. }
  2357. case COMMAND_SAY:{
  2358. if (sep && sep->arg[0][0]) {
  2359. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  2360. if (cmdTarget && !(cmdTarget->IsPlayer()))
  2361. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  2362. }
  2363. else
  2364. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  2365. break;
  2366. }
  2367. case COMMAND_TELL:{
  2368. if(sep && sep->arg[0] && sep->argplus[1]){
  2369. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1]))
  2370. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  2371. }else
  2372. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  2373. break;
  2374. }
  2375. case COMMAND_SHOUT:{
  2376. if(sep && sep->arg[0][0])
  2377. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  2378. else
  2379. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  2380. break;
  2381. }
  2382. case COMMAND_AUCTION:{
  2383. if(sep && sep->arg[0][0])
  2384. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  2385. else
  2386. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  2387. break;
  2388. }
  2389. case COMMAND_OOC:{
  2390. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2391. if(sep && sep->arg[0][0])
  2392. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0]);
  2393. else
  2394. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2395. break;
  2396. }
  2397. case COMMAND_EMOTE:{
  2398. if(sep && sep->arg[0][0])
  2399. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2400. else
  2401. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2402. break;
  2403. }
  2404. case COMMAND_RACE:{
  2405. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2406. if(sep->arg[1][0] && sep->IsNumber(1)){
  2407. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2408. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2409. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2410. client->GetPlayer()->SetCharSheetChanged(true);
  2411. }
  2412. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2413. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2414. //client->QueuePacket(outapp);
  2415. }
  2416. else{
  2417. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2418. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2419. }
  2420. break;
  2421. }
  2422. case COMMAND_BANK_DEPOSIT:{
  2423. if(client->GetBanker() && sep && sep->arg[0]){
  2424. int64 amount = 0;
  2425. string deposit = string(sep->arg[0]);
  2426. amount = atoi64(deposit.c_str());
  2427. client->BankDeposit(amount);
  2428. }
  2429. break;
  2430. }
  2431. case COMMAND_BANK_WITHDRAWAL:{
  2432. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2433. int64 amount = 0;
  2434. string deposit = string(sep->arg[0]);
  2435. amount = atoi64(deposit.c_str());
  2436. client->BankWithdrawal(amount);
  2437. }
  2438. break;
  2439. }
  2440. case COMMAND_BANK_CANCEL:{
  2441. Spawn* banker = cmdTarget;
  2442. client->Bank(banker, true);
  2443. break;
  2444. }
  2445. case COMMAND_BANK:{
  2446. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2447. Spawn* banker = cmdTarget;
  2448. client->Bank(banker);
  2449. break;
  2450. }
  2451. case COMMAND_GUILD_BANK:{
  2452. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2453. //Spawn* banker = client->GetPlayer()->GetTarget();
  2454. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2455. break;
  2456. }
  2457. case COMMAND_START_MAIL: {
  2458. client->SetMailTransaction(cmdTarget);
  2459. client->SendMailList();
  2460. break;
  2461. }
  2462. case COMMAND_CANCEL_MAIL: {
  2463. client->SetMailTransaction(0);
  2464. break;
  2465. }
  2466. case COMMAND_GET_MAIL_MESSAGE: {
  2467. if (sep && sep->arg[0] && sep->IsNumber(0))
  2468. client->DisplayMailMessage(atoul(sep->arg[0]));
  2469. break;
  2470. }
  2471. case COMMAND_ADD_MAIL_PLAT: {
  2472. if (sep && sep->arg[0] && sep->IsNumber(0))
  2473. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2474. break;
  2475. }
  2476. case COMMAND_ADD_MAIL_GOLD: {
  2477. if (sep && sep->arg[0] && sep->IsNumber(0))
  2478. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2479. break;
  2480. }
  2481. case COMMAND_ADD_MAIL_SILVER: {
  2482. if (sep && sep->arg[0] && sep->IsNumber(0))
  2483. client->AddMailCoin(0, atoul(sep->arg[0]));
  2484. break;
  2485. }
  2486. case COMMAND_ADD_MAIL_COPPER: {
  2487. if (sep && sep->arg[0] && sep->IsNumber(0))
  2488. client->AddMailCoin(atoul(sep->arg[0]));
  2489. break;
  2490. }
  2491. case COMMAND_SET_MAIL_ITEM: {
  2492. if(sep && sep->IsNumber(0) && sep->IsNumber(2))
  2493. {
  2494. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2495. if(item)
  2496. {
  2497. int16 quantity = atoul(sep->arg[1]);
  2498. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2499. {
  2500. return;
  2501. }
  2502. if(item->IsBag())
  2503. {
  2504. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2505. if(bag_items && bag_items->size() > 0)
  2506. {
  2507. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2508. safe_delete(bag_items);
  2509. return;
  2510. }
  2511. safe_delete(bag_items);
  2512. }
  2513. Item* itemtoadd = item;
  2514. if(quantity > 0)
  2515. {
  2516. if(quantity > item->details.count)
  2517. return;
  2518. Item* tmpItem = new Item(item);
  2519. tmpItem->details.count = quantity;
  2520. itemtoadd = tmpItem;
  2521. }
  2522. if(client->AddMailItem(itemtoadd))
  2523. {
  2524. client->RemoveItem(item, quantity, true);
  2525. }
  2526. }
  2527. }
  2528. break;
  2529. }
  2530. case COMMAND_REMOVE_MAIL_PLAT: {
  2531. if (sep && sep->arg[0] && sep->IsNumber(0))
  2532. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2533. break;
  2534. }
  2535. case COMMAND_REMOVE_MAIL_GOLD: {
  2536. if (sep && sep->arg[0] && sep->IsNumber(0))
  2537. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2538. break;
  2539. }
  2540. case COMMAND_REMOVE_MAIL_SILVER: {
  2541. if (sep && sep->arg[0] && sep->IsNumber(0))
  2542. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2543. break;
  2544. }
  2545. case COMMAND_REMOVE_MAIL_COPPER: {
  2546. if (sep && sep->arg[0] && sep->IsNumber(0))
  2547. client->RemoveMailCoin(atoul(sep->arg[0]));
  2548. break;
  2549. }
  2550. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2551. if (sep && sep->arg[0] && sep->IsNumber(0))
  2552. client->TakeMailAttachments(atoul(sep->arg[0]));
  2553. break;
  2554. }
  2555. case COMMAND_CANCEL_SEND_MAIL: {
  2556. client->ResetSendMail();
  2557. break;
  2558. }
  2559. case COMMAND_DELETE_MAIL_MESSAGE: {
  2560. if (sep && sep->arg[0] && sep->IsNumber(0))
  2561. client->DeleteMail(atoul(sep->arg[0]), true);
  2562. break;
  2563. }
  2564. case COMMAND_REPORT_SPAM: {
  2565. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2566. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2567. break;
  2568. }
  2569. case COMMAND_KILL:{
  2570. Spawn* dead = 0;
  2571. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2572. dead=client->GetPlayer();
  2573. client->GetPlayer()->SetHP(0);
  2574. client->GetPlayer()->KillSpawn(dead);
  2575. }else{
  2576. dead= cmdTarget;
  2577. if(dead && dead->IsPlayer() == false){
  2578. dead->SetHP(0);
  2579. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2580. client->GetCurrentZone()->RemoveSpawn(dead, true);
  2581. else
  2582. client->GetPlayer()->KillSpawn(dead);
  2583. }else{
  2584. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2585. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2586. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2587. }
  2588. }
  2589. break;
  2590. }
  2591. case COMMAND_LEVEL:{
  2592. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2593. int16 new_level = atoi(sep->arg[ndx]);
  2594. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2595. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2596. else {
  2597. if (new_level < 1)
  2598. new_level = 1;
  2599. if (new_level > 255)
  2600. new_level = 255;
  2601. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2602. }
  2603. }else
  2604. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2605. break;
  2606. }
  2607. case COMMAND_SIT: {
  2608. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2609. if(client->GetPlayer()->GetHP() > 0){
  2610. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2611. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2612. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2613. }
  2614. break;
  2615. }
  2616. case COMMAND_STAND: {
  2617. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2618. if(client->GetPlayer()->GetHP() > 0){
  2619. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2620. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2621. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2622. }
  2623. break;
  2624. }
  2625. case COMMAND_CLASS:{
  2626. if(sep && sep->arg[ndx][0]){
  2627. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2628. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2629. }else
  2630. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2631. break;
  2632. }
  2633. case COMMAND_GENDER:{
  2634. if(sep && sep->arg[ndx][0]){
  2635. client->GetPlayer()->GetInfoStruct()->set_gender(atoi(sep->arg[ndx]));
  2636. client->GetPlayer()->SetCharSheetChanged(true);
  2637. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  2638. }else{
  2639. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  2640. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  2641. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  2642. }
  2643. break;
  2644. }
  2645. case COMMAND_FLYMODE:{
  2646. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2647. PrintSep(sep, "COMMAND_FLYMODE");
  2648. int8 val = atoi(sep->arg[0]);
  2649. ClientPacketFunctions::SendFlyMode(client, val);
  2650. }
  2651. else{
  2652. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  2653. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2654. }
  2655. break;
  2656. }
  2657. case COMMAND_LOOT_LIST:{
  2658. Spawn* spawn = cmdTarget;
  2659. if(spawn && spawn->IsEntity()){
  2660. if (sep && sep->arg[0]) {
  2661. if (!spawn->GetDatabaseID())
  2662. {
  2663. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  2664. break;
  2665. }
  2666. else if (!spawn->IsNPC())
  2667. {
  2668. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2669. break;
  2670. }
  2671. bool reloadLoot = false;
  2672. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2673. {
  2674. int32 loottable_id = atoul(sep->arg[1]);
  2675. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2676. {
  2677. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2678. reloadLoot = true;
  2679. }
  2680. else
  2681. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2682. }
  2683. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2684. {
  2685. int32 loottable_id = atoul(sep->arg[1]);
  2686. if (loottable_id > 0)
  2687. {
  2688. database.AddLootTableToSpawn(spawn, loottable_id);
  2689. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2690. reloadLoot = true;
  2691. }
  2692. else
  2693. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2694. }
  2695. else if (!stricmp(sep->arg[0], "clearall"))
  2696. {
  2697. if (database.RemoveSpawnLootTable(spawn, 0))
  2698. {
  2699. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2700. reloadLoot = true;
  2701. }
  2702. else
  2703. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2704. }
  2705. else
  2706. {
  2707. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2708. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2709. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2710. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2711. break;
  2712. }
  2713. if (reloadLoot)
  2714. {
  2715. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2716. if (spawn->IsNPC())
  2717. {
  2718. Entity* ent = (Entity*)spawn;
  2719. ent->SetLootCoins(0);
  2720. ent->ClearLoot();
  2721. spawn->GetZone()->AddLoot((NPC*)spawn);
  2722. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2723. }
  2724. }
  2725. break; // nothing further this is the end of these sub commands
  2726. }
  2727. else
  2728. {
  2729. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()), spawn);
  2730. if (loot_list.size() > 0) {
  2731. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2732. vector<int32>::iterator list_itr;
  2733. LootTable* table = 0;
  2734. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2735. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2736. if (table)
  2737. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2738. }
  2739. }
  2740. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2741. vector<Item*>* items = spawn->GetLootItems();
  2742. if (items) {
  2743. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2744. vector<Item*>::iterator itr;
  2745. Item* item = 0;
  2746. for (itr = items->begin(); itr != items->end(); itr++) {
  2747. item = *itr;
  2748. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2749. }
  2750. }
  2751. else
  2752. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2753. }
  2754. }
  2755. break;
  2756. }
  2757. case COMMAND_LOOT_SETCOIN:{
  2758. Spawn* spawn = cmdTarget;
  2759. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2760. spawn->SetLootCoins(atoul(sep->arg[0]));
  2761. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2762. }
  2763. else
  2764. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2765. break;
  2766. }
  2767. case COMMAND_LOOT_ADDITEM:{
  2768. Spawn* spawn = cmdTarget;
  2769. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2770. int16 charges = 1;
  2771. if(sep->arg[1] && sep->IsNumber(1))
  2772. charges = atoi(sep->arg[1]);
  2773. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2774. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2775. }
  2776. else
  2777. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2778. break;
  2779. }
  2780. case COMMAND_LOOT_REMOVEITEM:{
  2781. Spawn* spawn = cmdTarget;
  2782. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2783. Item* item = spawn->LootItem(atoul(sep->arg[0]));
  2784. safe_delete(item);
  2785. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2786. }
  2787. else
  2788. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2789. break;
  2790. }
  2791. case COMMAND_LOOT_CORPSE:
  2792. case COMMAND_DISARM:
  2793. case COMMAND_LOOT:{
  2794. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2795. {
  2796. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2797. break;
  2798. }
  2799. if(cmdTarget && cmdTarget->IsEntity()){
  2800. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2801. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2802. client->OpenChest(cmdTarget, true);
  2803. else
  2804. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2805. if (!(cmdTarget)->HasLoot()){
  2806. if (((Entity*)cmdTarget)->IsNPC())
  2807. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2808. }
  2809. }
  2810. else
  2811. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2812. }
  2813. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2814. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2815. break;
  2816. }
  2817. case COMMAND_RELOADSPAWNSCRIPTS:{
  2818. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2819. if (lua_interface)
  2820. lua_interface->SetLuaSystemReloading(true);
  2821. world.ResetSpawnScripts();
  2822. database.LoadSpawnScriptData();
  2823. if(lua_interface) {
  2824. lua_interface->DestroySpawnScripts();
  2825. lua_interface->SetLuaSystemReloading(false);
  2826. }
  2827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2828. break;
  2829. }
  2830. case COMMAND_RELOADREGIONSCRIPTS:{
  2831. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2832. if(lua_interface) {
  2833. lua_interface->DestroyRegionScripts();
  2834. }
  2835. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2836. break;
  2837. }
  2838. case COMMAND_RELOADLUASYSTEM:{
  2839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2840. world.SetReloadingSubsystem("LuaSystem");
  2841. if(lua_interface) {
  2842. lua_interface->SetLuaSystemReloading(true);
  2843. }
  2844. zone_list.DeleteSpellProcess();
  2845. master_spell_list.Reload();
  2846. if (lua_interface)
  2847. lua_interface->ReloadSpells();
  2848. zone_list.LoadSpellProcess();
  2849. if(lua_interface){
  2850. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2851. map<Client*, int32>::iterator itr;
  2852. for(itr = debug_clients.begin(); itr != debug_clients.end(); itr++){
  2853. if(lua_interface)
  2854. lua_interface->UpdateDebugClients(itr->first);
  2855. }
  2856. }
  2857. world.ResetSpawnScripts();
  2858. database.LoadSpawnScriptData();
  2859. world.ResetZoneScripts();
  2860. database.LoadZoneScriptData();
  2861. if(lua_interface) {
  2862. lua_interface->DestroySpawnScripts();
  2863. lua_interface->DestroyRegionScripts();
  2864. lua_interface->DestroyQuests();
  2865. lua_interface->DestroyItemScripts();
  2866. lua_interface->DestroyZoneScripts();
  2867. }
  2868. int32 quest_count = database.LoadQuests();
  2869. int32 spell_count = 0;
  2870. if(lua_interface) {
  2871. spell_count = database.LoadSpellScriptData();
  2872. lua_interface->SetLuaSystemReloading(false);
  2873. }
  2874. world.RemoveReloadingSubSystem("LuaSystem");
  2875. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2876. break;
  2877. }
  2878. case COMMAND_DECLINE_QUEST:{
  2879. int32 quest_id = 0;
  2880. if(sep && sep->arg[0] && sep->IsNumber(0))
  2881. quest_id = atoul(sep->arg[0]);
  2882. if(quest_id > 0){
  2883. Quest* quest = client->GetPendingQuest(quest_id);
  2884. if(quest){
  2885. client->RemovePendingQuest(quest);
  2886. if(lua_interface)
  2887. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2888. safe_delete(quest);
  2889. client->GetCurrentZone()->SendQuestUpdates(client);
  2890. }
  2891. }
  2892. break;
  2893. }
  2894. case COMMAND_DELETE_QUEST:{
  2895. int32 quest_id = 0;
  2896. if(sep && sep->arg[0] && sep->IsNumber(0))
  2897. quest_id = atoul(sep->arg[0]);
  2898. if(quest_id > 0){
  2899. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2900. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2901. if (quest)
  2902. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2903. }
  2904. client->RemovePlayerQuest(quest_id);
  2905. client->GetCurrentZone()->SendQuestUpdates(client);
  2906. }
  2907. break;
  2908. }
  2909. case COMMAND_ACCEPT_QUEST:{
  2910. int32 quest_id = 0;
  2911. if(sep && sep->arg[0] && sep->IsNumber(0))
  2912. quest_id = atoul(sep->arg[0]);
  2913. if(quest_id > 0){
  2914. client->AcceptQuest(quest_id);
  2915. }
  2916. break;
  2917. }
  2918. case COMMAND_NAME:{
  2919. if(sep && sep->arg[ndx][0]){
  2920. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  2921. client->GetPlayer()->SetCharSheetChanged(true);
  2922. }else
  2923. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2924. break;
  2925. }
  2926. case COMMAND_GROUPSAY:{
  2927. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2928. if(sep && sep->arg[0] && gmi)
  2929. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2930. break;
  2931. }
  2932. case COMMAND_GROUPINVITE: {
  2933. Entity* target = 0;
  2934. Client* target_client = 0;
  2935. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2936. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2937. return;
  2938. }
  2939. // name provided with command so it has to be a player, npc not supported here
  2940. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2941. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2942. if (target_client) {
  2943. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2944. target = 0;
  2945. else
  2946. target = target_client->GetPlayer();
  2947. }
  2948. }
  2949. // if name was not provided use the players target, npc or player supported here
  2950. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2951. target = (Entity*)client->GetPlayer()->GetTarget();
  2952. if (target->IsPlayer()) {
  2953. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2954. }
  2955. }
  2956. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2957. if (result == 0) {
  2958. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2959. if (target_client) {
  2960. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2961. if (packet) {
  2962. packet->setDataByName("type", 1);
  2963. packet->setDataByName("name", client->GetPlayer()->GetName());
  2964. packet->setDataByName("unknown2", 1);
  2965. target_client->QueuePacket(packet->serialize());
  2966. safe_delete(packet);
  2967. }
  2968. }
  2969. }
  2970. else if (result == 1)
  2971. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2972. else if (result == 2)
  2973. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2974. else if (result == 3)
  2975. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2976. else if (result == 4)
  2977. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2978. else if (result == 5)
  2979. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2980. else if (result == 6)
  2981. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2982. else
  2983. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2984. break;
  2985. }
  2986. case COMMAND_GROUPDISBAND: {
  2987. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2988. if (gmi) { // TODO: Leader check
  2989. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2990. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2991. }
  2992. break;
  2993. }
  2994. case COMMAND_GROUP_LEAVE: {
  2995. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2996. if (gmi) {
  2997. int32 group_id = gmi->group_id;
  2998. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2999. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  3000. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  3001. }
  3002. else {
  3003. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  3004. }
  3005. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  3006. }
  3007. break;
  3008. }
  3009. case COMMAND_FRIEND_ADD:{
  3010. string name = "";
  3011. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3012. name = database.GetPlayerName(sep->arg[0]);
  3013. else if(cmdTarget && cmdTarget->IsPlayer())
  3014. name = string(cmdTarget->GetName());
  3015. if(name.length() > 0){
  3016. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3017. if(client->GetPlayer()->IsIgnored(name.c_str())){
  3018. client->GetPlayer()->RemoveIgnore(name.c_str());
  3019. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3020. client->SendChatRelationship(3, name.c_str());
  3021. }
  3022. client->GetPlayer()->AddFriend(name.c_str(), true);
  3023. client->SendChatRelationship(0, name.c_str());
  3024. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  3025. if(zone_list.GetClientByCharName(name))
  3026. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  3027. }
  3028. else
  3029. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  3030. }
  3031. else
  3032. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3033. break;
  3034. }
  3035. case COMMAND_FRIEND_REMOVE:{
  3036. string name = "";
  3037. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3038. name = database.GetPlayerName(sep->arg[0]);
  3039. else if(cmdTarget && cmdTarget->IsPlayer())
  3040. name = string(cmdTarget->GetName());
  3041. if(name.length() > 0){
  3042. client->GetPlayer()->RemoveFriend(name.c_str());
  3043. client->SendChatRelationship(1, name.c_str());
  3044. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3045. }
  3046. else
  3047. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3048. break;
  3049. }
  3050. case COMMAND_FRIENDS:{
  3051. break;
  3052. }
  3053. case COMMAND_IGNORE_ADD:{
  3054. string name = "";
  3055. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3056. name = database.GetPlayerName(sep->arg[0]);
  3057. else if(cmdTarget && cmdTarget->IsPlayer())
  3058. name = string(cmdTarget->GetName());
  3059. if(name.length() > 0){
  3060. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3061. if(client->GetPlayer()->IsFriend(name.c_str())){
  3062. client->GetPlayer()->RemoveFriend(name.c_str());
  3063. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3064. client->SendChatRelationship(1, name.c_str());
  3065. }
  3066. client->GetPlayer()->AddIgnore(name.c_str(), true);
  3067. client->SendChatRelationship(2, name.c_str());
  3068. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  3069. }
  3070. else
  3071. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  3072. }
  3073. else
  3074. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3075. break;
  3076. }
  3077. case COMMAND_IGNORE_REMOVE:{
  3078. string name = "";
  3079. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3080. name = database.GetPlayerName(sep->arg[0]);
  3081. else if(cmdTarget && cmdTarget->IsPlayer())
  3082. name = string(cmdTarget->GetName());
  3083. if(name.length() > 0){
  3084. client->GetPlayer()->RemoveIgnore(name.c_str());
  3085. client->SendChatRelationship(3, name.c_str());
  3086. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3087. }
  3088. break;
  3089. }
  3090. case COMMAND_IGNORES:{
  3091. break;
  3092. }
  3093. case COMMAND_GROUP_KICK:{
  3094. Entity* kicked = 0;
  3095. Client* kicked_client = 0;
  3096. int32 group_id = 0;
  3097. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  3098. return;
  3099. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  3100. if (sep && sep->arg[0]) {
  3101. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  3102. if (kicked_client)
  3103. kicked = kicked_client->GetPlayer();
  3104. }
  3105. else if (cmdTarget && cmdTarget->IsEntity()) {
  3106. kicked = (Entity*)cmdTarget;
  3107. }
  3108. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  3109. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  3110. if (kicked)
  3111. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  3112. if(send_kicked_message)
  3113. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  3114. else
  3115. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  3116. if (kicked_client)
  3117. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  3118. break;
  3119. }
  3120. case COMMAND_GROUP_MAKE_LEADER:{
  3121. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3122. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  3123. return;
  3124. }
  3125. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  3126. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  3127. if (new_leader) {
  3128. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  3129. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  3130. }
  3131. }
  3132. else
  3133. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  3134. }
  3135. else if (cmdTarget && cmdTarget->IsPlayer())
  3136. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  3137. else
  3138. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  3139. break;
  3140. }
  3141. case COMMAND_GROUP_ACCEPT_INVITE: {
  3142. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  3143. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  3144. if (result == 0)
  3145. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  3146. else if (result == 1)
  3147. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  3148. else if (result == 2)
  3149. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  3150. else
  3151. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  3152. }
  3153. break;
  3154. }
  3155. case COMMAND_GROUP_DECLINE_INVITE: {
  3156. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  3157. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  3158. }
  3159. break;
  3160. }
  3161. case COMMAND_SUMMON:{
  3162. char* search_name = 0;
  3163. if(sep && sep->arg[0][0])
  3164. search_name = sep->arg[0];
  3165. if(!search_name && !cmdTarget){
  3166. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  3167. 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.");
  3168. }
  3169. else{
  3170. if(!client->Summon(search_name))
  3171. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3172. }
  3173. break;
  3174. }
  3175. case COMMAND_GOTO:{
  3176. const char* search_name = 0;
  3177. if(sep && sep->arg[0][0])
  3178. search_name = sep->argplus[0];
  3179. if(!search_name && !cmdTarget){
  3180. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  3181. 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.");
  3182. }
  3183. else{
  3184. if(!client->GotoSpawn(search_name))
  3185. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3186. }
  3187. break;
  3188. }
  3189. case COMMAND_MOVE:{
  3190. bool success = false;
  3191. try{
  3192. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  3193. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  3194. if(app){
  3195. client->QueuePacket(app);
  3196. success = true;
  3197. }
  3198. }
  3199. }
  3200. catch(...){}
  3201. if(!success){
  3202. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  3203. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  3204. }
  3205. break;
  3206. }
  3207. case COMMAND_SETTIME:{
  3208. if(sep && sep->arg[0]){
  3209. world.MWorldTime.writelock(__FUNCTION__, __LINE__);
  3210. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  3211. if(sep->arg[1] && sep->IsNumber(1))
  3212. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  3213. if(sep->arg[2] && sep->IsNumber(2))
  3214. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  3215. if(sep->arg[3] && sep->IsNumber(3))
  3216. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  3217. world.MWorldTime.releasewritelock(__FUNCTION__, __LINE__);
  3218. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  3219. }
  3220. else{
  3221. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  3222. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  3223. }
  3224. break;
  3225. }
  3226. case COMMAND_VERSION:{
  3227. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  3228. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  3229. break;
  3230. }
  3231. case COMMAND_ZONE:{
  3232. int32 instanceID = 0;
  3233. string zone;
  3234. int32 zone_id = 0;
  3235. bool listSearch = false;
  3236. bool isInstance = false;
  3237. ZoneServer* zsZone = 0;
  3238. if(sep && sep->arg[0][0])
  3239. {
  3240. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  3241. listSearch = true;
  3242. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  3243. {
  3244. zone_list.SendZoneList(client);
  3245. break;
  3246. }
  3247. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  3248. {
  3249. if(sep->IsNumber(1))
  3250. instanceID = atol(sep->arg[1]);
  3251. }
  3252. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  3253. {
  3254. PrintSep(sep, "ZONE LOCK");
  3255. if(sep->IsNumber(1))
  3256. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  3257. else
  3258. zsZone = zone_list.Get(sep->arg[1], false);
  3259. if( zsZone )
  3260. {
  3261. zsZone->SetZoneLockState(true);
  3262. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3263. }
  3264. else
  3265. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  3266. break;
  3267. }
  3268. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  3269. {
  3270. PrintSep(sep, "ZONE UNLOCK");
  3271. if(sep->IsNumber(1))
  3272. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  3273. else
  3274. zsZone = zone_list.Get(sep->arg[1], false);
  3275. if( zsZone )
  3276. {
  3277. zsZone->SetZoneLockState(false);
  3278. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3279. }
  3280. else
  3281. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  3282. break;
  3283. }
  3284. else
  3285. {
  3286. if(sep->IsNumber(0))
  3287. {
  3288. zone_id = atoul(sep->arg[0]);
  3289. string zonename = database.GetZoneName(zone_id);
  3290. if(zonename.length() > 0)
  3291. zone = zonename;
  3292. }
  3293. else
  3294. zone = sep->arg[0];
  3295. }
  3296. if(instanceID > 0)
  3297. {
  3298. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  3299. if(zsInstance != NULL)
  3300. {
  3301. instanceID = zsInstance->GetInstanceID();
  3302. zone = zsInstance->GetZoneName();
  3303. zone_id = zsInstance->GetZoneID();
  3304. isInstance = true;
  3305. }
  3306. }
  3307. }
  3308. if(!listSearch)
  3309. {
  3310. if(zone.length() == 0)
  3311. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  3312. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  3313. zone_id != client->GetCurrentZone()->GetZoneID())
  3314. {
  3315. const char* zonestr = zone.c_str();
  3316. if(database.VerifyZone(zonestr))
  3317. {
  3318. if(client->CheckZoneAccess(zonestr))
  3319. {
  3320. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  3321. if(isInstance)
  3322. client->Zone(instanceID,true,true);
  3323. else
  3324. client->Zone(zonestr);
  3325. }
  3326. }
  3327. else
  3328. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  3329. }
  3330. else
  3331. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  3332. }
  3333. else
  3334. {
  3335. const char* name = 0;
  3336. if(sep && sep->arg[1][0])
  3337. {
  3338. map<int32, string>* zone_names;
  3339. name = sep->argplus[1];
  3340. sint16 status = client->GetAdminStatus();
  3341. if( status > 0 )
  3342. {
  3343. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  3344. zone_names = database.GetZoneList(name, true);
  3345. }
  3346. else
  3347. zone_names = database.GetZoneList(name);
  3348. if(!zone_names)
  3349. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  3350. else
  3351. {
  3352. map<int32, string>::iterator itr;
  3353. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  3354. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  3355. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  3356. safe_delete(zone_names);
  3357. }
  3358. }
  3359. else
  3360. {
  3361. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  3362. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  3363. }
  3364. }
  3365. break;
  3366. }
  3367. case COMMAND_USE: {
  3368. Spawn* target = cmdTarget;
  3369. if (target && target->IsWidget())
  3370. ((Widget*)target)->HandleUse(client, "use");
  3371. break;
  3372. }
  3373. case COMMAND_OPEN: {
  3374. Spawn* target = cmdTarget;
  3375. if (target && target->IsWidget())
  3376. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  3377. break;
  3378. }
  3379. case COMMAND_CASTSPELL: {
  3380. if (sep && sep->arg[0] && sep->IsNumber(0))
  3381. {
  3382. int8 tier = 1;
  3383. if (sep->arg[1] && sep->IsNumber(1))
  3384. tier = atoul(sep->arg[1]);
  3385. int8 self = 1;
  3386. if (sep->arg[1] && sep->IsNumber(2))
  3387. {
  3388. self = atoul(sep->arg[2]);
  3389. if(self != 1 && !cmdTarget->IsEntity())
  3390. {
  3391. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  3392. self = 1;
  3393. }
  3394. }
  3395. int32 spellid = atoul(sep->arg[0]);
  3396. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  3397. if (spell)
  3398. {
  3399. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3400. SpellProcess* spellProcess = 0;
  3401. // Get the current zones spell process
  3402. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3403. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3404. }
  3405. else
  3406. {
  3407. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3408. }
  3409. }
  3410. else if (sep && sep->arg[0])
  3411. {
  3412. database.FindSpell(client, (char*)sep->argplus[0]);
  3413. }
  3414. else
  3415. {
  3416. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3417. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3418. }
  3419. break;
  3420. }
  3421. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3422. if (client->GetVersion() <= 546)
  3423. break;
  3424. if (sep && sep->GetArgNumber() == 4)
  3425. {
  3426. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3427. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3428. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3429. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3430. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  3431. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3432. ClientPacketFunctions::SendSkillSlotMappings(client);
  3433. }
  3434. else
  3435. {
  3436. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3437. }
  3438. break;
  3439. }
  3440. case COMMAND_MOVE_ITEM:
  3441. {
  3442. int32 id = 0;
  3443. if (sep && sep->IsNumber(0))
  3444. id = atoul(sep->arg[0]);
  3445. Spawn* spawn = 0;
  3446. if (id == 0)
  3447. {
  3448. spawn = cmdTarget;
  3449. }
  3450. else
  3451. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3452. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3453. break;
  3454. client->SendMoveObjectMode(spawn, 0);
  3455. break;
  3456. }
  3457. case COMMAND_PICKUP:
  3458. {
  3459. int32 id = 0;
  3460. if (sep && sep->IsNumber(0))
  3461. id = atoul(sep->arg[0]);
  3462. Spawn* spawn = 0;
  3463. if (id == 0)
  3464. {
  3465. spawn = cmdTarget;
  3466. }
  3467. else
  3468. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3469. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3470. break;
  3471. client->AddItem(spawn->GetPickupItemID(), 1);
  3472. Query query;
  3473. 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());
  3474. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3475. client->GetCurrentZone()->RemoveSpawn(spawn, true, true);
  3476. }
  3477. // we had a UI Window displayed, update the house items
  3478. if ( id > 0 )
  3479. client->GetCurrentZone()->SendHouseItems(client);
  3480. break;
  3481. }
  3482. case COMMAND_HOUSE_DEPOSIT:
  3483. {
  3484. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3485. // arg0 = ??? (set to 3)
  3486. // arg1 = coin (in copper)
  3487. // arg2 = status? (not implemented yet)
  3488. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3489. if (ph && sep && sep->IsNumber(1))
  3490. {
  3491. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3492. int32 outValStatus = 0;
  3493. if(sep->IsNumber(2))
  3494. {
  3495. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3496. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3497. outValStatus = 0; // cheat check
  3498. }
  3499. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3500. {
  3501. if(outValStatus)
  3502. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3503. char query[256];
  3504. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3505. if (itr != ph->depositsMap.end())
  3506. {
  3507. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %I64u, last_amount = %I64u, status = status + %u, last_status = %u where house_id = %u and instance_id = %u and name='%s'", Timer::GetUnixTimeStamp(), outValCoin, outValCoin, outValStatus, outValStatus, ph->house_id, ph->instance_id, client->GetPlayer()->GetName());
  3508. }
  3509. else
  3510. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %I64u, status = %u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outValCoin, outValStatus);
  3511. if (database.RunQuery(query, strnlen(query, 256)))
  3512. {
  3513. ph->escrow_coins += outValCoin;
  3514. ph->escrow_status += outValStatus;
  3515. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3516. database.LoadDeposits(ph);
  3517. client->PlaySound("coin_cha_ching");
  3518. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3519. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3520. }
  3521. else
  3522. {
  3523. if(outValCoin)
  3524. client->GetPlayer()->AddCoins(outValCoin);
  3525. if(outValStatus)
  3526. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3527. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3528. }
  3529. }
  3530. }
  3531. break;
  3532. }
  3533. case COMMAND_HOUSE:
  3534. {
  3535. if (sep && sep->IsNumber(0))
  3536. {
  3537. int32 unique_id = atoi(sep->arg[0]);
  3538. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3539. HouseZone* hz = 0;
  3540. if (ph)
  3541. hz = world.GetHouseZone(ph->house_id);
  3542. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3543. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3544. }
  3545. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3546. {
  3547. // inside a house or something? Send the access window
  3548. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3549. HouseZone* hz = 0;
  3550. if ( ph )
  3551. hz = world.GetHouseZone(ph->house_id);
  3552. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3553. client->GetCurrentZone()->SendHouseItems(client);
  3554. }
  3555. break;
  3556. }
  3557. case COMMAND_HOUSE_UI:
  3558. {
  3559. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3560. {
  3561. int32 unique_id = atoi(sep->arg[0]);
  3562. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3563. HouseZone* hz = 0;
  3564. if ( ph )
  3565. hz = world.GetHouseZone(ph->house_id);
  3566. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3567. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  3568. }
  3569. break;
  3570. }
  3571. case COMMAND_PLACE_HOUSE_ITEM: {
  3572. if (sep && sep->IsNumber(0))
  3573. {
  3574. int32 uniqueid = atoi(sep->arg[0]);
  3575. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3576. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3577. if (item && item->IsHouseItem())
  3578. {
  3579. if (!client->HasOwnerOrEditAccess())
  3580. {
  3581. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3582. break;
  3583. }
  3584. else if (!item->generic_info.appearance_id)
  3585. {
  3586. 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);
  3587. break;
  3588. }
  3589. if (client->GetTempPlacementSpawn())
  3590. {
  3591. Spawn* tmp = client->GetTempPlacementSpawn();
  3592. client->GetCurrentZone()->RemoveSpawn(tmp);
  3593. client->SetTempPlacementSpawn(nullptr);
  3594. }
  3595. Spawn* spawn = new Object();
  3596. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3597. spawn->SetID(Spawn::NextID());
  3598. spawn->SetX(client->GetPlayer()->GetX());
  3599. spawn->SetY(client->GetPlayer()->GetY());
  3600. spawn->SetZ(client->GetPlayer()->GetZ());
  3601. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3602. spawn->SetSpawnOrigX(spawn->GetX());
  3603. spawn->SetSpawnOrigY(spawn->GetY());
  3604. spawn->SetSpawnOrigZ(spawn->GetZ());
  3605. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3606. spawn->appearance.targetable = 1;
  3607. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3608. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3609. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3610. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3611. spawn->SetZone(client->GetCurrentZone());
  3612. client->GetCurrentZone()->SendSpawn(spawn, client);
  3613. client->SetTempPlacementSpawn(spawn);
  3614. client->SetPlacementUniqueItemID(uniqueid);
  3615. client->SendMoveObjectMode(spawn, 0);
  3616. }
  3617. }
  3618. break;
  3619. }
  3620. case COMMAND_GM:
  3621. {
  3622. if (sep && sep->arg[0] && sep->arg[1])
  3623. {
  3624. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3625. if (strcmp(sep->arg[0], "vision") == 0)
  3626. {
  3627. client->GetPlayer()->SetGMVision(onOff);
  3628. #if defined(__GNUC__)
  3629. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3630. #else
  3631. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3632. #endif
  3633. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3634. if (onOff)
  3635. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3636. else
  3637. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3638. }
  3639. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3640. {
  3641. client->SetRegionDebug(onOff);
  3642. #if defined(__GNUC__)
  3643. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3644. #else
  3645. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3646. #endif
  3647. if (onOff)
  3648. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  3649. else
  3650. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  3651. }
  3652. else if (strcmp(sep->arg[0], "luadebug") == 0)
  3653. {
  3654. client->SetLuaDebugClient(onOff);
  3655. #if defined(__GNUC__)
  3656. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3657. #else
  3658. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  3659. #endif
  3660. if (onOff)
  3661. {
  3662. if (lua_interface)
  3663. lua_interface->UpdateDebugClients(client);
  3664. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3665. }
  3666. else
  3667. {
  3668. if (lua_interface)
  3669. lua_interface->RemoveDebugClients(client);
  3670. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3671. }
  3672. }
  3673. }
  3674. break;
  3675. }
  3676. case COMMAND_ATTACK:
  3677. case COMMAND_AUTO_ATTACK:{
  3678. int8 type = 1;
  3679. Player* player = client->GetPlayer();
  3680. if(!player)
  3681. break;
  3682. bool incombat = player->EngagedInCombat();
  3683. if(sep && sep->arg[0] && sep->IsNumber(0))
  3684. type = atoi(sep->arg[0]);
  3685. if(client->GetPlayer()->GetHP() == 0){
  3686. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  3687. break;
  3688. }
  3689. if(type == 0){
  3690. if(incombat)
  3691. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3692. player->StopCombat(type);
  3693. }
  3694. else {
  3695. if(type == 2){
  3696. player->InCombat(false);
  3697. if(incombat && player->GetRangeAttack()){
  3698. player->StopCombat(type);
  3699. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3700. }
  3701. else{
  3702. player->SetRangeAttack(true);
  3703. player->InCombat(true, true);
  3704. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3705. }
  3706. }
  3707. else {
  3708. player->InCombat(false, true);
  3709. player->SetRangeAttack(false);
  3710. player->InCombat(true);
  3711. if(!incombat)
  3712. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3713. }
  3714. /*else
  3715. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  3716. }
  3717. player->SetCharSheetChanged(true);
  3718. break;
  3719. }
  3720. case COMMAND_DEPOP:{
  3721. bool allow_respawns = false;
  3722. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3723. if(atoi(sep->arg[0]) == 1)
  3724. allow_respawns = true;
  3725. }
  3726. client->GetCurrentZone()->Depop(allow_respawns);
  3727. break;
  3728. }
  3729. case COMMAND_REPOP:{
  3730. client->GetCurrentZone()->Depop(false, true);
  3731. break;
  3732. }
  3733. case COMMAND_BUYBACK:{
  3734. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3735. // 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
  3736. int64 id = atoi64(sep->arg[0]);
  3737. // get the first int32, the item id
  3738. //int32 item_id = (int32)id;
  3739. // get the second int32, the unique id
  3740. int32 unique_id = (int32)(id>>32);
  3741. int8 quantity = atoi(sep->arg[1]);
  3742. if(quantity == 255)
  3743. quantity = 1;
  3744. client->BuyBack(unique_id, quantity);
  3745. }
  3746. break;
  3747. }
  3748. case COMMAND_MERCHANT_BUY:{
  3749. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3750. int32 item_id = atoul(sep->arg[0]);
  3751. int8 quantity = atoi(sep->arg[1]);
  3752. client->BuyItem(item_id, quantity);
  3753. }
  3754. else
  3755. Command_SendMerchantWindow(client, sep);
  3756. break;
  3757. }
  3758. case COMMAND_MERCHANT_SELL:{
  3759. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3760. // 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
  3761. int64 id = atoi64(sep->arg[0]);
  3762. // get the first int32, the item id
  3763. int32 item_id = (int32)id;
  3764. // get the second int32, the unique id
  3765. int32 unique_id = (int32)(id>>32);
  3766. int8 quantity = atoi(sep->arg[1]);
  3767. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  3768. client->SellItem(item_id, quantity, unique_id);
  3769. }
  3770. break;
  3771. }
  3772. case COMMAND_MENDER_REPAIR: {
  3773. if (sep && sep->arg[0] && sep->IsNumber(0))
  3774. client->RepairItem(atoul(sep->arg[0]));
  3775. break;
  3776. }
  3777. case COMMAND_MENDER_REPAIR_ALL: {
  3778. client->RepairAllItems();
  3779. break;
  3780. }
  3781. case COMMAND_CANCEL_MERCHANT:{
  3782. client->SetMerchantTransaction(0);
  3783. break;
  3784. }
  3785. case COMMAND_START_MERCHANT:{
  3786. break;
  3787. }
  3788. case COMMAND_INVULNERABLE:{
  3789. sint8 val = -1;
  3790. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3791. val = atoi(sep->arg[0]);
  3792. //devn00b: Fix for linux builds
  3793. #if defined(__GNUC__)
  3794. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  3795. #else
  3796. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3797. #endif
  3798. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3799. client->GetPlayer()->SetInvulnerable(val==1);
  3800. if(client->GetPlayer()->GetInvulnerable())
  3801. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  3802. else
  3803. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  3804. }
  3805. if(val == -1)
  3806. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  3807. break;
  3808. }
  3809. case COMMAND_REPAIR: {
  3810. Spawn* spawn = cmdTarget;
  3811. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  3812. client->SendHailCommand(spawn);
  3813. client->SetMerchantTransaction(spawn);
  3814. client->SendRepairList();
  3815. }
  3816. break;
  3817. }
  3818. case COMMAND_LOTTO: {
  3819. Spawn* spawn = cmdTarget;
  3820. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  3821. client->SetMerchantTransaction(spawn);
  3822. client->ShowLottoWindow();
  3823. }
  3824. break;
  3825. }
  3826. case COMMAND_ACCEPT_REWARD:{
  3827. int32 unknown = 0;
  3828. int32 selectable_item_id = 0;
  3829. //Quest *quest = 0;
  3830. Collection *collection = 0;
  3831. /* no idea what the first argument is for (faction maybe?)
  3832. if the reward has a selectable item reward, it's sent as the second argument
  3833. if neither of these are included in the reward, there is no sep
  3834. 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
  3835. only 1 quest or collection reward may be displayed at a time */
  3836. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3837. unknown = atoul(sep->arg[0]);
  3838. selectable_item_id = atoul(sep->arg[1]);
  3839. }
  3840. //if ((quest = player->GetPendingQuestReward()))
  3841. // client->AcceptQuestRewards(quest, selectable_item_id);
  3842. /* the below needs to go away eventually and be redone */
  3843. int32 item_id = 0;
  3844. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3845. item_id = atoul(sep->arg[0]);
  3846. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3847. if(quest){
  3848. client->AcceptQuestReward(quest, item_id);
  3849. break;
  3850. }
  3851. bool collectedItems = false;
  3852. if (collection = player->GetPendingCollectionReward())
  3853. {
  3854. client->AcceptCollectionRewards(collection, selectable_item_id);
  3855. collectedItems = true;
  3856. }
  3857. else if (client->GetPlayer()->HasPendingItemRewards()) {
  3858. vector<Item*> items = client->GetPlayer()->GetPendingItemRewards();
  3859. if (items.size() > 0) {
  3860. collectedItems = true;
  3861. for (int i = 0; i < items.size(); i++) {
  3862. client->GetPlayer()->AddItem(new Item(items[i]));
  3863. }
  3864. client->GetPlayer()->ClearPendingItemRewards();
  3865. }
  3866. map<int32, Item*> selectable_item = client->GetPlayer()->GetPendingSelectableItemReward(item_id);
  3867. if (selectable_item.size() > 0) {
  3868. collectedItems = true;
  3869. map<int32, Item*>::iterator itr;
  3870. for (itr = selectable_item.begin(); itr != selectable_item.end(); itr++) {
  3871. client->GetPlayer()->AddItem(new Item(itr->second));
  3872. client->GetPlayer()->ClearPendingSelectableItemRewards(itr->first);
  3873. }
  3874. }
  3875. }
  3876. if (collectedItems) {
  3877. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  3878. if (outapp)
  3879. client->QueuePacket(outapp);
  3880. }
  3881. else
  3882. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  3883. break;
  3884. }
  3885. case COMMAND_BUY_FROM_BROKER:{
  3886. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3887. int32 item_id = atoul(sep->arg[0]);
  3888. int16 quantity = atoul(sep->arg[1]);
  3889. Item* item = master_item_list.GetItem(item_id);
  3890. if(item && item->generic_info.max_charges > 1)
  3891. quantity = item->generic_info.max_charges;
  3892. client->AddItem(item_id, quantity);
  3893. }
  3894. break;
  3895. }
  3896. case COMMAND_SEARCH_STORES_PAGE:{
  3897. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3898. int32 page = atoul(sep->arg[0]);
  3899. client->SearchStore(page);
  3900. }
  3901. break;
  3902. }
  3903. case COMMAND_SEARCH_STORES:{
  3904. if(sep && sep->arg[0][0]){
  3905. const char* values = sep->argplus[0];
  3906. if(values){
  3907. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  3908. map<string, string> str_values = TranslateBrokerRequest(values);
  3909. vector<Item*>* items = master_item_list.GetItems(str_values);
  3910. if(items){
  3911. client->SetItemSearch(items);
  3912. client->SearchStore(0);
  3913. }
  3914. }
  3915. }
  3916. break;
  3917. }
  3918. case COMMAND_LUADEBUG:{
  3919. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  3920. client->SetLuaDebugClient(true);
  3921. if(lua_interface)
  3922. lua_interface->UpdateDebugClients(client);
  3923. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3924. }
  3925. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  3926. client->SetLuaDebugClient(false);
  3927. if(lua_interface)
  3928. lua_interface->RemoveDebugClients(client);
  3929. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3930. }
  3931. else{
  3932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  3933. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  3934. }
  3935. break;
  3936. }
  3937. case COMMAND_SPAWN_GROUP:
  3938. {
  3939. Spawn* target = cmdTarget;
  3940. if(target && target->IsPlayer() == false)
  3941. {
  3942. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  3943. {
  3944. if(target->GetSpawnLocationPlacementID() > 0)
  3945. {
  3946. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  3947. {
  3948. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  3949. if(id > 0)
  3950. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  3951. else
  3952. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  3953. target->SetSpawnGroupID(id);
  3954. target->AddSpawnToGroup(target);
  3955. }
  3956. else
  3957. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  3958. }
  3959. else
  3960. 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.");
  3961. }
  3962. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  3963. {
  3964. if(sep->arg[1] && sep->IsNumber(1))
  3965. {
  3966. int32 group_id = atoul(sep->arg[1]);
  3967. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  3968. if(leader)
  3969. {
  3970. leader->AddSpawnToGroup(target);
  3971. target->SetSpawnGroupID(group_id);
  3972. if(database.SpawnGroupAddSpawn(target, group_id))
  3973. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  3974. else
  3975. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  3976. }
  3977. else
  3978. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  3979. }
  3980. else
  3981. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  3982. }
  3983. else if(target->GetSpawnGroupID() == 0)
  3984. {
  3985. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  3986. }
  3987. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  3988. {
  3989. int32 group_id = target->GetSpawnGroupID();
  3990. target->RemoveSpawnFromGroup();
  3991. if(database.SpawnGroupRemoveSpawn(target, group_id))
  3992. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  3993. else
  3994. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  3995. }
  3996. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  3997. {
  3998. int32 group_id = target->GetSpawnGroupID();
  3999. if(sep->arg[1] && sep->IsNumber(1))
  4000. {
  4001. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  4002. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  4003. else
  4004. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  4005. }
  4006. else
  4007. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  4008. }
  4009. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  4010. {
  4011. int32 group_id = target->GetSpawnGroupID();
  4012. if(sep->arg[1] && sep->IsNumber(1))
  4013. {
  4014. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  4015. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  4016. else
  4017. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  4018. }
  4019. else
  4020. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  4021. }
  4022. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  4023. {
  4024. if(sep->arg[1] && sep->IsNumber(1))
  4025. {
  4026. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  4027. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  4028. else
  4029. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  4030. }
  4031. else
  4032. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  4033. }
  4034. else
  4035. {
  4036. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  4037. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  4038. }
  4039. }
  4040. else
  4041. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  4042. break;
  4043. }
  4044. case COMMAND_SPAWN_COMBINE:{
  4045. Spawn* spawn = cmdTarget;
  4046. float radius = 0;
  4047. bool failed = true;
  4048. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  4049. failed = false;
  4050. if(spawn->GetSpawnGroupID() > 0){
  4051. 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.");
  4052. }
  4053. else if(sep->IsNumber(0)){
  4054. radius = atof(sep->arg[0]);
  4055. client->CombineSpawns(radius, spawn);
  4056. }
  4057. else{
  4058. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  4059. client->AddCombineSpawn(spawn);
  4060. }
  4061. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  4062. client->RemoveCombineSpawn(spawn);
  4063. }
  4064. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  4065. const char* name = 0;
  4066. if(sep->arg[1] && sep->arg[1][0])
  4067. name = sep->argplus[1];
  4068. client->SaveCombineSpawns(name);
  4069. }
  4070. else
  4071. failed = true;
  4072. }
  4073. }
  4074. if(failed){
  4075. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  4076. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  4077. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  4078. }
  4079. break;
  4080. }
  4081. case COMMAND_SPAWN_CREATE:{
  4082. Spawn* spawn = 0;
  4083. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4084. spawn = new Object();
  4085. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4086. }
  4087. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4088. spawn = new GroundSpawn();
  4089. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4090. }
  4091. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4092. spawn = new Sign();
  4093. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4094. }
  4095. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4096. spawn = new NPC();
  4097. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4098. spawn->appearance.pos.collision_radius = 32;
  4099. spawn->secondary_command_list_id = 0;
  4100. spawn->primary_command_list_id = 0;
  4101. spawn->appearance.display_name = 1;
  4102. spawn->appearance.show_level = 1;
  4103. spawn->appearance.attackable = 1;
  4104. }
  4105. else{
  4106. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  4107. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  4108. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  4109. break;
  4110. }
  4111. spawn->SetID(Spawn::NextID());
  4112. spawn->SetX(client->GetPlayer()->GetX());
  4113. spawn->SetY(client->GetPlayer()->GetY());
  4114. spawn->SetZ(client->GetPlayer()->GetZ());
  4115. spawn->SetHeading(client->GetPlayer()->GetHeading());
  4116. spawn->SetSpawnOrigX(spawn->GetX());
  4117. spawn->SetSpawnOrigY(spawn->GetY());
  4118. spawn->SetSpawnOrigZ(spawn->GetZ());
  4119. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4120. if(spawn->IsSign())
  4121. {
  4122. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  4123. ((Sign*)spawn)->SetSignDistance(20.0f);
  4124. ((Sign*)spawn)->SetIncludeLocation(1);
  4125. ((Sign*)spawn)->SetIncludeHeading(1);
  4126. ((Sign*)spawn)->SetInitialState(1);
  4127. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  4128. ((Sign*)spawn)->SetActivityStatus(64);
  4129. spawn->appearance.race = 0;
  4130. spawn->SetLevel(0);
  4131. spawn->SetHP(0);
  4132. spawn->SetTotalHP(0);
  4133. spawn->SetPower(0);
  4134. spawn->SetTotalPower(0);
  4135. spawn->SetEncounterLevel(0);
  4136. spawn->SetTargetable(0);
  4137. spawn->SetSogaModelType(0);
  4138. spawn->SetCollisionRadius(19);
  4139. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  4140. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  4141. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  4142. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4143. spawn->appearance.model_type = atoul(sep->arg[1]);
  4144. }
  4145. else
  4146. {
  4147. spawn->appearance.targetable = 1;
  4148. spawn->appearance.race = 255;
  4149. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4150. spawn->SetModelType(atoi(sep->arg[1]));
  4151. spawn->SetAdventureClass(atoi(sep->arg[2]));
  4152. spawn->SetLevel(atoi(sep->arg[3]));
  4153. spawn->SetName(sep->arg[4]);
  4154. if(sep->arg[5][0] && sep->IsNumber(5))
  4155. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  4156. if(sep->arg[6][0] && sep->IsNumber(6))
  4157. spawn->size = atoi(sep->arg[6]);
  4158. if(spawn->GetTotalHP() == 0){
  4159. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  4160. spawn->SetHP(25*spawn->GetLevel() + 1);
  4161. }
  4162. if(spawn->GetTotalPower() == 0){
  4163. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  4164. spawn->SetPower(25*spawn->GetLevel() + 1);
  4165. }
  4166. }
  4167. client->GetCurrentZone()->AddSpawn(spawn);
  4168. break;
  4169. }
  4170. case COMMAND_SPAWN_EQUIPMENT:{
  4171. Spawn* spawn = cmdTarget;
  4172. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  4173. int8 slot = atoi(sep->arg[0]);
  4174. int16 type = atoi(sep->arg[1]);
  4175. int8 red = 0;
  4176. int8 green = 0;
  4177. int8 blue = 0;
  4178. int8 h_red = 0;
  4179. int8 h_green = 0;
  4180. int8 h_blue = 0;
  4181. if(sep->arg[2])
  4182. red = atoi(sep->arg[2]);
  4183. if(sep->arg[3])
  4184. green = atoi(sep->arg[3]);
  4185. if(sep->arg[4])
  4186. blue = atoi(sep->arg[4]);
  4187. if(sep->arg[5])
  4188. h_red = atoi(sep->arg[5]);
  4189. if(sep->arg[6])
  4190. h_green = atoi(sep->arg[6]);
  4191. if(sep->arg[7])
  4192. h_blue = atoi(sep->arg[7]);
  4193. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  4194. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  4195. }
  4196. else{
  4197. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  4198. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  4199. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  4200. }
  4201. break;
  4202. }
  4203. case COMMAND_SPAWN_DETAILS: {
  4204. Spawn* spawn = cmdTarget;
  4205. if (sep && sep->arg[0][0]) {
  4206. if (cmdTarget)
  4207. {
  4208. if (ToLower(string(sep->arg[0])) == "los")
  4209. {
  4210. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  4211. if (hasLOS)
  4212. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  4213. else
  4214. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  4215. break;
  4216. }
  4217. else if (ToLower(string(sep->arg[0])) == "bestz")
  4218. {
  4219. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  4220. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  4221. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  4222. break;
  4223. }
  4224. else if (ToLower(string(sep->arg[0])) == "inwater")
  4225. {
  4226. if (cmdTarget->GetRegionMap() == nullptr)
  4227. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  4228. else
  4229. {
  4230. bool inWater = cmdTarget->InWater();
  4231. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  4232. }
  4233. break;
  4234. }
  4235. else if (ToLower(string(sep->arg[0])) == "inlava")
  4236. {
  4237. if (cmdTarget->GetRegionMap() == nullptr)
  4238. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4239. else
  4240. {
  4241. bool inLava = cmdTarget->InLava();
  4242. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  4243. }
  4244. break;
  4245. }
  4246. else if (ToLower(string(sep->arg[0])) == "regions")
  4247. {
  4248. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  4249. if (cmdTarget->GetRegionMap() == nullptr)
  4250. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4251. else
  4252. {
  4253. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  4254. }
  4255. break;
  4256. }
  4257. else if (ToLower(string(sep->arg[0])) == "behind")
  4258. {
  4259. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  4260. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  4261. break;
  4262. }
  4263. else if (ToLower(string(sep->arg[0])) == "infront")
  4264. {
  4265. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  4266. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  4267. break;
  4268. }
  4269. else if (ToLower(string(sep->arg[0])) == "flank")
  4270. {
  4271. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  4272. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  4273. break;
  4274. }
  4275. }
  4276. if (sep->IsNumber(0))
  4277. {
  4278. float radius = atof(sep->arg[0]);
  4279. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  4280. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  4281. break;
  4282. }
  4283. }
  4284. if (spawn) {
  4285. const char* type = "NPC";
  4286. if (spawn->IsObject())
  4287. type = "Object";
  4288. else if (spawn->IsSign())
  4289. type = "Sign";
  4290. else if (spawn->IsWidget())
  4291. type = "Widget";
  4292. else if (spawn->IsGroundSpawn())
  4293. type = "GroundSpawn";
  4294. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  4295. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  4296. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  4297. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  4298. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  4299. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  4300. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  4301. 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());
  4302. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  4303. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  4304. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  4305. if (spawn->IsEntity()) {
  4306. 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());
  4307. 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());
  4308. }
  4309. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  4310. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  4311. 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());
  4312. 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);
  4313. if (spawn->IsNPC())
  4314. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  4315. string details;
  4316. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  4317. details += "Type: " + string(type) + "\n";
  4318. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  4319. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  4320. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  4321. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  4322. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  4323. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  4324. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  4325. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  4326. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  4327. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  4328. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  4329. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  4330. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  4331. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  4332. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  4333. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  4334. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  4335. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  4336. char x[16];
  4337. sprintf(x, "%.2f", spawn->GetX());
  4338. char y[16];
  4339. sprintf(y, "%.2f", spawn->GetY());
  4340. char z[16];
  4341. sprintf(z, "%.2f", spawn->GetZ());
  4342. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  4343. string details2;
  4344. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  4345. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  4346. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  4347. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  4348. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  4349. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  4350. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  4351. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  4352. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  4353. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  4354. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  4355. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  4356. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  4357. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  4358. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  4359. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  4360. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  4361. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  4362. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  4363. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  4364. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  4365. string details3;
  4366. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  4367. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  4368. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  4369. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  4370. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  4371. if(spawn->IsEntity())
  4372. {
  4373. Entity* ent = (Entity*)spawn;
  4374. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  4375. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  4376. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  4377. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  4378. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  4379. }
  4380. string details4;
  4381. if (spawn->IsEntity()) {
  4382. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  4383. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4384. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4385. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4386. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4387. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4388. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4389. if (spawn->IsNPC()) {
  4390. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4391. }
  4392. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4393. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4394. }
  4395. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4396. client->SendShowBook(client->GetPlayer(), title, 4, details, details2, details3, details4);
  4397. }
  4398. else {
  4399. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4400. 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.");
  4401. }
  4402. break;
  4403. }
  4404. case COMMAND_SPAWN_TARGET:{
  4405. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4406. int32 spawn_id = atoul(sep->arg[0]);
  4407. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4408. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4409. }
  4410. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4411. float distance = atof(sep->arg[1]);
  4412. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4413. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4414. }
  4415. else{
  4416. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4417. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4418. }
  4419. break;
  4420. }
  4421. case COMMAND_SPAWN_SET:
  4422. {
  4423. Spawn* spawn = cmdTarget;
  4424. sint16 set_type = -1;
  4425. string type_str;
  4426. if (spawn)
  4427. {
  4428. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4429. 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)
  4430. {
  4431. // set the type, which will be 0 if location or list or invalid
  4432. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4433. }
  4434. if(set_type > 0)
  4435. {
  4436. // check if spawn set is NOT a char update, or not location, or isn't a number
  4437. 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)
  4438. {
  4439. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4440. }
  4441. else
  4442. {
  4443. string name = string(spawn->GetName());
  4444. bool customSetSpawn = false;
  4445. if(set_type >= SPAWN_SET_CHEEK_TYPE && set_type <= SPAWN_SET_SOGA_NOSE_TYPE)
  4446. {
  4447. int8 index = sep->IsNumber(2) ? atoul(sep->arg[2]) : 0;
  4448. // override the standard setspawncommand, we pass arguments different!
  4449. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1], true, false, nullptr, index))
  4450. customSetSpawn = true;
  4451. }
  4452. if(customSetSpawn || SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4453. {
  4454. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4455. {
  4456. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4457. }
  4458. else if (set_type == SPAWN_SET_VALUE_NAME)
  4459. {
  4460. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4461. }
  4462. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4463. {
  4464. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4465. }
  4466. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4467. {
  4468. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4469. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  4470. }
  4471. else
  4472. {
  4473. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  4474. }
  4475. switch (set_type)
  4476. {
  4477. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4478. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4479. case SPAWN_SET_VALUE_FACTION:
  4480. case SPAWN_SET_AAXP_REWARDS:
  4481. case SPAWN_SET_CHEEK_TYPE:
  4482. case SPAWN_SET_CHIN_TYPE:
  4483. case SPAWN_SET_EAR_TYPE:
  4484. case SPAWN_SET_EYE_BROW_TYPE:
  4485. case SPAWN_SET_EYE_TYPE:
  4486. case SPAWN_SET_LIP_TYPE:
  4487. case SPAWN_SET_NOSE_TYPE:
  4488. case SPAWN_SET_BODY_SIZE:
  4489. case SPAWN_SET_BODY_AGE:
  4490. case SPAWN_SET_SOGA_CHEEK_TYPE:
  4491. case SPAWN_SET_SOGA_CHIN_TYPE:
  4492. case SPAWN_SET_SOGA_EAR_TYPE:
  4493. case SPAWN_SET_SOGA_EYE_BROW_TYPE:
  4494. case SPAWN_SET_SOGA_EYE_TYPE:
  4495. case SPAWN_SET_SOGA_LIP_TYPE:
  4496. case SPAWN_SET_SOGA_NOSE_TYPE:
  4497. case SPAWN_SET_SOGA_BODY_SIZE:
  4498. case SPAWN_SET_SOGA_BODY_AGE:
  4499. {
  4500. // not applicable already ran db command
  4501. break;
  4502. }
  4503. default:
  4504. {
  4505. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4506. break;
  4507. }
  4508. }
  4509. 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))
  4510. {
  4511. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4512. {
  4513. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  4514. }
  4515. else if(spawn->GetSpawnLocationID() > 0)
  4516. {
  4517. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4518. }
  4519. }
  4520. else
  4521. {
  4522. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4523. {
  4524. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  4525. }
  4526. else if(spawn->GetDatabaseID() > 0)
  4527. {
  4528. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4529. }
  4530. }
  4531. }
  4532. }
  4533. }
  4534. else if(set_type == 0)
  4535. {
  4536. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4537. map<string, int8>::iterator itr;
  4538. int i=0;
  4539. string list;
  4540. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4541. {
  4542. if(i==10)
  4543. {
  4544. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4545. i = 0;
  4546. }
  4547. if(i>0)
  4548. {
  4549. list.append(", ").append(itr->first);
  4550. }
  4551. else
  4552. {
  4553. list = itr->first;
  4554. }
  4555. }
  4556. if(list.length() > 0)
  4557. {
  4558. // if 1 or more, display in client.
  4559. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4560. }
  4561. }
  4562. else
  4563. {
  4564. // syntax fail
  4565. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4566. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4567. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4568. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4569. }
  4570. }
  4571. break;
  4572. }
  4573. case COMMAND_SPAWN_REMOVE:{
  4574. Spawn* spawn = cmdTarget;
  4575. if(spawn && !spawn->IsPlayer()){
  4576. if(spawn->GetSpawnLocationID() > 0){
  4577. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4578. client->GetCurrentZone()->RemoveSpawn(spawn, true, false);
  4579. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  4580. }
  4581. else
  4582. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4583. }
  4584. else
  4585. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4586. }
  4587. else{
  4588. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4589. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4590. }
  4591. break;
  4592. }
  4593. case COMMAND_SPAWN_LIST:{
  4594. if(sep && sep->arg[0][0]){
  4595. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4596. vector<string>::iterator itr;
  4597. if(results){
  4598. for(itr=results->begin();itr!=results->end();itr++){
  4599. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4600. }
  4601. safe_delete(results);
  4602. }
  4603. else
  4604. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4605. }
  4606. else{
  4607. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4608. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4609. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4610. }
  4611. break;
  4612. }
  4613. case COMMAND_SPAWN_ADD:{
  4614. Spawn* spawn = cmdTarget;
  4615. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  4616. if(spawn->GetSpawnLocationID() > 0){
  4617. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4618. break;
  4619. }
  4620. if(spawn->GetDatabaseID() == 0){
  4621. if(database.SaveSpawnInfo(spawn)) {
  4622. char spawn_type[32];
  4623. memset(spawn_type, 0, sizeof(spawn_type));
  4624. if (spawn->IsNPC())
  4625. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4626. else if (spawn->IsObject())
  4627. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4628. else if (spawn->IsSign())
  4629. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4630. else if (spawn->IsGroundSpawn())
  4631. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4632. else
  4633. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4634. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4635. }
  4636. else
  4637. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4638. }
  4639. int32 spawn_group_id = 0;
  4640. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4641. spawn_group_id = database.GetNextSpawnLocation();
  4642. else
  4643. spawn_group_id = atol(sep->arg[0]);
  4644. int8 percent = 100;
  4645. if(sep->arg[2] && sep->IsNumber(2))
  4646. percent = atoi(sep->arg[2]);
  4647. spawn->SetSpawnLocationID(spawn_group_id);
  4648. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4649. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4650. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4651. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4652. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4653. else
  4654. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  4655. }
  4656. else{
  4657. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  4658. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  4659. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  4660. }
  4661. break;
  4662. }
  4663. case COMMAND_SPAWN:{
  4664. int32 id = 0;
  4665. Spawn* spawn = 0;
  4666. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4667. id = atol(sep->arg[0]);
  4668. spawn = client->GetCurrentZone()->GetSpawn(id);
  4669. }
  4670. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  4671. id = 0;
  4672. if(!id || !spawn){
  4673. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  4674. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  4675. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  4676. safe_delete(sep);
  4677. return;
  4678. }
  4679. if(sep && sep->arg[1][0]){
  4680. float x = atof(sep->arg[1]);
  4681. spawn->appearance.pos.X = x;
  4682. }
  4683. else
  4684. spawn->SetX(client->GetPlayer()->GetX(), false);
  4685. if(sep && sep->arg[2][0]){
  4686. float y = atof(sep->arg[2]);
  4687. spawn->appearance.pos.Y = y;
  4688. }
  4689. else
  4690. spawn->SetY(client->GetPlayer()->GetY(), false);
  4691. if(sep && sep->arg[3][0]){
  4692. float z = atof(sep->arg[3]);
  4693. spawn->appearance.pos.Z = z;
  4694. }
  4695. else
  4696. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  4697. if(sep && sep->arg[4][0]){
  4698. float heading = atof(sep->arg[4]);
  4699. spawn->SetHeading(heading);
  4700. }
  4701. else
  4702. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  4703. spawn->SetSpawnOrigX(spawn->GetX());
  4704. spawn->SetSpawnOrigY(spawn->GetY());
  4705. spawn->SetSpawnOrigZ(spawn->GetZ());
  4706. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4707. if(sep && sep->arg[5][0])
  4708. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  4709. else
  4710. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4711. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  4712. spawn->SetTotalHP(spawn->GetLevel() * 15);
  4713. spawn->SetHP(spawn->GetTotalHP());
  4714. }
  4715. if(spawn->GetTotalPower() == 0){
  4716. spawn->SetTotalPower(spawn->GetLevel() * 15);
  4717. spawn->SetPower(spawn->GetTotalPower());
  4718. }
  4719. const char* script = world.GetSpawnScript(id);
  4720. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  4721. spawn->SetSpawnScript(string(script));
  4722. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  4723. client->GetCurrentZone()->AddSpawn(spawn);
  4724. if(spawn->IsNPC())
  4725. spawn->GetZone()->AddLoot((NPC*)spawn);
  4726. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  4727. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  4728. break;
  4729. }
  4730. case COMMAND_ADMINFLAG:
  4731. {
  4732. if(sep && sep->arg[0]){
  4733. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  4734. sint16 new_status = atoi(sep->arg[1]);
  4735. if(tmp_status == -10)
  4736. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  4737. else if(tmp_status >= client->GetAdminStatus())
  4738. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  4739. else if (new_status > client->GetAdminStatus())
  4740. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  4741. else{
  4742. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  4743. if (!client2)
  4744. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  4745. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  4746. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  4747. if (client2) {
  4748. client2->SetAdminStatus(new_status);
  4749. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  4750. }
  4751. }
  4752. else
  4753. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  4754. }
  4755. }else{
  4756. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  4757. if(status != client->GetAdminStatus())
  4758. {
  4759. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  4760. client->SetAdminStatus(status);
  4761. }
  4762. else
  4763. {
  4764. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  4765. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  4766. client->Message(CHANNEL_COLOR_YELLOW," Admin User: %i", status);
  4767. }
  4768. }
  4769. break;
  4770. }
  4771. case COMMAND_CANNEDEMOTE:{
  4772. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  4773. break;
  4774. }
  4775. case COMMAND_BROADCAST: {
  4776. if (sep && sep->arg[0])
  4777. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  4778. else
  4779. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  4780. break;
  4781. }
  4782. case COMMAND_ANNOUNCE: {
  4783. if (sep && sep->arg[0])
  4784. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  4785. else
  4786. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  4787. break;
  4788. }
  4789. case COMMAND_RELOAD_ITEMS:{
  4790. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  4791. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  4792. database.ReloadItemList();
  4793. database.LoadMerchantInformation();
  4794. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  4795. break;
  4796. }
  4797. case COMMAND_ENABLE_ABILITY_QUE:{
  4798. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  4799. if(app)
  4800. client->QueuePacket(app);
  4801. break;
  4802. }
  4803. case COMMAND_ITEMSEARCH:
  4804. case COMMAND_FROMBROKER:{
  4805. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  4806. if (packet) {
  4807. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  4808. //packet->setDataByName("unknown", 1);
  4809. packet->setDataByName("unknown2", 5, 0);
  4810. packet->setDataByName("unknown2", 20, 1);
  4811. packet->setDataByName("unknown2", 58, 3);
  4812. packet->setDataByName("unknown2", 40, 4);
  4813. client->QueuePacket(packet->serialize());
  4814. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  4815. if (packet2) {
  4816. packet2->setDataByName("char_id", client->GetCharacterID());
  4817. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  4818. safe_delete(packet2);
  4819. }
  4820. safe_delete(packet);
  4821. }
  4822. break;
  4823. }
  4824. case COMMAND_ANIMTEST:{
  4825. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  4826. if(command_packet){
  4827. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  4828. if (cmdTarget)
  4829. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  4830. command_packet->setDataByName ( "spawn_id" , id);
  4831. int animID = 1;
  4832. if(sep && sep->arg[0] && sep->IsNumber(0))
  4833. animID = atoi(sep->arg[0]);
  4834. VisualState* vs = NULL;
  4835. if(animID == 0)
  4836. {
  4837. vs = visual_states.FindVisualState(sep->arg[0]);
  4838. }
  4839. char msg[128];
  4840. sprintf(msg,"Animation Test ID: %i",animID);
  4841. command_packet->setMediumStringByName ( "emote_msg" , msg );
  4842. if(vs != NULL)
  4843. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  4844. else
  4845. command_packet->setDataByName ( "anim_type", animID );
  4846. command_packet->setDataByName ( "unknown0", 0 );
  4847. EQ2Packet* outapp = command_packet->serialize();
  4848. client->QueuePacket(outapp);
  4849. safe_delete(command_packet);
  4850. }
  4851. break;
  4852. }
  4853. case COMMAND_KICK:
  4854. {
  4855. if( sep == 0 || sep->arg[0] == 0)
  4856. {
  4857. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  4858. }
  4859. else
  4860. {
  4861. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  4862. if ( kickClient == client )
  4863. {
  4864. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  4865. break;
  4866. }
  4867. else if(kickClient != NULL)
  4868. {
  4869. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  4870. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  4871. {
  4872. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  4873. break;
  4874. }
  4875. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  4876. kickClient->Disconnect();
  4877. }
  4878. else
  4879. {
  4880. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  4881. }
  4882. }
  4883. break;
  4884. }
  4885. case COMMAND_LOCK:
  4886. {
  4887. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  4888. int worldLocked = atoi(sep->arg[0]);
  4889. net.world_locked = worldLocked;
  4890. if ( worldLocked )
  4891. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  4892. else
  4893. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  4894. }
  4895. else
  4896. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  4897. break;
  4898. }
  4899. case COMMAND_BAN:{
  4900. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  4901. {
  4902. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  4903. }
  4904. else
  4905. {
  4906. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  4907. if ( kickClient == client )
  4908. {
  4909. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  4910. break;
  4911. }
  4912. else if(kickClient != NULL)
  4913. {
  4914. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  4915. if ( maxStatus > client->GetAdminStatus( ) ||
  4916. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  4917. {
  4918. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  4919. break;
  4920. }
  4921. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  4922. int perm = atol(sep->arg[1]);
  4923. if ( perm == 1 )
  4924. database.UpdateAdminStatus(sep->arg[0],-2);
  4925. else
  4926. database.UpdateAdminStatus(sep->arg[0],-1);
  4927. kickClient->Disconnect();
  4928. }
  4929. else
  4930. {
  4931. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  4932. }
  4933. }
  4934. break;
  4935. }
  4936. case COMMAND_SET_COMBAT_VOICE:{
  4937. int32 value = 0;
  4938. if(sep && sep->arg[0] && sep->IsNumber(0))
  4939. value = atoi(sep->arg[0]);
  4940. client->GetPlayer()->SetCombatVoice(value);
  4941. break;
  4942. }
  4943. case COMMAND_SET_EMOTE_VOICE:{
  4944. int32 value = 0;
  4945. if(sep && sep->arg[0] && sep->IsNumber(0))
  4946. value = atoi(sep->arg[0]);
  4947. client->GetPlayer()->SetEmoteVoice(value);
  4948. break;
  4949. }
  4950. case COMMAND_GIVEITEM:{
  4951. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  4952. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  4953. if ( itemToClient == NULL )
  4954. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  4955. else
  4956. {
  4957. int32 item_id = atol(sep->arg[1]);
  4958. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  4959. itemToClient->AddItem(item_id);
  4960. }
  4961. }
  4962. else
  4963. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  4964. break;
  4965. }
  4966. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  4967. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  4968. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  4969. case COMMAND_SKILL :
  4970. case COMMAND_SKILL_ADD :
  4971. case COMMAND_SKILL_REMOVE :
  4972. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  4973. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  4974. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  4975. case COMMAND_ENTITYCOMMAND :
  4976. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  4977. case COMMAND_MERCHANT :
  4978. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  4979. case COMMAND_APPEARANCE :
  4980. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  4981. case COMMAND_TRACK : { Command_Track(client); break; }
  4982. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  4983. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  4984. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  4985. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  4986. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  4987. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  4988. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  4989. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  4990. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  4991. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  4992. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  4993. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  4994. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  4995. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  4996. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  4997. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  4998. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  4999. case COMMAND_LOCATION : { Command_Location(client); break; }
  5000. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  5001. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  5002. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  5003. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  5004. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  5005. case COMMAND_GRID : { Command_Grid(client); break; }
  5006. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  5007. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  5008. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  5009. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  5010. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  5011. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  5012. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  5013. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  5014. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  5015. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  5016. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  5017. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  5018. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  5019. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  5020. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  5021. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  5022. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  5023. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  5024. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  5025. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  5026. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  5027. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  5028. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  5029. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  5030. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  5031. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  5032. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  5033. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  5034. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  5035. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  5036. case COMMAND_MOTD : { Command_MOTD(client); break; }
  5037. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  5038. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  5039. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  5040. case COMMAND_TITLE : { Command_Title(client); break; }
  5041. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  5042. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  5043. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  5044. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  5045. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  5046. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  5047. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  5048. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  5049. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  5050. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  5051. case COMMAND_PET : { Command_Pet(client, sep); break; }
  5052. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  5053. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  5054. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  5055. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  5056. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  5057. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  5058. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  5059. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  5060. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  5061. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  5062. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  5063. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  5064. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  5065. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  5066. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  5067. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  5068. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  5069. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  5070. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  5071. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  5072. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  5073. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  5074. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  5075. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  5076. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  5077. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  5078. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  5079. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  5080. case COMMAND_MODIFY : { Command_Modify(client); break; }
  5081. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  5082. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  5083. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  5084. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  5085. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  5086. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  5087. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  5088. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  5089. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  5090. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  5091. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  5092. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  5093. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  5094. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  5095. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  5096. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  5097. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  5098. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  5099. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  5100. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  5101. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  5102. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5103. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  5104. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  5105. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  5106. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  5107. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  5108. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  5109. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  5110. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  5111. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  5112. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  5113. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  5114. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  5115. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  5116. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  5117. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  5118. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  5119. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  5120. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  5121. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  5122. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  5123. case ADD_AA : { Add_AA(client, sep); break; }
  5124. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  5125. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  5126. case BACK_AA : { Back_AA(client, sep); break; }
  5127. case REMOVE_AA : { Remove_AA(client, sep); break; }
  5128. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  5129. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  5130. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  5131. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  5132. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  5133. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  5134. case COMMAND_CRAFTITEM: {
  5135. Item* item = 0;
  5136. if (sep && sep->IsNumber(0)) {
  5137. int32 item_id = atol(sep->arg[0]);
  5138. int32 quantity = 1;
  5139. if (sep->arg[1] && sep->IsNumber(1))
  5140. quantity = atoi(sep->arg[1]);
  5141. item = new Item(master_item_list.GetItem(item_id));
  5142. if (!item) {
  5143. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  5144. }
  5145. else {
  5146. item->details.count = quantity;
  5147. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  5148. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  5149. bool itemDeleted = false;
  5150. client->AddItem(item, &itemDeleted);
  5151. //Check for crafting quest updates
  5152. int8 update_amt = 0;
  5153. if (!itemDeleted && item->stack_count > 1)
  5154. update_amt = 1;
  5155. else
  5156. update_amt = quantity;
  5157. if(!itemDeleted)
  5158. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  5159. }
  5160. }
  5161. else {
  5162. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  5163. }
  5164. break;
  5165. }
  5166. case COMMAND_UNMENTOR:
  5167. case COMMAND_MENTOR: {
  5168. client->GetPlayer()->MentorTarget();
  5169. break;
  5170. }
  5171. default:
  5172. {
  5173. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  5174. break;
  5175. }
  5176. }
  5177. safe_delete(sep);
  5178. }
  5179. /******************** New COMMAND Handler Functions ********************/
  5180. /*
  5181. Started breaking apart the huge switch() for commands into sepErate
  5182. functions so it is easier to locate the blocks of code by command
  5183. -- JA 2012.03.03
  5184. */
  5185. // sample function header
  5186. /*
  5187. Function:
  5188. Purpose :
  5189. Params :
  5190. Dev :
  5191. Example :
  5192. */
  5193. //void Commands::Command()
  5194. //{
  5195. //}
  5196. /*
  5197. Function: Command_AcceptAdvancement()
  5198. Purpose : Player accepts a new advancement option
  5199. Params : Spell ID
  5200. Dev : Jabantiz
  5201. */
  5202. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  5203. {
  5204. Player *player = client->GetPlayer();
  5205. if (sep && sep->IsSet(0)) {
  5206. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  5207. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  5208. if (!player->HasSpell(trait->spellID, 0, true))
  5209. {
  5210. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5211. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5212. }
  5213. else
  5214. {
  5215. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5216. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  5217. player->RemoveSpellBookEntry(spell->GetSpellID());
  5218. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5219. player->UnlockSpell(spell);
  5220. client->SendSpellUpdate(spell);
  5221. }
  5222. // Spell book update
  5223. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  5224. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  5225. }
  5226. }
  5227. /*
  5228. Function:
  5229. Purpose :
  5230. Params :
  5231. Dev :
  5232. Example :
  5233. */
  5234. void Commands::Command_AFK(Client* client, Seperator* sep)
  5235. {
  5236. Player* player = client->GetPlayer();
  5237. player->toggle_character_flag(CF_AFK);
  5238. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  5239. if (player->get_character_flag(CF_AFK))
  5240. {
  5241. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  5242. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  5243. if (sep && sep->argplus[0])
  5244. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  5245. else
  5246. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  5247. string message = string(player->GetName()) + " is going afk.";
  5248. Spawn* target = player->GetTarget();
  5249. if (target && target != player)
  5250. {
  5251. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  5252. player->GetGender() == 1 ? message += "he" : message += "she";
  5253. message += " is going afk.";
  5254. }
  5255. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  5256. }
  5257. /*else
  5258. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  5259. }
  5260. /*
  5261. Function: Command_Appearance()
  5262. Purpose : Handles /appearance commands
  5263. Params : list
  5264. Dev : Scatman
  5265. Example : /appearance list
  5266. */
  5267. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  5268. {
  5269. if( handler == COMMAND_APPEARANCE )
  5270. {
  5271. // /appearance command by itself shows help (to be extended)
  5272. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5273. return;
  5274. }
  5275. else if( handler == COMMAND_APPEARANCE_LIST )
  5276. {
  5277. // /appearance list command expects "name" param
  5278. if (sep && sep->arg[0])
  5279. {
  5280. const char* appearance_name = sep->argplus[0];
  5281. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  5282. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  5283. if (appearances)
  5284. {
  5285. vector<int16>::iterator itr;
  5286. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  5287. {
  5288. int16 id = *itr;
  5289. string name = database.GetAppearanceName(id);
  5290. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  5291. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  5292. }
  5293. safe_delete(appearances);
  5294. }
  5295. }
  5296. else // no param
  5297. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5298. }
  5299. }
  5300. /*
  5301. Function: Command_Claim()
  5302. Purpose :
  5303. Params :
  5304. Dev :
  5305. Example :
  5306. */
  5307. void Commands::Command_Claim(Client* client, Seperator* sep)
  5308. {
  5309. if (sep && sep->arg[0] && sep->IsNumber(0))
  5310. {
  5311. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5312. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  5313. }
  5314. else
  5315. client->ShowClaimWindow();
  5316. }
  5317. /*
  5318. Function: Command_ClearAllQueued()
  5319. Purpose :
  5320. Params :
  5321. Dev :
  5322. Example :
  5323. */
  5324. void Commands::Command_ClearAllQueued(Client* client)
  5325. {
  5326. ZoneServer* zone = client->GetPlayer()->GetZone();
  5327. if (zone && zone->GetSpellProcess())
  5328. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  5329. }
  5330. /*
  5331. Function: Command_CancelMaintained()
  5332. Purpose : Cancels maintained spells
  5333. Params : Maintained Spell Index
  5334. Dev : Zcoretri
  5335. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  5336. */
  5337. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  5338. {
  5339. if (sep && sep->arg[0] && sep->IsNumber(0))
  5340. {
  5341. int32 spell_index = atoul(sep->arg[0]);
  5342. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  5343. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  5344. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  5345. // just not spelleffects/dets - Foof
  5346. //{
  5347. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled"))
  5348. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  5349. // }
  5350. //else
  5351. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  5352. }
  5353. }
  5354. /*
  5355. Function: Command_Create()
  5356. Purpose : Handler for starting Tradeskilling table
  5357. Params :
  5358. Dev : Zcoretri
  5359. Example :
  5360. */
  5361. void Commands::Command_Create(Client* client, Seperator* sep)
  5362. {
  5363. PrintSep(sep, "COMMAND_CREATE");
  5364. client->SendRecipeList();
  5365. client->ShowRecipeBook();
  5366. }
  5367. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  5368. {
  5369. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  5370. if (sep && sep->arg[0] && sep->IsNumber(0))
  5371. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  5372. }
  5373. /*
  5374. Function: Command_Distance()
  5375. Purpose : Displays distance from targeted spawn
  5376. Params :
  5377. Dev : Scatman
  5378. Example : /distance
  5379. */
  5380. void Commands::Command_Distance(Client* client)
  5381. {
  5382. Spawn* target = client->GetPlayer()->GetTarget();
  5383. if (target)
  5384. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  5385. else
  5386. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  5387. }
  5388. /*
  5389. Function: Command_Duel()
  5390. Purpose : Handle the /duel commands - not yet implemented
  5391. Params : unknown
  5392. Dev :
  5393. Example :
  5394. */
  5395. void Commands::Command_Duel(Client* client, Seperator* sep)
  5396. {
  5397. PrintSep(sep, "COMMAND_DUEL");
  5398. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  5399. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5400. }
  5401. /*
  5402. Function: Command_DuelBet()
  5403. Purpose : Handle the /duel commands - not yet implemented
  5404. Params : unknown
  5405. Dev :
  5406. Example :
  5407. */
  5408. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  5409. {
  5410. PrintSep(sep, "COMMAND_DUELBET");
  5411. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  5412. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5413. }
  5414. /*
  5415. Function: Command_DuelAccept()
  5416. Purpose : Handle the /duel commands - not yet implemented
  5417. Params : unknown
  5418. Dev :
  5419. Example :
  5420. */
  5421. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5422. {
  5423. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5424. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5425. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5426. }
  5427. /*
  5428. Function: Command_DuelDecline()
  5429. Purpose : Handle the /duel commands - not yet implemented
  5430. Params : unknown
  5431. Dev :
  5432. Example :
  5433. */
  5434. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5435. {
  5436. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5437. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5438. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5439. }
  5440. /*
  5441. Function: Command_DuelSurrender()
  5442. Purpose : Handle the /duel commands - not yet implemented
  5443. Params : unknown
  5444. Dev :
  5445. Example :
  5446. */
  5447. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5448. {
  5449. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5450. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5451. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5452. // JA, just messin around ;)
  5453. char surrender[64];
  5454. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5455. zone_list.HandleGlobalAnnouncement(surrender);
  5456. }
  5457. /*
  5458. Function: Command_DuelToggle()
  5459. Purpose : Handle the /duel commands - not yet implemented
  5460. Params : unknown
  5461. Dev :
  5462. Example :
  5463. */
  5464. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5465. {
  5466. PrintSep(sep, "COMMAND_DUEL");
  5467. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5468. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5469. }
  5470. /*
  5471. Function:
  5472. Purpose :
  5473. Params :
  5474. Dev :
  5475. Example :
  5476. */
  5477. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5478. {
  5479. if( handler == COMMAND_ENTITYCOMMAND )
  5480. {
  5481. // /entitycommand command by itself shows help (to be extended)
  5482. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5483. return;
  5484. }
  5485. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5486. {
  5487. // /entitycommand list command expects "name" param
  5488. if (sep && sep->arg[0])
  5489. {
  5490. const char* entity_command_name = sep->argplus[0];
  5491. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5492. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5493. map<int32, vector<EntityCommand*>*>::iterator itr;
  5494. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5495. {
  5496. vector<EntityCommand*>* entity_command_list = itr->second;
  5497. vector<EntityCommand*>::iterator itr2;
  5498. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5499. {
  5500. EntityCommand* entity_command = *itr2;
  5501. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5502. 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);
  5503. }
  5504. }
  5505. }
  5506. else // no command name
  5507. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5508. }
  5509. }
  5510. /*
  5511. Function: Command_Follow()
  5512. Purpose : Handle the /follow command - not yet implemented
  5513. Params :
  5514. Dev :
  5515. Example :
  5516. */
  5517. void Commands::Command_Follow(Client* client, Seperator* sep)
  5518. {
  5519. PrintSep(sep, "COMMAND_FOLLOW");
  5520. // flag to toggle if the players target is in the players group
  5521. bool targetInGroup = false;
  5522. // get a pointer to the players group
  5523. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5524. // If the player has a group and has a target
  5525. if (gmi && client->GetPlayer()->GetTarget()) {
  5526. deque<GroupMemberInfo*>::iterator itr;
  5527. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5528. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5529. if (group)
  5530. {
  5531. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5532. deque<GroupMemberInfo*>* members = group->GetMembers();
  5533. // Loop through the group members
  5534. for (itr = members->begin(); itr != members->end(); itr++) {
  5535. // If a group member matches a target
  5536. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  5537. // toggle the flag and break the loop
  5538. targetInGroup = true;
  5539. break;
  5540. }
  5541. }
  5542. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5543. }
  5544. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5545. }
  5546. if (targetInGroup) {
  5547. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5548. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5549. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5550. client->GetPlayer()->info_changed = true;
  5551. client->GetPlayer()->changed = true;
  5552. }
  5553. else
  5554. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5555. }
  5556. /*
  5557. Function: Command_StopFollow()
  5558. Purpose : Handle the /stop_follow command - not yet implemented
  5559. Params :
  5560. Dev :
  5561. Example :
  5562. */
  5563. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5564. {
  5565. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5566. if (client->GetPlayer()->GetFollowTarget()) {
  5567. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5568. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5569. client->GetPlayer()->SetFollowTarget(0);
  5570. client->GetPlayer()->info_changed = true;
  5571. client->GetPlayer()->changed = true;
  5572. }
  5573. }
  5574. #include "../Zone/SPGrid.h"
  5575. /*
  5576. Function: Command_Grid()
  5577. Purpose : Show player's current Grid ID
  5578. Params :
  5579. Dev : Scatman
  5580. Example : /grid
  5581. */
  5582. void Commands::Command_Grid(Client* client)
  5583. {
  5584. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  5585. if (client->GetPlayer()->GetMap() != nullptr) {
  5586. int32 grid = client->GetPlayer()->GetMap()->GetGrid()->GetGridID(client->GetPlayer());
  5587. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  5588. }
  5589. }
  5590. /*
  5591. Function: Command_Guild()
  5592. Purpose : Handler for all UI-related guild commands
  5593. Dev : Scatman
  5594. */
  5595. void Commands::Command_Guild(Client* client, Seperator* sep)
  5596. {
  5597. Guild* guild = client->GetPlayer()->GetGuild();
  5598. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  5599. {
  5600. const char* command = sep->arg[0];
  5601. int32 length = strlen(command);
  5602. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  5603. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  5604. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  5605. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5606. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5607. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5608. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5609. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  5610. guild->KickGuildMember(client, sep->arg[1]);
  5611. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  5612. guild->DemoteGuildMember(client, sep->arg[1]);
  5613. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  5614. guild->PromoteGuildMember(client, sep->arg[1]);
  5615. else if (strncmp(command, "points", length) == 0 && guild)
  5616. {
  5617. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  5618. {
  5619. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5620. {
  5621. float points = atof(sep->arg[2]);
  5622. const char* option = sep->arg[3];
  5623. const char* comment = sep->argplus[4];
  5624. if (strncmp(option, "all", strlen(option)) == 0)
  5625. guild->AddPointsToAll(client, points, comment);
  5626. else if (strncmp(option, "online", strlen(option)) == 0)
  5627. guild->AddPointsToAllOnline(client, points, comment);
  5628. else if (strncmp(option, "group", strlen(option)) == 0)
  5629. guild->AddPointsToGroup(client, points, comment);
  5630. else if (strncmp(option, "raid", strlen(option)) == 0)
  5631. guild->AddPointsToRaid(client, points, comment);
  5632. else
  5633. guild->AddPointsToGuildMember(client, points, option, comment);
  5634. }
  5635. }
  5636. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  5637. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  5638. else
  5639. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  5640. }
  5641. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  5642. guild->SetMOTD(sep->argplus[1]);
  5643. else if (strncmp(command, "recruiting", length) == 0 && guild)
  5644. {
  5645. if (sep->arg[1])
  5646. {
  5647. const char* option = sep->arg[1];
  5648. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  5649. guild->SetRecruitingShortDesc(sep->argplus[2]);
  5650. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  5651. guild->SetRecruitingFullDesc(sep->argplus[2]);
  5652. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5653. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5654. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5655. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  5656. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5657. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  5658. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  5659. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  5660. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  5661. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5662. else
  5663. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5664. }
  5665. else
  5666. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5667. }
  5668. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  5669. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5670. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  5671. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5672. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5673. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5674. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  5675. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  5676. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5677. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5678. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  5679. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  5680. else if (strncmp(command, "invite", length) == 0 && guild)
  5681. {
  5682. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5683. guild->InvitePlayer(client, sep->arg[1]);
  5684. else
  5685. {
  5686. Spawn* target = client->GetPlayer()->GetTarget();
  5687. if (target)
  5688. {
  5689. if (target->IsPlayer())
  5690. guild->InvitePlayer(client, target->GetName());
  5691. else
  5692. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  5693. }
  5694. }
  5695. }
  5696. else if (strncmp(command, "accept", length) == 0)
  5697. {
  5698. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5699. if (pgi && pgi->guild && pgi->invited_by)
  5700. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  5701. client->SetPendingGuildInvite(0);
  5702. }
  5703. else if (strncmp(command, "decline", length) == 0)
  5704. {
  5705. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5706. if (pgi && pgi->guild && pgi->invited_by)
  5707. {
  5708. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  5709. if (client_inviter)
  5710. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  5711. }
  5712. client->SetPendingGuildInvite(0);
  5713. }
  5714. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  5715. {
  5716. const char* guild_name = sep->argplus[1];
  5717. if (!guild_list.GetGuild(guild_name))
  5718. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  5719. else
  5720. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  5721. }
  5722. else if (strncmp(command, "search", length) == 0)
  5723. client->ShowGuildSearchWindow();
  5724. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  5725. {
  5726. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  5727. if (to_guild)
  5728. to_guild->SendGuildRecruitingDetails(client);
  5729. }
  5730. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  5731. {
  5732. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  5733. if (to_guild)
  5734. to_guild->SendGuildRecruitingImages(client);
  5735. }
  5736. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  5737. {
  5738. if (sep->arg[1])
  5739. {
  5740. const char* option = sep->arg[1];
  5741. if (strncmp(option, "toggle", strlen(option)) == 0)
  5742. guild->ToggleGuildRecruiterAdventureClass(client);
  5743. }
  5744. else
  5745. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  5746. }
  5747. else if (strncmp(command, "display_heraldry", length) == 0)
  5748. {
  5749. // JA: not sure this is right...
  5750. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  5751. client->GetPlayer()->SetCharSheetChanged(true);
  5752. }
  5753. else
  5754. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  5755. }
  5756. }
  5757. /*
  5758. Function: Command_GuildCreate()
  5759. Purpose : Display's in-game Guild Creation window
  5760. Dev : Scatman
  5761. */
  5762. void Commands::Command_CreateGuild(Client* client)
  5763. {
  5764. client->SendGuildCreateWindow();
  5765. }
  5766. /*
  5767. Function: Command_SetGuildOfficerNote()
  5768. Purpose :
  5769. Dev : Scatman
  5770. */
  5771. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  5772. {
  5773. if (sep && sep->arg[0] && sep->arg[1])
  5774. {
  5775. Guild* guild = client->GetPlayer()->GetGuild();
  5776. if (guild)
  5777. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  5778. }
  5779. }
  5780. /*
  5781. Function: Command_SetGuildMemberNote()
  5782. Purpose :
  5783. Dev : Scatman
  5784. */
  5785. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  5786. {
  5787. if (sep && sep->arg[0] && sep->arg[1])
  5788. {
  5789. Guild* guild = client->GetPlayer()->GetGuild();
  5790. if (guild)
  5791. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  5792. }
  5793. }
  5794. /*
  5795. Function: Command_GuildSay()
  5796. Purpose :
  5797. Dev : Scatman
  5798. */
  5799. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  5800. {
  5801. Guild* guild = client->GetPlayer()->GetGuild();
  5802. if (guild)
  5803. {
  5804. if (sep && sep->arg[0])
  5805. guild->HandleGuildSay(client, sep->argplus[0]);
  5806. }
  5807. else
  5808. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  5809. }
  5810. /*
  5811. Function: Command_OfficerSay()
  5812. Purpose :
  5813. Dev : Scatman
  5814. */
  5815. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  5816. {
  5817. Guild* guild = client->GetPlayer()->GetGuild();
  5818. if (guild)
  5819. {
  5820. if (sep && sep->arg[0])
  5821. guild->HandleOfficerSay(client, sep->argplus[0]);
  5822. }
  5823. else
  5824. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  5825. }
  5826. /*
  5827. Function: Command_Guilds()
  5828. Purpose : Shows help for /guild command
  5829. Params :
  5830. Dev : Scatman
  5831. Example :
  5832. */
  5833. void Commands::Command_Guilds(Client* client)
  5834. {
  5835. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  5836. }
  5837. /*
  5838. Function: Command_GuildsAdd()
  5839. Purpose : Add's players to a guild
  5840. Params : guild_name|guild_id, player name
  5841. Dev : Scatman
  5842. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  5843. */
  5844. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  5845. {
  5846. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5847. {
  5848. Guild* guild = 0;
  5849. bool found = true;
  5850. if (sep->IsNumber(0))
  5851. {
  5852. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5853. if (!guild)
  5854. {
  5855. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5856. found = false;
  5857. }
  5858. }
  5859. else
  5860. {
  5861. guild = guild_list.GetGuild(sep->arg[0]);
  5862. if (!guild)
  5863. {
  5864. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5865. found = false;
  5866. }
  5867. }
  5868. if (found)
  5869. {
  5870. Client* to_client = 0;
  5871. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5872. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5873. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5874. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5875. if (to_client)
  5876. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  5877. else
  5878. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5879. }
  5880. }
  5881. else
  5882. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  5883. }
  5884. /*
  5885. Function: Command_GuildsCreate()
  5886. Purpose : Creates a guild
  5887. Params : guild_name, player_name (optional)
  5888. Dev : Scatman
  5889. Example : /guilds create [guild name] (player name)
  5890. */
  5891. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  5892. {
  5893. if (sep && sep->arg[0])
  5894. {
  5895. const char* guild_name = sep->arg[0];
  5896. if (!guild_list.GetGuild(guild_name))
  5897. {
  5898. bool ret = false;
  5899. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5900. {
  5901. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5902. if (to_client)
  5903. {
  5904. world.CreateGuild(guild_name, to_client);
  5905. ret = true;
  5906. }
  5907. else
  5908. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  5909. }
  5910. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5911. {
  5912. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5913. if (to_client)
  5914. {
  5915. world.CreateGuild(guild_name, to_client);
  5916. ret = true;
  5917. }
  5918. }
  5919. else
  5920. {
  5921. world.CreateGuild(guild_name);
  5922. ret = true;
  5923. }
  5924. if (ret)
  5925. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  5926. else
  5927. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  5928. }
  5929. else
  5930. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  5931. }
  5932. else
  5933. 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.");
  5934. }
  5935. /*
  5936. Function: Command_GuildsDelete()
  5937. Purpose : Delete's a guild
  5938. Params : guild name
  5939. Dev : Scatman
  5940. Example : /guilds delete Test
  5941. */
  5942. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  5943. {
  5944. if (sep && sep->arg[0])
  5945. {
  5946. Guild* guild = 0;
  5947. bool found = true;
  5948. if (sep->IsNumber(0))
  5949. {
  5950. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5951. if (!guild)
  5952. {
  5953. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5954. found = false;
  5955. }
  5956. }
  5957. else
  5958. {
  5959. guild = guild_list.GetGuild(sep->arg[0]);
  5960. if (!guild)
  5961. {
  5962. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5963. found = false;
  5964. }
  5965. }
  5966. if (found)
  5967. {
  5968. guild->RemoveAllGuildMembers();
  5969. database.DeleteGuild(guild);
  5970. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  5971. guild_list.RemoveGuild(guild, true);
  5972. }
  5973. }
  5974. else
  5975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  5976. }
  5977. /*
  5978. Function: Command_GuildsList()
  5979. Purpose : Lists current guilds on server
  5980. Params :
  5981. Dev : Scatman
  5982. Example : /guilds list
  5983. */
  5984. void Commands::Command_GuildsList(Client* client)
  5985. {
  5986. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  5987. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  5988. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  5989. if (guilds->size() == 0)
  5990. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  5991. else {
  5992. while (itr.Next()) {
  5993. Guild* guild = itr.second;
  5994. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  5995. }
  5996. }
  5997. }
  5998. /*
  5999. Function: Command_GuildsRemove()
  6000. Purpose : Removes a player from a guild
  6001. Params : guild name|guild id, player name
  6002. Dev : Scatman
  6003. Example : /guilds remove 1 Admin = removes Admin from guild 1
  6004. */
  6005. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  6006. {
  6007. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6008. {
  6009. Guild* guild = 0;
  6010. bool found = true;
  6011. if (sep->IsNumber(0))
  6012. {
  6013. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6014. if (!guild)
  6015. {
  6016. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6017. found = false;
  6018. }
  6019. }
  6020. else
  6021. {
  6022. guild = guild_list.GetGuild(sep->arg[0]);
  6023. if (!guild)
  6024. {
  6025. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6026. found = false;
  6027. }
  6028. }
  6029. if (found)
  6030. {
  6031. Client* to_client = 0;
  6032. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6033. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6034. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6035. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6036. if (to_client)
  6037. {
  6038. Player* to_player = to_client->GetPlayer();
  6039. if (to_player->GetGuild())
  6040. {
  6041. if (to_player->GetGuild() == guild)
  6042. {
  6043. guild->KickGuildMember(client, to_player->GetName());
  6044. }
  6045. else
  6046. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  6047. }
  6048. else
  6049. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  6050. }
  6051. else
  6052. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6053. }
  6054. }
  6055. else
  6056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  6057. }
  6058. /*
  6059. Function: Command_InspectPlayer()
  6060. Purpose : Handle the Inspect functions
  6061. Params : Client to inspect
  6062. Dev : Scatman
  6063. Example : /inspect Scatman
  6064. */
  6065. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  6066. {
  6067. if (sep && sep->arg[0])
  6068. {
  6069. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  6070. if (inspect_client)
  6071. client->InspectPlayer(inspect_client->GetPlayer());
  6072. }
  6073. else
  6074. {
  6075. Spawn* target = client->GetPlayer()->GetTarget();
  6076. if (target && target->IsPlayer())
  6077. client->InspectPlayer((Player*)target);
  6078. }
  6079. }
  6080. /*
  6081. Function: Command_Inventory()
  6082. Purpose : Handle changes in player inventory
  6083. Params : <TBD>
  6084. Dev : All
  6085. Example : /inventory delete item_id
  6086. */
  6087. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  6088. {
  6089. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  6090. Player* player = client->GetPlayer();
  6091. if(sep && sep->arg[0][0])
  6092. {
  6093. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  6094. if(client->GetPlayer()->GetHP() == 0)
  6095. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  6096. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6097. {
  6098. int16 index = atoi(sep->arg[1]);
  6099. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6100. if(item)
  6101. {
  6102. if(item->details.item_locked)
  6103. {
  6104. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item in use.");
  6105. return;
  6106. }
  6107. if(item->GetItemScript() && lua_interface)
  6108. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  6109. //reobtain item make sure it wasn't removed
  6110. item = player->item_list.GetItemFromIndex(index);
  6111. int32 bag_id = 0;
  6112. if(item){
  6113. bag_id = item->details.inv_slot_id;
  6114. database.DeleteItem(client->GetCharacterID(), item, 0);
  6115. }
  6116. client->GetPlayer()->item_list.DestroyItem(index);
  6117. client->GetPlayer()->UpdateInventory(bag_id);
  6118. }
  6119. }
  6120. 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))
  6121. {
  6122. int16 from_index = atoi(sep->arg[1]);
  6123. sint16 to_slot = atoi(sep->arg[2]);
  6124. sint32 bag_id = atol(sep->arg[3]);
  6125. int8 charges = atoi(sep->arg[4]);
  6126. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  6127. if(item->details.item_locked)
  6128. {
  6129. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot move the item in use.");
  6130. return;
  6131. }
  6132. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  6133. {
  6134. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  6135. return;
  6136. }
  6137. sint32 old_inventory_id = 0;
  6138. if(item)
  6139. old_inventory_id = item->details.inv_slot_id;
  6140. //autobank
  6141. if (bag_id == -3 && to_slot == -1)
  6142. {
  6143. if (player->HasFreeBankSlot())
  6144. to_slot = player->FindFreeBankSlot();
  6145. else
  6146. {
  6147. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  6148. return;
  6149. }
  6150. }
  6151. //auto inventory
  6152. if (bag_id == 0 && to_slot == -1)
  6153. {
  6154. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6155. {
  6156. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  6157. return;
  6158. }
  6159. }
  6160. bool item_deleted = false;
  6161. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, &item_deleted, client->GetVersion());
  6162. client->QueuePacket(outapp);
  6163. if(item_deleted)
  6164. item = nullptr;
  6165. //removed from bag send update
  6166. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  6167. {
  6168. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  6169. if(outapp)
  6170. client->QueuePacket(outapp);
  6171. }
  6172. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  6173. {
  6174. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  6175. if(outapp)
  6176. client->QueuePacket(outapp);
  6177. }
  6178. }
  6179. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  6180. {
  6181. if(client->GetPlayer()->EngagedInCombat())
  6182. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  6183. else
  6184. {
  6185. int16 index = atoi(sep->arg[1]);
  6186. int8 slot_id = 255;
  6187. int8 unk3 = 0;
  6188. int8 appearance_equip = 0;
  6189. if(sep->arg[2][0] && sep->IsNumber(2))
  6190. slot_id = atoi(sep->arg[2]);
  6191. if(sep->arg[3][0] && sep->IsNumber(3))
  6192. unk3 = atoul(sep->arg[3]);
  6193. if(sep->arg[4][0] && sep->IsNumber(4))
  6194. appearance_equip = atoul(sep->arg[4]);
  6195. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  6196. EQ2Packet* outapp = 0;
  6197. for(int32 i=0;i<packets.size();i++)
  6198. {
  6199. outapp = packets[i];
  6200. if(outapp)
  6201. client->QueuePacket(outapp);
  6202. }
  6203. client->GetPlayer()->ChangePrimaryWeapon();
  6204. client->GetPlayer()->ChangeSecondaryWeapon();
  6205. client->GetPlayer()->ChangeRangedWeapon();
  6206. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6207. client->QueuePacket(characterSheetPackets);
  6208. }
  6209. }
  6210. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6211. {
  6212. if (client->GetPlayer()->EngagedInCombat())
  6213. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  6214. else {
  6215. int16 index = atoi(sep->arg[1]);
  6216. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6217. if (item) {
  6218. if(item->details.item_locked)
  6219. {
  6220. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot unpack the item in use.");
  6221. return;
  6222. }
  6223. // client->GetPlayer()->item_list.DestroyItem(index);
  6224. if (item->item_sets.size() > 0) {
  6225. for (int32 i = 0; i < item->item_sets.size(); i++) {
  6226. ItemSet* set = item->item_sets[i];
  6227. if (set->item_stack_size == 0)
  6228. set->item_stack_size += 1;
  6229. client->AddItem(set->item_id, set->item_stack_size);
  6230. }
  6231. }
  6232. }
  6233. client->RemoveItem(item, 1);
  6234. }
  6235. }
  6236. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  6237. {
  6238. if(client->GetPlayer()->EngagedInCombat())
  6239. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  6240. else
  6241. {
  6242. int16 index = atoi(sep->arg[1]);
  6243. sint32 bag_id = -999;
  6244. int8 to_slot = 255;
  6245. if(sep->arg[3][0])
  6246. {
  6247. if(sep->IsNumber(2))
  6248. bag_id = atol(sep->arg[2]);
  6249. if(sep->IsNumber(3))
  6250. to_slot = atoi(sep->arg[3]);
  6251. }
  6252. sint8 unk4 = 0;
  6253. int8 appearance_equip = 0;
  6254. if(sep->arg[4][0] && sep->IsNumber(4))
  6255. unk4 = atoi(sep->arg[4]);
  6256. if(sep->arg[5][0] && sep->IsNumber(5))
  6257. appearance_equip = atoul(sep->arg[5]);
  6258. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  6259. EQ2Packet* outapp = 0;
  6260. for(int32 i=0;i<packets.size();i++)
  6261. {
  6262. outapp = packets[i];
  6263. if(outapp)
  6264. client->QueuePacket(outapp);
  6265. }
  6266. client->GetPlayer()->ChangePrimaryWeapon();
  6267. client->GetPlayer()->ChangeSecondaryWeapon();
  6268. client->GetPlayer()->ChangeRangedWeapon();
  6269. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6270. client->QueuePacket(characterSheetPackets);
  6271. }
  6272. }
  6273. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6274. {
  6275. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  6276. int16 index1 = atoi(sep->arg[1]);
  6277. int16 index2 = atoi(sep->arg[2]);
  6278. int8 type = 0;
  6279. if(sep->IsNumber(3))
  6280. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  6281. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  6282. if(outapp)
  6283. client->QueuePacket(outapp);
  6284. else
  6285. {
  6286. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  6287. return;
  6288. }
  6289. }
  6290. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6291. {
  6292. sint16 to_slot = atoi(sep->arg[1]);
  6293. sint32 bag_id = atoi(sep->arg[2]);
  6294. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  6295. if (item) {
  6296. //auto inventory
  6297. if (bag_id == 0 && to_slot == -1)
  6298. {
  6299. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6300. {
  6301. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  6302. return;
  6303. }
  6304. // Set the slot for the item
  6305. item->details.inv_slot_id = bag_id;
  6306. item->details.slot_id = to_slot;
  6307. // Flag the item so it gets saved in its new location
  6308. item->save_needed = true;
  6309. // Add the item to its new location
  6310. if(player->item_list.AddItem(item)) {
  6311. // Remove the item from the overflow list
  6312. player->item_list.RemoveOverflowItem(item);
  6313. }
  6314. // Send the inventory update packet
  6315. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6316. return;
  6317. }
  6318. else if (bag_id == -3 && to_slot == -1) {
  6319. // Auto Bank
  6320. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  6321. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  6322. return;
  6323. }
  6324. item->details.inv_slot_id = bag_id;
  6325. item->details.slot_id = to_slot;
  6326. item->save_needed = true;
  6327. if(player->item_list.AddItem(item)) {
  6328. player->item_list.RemoveOverflowItem(item);
  6329. }
  6330. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6331. }
  6332. else if (bag_id == -4) {
  6333. // Shared Bank
  6334. if (!player->item_list.SharedBankAddAllowed(item)) {
  6335. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  6336. return;
  6337. }
  6338. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  6339. if (tmp_item) {
  6340. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6341. return;
  6342. }
  6343. else {
  6344. item->details.inv_slot_id = bag_id;
  6345. item->details.slot_id = to_slot;
  6346. item->save_needed = true;
  6347. if(player->item_list.AddItem(item)) {
  6348. player->item_list.RemoveOverflowItem(item);
  6349. }
  6350. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6351. return;
  6352. }
  6353. }
  6354. else {
  6355. // Try to get an item from the given bag id and slot id
  6356. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  6357. // Check to see if we got an item, if we do send an error,
  6358. // if we don't put the overflow item into this slot
  6359. if (tmp_item) {
  6360. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6361. }
  6362. else {
  6363. item->details.inv_slot_id = bag_id;
  6364. item->details.slot_id = to_slot;
  6365. item->save_needed = true;
  6366. if(player->item_list.AddItem(item)) {
  6367. player->item_list.RemoveOverflowItem(item);
  6368. }
  6369. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6370. return;
  6371. }
  6372. }
  6373. }
  6374. }
  6375. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6376. {
  6377. sint64 data = strtoull(sep->arg[1], NULL, 0);
  6378. int32 character_item_id = (int32) (data >> 32);
  6379. int32 item_id = (int32) (data & 0xffffffffL);
  6380. int8 sale_setting = atoi(sep->arg[2]);
  6381. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  6382. if(item)
  6383. {
  6384. item->no_sale = sale_setting;
  6385. item->save_needed = true;
  6386. client->SendSellMerchantList();
  6387. }
  6388. }
  6389. }
  6390. else
  6391. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  6392. }
  6393. /*
  6394. Function: Command_IRC()
  6395. Purpose : Handle the IRC functions
  6396. Params : IRC Commands
  6397. Dev : Scatman
  6398. Example : /irc say #Channel Hello World!
  6399. */
  6400. void Commands::Command_IRC(Client* client, Seperator* sep)
  6401. {
  6402. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  6403. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  6404. return;
  6405. }
  6406. if (sep && sep->arg[0][0]) {
  6407. if (strcasecmp(sep->arg[0], "say") == 0) {
  6408. if (sep->arg[1][0] && sep->arg[2][0]) {
  6409. if (sep->IsNumber(sep->arg[1]))
  6410. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  6411. else
  6412. irc.Say(client, sep->arg[1], sep->argplus[2]);
  6413. }
  6414. else
  6415. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  6416. }
  6417. else if (strcasecmp(sep->arg[0], "join") == 0) {
  6418. if (sep->arg[1][0])
  6419. irc.JoinChannel(client, sep->arg[1]);
  6420. else
  6421. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  6422. }
  6423. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  6424. if (sep->arg[1][0])
  6425. irc.LeaveChannel(client, sep->arg[1]);
  6426. else
  6427. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  6428. }
  6429. else if (strcasecmp(sep->arg[0], "list") == 0)
  6430. irc.ListChannels(client);
  6431. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  6432. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  6433. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  6434. else
  6435. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  6436. }
  6437. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  6438. irc.DisconnectFromServer(client);
  6439. else
  6440. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  6441. }
  6442. else
  6443. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  6444. }
  6445. /*
  6446. Function: Command_Languages()
  6447. Purpose : Show's languages the player knows
  6448. Params :
  6449. Dev : Zcoretri
  6450. Example :
  6451. */
  6452. void Commands::Command_Languages(Client* client, Seperator* sep)
  6453. {
  6454. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6455. list<Language*>::iterator itr;
  6456. Language* language;
  6457. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6458. for(itr = languages->begin(); itr != languages->end(); itr++)
  6459. {
  6460. language = *itr;
  6461. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6462. }
  6463. }
  6464. /*
  6465. Function: Command_SetLanguage()
  6466. Purpose : Handles language commands
  6467. Params : Language ID
  6468. Dev : Zcoretri
  6469. Example :
  6470. */
  6471. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6472. {
  6473. Player* player = client->GetPlayer();
  6474. if (sep && sep->arg[0])
  6475. {
  6476. if(!sep->IsNumber(0))
  6477. {
  6478. //String passed in
  6479. const char* value = sep->arg[0];
  6480. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6481. {
  6482. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6483. client->SendLanguagesUpdate(0);
  6484. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6485. }
  6486. else
  6487. {
  6488. if(player->HasLanguage(value))
  6489. {
  6490. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6491. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6492. client->SendLanguagesUpdate(language->GetID());
  6493. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6494. }
  6495. else
  6496. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6497. }
  6498. }
  6499. else
  6500. {
  6501. //Number passed in
  6502. int32 id = atoul(sep->arg[0]);
  6503. if(player->HasLanguage(id))
  6504. {
  6505. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6506. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6507. client->SendLanguagesUpdate(id);
  6508. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6509. }
  6510. else
  6511. {
  6512. Language* language = master_languages_list.GetLanguage(id);
  6513. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6514. }
  6515. }
  6516. }
  6517. else
  6518. {
  6519. //No value was passed in
  6520. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6521. if(id > 0)
  6522. {
  6523. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6524. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6525. }
  6526. else
  6527. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6528. }
  6529. }
  6530. /*
  6531. Function: Command_LastName()
  6532. Purpose : Sets player surname
  6533. Params : Name text
  6534. Dev : theFoof
  6535. Example :
  6536. */
  6537. void Commands::Command_LastName(Client* client, Seperator* sep)
  6538. {
  6539. if (!client)
  6540. return;
  6541. if (sep && sep->arg[0])
  6542. {
  6543. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6544. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6545. return;
  6546. }
  6547. client->RemovePendingLastName();
  6548. uchar* checkname = (uchar*)sep->arg[0];
  6549. bool valid_name = true;
  6550. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6551. if (!alpha_check(checkname[i])) {
  6552. valid_name = false;
  6553. break;
  6554. }
  6555. }
  6556. if (!valid_name) {
  6557. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6558. return;
  6559. }
  6560. string last_name = (string)sep->arg[0];
  6561. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6562. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6563. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6564. client->SetPendingLastName(last_name);
  6565. client->SendLastNameConfirmation();
  6566. }
  6567. else
  6568. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6569. }
  6570. }
  6571. /*
  6572. Function: Command_ConfirmLastName()
  6573. Purpose : Confirms setting of player surname
  6574. Params : Name text
  6575. Dev : theFoof
  6576. Example :
  6577. */
  6578. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6579. {
  6580. if (!client)
  6581. return;
  6582. string* name = client->GetPendingLastName();
  6583. if (name){
  6584. Player* player = client->GetPlayer();
  6585. player->SetLastName(name->c_str(), false);
  6586. client->SendTitleUpdate();
  6587. player->SetCharSheetChanged(true);
  6588. client->RemovePendingLastName();
  6589. }
  6590. }
  6591. /*
  6592. Function: Command_Location()
  6593. Purpose : Display's Help for /location commands
  6594. Params :
  6595. Dev : Scatman
  6596. Example : /location = show's help for command
  6597. */
  6598. void Commands::Command_Location(Client* client)
  6599. {
  6600. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6601. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6602. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6603. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6604. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6605. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6606. }
  6607. /*
  6608. Function: Command_LocationAdd()
  6609. Purpose : Add's a location to an existing location config
  6610. Params : location_id
  6611. Dev : Scatman
  6612. Example : /location add {location_id}
  6613. */
  6614. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6615. {
  6616. if (sep && sep->arg[0] && sep->IsNumber(0))
  6617. {
  6618. int32 location_id = atoul(sep->arg[0]);
  6619. float x = client->GetPlayer()->GetX();
  6620. float y = client->GetPlayer()->GetY();
  6621. float z = client->GetPlayer()->GetZ();
  6622. if (database.AddLocationPoint(location_id, x, y, z))
  6623. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6624. else
  6625. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6626. }
  6627. else
  6628. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6629. }
  6630. /*
  6631. Function: Command_LocationCreate()
  6632. Purpose : Creates a new location config
  6633. Params : location name, 0/1 for include_y (optional)
  6634. Dev : Scatman
  6635. Example : /location create Test 1 = creates a new location named Test with include_y True
  6636. */
  6637. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6638. {
  6639. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6640. {
  6641. const char* name = sep->arg[0];
  6642. bool include_y = false;
  6643. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6644. include_y = true;
  6645. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  6646. if (location_id > 0)
  6647. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6648. else
  6649. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6650. }
  6651. else
  6652. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6653. }
  6654. /*
  6655. Function: Command_LocationDelete()
  6656. Purpose : Delete's a location config and all it's location points
  6657. Params : location_id
  6658. Dev : Scatman
  6659. Example : /location delete {location_id}
  6660. */
  6661. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6662. {
  6663. if (sep && sep->arg[0] && sep->IsNumber(0))
  6664. {
  6665. int32 location_id = atoul(sep->arg[0]);
  6666. if (database.DeleteLocation(location_id))
  6667. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6668. else
  6669. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6670. }
  6671. else
  6672. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6673. }
  6674. /*
  6675. Function: Command_LocationList()
  6676. Purpose : Display's a list of location points
  6677. Params : location_id
  6678. Dev : Scatman
  6679. Example : /location list {location_id}
  6680. */
  6681. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6682. {
  6683. if (sep && sep->arg[0])
  6684. {
  6685. const char* option = sep->arg[0];
  6686. if (strncmp(option, "locations", strlen(option)) == 0)
  6687. database.ListLocations(client);
  6688. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  6689. {
  6690. int32 location_id = atoul(sep->arg[1]);
  6691. database.ListLocationPoints(client, location_id);
  6692. }
  6693. else
  6694. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6695. }
  6696. else
  6697. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6698. }
  6699. /*
  6700. Function: Command_LocationRemove()
  6701. Purpose : Removes a single location point from a location config
  6702. Params : location_point_id (gotten from /location list {id})
  6703. Dev : Scatman
  6704. Example : /location remove 1 = will remove location_point_id 1
  6705. */
  6706. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  6707. {
  6708. if (sep && sep->arg[0] && sep->IsNumber(0))
  6709. {
  6710. int32 location_point_id = atoul(sep->arg[0]);
  6711. if (database.DeleteLocationPoint(location_point_id))
  6712. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  6713. else
  6714. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  6715. }
  6716. else
  6717. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  6718. }
  6719. /*
  6720. Function: Command_Merchant()
  6721. Purpose : Handles Merchant commands
  6722. Params : list
  6723. Dev : Scatman
  6724. Example : /merchant list
  6725. */
  6726. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  6727. {
  6728. if( handler == COMMAND_MERCHANT )
  6729. {
  6730. // /merchant command by itself shows help (to be extended)
  6731. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6732. return;
  6733. }
  6734. else if( handler == COMMAND_MERCHANT_LIST )
  6735. {
  6736. // /merchant list command expects "description" param
  6737. if (sep && sep->arg[0])
  6738. {
  6739. const char* merchant_description = sep->argplus[0];
  6740. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  6741. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  6742. map<int32, MerchantInfo*>::iterator itr;
  6743. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  6744. {
  6745. string description = database.GetMerchantDescription(itr->first);
  6746. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  6747. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  6748. }
  6749. }
  6750. else // no description
  6751. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6752. }
  6753. }
  6754. /*
  6755. Function: Command_Modify()
  6756. Purpose : to replace our other "set" commands
  6757. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  6758. Dev : John Adams
  6759. Example : /modify spell set name "Aegolism III"
  6760. */
  6761. void Commands::Command_Modify(Client* client)
  6762. {
  6763. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  6764. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  6765. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  6766. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  6767. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  6768. }
  6769. /*
  6770. Function: Command_ModifySpawn()
  6771. Purpose : replace "spawn set" commands
  6772. Params : Action : the action to perform (or special handler)
  6773. : Field : the DB field to change
  6774. : Value : what to set the value to
  6775. : Target : what object to change (my target, or spawn_id)
  6776. Dev : John Adams
  6777. Example : /modify spawn set name "Lady Vox"
  6778. :
  6779. Note : Special Handlers, like "zoneto" for Signs
  6780. : /modify spawn zoneto
  6781. : Will set a sign's zone x/y/z to my current coords
  6782. */
  6783. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  6784. {
  6785. PrintSep(sep, "COMMAND_MODIFY");
  6786. // need at least 2 args for a valid command
  6787. if( sep && sep->arg[1] )
  6788. {
  6789. // JA: just a quick implementation because I need it :)
  6790. if (strcmp(sep->arg[0], "zoneto") == 0)
  6791. {
  6792. if( sep->IsNumber(1) )
  6793. {
  6794. int32 spawn_id = atoul(sep->arg[1]);
  6795. float x_coord = client->GetPlayer()->GetX();
  6796. float y_coord = client->GetPlayer()->GetY();
  6797. float z_coord = client->GetPlayer()->GetZ();
  6798. float h_coord = client->GetPlayer()->GetHeading();
  6799. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  6800. }
  6801. else
  6802. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  6803. }
  6804. }
  6805. else
  6806. Command_Modify(client);
  6807. }
  6808. /*
  6809. Function: Command_ModifyCharacter()
  6810. Purpose : to replace our other "set" commands
  6811. Params : Action : Add, Remove
  6812. : Field : copper, silver, gold, plat
  6813. : Value : min 1, max unlimited
  6814. : Target : Self, Player
  6815. Dev : Cynnar
  6816. Example : /modify character add gold 50
  6817. : /modify character remove silver 25
  6818. */
  6819. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  6820. {
  6821. PrintSep(sep, "COMMAND_MODIFY");
  6822. int64 value = 0;
  6823. Player* player = client->GetPlayer();
  6824. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  6825. player = (Player*)player->GetTarget();
  6826. // need at least 2 args for a valid command
  6827. if( sep && sep->arg[1] )
  6828. {
  6829. if (strcmp(sep->arg[0], "add") == 0)
  6830. {
  6831. if (strcmp(sep->arg[1], "copper") == 0)
  6832. {
  6833. value = atoi64(sep->arg[2]);
  6834. player->AddCoins(value);
  6835. if (client->GetPlayer() == player)
  6836. {
  6837. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  6838. }
  6839. else {
  6840. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  6841. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  6842. }
  6843. }
  6844. else if (strcmp(sep->arg[1], "silver") == 0)
  6845. {
  6846. value = atoi64(sep->arg[2]) * 100;
  6847. player->AddCoins(value);
  6848. if (client->GetPlayer() == player)
  6849. {
  6850. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  6851. }
  6852. else {
  6853. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  6854. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  6855. }
  6856. }
  6857. else if (strcmp(sep->arg[1], "gold") == 0)
  6858. {
  6859. value = atoi64(sep->arg[2]) * 10000;
  6860. player->AddCoins(value);
  6861. if (client->GetPlayer() == player)
  6862. {
  6863. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  6864. }
  6865. else {
  6866. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6867. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6868. }
  6869. }
  6870. else if (strcmp(sep->arg[1], "plat") == 0)
  6871. {
  6872. value = atoi64(sep->arg[2]) * 1000000;
  6873. player->AddCoins(value);
  6874. if (client->GetPlayer() == player)
  6875. {
  6876. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  6877. }
  6878. else {
  6879. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  6880. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  6881. }
  6882. }
  6883. else
  6884. {
  6885. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  6886. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  6887. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  6888. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  6889. }
  6890. }
  6891. else if (strcmp(sep->arg[0], "remove") == 0)
  6892. {
  6893. if (strcmp(sep->arg[1], "copper") == 0)
  6894. {
  6895. value = atoi64(sep->arg[2]);
  6896. player->RemoveCoins(value);
  6897. if (client->GetPlayer() == player)
  6898. {
  6899. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  6900. }
  6901. else {
  6902. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  6903. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  6904. }
  6905. }
  6906. else if (strcmp(sep->arg[1], "silver") == 0)
  6907. {
  6908. value = atoi64(sep->arg[2]) * 100;
  6909. player->RemoveCoins(value);
  6910. if (client->GetPlayer() == player)
  6911. {
  6912. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  6913. }
  6914. else {
  6915. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  6916. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  6917. }
  6918. }
  6919. else if (strcmp(sep->arg[1], "gold") == 0)
  6920. {
  6921. value = atoi64(sep->arg[2]) * 10000;
  6922. player->RemoveCoins(value);
  6923. if (client->GetPlayer() == player)
  6924. {
  6925. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  6926. }
  6927. else {
  6928. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  6929. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6930. }
  6931. }
  6932. else if (strcmp(sep->arg[1], "plat") == 0)
  6933. {
  6934. value = atoi64(sep->arg[2]) * 1000000;
  6935. player->RemoveCoins(value);
  6936. if (client->GetPlayer() == player)
  6937. {
  6938. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  6939. }
  6940. else {
  6941. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  6942. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  6943. }
  6944. }
  6945. else
  6946. {
  6947. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  6948. }
  6949. }
  6950. else if (strcmp(sep->arg[0], "set") == 0) {
  6951. if (strcmp(sep->arg[1], "tslevel") == 0) {
  6952. int8 level = atoi(sep->arg[2]);
  6953. if (level > 0 && level < 256) {
  6954. if (player) {
  6955. if (client->GetPlayer() == player)
  6956. client->ChangeTSLevel(player->GetTSLevel(), level);
  6957. else
  6958. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  6959. }
  6960. }
  6961. else
  6962. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  6963. }
  6964. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  6965. int8 tsclass = atoi(sep->arg[2]);
  6966. player->SetTradeskillClass(tsclass);
  6967. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  6968. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  6969. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  6970. player->SetCharSheetChanged(true);
  6971. }
  6972. }
  6973. }
  6974. else
  6975. {
  6976. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  6977. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  6978. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  6979. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  6980. }
  6981. }
  6982. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  6983. {
  6984. PrintSep(sep, "COMMAND_MODIFY");
  6985. // need at least 2 args for a valid command
  6986. if( sep && sep->arg[1] )
  6987. {
  6988. }
  6989. else
  6990. Command_Modify(client);
  6991. }
  6992. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  6993. {
  6994. PrintSep(sep, "COMMAND_MODIFY");
  6995. // need at least 2 args for a valid command
  6996. if( sep && sep->arg[1] )
  6997. {
  6998. }
  6999. else
  7000. Command_Modify(client);
  7001. }
  7002. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  7003. {
  7004. PrintSep(sep, "COMMAND_MODIFY");
  7005. // need at least 2 args for a valid command
  7006. if( sep && sep->arg[1] )
  7007. {
  7008. }
  7009. else
  7010. Command_Modify(client);
  7011. }
  7012. /*
  7013. Function: Command_ModifyQuest()
  7014. Purpose : to list players quest and completed quests
  7015. Params : Action : list, completed
  7016. : Target : Self, Player
  7017. Dev : Cynnar
  7018. Example : /modify quest list
  7019. : /modify quest completed
  7020. */
  7021. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  7022. {
  7023. PrintSep(sep, "COMMAND_MODIFY");
  7024. int64 value = 0;
  7025. Player* player = client->GetPlayer();
  7026. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7027. player = (Player*)player->GetTarget();
  7028. // need at least 2 args for a valid command
  7029. if (sep && sep->arg[1])
  7030. {
  7031. if (strcmp(sep->arg[0], "list") == 0)
  7032. {
  7033. map<int32, Quest*>* quests = player->GetPlayerQuests();
  7034. map<int32, Quest*>::iterator itr;
  7035. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  7036. if (quests->size() == 0)
  7037. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  7038. else
  7039. {
  7040. for (itr = quests->begin(); itr != quests->end(); itr++)
  7041. {
  7042. Quest* quest = itr->second;
  7043. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7044. }
  7045. }
  7046. }
  7047. else if (strcmp(sep->arg[0], "completed") == 0)
  7048. {
  7049. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  7050. map<int32, Quest*>::iterator itr;
  7051. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  7052. if (quests->size() == 0)
  7053. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  7054. else
  7055. {
  7056. for (itr = quests->begin(); itr != quests->end(); itr++)
  7057. {
  7058. Quest* quest = itr->second;
  7059. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7060. }
  7061. }
  7062. }
  7063. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  7064. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  7065. else if (strcmp(sep->arg[0], "remove") == 0)
  7066. {
  7067. int32 quest_id = 0;
  7068. if (sep && sep->arg[1] && sep->IsNumber(1))
  7069. quest_id = atoul(sep->arg[1]);
  7070. if (quest_id > 0)
  7071. {
  7072. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  7073. {
  7074. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7075. if (quest)
  7076. if (client->GetPlayer() == player)
  7077. {
  7078. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  7079. }
  7080. else
  7081. {
  7082. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  7083. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  7084. }
  7085. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  7086. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  7087. }
  7088. client->RemovePlayerQuest(quest_id);
  7089. client->GetCurrentZone()->SendQuestUpdates(client);
  7090. }
  7091. }
  7092. else if (strcmp(sep->arg[0], "advance") == 0)
  7093. {
  7094. int32 quest_id = 0;
  7095. int32 step = 0;
  7096. if (sep && sep->arg[1] && sep->IsNumber(1))
  7097. {
  7098. quest_id = atoul(sep->arg[1]);
  7099. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7100. if (sep && sep->arg[2] && sep->IsNumber(1))
  7101. {
  7102. step = atoul(sep->arg[2]);
  7103. if (quest_id > 0 && step > 0)
  7104. {
  7105. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  7106. {
  7107. if (client)
  7108. {
  7109. client->AddPendingQuestUpdate(quest_id, step);
  7110. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  7111. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  7112. }
  7113. }
  7114. }
  7115. else
  7116. {
  7117. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  7118. }
  7119. }
  7120. else
  7121. {
  7122. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  7123. }
  7124. }
  7125. else
  7126. {
  7127. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  7128. }
  7129. }
  7130. else
  7131. {
  7132. Command_Modify(client);
  7133. }
  7134. }
  7135. else
  7136. {
  7137. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  7138. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  7139. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  7140. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  7141. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  7142. }
  7143. }
  7144. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  7145. {
  7146. PrintSep(sep, "COMMAND_MODIFY");
  7147. // need at least 2 args for a valid command
  7148. if( sep && sep->arg[1] )
  7149. {
  7150. if (strcmp(sep->arg[0], "add") == 0) {
  7151. const char* skill_name = sep->argplus[1];
  7152. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7153. if (skill) {
  7154. Player* player = 0;
  7155. Client* to_client = 0;
  7156. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7157. player = (Player*)client->GetPlayer()->GetTarget();
  7158. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7159. }
  7160. else {
  7161. player = client->GetPlayer();
  7162. to_client = client;
  7163. }
  7164. if (player)
  7165. {
  7166. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7167. {
  7168. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7169. if (to_client == client) {
  7170. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  7171. }
  7172. else {
  7173. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7174. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7175. }
  7176. }
  7177. else
  7178. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  7179. }
  7180. }
  7181. else
  7182. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7183. }
  7184. else if (strcmp(sep->arg[0], "remove") == 0) {
  7185. const char* skill_name = sep->argplus[1];
  7186. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7187. if (skill) {
  7188. Player* player = 0;
  7189. Client* to_client = 0;
  7190. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7191. player = (Player*)client->GetPlayer()->GetTarget();
  7192. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7193. }
  7194. else {
  7195. player = client->GetPlayer();
  7196. to_client = client;
  7197. }
  7198. if (player)
  7199. {
  7200. if (player->GetSkills()->HasSkill(skill->skill_id))
  7201. {
  7202. player->RemoveSkillFromDB(skill, true);
  7203. if (client == to_client) {
  7204. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  7205. }
  7206. else {
  7207. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7208. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7209. }
  7210. }
  7211. else {
  7212. if (client == to_client)
  7213. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  7214. else
  7215. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7216. }
  7217. }
  7218. }
  7219. else
  7220. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7221. }
  7222. else if (strcmp(sep->arg[0], "set") == 0) {
  7223. if (!sep->IsNumber(2)) {
  7224. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  7225. return;
  7226. }
  7227. const char* skill_name = sep->arg[1];
  7228. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7229. if (skill) {
  7230. int16 val = atoi(sep->arg[2]);
  7231. Player* player = 0;
  7232. Client* to_client = 0;
  7233. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7234. player = (Player*)client->GetPlayer()->GetTarget();
  7235. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7236. }
  7237. else {
  7238. player = client->GetPlayer();
  7239. to_client = client;
  7240. }
  7241. if (player)
  7242. {
  7243. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  7244. player->GetSkills()->SetSkill(skill->skill_id, val);
  7245. if (client != to_client)
  7246. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  7247. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  7248. }
  7249. else {
  7250. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  7251. }
  7252. }
  7253. }
  7254. else {
  7255. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7256. }
  7257. }
  7258. else {
  7259. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7260. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7261. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7262. }
  7263. }
  7264. else {
  7265. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7266. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7267. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7268. }
  7269. }
  7270. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  7271. {
  7272. PrintSep(sep, "COMMAND_MODIFY");
  7273. // need at least 2 args for a valid command
  7274. if( sep && sep->arg[1] )
  7275. {
  7276. }
  7277. else
  7278. Command_Modify(client);
  7279. }
  7280. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  7281. {
  7282. PrintSep(sep, "COMMAND_MODIFY");
  7283. // need at least 2 args for a valid command
  7284. if( sep && sep->arg[1] )
  7285. {
  7286. }
  7287. else
  7288. Command_Modify(client);
  7289. }
  7290. /*
  7291. Function: Command_MOTD()
  7292. Purpose : Displays server MOTD
  7293. Params :
  7294. Dev : LethalEncounter
  7295. Example : /motd
  7296. */
  7297. void Commands::Command_MOTD(Client* client)
  7298. {
  7299. if (client)
  7300. ClientPacketFunctions::SendMOTD(client);
  7301. }
  7302. /*
  7303. Function: Command_Pet()
  7304. Purpose : Handle Pet {Command} commands
  7305. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  7306. Dev :
  7307. Example : /pet preserve_master
  7308. */
  7309. void Commands::Command_Pet(Client* client, Seperator* sep)
  7310. {
  7311. PrintSep(sep, "COMMAND_PET");
  7312. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  7313. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7314. if (!sep || !sep->arg[0])
  7315. return; // should have sep->arg[0] filled
  7316. if (strcmp(sep->arg[0], "hide") == 0) {
  7317. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  7318. Entity* pet = client->GetPlayer()->GetDeityPet();
  7319. if (pet) {
  7320. if (pet->IsPrivateSpawn())
  7321. client->GetPlayer()->HideDeityPet(false);
  7322. else
  7323. client->GetPlayer()->HideDeityPet(true);
  7324. }
  7325. pet = client->GetPlayer()->GetCosmeticPet();
  7326. if (pet) {
  7327. if (pet->IsPrivateSpawn())
  7328. client->GetPlayer()->HideCosmeticPet(false);
  7329. else
  7330. client->GetPlayer()->HideCosmeticPet(true);
  7331. }
  7332. return;
  7333. }
  7334. // below is for all combat pets
  7335. if (!client->GetPlayer()->HasPet()) {
  7336. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  7337. return;
  7338. }
  7339. if (strcmp(sep->arg[0], "stay") == 0) {
  7340. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  7341. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  7342. client->GetPlayer()->SetCharSheetChanged(true);
  7343. if (client->GetPlayer()->GetPet())
  7344. client->GetPlayer()->GetPet()->following = false;
  7345. if (client->GetPlayer()->GetCharmedPet())
  7346. client->GetPlayer()->GetCharmedPet()->following = false;
  7347. }
  7348. else if (strcmp(sep->arg[0], "follow") == 0) {
  7349. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  7350. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  7351. client->GetPlayer()->SetCharSheetChanged(true);
  7352. }
  7353. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  7354. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  7355. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  7356. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  7357. }
  7358. else {
  7359. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  7360. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  7361. }
  7362. client->GetPlayer()->SetCharSheetChanged(true);
  7363. }
  7364. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  7365. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  7366. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  7367. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  7368. }
  7369. else {
  7370. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  7371. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  7372. }
  7373. client->GetPlayer()->SetCharSheetChanged(true);
  7374. }
  7375. else if (strcmp(sep->arg[0], "backoff") == 0) {
  7376. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  7377. if (client->GetPlayer()->GetPet())
  7378. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  7379. if (client->GetPlayer()->GetCharmedPet())
  7380. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  7381. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  7382. client->GetPlayer()->SetCharSheetChanged(true);
  7383. }
  7384. else if (strcmp(sep->arg[0], "attack") == 0) {
  7385. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  7386. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  7387. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  7388. if (client->GetPlayer()->GetPet())
  7389. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7390. if (client->GetPlayer()->GetCharmedPet())
  7391. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7392. }
  7393. else
  7394. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  7395. }
  7396. else
  7397. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  7398. }
  7399. else if (strcmp(sep->arg[0], "getlost") == 0) {
  7400. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  7401. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  7402. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  7403. }
  7404. else
  7405. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  7406. }
  7407. /*
  7408. Function: Command_PetName()
  7409. Purpose : Pet your name (???)
  7410. Params :
  7411. Dev :
  7412. Example :
  7413. */
  7414. void Commands::Command_PetName(Client* client, Seperator* sep)
  7415. {
  7416. PrintSep(sep, "COMMAND_PETNAME");
  7417. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  7418. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7419. }
  7420. /*
  7421. Function: Command_NamePet()
  7422. Purpose : Name your pet
  7423. Params :
  7424. Dev :
  7425. Example :
  7426. */
  7427. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7428. {
  7429. PrintSep(sep, "COMMAND_NAME_PET");
  7430. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7431. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7432. }
  7433. /*
  7434. Function: Command_Rename()
  7435. Purpose : Renames existing pet
  7436. Params :
  7437. Dev :
  7438. Example :
  7439. */
  7440. void Commands::Command_Rename(Client* client, Seperator* sep)
  7441. {
  7442. PrintSep(sep, "COMMAND_RENAME");
  7443. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7444. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7445. }
  7446. /*
  7447. Function: Command_ConfirmRename()
  7448. Purpose : Confirms renaming your pet
  7449. Params :
  7450. Dev :
  7451. Example :
  7452. */
  7453. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7454. {
  7455. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7456. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7457. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7458. }
  7459. /*
  7460. Function: Command_PetOptions()
  7461. Purpose : Sets various pet options
  7462. Params :
  7463. Dev :
  7464. Example :
  7465. */
  7466. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7467. {
  7468. PrintSep(sep, "COMMAND_PETOPTIONS");
  7469. Player* player = client->GetPlayer();
  7470. Spawn* target = player->GetTarget();
  7471. if (!target)
  7472. return;
  7473. if (target == player->GetPet())
  7474. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7475. else if (target == player->GetCharmedPet())
  7476. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7477. else if (target == player->GetCosmeticPet())
  7478. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7479. else if (target == player->GetDeityPet())
  7480. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7481. }
  7482. /*
  7483. Function: Command_Random()
  7484. Purpose : Handles /random dice roll in-game
  7485. Params : 1-100
  7486. Dev : Scatman
  7487. Example : /randon 1 100
  7488. */
  7489. void Commands::Command_Random(Client* client, Seperator* sep)
  7490. {
  7491. char message[256] = {0};
  7492. if (sep)
  7493. {
  7494. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7495. 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])));
  7496. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7497. 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])));
  7498. else
  7499. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7500. }
  7501. else
  7502. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7503. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7504. }
  7505. /*
  7506. Function: Command_Randomize()
  7507. Purpose : Sets randomize (appearance) values for NPCs
  7508. Params : Attrib Name
  7509. Dev : Scatman
  7510. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7511. */
  7512. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7513. {
  7514. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7515. if (target)
  7516. {
  7517. if (target->IsNPC())
  7518. {
  7519. if (sep && sep->arg[0] && !sep->IsNumber(0))
  7520. {
  7521. const char* value = sep->arg[0];
  7522. if (strncasecmp(value, "show", strlen(value)) == 0)
  7523. {
  7524. client->DisplayRandomizeFeatures(target->GetRandomize());
  7525. }
  7526. else
  7527. {
  7528. if (sep->arg[1] && sep->IsNumber(1))
  7529. {
  7530. int8 option = atoi(sep->arg[1]);
  7531. if (option == 0 || option == 1)
  7532. {
  7533. int32 feature = 0;
  7534. char feature_text[32] = {0};
  7535. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7536. feature = RANDOMIZE_GENDER;
  7537. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7538. }
  7539. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7540. feature = RANDOMIZE_RACE;
  7541. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7542. }
  7543. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7544. feature = RANDOMIZE_MODEL_TYPE;
  7545. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7546. }
  7547. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7548. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7549. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7550. }
  7551. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7552. feature = RANDOMIZE_HAIR_TYPE;
  7553. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7554. }
  7555. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7556. feature = RANDOMIZE_WING_TYPE;
  7557. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7558. }
  7559. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7560. feature = RANDOMIZE_CHEEK_TYPE;
  7561. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7562. }
  7563. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7564. feature = RANDOMIZE_CHIN_TYPE;
  7565. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7566. }
  7567. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7568. feature = RANDOMIZE_EAR_TYPE;
  7569. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7570. }
  7571. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7572. feature = RANDOMIZE_EYE_BROW_TYPE;
  7573. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7574. }
  7575. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7576. feature = RANDOMIZE_EYE_TYPE;
  7577. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7578. }
  7579. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7580. feature = RANDOMIZE_LIP_TYPE;
  7581. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7582. }
  7583. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7584. feature = RANDOMIZE_NOSE_TYPE;
  7585. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7586. }
  7587. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7588. feature = RANDOMIZE_EYE_COLOR;
  7589. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7590. }
  7591. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7592. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7593. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7594. }
  7595. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7596. feature = RANDOMIZE_HAIR_COLOR1;
  7597. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7598. }
  7599. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7600. feature = RANDOMIZE_HAIR_COLOR2;
  7601. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7602. }
  7603. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7604. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7605. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7606. }
  7607. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7608. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7609. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7610. }
  7611. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7612. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7613. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7614. }
  7615. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7616. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7617. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7618. }
  7619. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7620. feature = RANDOMIZE_SKIN_COLOR;
  7621. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7622. }
  7623. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7624. feature = RANDOMIZE_WING_COLOR1;
  7625. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7626. }
  7627. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7628. feature = RANDOMIZE_WING_COLOR2;
  7629. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7630. }
  7631. else {
  7632. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7633. 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'.");
  7634. }
  7635. if (feature > 0) {
  7636. if (option == 1) {
  7637. if (target->GetRandomize() & feature)
  7638. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  7639. else {
  7640. target->AddRandomize(feature);
  7641. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  7642. database.UpdateRandomize(target->GetDatabaseID(), feature);
  7643. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  7644. }
  7645. }
  7646. else {
  7647. if (target->GetRandomize() & feature) {
  7648. target->AddRandomize(-feature);
  7649. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  7650. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  7651. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  7652. }
  7653. else
  7654. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  7655. }
  7656. }
  7657. }
  7658. else
  7659. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7660. }
  7661. else
  7662. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7663. }
  7664. }
  7665. else {
  7666. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  7667. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  7668. 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'.");
  7669. }
  7670. }
  7671. else
  7672. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  7673. }
  7674. else
  7675. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  7676. }
  7677. /*
  7678. Function: Command_ShowCloak()
  7679. Purpose : Character Settings combo box for Show Cloak
  7680. Params : true/false
  7681. Dev : John Adams
  7682. Example :
  7683. */
  7684. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  7685. {
  7686. Player* player = client->GetPlayer();
  7687. if (sep && sep->arg[0])
  7688. {
  7689. const char* value = sep->arg[0];
  7690. if (strncasecmp(value, "true", strlen(value)) == 0)
  7691. {
  7692. player->set_character_flag(CF_SHOW_CLOAK);
  7693. player->reset_character_flag(CF2_SHOW_RANGED);
  7694. }
  7695. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7696. player->reset_character_flag(CF_SHOW_CLOAK);
  7697. else
  7698. {
  7699. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7700. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7701. }
  7702. }
  7703. }
  7704. /*
  7705. Function: Command_ShowHelm()
  7706. Purpose : Character Settings combo box for Show Helm
  7707. Params : true/false
  7708. Dev : John Adams
  7709. Example :
  7710. */
  7711. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  7712. {
  7713. Player* player = client->GetPlayer();
  7714. if (sep && sep->arg[0])
  7715. {
  7716. const char* value = sep->arg[0];
  7717. if (strncasecmp(value, "true", strlen(value)) == 0)
  7718. {
  7719. player->reset_character_flag(CF_HIDE_HELM);
  7720. player->set_character_flag(CF_HIDE_HOOD);
  7721. }
  7722. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7723. player->set_character_flag(CF_HIDE_HELM);
  7724. else
  7725. {
  7726. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7727. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7728. }
  7729. }
  7730. }
  7731. /*
  7732. Function: Command_ShowHood()
  7733. Purpose : Character Settings combo box for Show Hood
  7734. Params : true/false
  7735. Dev : John Adams
  7736. Example :
  7737. */
  7738. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  7739. {
  7740. Player* player = client->GetPlayer();
  7741. if (sep && sep->arg[0])
  7742. {
  7743. const char* value = sep->arg[0];
  7744. if (strncasecmp(value, "true", strlen(value)) == 0)
  7745. {
  7746. player->reset_character_flag(CF_HIDE_HOOD);
  7747. player->set_character_flag(CF_HIDE_HELM);
  7748. }
  7749. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7750. player->set_character_flag(CF_HIDE_HOOD);
  7751. else
  7752. {
  7753. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7754. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7755. }
  7756. }
  7757. }
  7758. /*
  7759. Function: Command_ShowHoodHelm()
  7760. Purpose : Character Settings combo box for Show Helm or Hood
  7761. Params : true/false
  7762. Dev : John Adams
  7763. Example :
  7764. */
  7765. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  7766. {
  7767. Player* player = client->GetPlayer();
  7768. if (sep && sep->arg[0])
  7769. {
  7770. const char* value = sep->arg[0];
  7771. if (strncasecmp(value, "true", strlen(value)) == 0)
  7772. {
  7773. player->reset_character_flag(CF_HIDE_HOOD);
  7774. player->reset_character_flag(CF_HIDE_HELM);
  7775. }
  7776. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7777. {
  7778. // don't think we ever wind up in here...
  7779. player->set_character_flag(CF_HIDE_HOOD);
  7780. player->set_character_flag(CF_HIDE_HELM);
  7781. }
  7782. else
  7783. {
  7784. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7785. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7786. }
  7787. }
  7788. }
  7789. /*
  7790. Function: Command_ShowRanged()
  7791. Purpose : Character Settings combo box for Show Ranged weapon
  7792. Params : true/false
  7793. Dev : John Adams
  7794. Example :
  7795. */
  7796. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  7797. {
  7798. Player* player = client->GetPlayer();
  7799. if (sep && sep->arg[0])
  7800. {
  7801. const char* value = sep->arg[0];
  7802. if (strncasecmp(value, "true", strlen(value)) == 0)
  7803. {
  7804. player->set_character_flag(CF2_SHOW_RANGED);
  7805. player->reset_character_flag(CF_SHOW_CLOAK);
  7806. }
  7807. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7808. player->reset_character_flag(CF2_SHOW_RANGED);
  7809. else
  7810. {
  7811. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7812. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7813. }
  7814. }
  7815. }
  7816. /*
  7817. Function:
  7818. Purpose :
  7819. Params :
  7820. Dev :
  7821. Example :
  7822. */
  7823. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  7824. {
  7825. Player* player = 0;
  7826. Client* to_client = 0;
  7827. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  7828. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  7829. switch(handler)
  7830. {
  7831. case COMMAND_SKILL:
  7832. {
  7833. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  7834. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  7835. break;
  7836. }
  7837. case COMMAND_SKILL_ADD:
  7838. {
  7839. if (sep && sep->arg[0])
  7840. {
  7841. const char* skill_name = sep->argplus[0];
  7842. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7843. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  7844. {
  7845. player = to_client->GetPlayer();
  7846. if (player)
  7847. {
  7848. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7849. {
  7850. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7851. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7852. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7853. }
  7854. else
  7855. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  7856. }
  7857. }
  7858. else if (skill) // add skill to yourself
  7859. {
  7860. player = client->GetPlayer();
  7861. if (player)
  7862. {
  7863. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7864. {
  7865. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7866. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  7867. }
  7868. else
  7869. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  7870. }
  7871. }
  7872. else
  7873. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  7874. }
  7875. else
  7876. {
  7877. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  7878. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  7879. }
  7880. break;
  7881. }
  7882. case COMMAND_SKILL_REMOVE:
  7883. {
  7884. if (sep && sep->arg[0])
  7885. {
  7886. const char* skill_name = sep->argplus[0];
  7887. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7888. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  7889. {
  7890. player = to_client->GetPlayer();
  7891. if (player)
  7892. {
  7893. if (player->GetSkills()->HasSkill(skill->skill_id))
  7894. {
  7895. player->RemoveSkillFromDB(skill, true);
  7896. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7897. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7898. }
  7899. else
  7900. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7901. }
  7902. }
  7903. else if(skill) // remove skill from yourself
  7904. {
  7905. Player* player = client->GetPlayer();
  7906. if (player)
  7907. {
  7908. if (player->GetSkills()->HasSkill(skill->skill_id))
  7909. {
  7910. player->RemoveSkillFromDB(skill, true);
  7911. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  7912. }
  7913. else
  7914. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  7915. }
  7916. }
  7917. else
  7918. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  7919. }
  7920. else
  7921. {
  7922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  7923. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  7924. }
  7925. break;
  7926. }
  7927. case COMMAND_SKILL_LIST:
  7928. {
  7929. if (sep && sep->arg[0])
  7930. {
  7931. const char* skill_name = sep->argplus[0];
  7932. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  7933. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  7934. map<int32, Skill*>::iterator itr;
  7935. if (skills && skills->size() > 0)
  7936. {
  7937. for (itr = skills->begin(); itr != skills->end(); itr++)
  7938. {
  7939. Skill* skill = itr->second;
  7940. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  7941. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  7942. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  7943. }
  7944. }
  7945. }
  7946. else
  7947. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  7948. break;
  7949. }
  7950. }
  7951. }
  7952. /*
  7953. Function: Command_SpawnTemplate()
  7954. Purpose : Create or Use defined Spawn Templates
  7955. Params : create, save, rempve, list
  7956. Dev : John Adams
  7957. Example : /spawn template create "Test"
  7958. */
  7959. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  7960. {
  7961. if (sep == NULL || sep->arg[0] == NULL)
  7962. {
  7963. 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.");
  7964. return;
  7965. }
  7966. // got params, continue
  7967. const char * template_cmd = sep->arg[0];
  7968. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  7969. {
  7970. if (!sep->IsSet(1))
  7971. {
  7972. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  7973. 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.");
  7974. return;
  7975. }
  7976. map<int32, string>* template_names = 0;
  7977. if (sep->IsNumber(1))
  7978. {
  7979. int32 location_id = 0;
  7980. location_id = atoi(sep->arg[1]);
  7981. template_names = database.GetSpawnTemplateListByID(location_id);
  7982. }
  7983. else
  7984. {
  7985. const char* name = 0;
  7986. name = sep->argplus[1];
  7987. template_names = database.GetSpawnTemplateListByName(name);
  7988. }
  7989. if(!template_names)
  7990. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  7991. else
  7992. {
  7993. map<int32, string>::iterator itr;
  7994. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  7995. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  7996. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  7997. safe_delete(template_names);
  7998. }
  7999. }
  8000. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  8001. {
  8002. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8003. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  8004. {
  8005. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  8006. {
  8007. // first, lookup to see if template name already exists
  8008. const char* name = 0;
  8009. name = sep->argplus[1];
  8010. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  8011. if(!template_names)
  8012. {
  8013. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  8014. if( new_template_id > 0 )
  8015. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  8016. else
  8017. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  8018. }
  8019. else
  8020. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  8021. }
  8022. else
  8023. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  8024. }
  8025. else
  8026. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  8027. }
  8028. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  8029. {
  8030. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  8031. {
  8032. int32 template_id = 0;
  8033. template_id = atoi(sep->arg[1]);
  8034. if (database.RemoveSpawnTemplate(template_id))
  8035. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  8036. else
  8037. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  8038. }
  8039. else
  8040. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  8041. }
  8042. // Renamed create to spawn
  8043. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  8044. {
  8045. if (sep && sep->arg[1][0])
  8046. {
  8047. int32 new_location = 0;
  8048. if (sep->IsNumber(1))
  8049. {
  8050. int32 template_id = 0;
  8051. template_id = atoi(sep->arg[1]);
  8052. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  8053. if( new_location > 0 )
  8054. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  8055. else
  8056. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  8057. }
  8058. else
  8059. {
  8060. const char* name = 0;
  8061. name = sep->argplus[1];
  8062. new_location = database.CreateSpawnFromTemplateByName(client, name);
  8063. if( new_location > 0 )
  8064. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  8065. else
  8066. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  8067. }
  8068. }
  8069. else
  8070. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  8071. }
  8072. else
  8073. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  8074. }
  8075. void Commands::Command_Speed(Client* client, Seperator* sep) {
  8076. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  8077. float new_speed = atof(sep->arg[0]);
  8078. if (new_speed > 0.0f)
  8079. {
  8080. client->GetPlayer()->SetSpeed(new_speed, true);
  8081. client->GetPlayer()->SetCharSheetChanged(true);
  8082. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  8083. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  8084. }
  8085. else
  8086. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  8087. }
  8088. else{
  8089. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  8090. }
  8091. }
  8092. /*
  8093. Function: Command_StationMarketPlace()
  8094. Purpose : just trying to eat the console spam for now
  8095. Params :
  8096. Dev : John
  8097. */
  8098. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  8099. {
  8100. PrintSep(sep, "COMMAND_SMP");
  8101. // This will reduce the spam from once every 10 sec to once every 30 sec,
  8102. // can't seem to reduce it any more get rid of it completely...
  8103. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  8104. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  8105. if (packet) {
  8106. packet->setDataByName("account_id", client->GetAccountID());
  8107. packet->setDataByName("character_id", client->GetCharacterID());
  8108. packet->setDataByName("unknown1", 1, 5);
  8109. packet->setDataByName("unknown1", 26, 6);
  8110. packet->setDataByName("unknown2", 0xFFFFFFFF);
  8111. packet->setDataByName("unknown3", 248, 1);
  8112. client->QueuePacket(packet->serialize());
  8113. }
  8114. safe_delete(packet);
  8115. }
  8116. }
  8117. /*
  8118. Function: Command_StopDrinking()
  8119. Purpose : Stops player from auto-consuming drink
  8120. Params :
  8121. Dev : Zcoretri
  8122. Example : /stopdrinking
  8123. */
  8124. void Commands::Command_StopDrinking(Client* client)
  8125. {
  8126. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  8127. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  8128. }
  8129. /*
  8130. Function: Command_StopEating()
  8131. Purpose : Stops player from auto-consuming food
  8132. Params :
  8133. Dev : Zcoretri
  8134. Example : /stopeating
  8135. */
  8136. void Commands::Command_StopEating(Client* client)
  8137. {
  8138. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  8139. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  8140. }
  8141. /*
  8142. Function: Command_Title()
  8143. Purpose : Help for /title command
  8144. Params : n/a
  8145. Dev : Zcoretri
  8146. Example : /title
  8147. */
  8148. void Commands::Command_Title(Client* client)
  8149. {
  8150. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  8151. }
  8152. /*
  8153. Function: Command_TitleList()
  8154. Purpose : List available titles for player
  8155. Params : n/a
  8156. Dev : Zcoretri
  8157. Example : /title list
  8158. */
  8159. void Commands::Command_TitleList(Client* client)
  8160. {
  8161. // must call release read lock before leaving function on GetPlayerTitles
  8162. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  8163. vector<Title*>::iterator itr;
  8164. Title* title;
  8165. sint32 i = 0;
  8166. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  8167. for(itr = titles->begin(); itr != titles->end(); itr++)
  8168. {
  8169. title = *itr;
  8170. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  8171. i++;
  8172. }
  8173. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  8174. }
  8175. /*
  8176. Function: Command_TitleSetPrefix()
  8177. Purpose : Set Prefix title for player
  8178. Params : Title ID
  8179. Dev : Zcoretri
  8180. Example : /title setprefix 1
  8181. */
  8182. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  8183. {
  8184. if (sep && sep->arg[0] && sep->IsNumber(0))
  8185. {
  8186. sint32 index = atoul(sep->arg[0]);
  8187. if(index > -1)
  8188. {
  8189. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8190. if(!title)
  8191. {
  8192. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8193. return;
  8194. }
  8195. else if(!title->GetPrefix())
  8196. {
  8197. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  8198. return;
  8199. }
  8200. }
  8201. else // make sure client doesn't pass some bogus negative index
  8202. index = -1;
  8203. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  8204. client->SendTitleUpdate();
  8205. }
  8206. }
  8207. /*
  8208. Function: Command_TitleSetSuffix()
  8209. Purpose : Set Suffix title for player
  8210. Params : Title ID
  8211. Dev : Zcoretri
  8212. Example : /title setsuffix 1
  8213. */
  8214. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  8215. {
  8216. if (sep && sep->arg[0] && sep->IsNumber(0))
  8217. {
  8218. sint32 index = atoul(sep->arg[0]);
  8219. if(index > -1)
  8220. {
  8221. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8222. if(!title)
  8223. {
  8224. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8225. return;
  8226. }
  8227. else if(title->GetPrefix())
  8228. {
  8229. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  8230. return;
  8231. }
  8232. }
  8233. else // make sure client doesn't pass some bogus negative index
  8234. index = -1;
  8235. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  8236. client->SendTitleUpdate();
  8237. }
  8238. }
  8239. /*
  8240. Function: Command_TitleFix()
  8241. Purpose : Fix title for player (???)
  8242. Params :
  8243. Dev : Zcoretri
  8244. Example :
  8245. */
  8246. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  8247. {
  8248. PrintSep(sep, "COMMAND_TITLE_FIX");
  8249. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  8250. }
  8251. /*
  8252. Function: Command_Toggle_Anonymous()
  8253. Purpose : Toggles player Anonymous
  8254. Params :
  8255. Dev : paulgh
  8256. Example : /anon
  8257. */
  8258. void Commands::Command_Toggle_Anonymous(Client* client)
  8259. {
  8260. Player* player = client->GetPlayer();
  8261. player->toggle_character_flag(CF_ANONYMOUS);
  8262. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  8263. if (player->get_character_flag(CF_ANONYMOUS))
  8264. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  8265. else
  8266. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  8267. }
  8268. /*
  8269. Function: Command_Toggle_AutoConsume()
  8270. Purpose : Toggles player food/drink auto consume
  8271. Params : unknown
  8272. Dev : paulgh
  8273. Example : /set_auto_consume
  8274. */
  8275. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  8276. {
  8277. Player* player = client->GetPlayer();
  8278. if (sep && sep->arg[0])
  8279. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  8280. if (sep && sep->arg[0] && sep->IsNumber(0))
  8281. {
  8282. int8 slot = atoi(sep->arg[0]);
  8283. int8 flag = atoi(sep->arg[1]);
  8284. if (client->GetVersion() <= 283) {
  8285. slot += 4;
  8286. }
  8287. else if (client->GetVersion() <= 546) {
  8288. slot += 2;
  8289. }
  8290. if (slot == EQ2_FOOD_SLOT)
  8291. {
  8292. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  8293. player->SetCharSheetChanged(true);
  8294. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8295. if (flag == 1)
  8296. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  8297. else
  8298. {
  8299. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  8300. return;
  8301. }
  8302. }
  8303. else
  8304. {
  8305. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  8306. player->SetCharSheetChanged(true);
  8307. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8308. if (flag == 1)
  8309. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  8310. else
  8311. {
  8312. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  8313. return;
  8314. }
  8315. }
  8316. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  8317. return;
  8318. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  8319. return;
  8320. Item* item = player->GetEquipmentList()->GetItem(slot);
  8321. if(item)
  8322. client->ConsumeFoodDrink(item, slot);
  8323. }
  8324. }
  8325. /*
  8326. Function: Command_Toggle_BonusXP()
  8327. Purpose : Toggles player Bonus XP
  8328. Params :
  8329. Dev : John Adams
  8330. Example : /disable_char_bonus_exp
  8331. */
  8332. void Commands::Command_Toggle_BonusXP(Client* client)
  8333. {
  8334. Player* player = client->GetPlayer();
  8335. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  8336. player->SetCharSheetChanged(true);
  8337. }
  8338. /*
  8339. Function: Command_Toggle_CombatXP()
  8340. Purpose : Toggles player Adventure XP
  8341. Params :
  8342. Dev : John Adams
  8343. Example : /disable_combat_exp
  8344. */
  8345. void Commands::Command_Toggle_CombatXP(Client* client)
  8346. {
  8347. Player* player = client->GetPlayer();
  8348. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  8349. player->SetCharSheetChanged(true);
  8350. }
  8351. /*
  8352. Function: Command_Toggle_GMHide()
  8353. Purpose : Toggles hiding player GM status
  8354. Params :
  8355. Dev : Scatman
  8356. Example : /gm_hide
  8357. */
  8358. void Commands::Command_Toggle_GMHide(Client* client)
  8359. {
  8360. Player* player = client->GetPlayer();
  8361. player->toggle_character_flag(CF_HIDE_STATUS);
  8362. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  8363. }
  8364. /*
  8365. Function: Command_Toggle_GMVanish()
  8366. Purpose : Toggles hiding GM players from /who searches
  8367. Params :
  8368. Dev : Scatman
  8369. Example : /gm_vanish
  8370. */
  8371. void Commands::Command_Toggle_GMVanish(Client* client)
  8372. {
  8373. Player* player = client->GetPlayer();
  8374. player->toggle_character_flag(CF_GM_HIDDEN);
  8375. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  8376. }
  8377. /*
  8378. Function: Command_Toggle_Illusions()
  8379. Purpose : Toggles player illusion form
  8380. Params : not sure sep is needed, testing
  8381. Dev : paulgh
  8382. Example : /hide_illusions
  8383. */
  8384. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  8385. {
  8386. if (sep && sep->arg[0])
  8387. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  8388. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  8389. }
  8390. /*
  8391. Function: Command_Toggle_LFG()
  8392. Purpose : Toggles player LFG Flag
  8393. Params :
  8394. Dev : paulgh
  8395. Example : /lfg
  8396. */
  8397. void Commands::Command_Toggle_LFG(Client* client)
  8398. {
  8399. Player* player = client->GetPlayer();
  8400. player->toggle_character_flag(CF_LFG);
  8401. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  8402. if (player->get_character_flag(CF_LFG))
  8403. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  8404. else
  8405. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  8406. }
  8407. /*
  8408. Function: Command_Toggle_LFW()
  8409. Purpose : Toggles player LFW Flag
  8410. Params :
  8411. Dev : paulgh
  8412. Example : /lfw
  8413. */
  8414. void Commands::Command_Toggle_LFW(Client* client)
  8415. {
  8416. Player* player = client->GetPlayer();
  8417. player->toggle_character_flag(CF_LFW);
  8418. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8419. if (player->get_character_flag(CF_LFW))
  8420. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8421. else
  8422. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8423. }
  8424. /*
  8425. Function: Command_Toggle_QuestXP()
  8426. Purpose : Toggles player Quest XP
  8427. Params :
  8428. Dev : John Adams
  8429. Example : /disable_quest_exp
  8430. */
  8431. void Commands::Command_Toggle_QuestXP(Client* client)
  8432. {
  8433. Player* player = client->GetPlayer();
  8434. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8435. player->SetCharSheetChanged(true);
  8436. }
  8437. /*
  8438. Function: Command_Toggle_Roleplaying()
  8439. Purpose : Toggles player Roleplaying flag
  8440. Params :
  8441. Dev : paulgh
  8442. Example : /role
  8443. */
  8444. void Commands::Command_Toggle_Roleplaying(Client* client)
  8445. {
  8446. Player* player = client->GetPlayer();
  8447. player->toggle_character_flag(CF_ROLEPLAYING);
  8448. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8449. if (player->get_character_flag(CF_ROLEPLAYING))
  8450. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8451. else
  8452. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8453. }
  8454. void Commands::Command_Toggle_Duels(Client* client)
  8455. {
  8456. Player* player = client->GetPlayer();
  8457. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8458. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8459. }
  8460. void Commands::Command_Toggle_Trades(Client* client)
  8461. {
  8462. Player* player = client->GetPlayer();
  8463. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8464. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8465. }
  8466. void Commands::Command_Toggle_Guilds(Client* client)
  8467. {
  8468. Player* player = client->GetPlayer();
  8469. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8470. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8471. }
  8472. void Commands::Command_Toggle_Groups(Client* client)
  8473. {
  8474. Player* player = client->GetPlayer();
  8475. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8476. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8477. }
  8478. void Commands::Command_Toggle_Raids(Client* client)
  8479. {
  8480. Player* player = client->GetPlayer();
  8481. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8482. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8483. }
  8484. void Commands::Command_Toggle_LON(Client* client)
  8485. {
  8486. Player* player = client->GetPlayer();
  8487. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8488. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8489. }
  8490. void Commands::Command_Toggle_VoiceChat(Client* client)
  8491. {
  8492. Player* player = client->GetPlayer();
  8493. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8494. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8495. }
  8496. /*
  8497. Function: Command_TradeStart()
  8498. Purpose : Starts item/coin trade between players
  8499. Params :
  8500. Dev :
  8501. Example :
  8502. */
  8503. #include "../Trade.h"
  8504. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  8505. {
  8506. PrintSep(sep, "COMMAND_START_TRADE");
  8507. Entity* trader = client->GetPlayer();
  8508. Entity* trader2 = 0;
  8509. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8510. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  8511. if (spawn) {
  8512. if (spawn->IsEntity())
  8513. trader2 = (Entity*)spawn;
  8514. }
  8515. }
  8516. else if (client->GetPlayer()->GetTarget()) {
  8517. if (client->GetPlayer()->GetTarget()->IsEntity())
  8518. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  8519. }
  8520. // can only trade with player or bots
  8521. if (trader && trader2) {
  8522. if (trader == trader2) {
  8523. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  8524. }
  8525. else if (trader2->IsPlayer() || trader2->IsBot()) {
  8526. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  8527. if (trader->trade)
  8528. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  8529. else if (trader2->trade)
  8530. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  8531. else {
  8532. Trade* trade = new Trade(trader, trader2);
  8533. trader->trade = trade;
  8534. trader2->trade = trade;
  8535. }
  8536. }
  8537. else {
  8538. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8539. }
  8540. }
  8541. else
  8542. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8543. }
  8544. /*
  8545. Function: Command_Track()
  8546. Purpose : Starts/Stops Tracking for a player
  8547. Params :
  8548. Dev : Scatman
  8549. Example : /track
  8550. */
  8551. void Commands::Command_Track(Client* client)
  8552. {
  8553. if (!client->GetPlayer()->GetIsTracking())
  8554. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8555. else
  8556. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8557. }
  8558. /*
  8559. Function: Command_TradeAccept()
  8560. Purpose : Accepts item/coin trade between players
  8561. Params :
  8562. Dev :
  8563. Example :
  8564. */
  8565. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8566. {
  8567. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8568. Trade* trade = client->GetPlayer()->trade;
  8569. if (trade) {
  8570. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8571. if (trade_complete)
  8572. safe_delete(trade);
  8573. }
  8574. else
  8575. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8576. }
  8577. /*
  8578. Function: Command_TradeReject()
  8579. Purpose : Rejects item/coin trade between players
  8580. Params :
  8581. Dev :
  8582. Example :
  8583. */
  8584. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8585. {
  8586. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8587. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  8588. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8589. }
  8590. /*
  8591. Function: Command_TradeCancel()
  8592. Purpose : Cancels item/coin trade between players
  8593. Params :
  8594. Dev :
  8595. Example :
  8596. */
  8597. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8598. {
  8599. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8600. Trade* trade = client->GetPlayer()->trade;
  8601. if (trade) {
  8602. trade->CancelTrade(client->GetPlayer());
  8603. safe_delete(trade);
  8604. }
  8605. else
  8606. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8607. }
  8608. /*
  8609. Function: Command_TradeSetCoin()
  8610. Purpose : Sets coin trade between players
  8611. Params :
  8612. Dev :
  8613. Example :
  8614. */
  8615. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8616. {
  8617. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8618. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8619. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8620. }
  8621. /*
  8622. Function: Command_TradeAddCoin()
  8623. Purpose : Adds coin to trade between players
  8624. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8625. Dev :
  8626. Example :
  8627. */
  8628. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  8629. {
  8630. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  8631. Trade* trade = client->GetPlayer()->trade;
  8632. if (trade) {
  8633. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8634. int32 amount = atoi(sep->arg[0]);
  8635. int64 val = 0;
  8636. switch (handler) {
  8637. case COMMAND_ADD_TRADE_COPPER:
  8638. {
  8639. val = amount;
  8640. trade->AddCoinToTrade(client->GetPlayer(), val);
  8641. break;
  8642. }
  8643. case COMMAND_ADD_TRADE_SILVER:
  8644. {
  8645. val = amount * 100;
  8646. trade->AddCoinToTrade(client->GetPlayer(), val);
  8647. break;
  8648. }
  8649. case COMMAND_ADD_TRADE_GOLD:
  8650. {
  8651. val = amount * 10000;
  8652. trade->AddCoinToTrade(client->GetPlayer(), val);
  8653. break;
  8654. }
  8655. case COMMAND_ADD_TRADE_PLAT:
  8656. {
  8657. val = amount * 1000000;
  8658. trade->AddCoinToTrade(client->GetPlayer(), val);
  8659. break;
  8660. }
  8661. default:
  8662. {
  8663. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8664. break;
  8665. }
  8666. }
  8667. }
  8668. else
  8669. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  8670. }
  8671. else
  8672. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8673. }
  8674. /*
  8675. Function: Command_TradeRemoveCoin()
  8676. Purpose : Removes coin from trade between players
  8677. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8678. Dev :
  8679. Example :
  8680. */
  8681. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  8682. {
  8683. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  8684. Trade* trade = client->GetPlayer()->trade;
  8685. if (trade) {
  8686. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8687. int32 amount = atoi(sep->arg[0]);
  8688. int64 val = 0;
  8689. switch (handler) {
  8690. case COMMAND_REMOVE_TRADE_COPPER:
  8691. {
  8692. val = amount;
  8693. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8694. break;
  8695. }
  8696. case COMMAND_REMOVE_TRADE_SILVER:
  8697. {
  8698. val = amount * 100;
  8699. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8700. break;
  8701. }
  8702. case COMMAND_REMOVE_TRADE_GOLD:
  8703. {
  8704. val = amount * 10000;
  8705. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8706. break;
  8707. }
  8708. case COMMAND_REMOVE_TRADE_PLAT:
  8709. {
  8710. val = amount * 1000000;
  8711. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8712. break;
  8713. }
  8714. default:
  8715. {
  8716. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8717. break;
  8718. }
  8719. }
  8720. }
  8721. else
  8722. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  8723. }
  8724. else
  8725. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8726. }
  8727. /*
  8728. Function: Command_TradeAddItem()
  8729. Purpose : Adds item to trade between players
  8730. Params :
  8731. Dev :
  8732. Example :
  8733. */
  8734. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  8735. {
  8736. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  8737. /*
  8738. arg[0] = item index
  8739. arg[1] = slot
  8740. arg[2] = quantity
  8741. */
  8742. if (!client->GetPlayer()->trade) {
  8743. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  8744. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8745. return;
  8746. }
  8747. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  8748. Item* item = 0;
  8749. int32 index = atoi(sep->arg[0]);
  8750. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  8751. if (item) {
  8752. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  8753. if (result == 1)
  8754. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  8755. else if (result == 2)
  8756. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  8757. else if (result == 3)
  8758. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  8759. else if (result == 255)
  8760. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  8761. }
  8762. else {
  8763. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  8764. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  8765. }
  8766. }
  8767. else
  8768. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  8769. }
  8770. /*
  8771. Function: Command_TradeRemoveItem()
  8772. Purpose : Removes item from trade between players
  8773. Params :
  8774. Dev :
  8775. Example :
  8776. */
  8777. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  8778. {
  8779. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  8780. /*
  8781. arg[0] = trade window slot
  8782. */
  8783. Trade* trade = client->GetPlayer()->trade;
  8784. if (trade) {
  8785. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8786. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  8787. }
  8788. else
  8789. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  8790. }
  8791. else
  8792. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8793. }
  8794. void Commands::Command_TryOn(Client* client, Seperator* sep)
  8795. {
  8796. Item *item = 0;
  8797. sint32 crc;
  8798. if (sep) {
  8799. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  8800. if (client->GetVersion() < 1096) {
  8801. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  8802. {
  8803. item = master_item_list.GetItem(atoul(sep->arg[1]));
  8804. crc = atol(sep->arg[2]);
  8805. }
  8806. }
  8807. else {
  8808. // From the broker and links in chat
  8809. if (strcmp(sep->arg[0], "crc") == 0) {
  8810. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  8811. item = master_item_list.GetItem(atoul(sep->arg[2]));
  8812. crc = atol(sep->arg[3]);
  8813. }
  8814. }
  8815. // From inventory
  8816. if (strcmp(sep->arg[0], "dbid") == 0) {
  8817. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  8818. item = master_item_list.GetItem(atoul(sep->arg[2]));
  8819. crc = atol(sep->arg[4]);
  8820. }
  8821. }
  8822. }
  8823. if (item)
  8824. client->ShowDressingRoom(item, crc);
  8825. }
  8826. }
  8827. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  8828. const char *channel_name, *password = NULL;
  8829. if (sep == NULL || !sep->IsSet(0)) {
  8830. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  8831. return;
  8832. }
  8833. channel_name = sep->arg[0];
  8834. if (sep->IsSet(1))
  8835. password = sep->arg[1];
  8836. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  8837. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  8838. return;
  8839. }
  8840. if (chat.IsInChannel(client, channel_name)) {
  8841. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  8842. return;
  8843. }
  8844. if (chat.HasPassword(channel_name)) {
  8845. if (password == NULL) {
  8846. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  8847. return;
  8848. }
  8849. if (!chat.PasswordMatches(channel_name, password)) {
  8850. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  8851. return;
  8852. }
  8853. }
  8854. if (!chat.JoinChannel(client, channel_name))
  8855. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  8856. }
  8857. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  8858. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  8859. Command_JoinChannel(client, sep);
  8860. }
  8861. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  8862. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  8863. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  8864. PrintSep(sep, "tellchannel");
  8865. return;
  8866. }
  8867. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  8868. }
  8869. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  8870. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8871. if (sep->IsSet(0)) {
  8872. if (atoi(sep->arg[0]) == 1) {
  8873. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  8874. if (packet2) {
  8875. packet2->setDataByName("spell_type", 2);
  8876. packet2->setDataByName("spell_id", 8308);
  8877. packet2->setDataByName("spell_name", "Sprint");
  8878. packet2->setDataByName("add_silently", 0);
  8879. packet2->setDataByName("tier", 1);
  8880. packet2->setDataByName("blah1", 1);
  8881. packet2->setDataByName("blah2", 1);
  8882. EQ2Packet* outapp = packet2->serialize();
  8883. DumpPacket(outapp);
  8884. client->QueuePacket(outapp);
  8885. safe_delete(packet2);
  8886. }
  8887. }
  8888. else if (atoi(sep->arg[0]) == 2) {
  8889. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  8890. if (packet2) {
  8891. packet2->setDataByName("guild_name", "Test");
  8892. packet2->setDataByName("guild_motd", "Test MOTD");
  8893. packet2->setDataByName("guild_id", 1234);
  8894. packet2->setDataByName("guild_level", 1);
  8895. packet2->setDataByName("unknown", 2);
  8896. packet2->setDataByName("unknown2", 3);
  8897. packet2->setDataByName("exp_current", 1);
  8898. packet2->setDataByName("exp_to_next_level", 4);
  8899. EQ2Packet* outapp = packet2->serialize();
  8900. DumpPacket(outapp);
  8901. client->QueuePacket(outapp);
  8902. safe_delete(packet2);
  8903. }
  8904. }
  8905. else if (atoi(sep->arg[0]) == 3) {
  8906. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  8907. if (packet2) {
  8908. packet2->setDataByName("guild_id", 1234);
  8909. packet2->setDataByName("character_id", 1);
  8910. packet2->setDataByName("account_id", 2);
  8911. packet2->setDataByName("guild_level", 1);
  8912. packet2->setDataByName("name", "Test");
  8913. packet2->setDataByName("unknown2", 0);
  8914. packet2->setDataByName("unknown3", 1);
  8915. packet2->setDataByName("adventure_class", 6);
  8916. packet2->setDataByName("adventure_level", 7);
  8917. packet2->setDataByName("tradeskill_class", 4);
  8918. packet2->setDataByName("tradeskill_level", 5);
  8919. packet2->setDataByName("rank", 0);
  8920. packet2->setDataByName("member_flags", 2);
  8921. packet2->setDataByName("join_date", 1591112273);
  8922. packet2->setDataByName("guild_status", 2);
  8923. packet2->setDataByName("last_login", 1591132273);
  8924. packet2->setDataByName("recruiter_id", 1);
  8925. packet2->setDataByName("points", 2345);
  8926. packet2->setDataByName("note", "note");
  8927. packet2->setMediumStringByName("officer_note", "O note");
  8928. packet2->setMediumStringByName("zone", "Blah");
  8929. EQ2Packet* outapp = packet2->serialize();
  8930. DumpPacket(outapp);
  8931. client->QueuePacket(outapp);
  8932. safe_delete(packet2);
  8933. }
  8934. }
  8935. else if (atoi(sep->arg[0]) == 5) {
  8936. int16 offset = atoi(sep->arg[1]);
  8937. int32 value1 = atol(sep->arg[2]);
  8938. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  8939. client->QueuePacket(outapp);
  8940. }
  8941. else if (atoi(sep->arg[0]) == 6) {
  8942. Spawn* spawn = client->GetPlayer()->GetTarget();
  8943. if (!spawn)
  8944. spawn = client->GetPlayer();
  8945. else if (spawn->IsEntity())
  8946. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  8947. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  8948. }
  8949. else if (atoi(sep->arg[0]) == 7) {
  8950. int32 id = 0;
  8951. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  8952. if (spawn) {
  8953. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  8954. spawn->SetY(client->GetPlayer()->GetY(), false);
  8955. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  8956. float heading = client->GetPlayer()->GetHeading() + 180;
  8957. if (heading > 360)
  8958. heading -= 360;
  8959. spawn->SetLevel(5);
  8960. spawn->SetAdventureClass(4);
  8961. spawn->SetHeading(heading, false);
  8962. spawn->SetSpawnOrigX(spawn->GetX());
  8963. spawn->SetSpawnOrigY(spawn->GetY());
  8964. spawn->SetSpawnOrigZ(spawn->GetZ());
  8965. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  8966. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8967. spawn->appearance.targetable = 1;
  8968. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  8969. spawn->SetTotalHP(spawn->GetLevel() * 15);
  8970. spawn->SetHP(spawn->GetTotalHP());
  8971. }
  8972. if (spawn->GetTotalPower() == 0) {
  8973. spawn->SetTotalPower(spawn->GetLevel() * 15);
  8974. spawn->SetPower(spawn->GetTotalPower());
  8975. }
  8976. int16 offset = atoi(sep->arg[1]);
  8977. int32 value1 = atol(sep->arg[2]);
  8978. sprintf(spawn->appearance.name, "Offset %i", offset);
  8979. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  8980. DumpPacket(ret);
  8981. client->QueuePacket(ret);
  8982. }
  8983. }
  8984. else if (atoi(sep->arg[0]) == 8) {
  8985. int32 id = atoi(sep->arg[1]);
  8986. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  8987. if (spawn) {
  8988. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  8989. spawn->SetY(client->GetPlayer()->GetY(), false);
  8990. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  8991. float heading = client->GetPlayer()->GetHeading() + 180;
  8992. if (heading > 360)
  8993. heading -= 360;
  8994. spawn->SetLevel(5);
  8995. spawn->SetAdventureClass(4);
  8996. spawn->SetHeading(heading, false);
  8997. spawn->SetSpawnOrigX(spawn->GetX());
  8998. spawn->SetSpawnOrigY(spawn->GetY());
  8999. spawn->SetSpawnOrigZ(spawn->GetZ());
  9000. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9001. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9002. spawn->appearance.targetable = 1;
  9003. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9004. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9005. spawn->SetHP(spawn->GetTotalHP());
  9006. }
  9007. if (spawn->GetTotalPower() == 0) {
  9008. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9009. spawn->SetPower(spawn->GetTotalPower());
  9010. }
  9011. int16 offset = atoi(sep->arg[2]);
  9012. int16 offset2 = atoi(sep->arg[3]);
  9013. int32 value1 = atol(sep->arg[4]);
  9014. int16 offset3 = 0;
  9015. int16 offset4 = 0;
  9016. int32 value2 = 0;
  9017. if (sep->IsSet(7)) {
  9018. offset3 = atoi(sep->arg[5]);
  9019. offset4 = atoi(sep->arg[6]);
  9020. value2 = atol(sep->arg[7]);
  9021. }
  9022. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  9023. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  9024. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  9025. DumpPacket(ret);
  9026. client->QueuePacket(ret);
  9027. }
  9028. }
  9029. else if (atoi(sep->arg[0]) == 9) {
  9030. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  9031. if (packet2) {
  9032. packet2->setArrayLengthByName("location_count", 1);
  9033. packet2->setArrayDataByName("location_ida", 1234);
  9034. packet2->setArrayDataByName("unknown2a", 3);
  9035. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  9036. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  9037. packet2->setArrayDataByName("distance", 134);
  9038. EQ2Packet* app = packet2->serialize();
  9039. if (sep->IsSet(2)) {
  9040. int8 offset = atoi(sep->arg[1]);
  9041. uchar* ptr2 = app->pBuffer;
  9042. ptr2 += offset;
  9043. if (sep->IsNumber(2)) {
  9044. int32 value1 = atol(sep->arg[2]);
  9045. if (value1 > 0xFFFF)
  9046. memcpy(ptr2, (uchar*)&value1, 4);
  9047. else if (value1 > 0xFF)
  9048. memcpy(ptr2, (uchar*)&value1, 2);
  9049. else
  9050. memcpy(ptr2, (uchar*)&value1, 1);
  9051. }
  9052. else {
  9053. int8 len = strlen(sep->arg[2]);
  9054. memcpy(ptr2, (uchar*)&len, 1);
  9055. ptr2 += 1;
  9056. memcpy(ptr2, sep->arg[2], len);
  9057. }
  9058. }
  9059. DumpPacket(app);
  9060. client->QueuePacket(app);
  9061. safe_delete(packet2);
  9062. }
  9063. }
  9064. else if (atoi(sep->arg[0]) == 10) {
  9065. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  9066. if (packet2) {
  9067. packet2->setArrayLengthByName("num_quests", 1);
  9068. packet2->setArrayDataByName("active", 1);
  9069. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  9070. packet2->setArrayDataByName("quest_type", "Hallmark");
  9071. packet2->setArrayDataByName("quest_zone", "Hallmark");
  9072. packet2->setArrayDataByName("journal_updated", 1);
  9073. packet2->setArrayDataByName("quest_id", 524);
  9074. packet2->setArrayDataByName("day", 19);
  9075. packet2->setArrayDataByName("month", 6);
  9076. packet2->setArrayDataByName("year", 20);
  9077. packet2->setArrayDataByName("level", 2);
  9078. packet2->setArrayDataByName("encounter_level", 4);
  9079. packet2->setArrayDataByName("difficulty", 3);
  9080. packet2->setArrayDataByName("visible", 1);
  9081. packet2->setDataByName("visible_quest_id", 524);
  9082. packet2->setDataByName("player_crc", 2900677088);
  9083. packet2->setDataByName("player_name", "LethalEncounter");
  9084. EQ2Packet* app = packet2->serialize();
  9085. if (sep->IsSet(2)) {
  9086. int8 offset = atoi(sep->arg[1]);
  9087. uchar* ptr2 = app->pBuffer;
  9088. ptr2 += offset;
  9089. if (sep->IsNumber(2)) {
  9090. int32 value1 = atol(sep->arg[2]);
  9091. if (value1 > 0xFFFF)
  9092. memcpy(ptr2, (uchar*)&value1, 4);
  9093. else if (value1 > 0xFF)
  9094. memcpy(ptr2, (uchar*)&value1, 2);
  9095. else
  9096. memcpy(ptr2, (uchar*)&value1, 1);
  9097. }
  9098. else {
  9099. int8 len = strlen(sep->arg[2]);
  9100. memcpy(ptr2, (uchar*)&len, 1);
  9101. ptr2 += 1;
  9102. memcpy(ptr2, sep->arg[2], len);
  9103. }
  9104. }
  9105. DumpPacket(app);
  9106. client->QueuePacket(app);
  9107. safe_delete(packet2);
  9108. }
  9109. }
  9110. else if (atoi(sep->arg[0]) == 11) {
  9111. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9112. if (packet2) {
  9113. packet2->setDataByName("quest_id", 524);
  9114. packet2->setDataByName("player_crc", 2900677088);
  9115. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  9116. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  9117. packet2->setDataByName("type", "Hallmark");
  9118. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9119. packet2->setDataByName("day", 19);
  9120. packet2->setDataByName("month", 6);
  9121. packet2->setDataByName("year", 20);
  9122. packet2->setDataByName("level", 1);
  9123. packet2->setDataByName("encounter_level", 1);
  9124. packet2->setDataByName("difficulty", 1);
  9125. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9126. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9127. //packet2->setDataByName("timer_duration", 300);
  9128. //packet2->setDataByName("timer_running", 1);
  9129. packet2->setArrayLengthByName("task_groups_completed", 9);
  9130. packet2->setArrayLengthByName("num_task_groups", 10);
  9131. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  9132. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  9133. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  9134. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  9135. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  9136. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  9137. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  9138. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  9139. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  9140. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  9141. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  9142. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9143. packet2->setSubArrayLengthByName("num_updates", 1);
  9144. packet2->setSubArrayDataByName("update_currentval", 0);
  9145. packet2->setSubArrayDataByName("update_maxval", 1);
  9146. packet2->setSubArrayDataByName("icon", 11);
  9147. */
  9148. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9149. packet2->setDataByName("journal_updated", 1);
  9150. packet2->setDataByName("bullets", 1);
  9151. EQ2Packet* app = packet2->serialize();
  9152. if (sep->IsSet(2)) {
  9153. int16 offset = atoi(sep->arg[1]);
  9154. uchar* ptr2 = app->pBuffer;
  9155. ptr2 += offset;
  9156. if (sep->IsNumber(2)) {
  9157. int32 value1 = atol(sep->arg[2]);
  9158. if (value1 > 0xFFFF)
  9159. memcpy(ptr2, (uchar*)&value1, 4);
  9160. else if (value1 > 0xFF)
  9161. memcpy(ptr2, (uchar*)&value1, 2);
  9162. else
  9163. memcpy(ptr2, (uchar*)&value1, 1);
  9164. }
  9165. else {
  9166. int16 len = strlen(sep->arg[2]);
  9167. memcpy(ptr2, (uchar*)&len, 2);
  9168. ptr2 += 2;
  9169. memcpy(ptr2, sep->arg[2], len);
  9170. }
  9171. }
  9172. DumpPacket(app);
  9173. client->QueuePacket(app);
  9174. safe_delete(packet2);
  9175. }
  9176. }
  9177. else if (atoi(sep->arg[0]) == 12) {
  9178. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9179. if (packet2) {
  9180. packet2->setDataByName("quest_id", 524);
  9181. packet2->setDataByName("player_crc", 2900677088);
  9182. packet2->setDataByName("name", "Archetype Selection");
  9183. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  9184. packet2->setDataByName("type", "Hallmark");
  9185. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9186. packet2->setDataByName("day", 19);
  9187. packet2->setDataByName("month", 6);
  9188. packet2->setDataByName("year", 20);
  9189. packet2->setDataByName("level", 2);
  9190. packet2->setDataByName("encounter_level", 4);
  9191. packet2->setDataByName("difficulty", 3);
  9192. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9193. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9194. packet2->setDataByName("timer_duration", 300);
  9195. packet2->setDataByName("timer_running", 1);
  9196. packet2->setArrayLengthByName("task_groups_completed", 0);
  9197. packet2->setArrayLengthByName("num_task_groups", 1);
  9198. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  9199. packet2->setSubArrayLengthByName("num_tasks", 1);
  9200. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9201. packet2->setSubArrayLengthByName("num_updates", 1);
  9202. packet2->setSubArrayDataByName("update_currentval", 0);
  9203. packet2->setSubArrayDataByName("update_maxval", 1);
  9204. packet2->setSubArrayDataByName("icon", 11);
  9205. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9206. packet2->setDataByName("journal_updated", 1);
  9207. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9208. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9209. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  9210. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9211. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9212. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9213. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9214. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  9215. Item* item = master_item_list.GetItem(152755);
  9216. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9217. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9218. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  9219. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  9220. packet2->setSubstructDataByName("item", "icon", 0xe7);
  9221. packet2->setSubstructDataByName("item", "tier", 4);
  9222. packet2->setSubstructDataByName("item", "flags", 0x60);
  9223. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  9224. packet2->setSubstructDataByName("item", "stat_type", 1);
  9225. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  9226. packet2->setSubstructDataByName("item", "value", 3);
  9227. packet2->setSubstructDataByName("item", "condition", 100);
  9228. packet2->setSubstructDataByName("item", "weight", 1);
  9229. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  9230. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  9231. packet2->setSubstructDataByName("item", "skill_min", 1);
  9232. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  9233. packet2->setSubstructDataByName("item", "adventure_class", 1);
  9234. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  9235. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  9236. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  9237. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  9238. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  9239. packet2->setSubstructDataByName("item", "level", 0x1e);
  9240. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  9241. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  9242. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  9243. //packet2->PrintPacket();
  9244. EQ2Packet* app = packet2->serialize();
  9245. if (sep->IsSet(2)) {
  9246. int16 offset = atoi(sep->arg[1]);
  9247. uchar* ptr2 = app->pBuffer;
  9248. ptr2 += offset;
  9249. if (sep->IsNumber(2)) {
  9250. int32 value1 = atol(sep->arg[2]);
  9251. if (value1 > 0xFFFF)
  9252. memcpy(ptr2, (uchar*)&value1, 4);
  9253. else if (value1 > 0xFF)
  9254. memcpy(ptr2, (uchar*)&value1, 2);
  9255. else
  9256. memcpy(ptr2, (uchar*)&value1, 1);
  9257. }
  9258. else {
  9259. int16 len = strlen(sep->arg[2]);
  9260. memcpy(ptr2, (uchar*)&len, 2);
  9261. ptr2 += 2;
  9262. memcpy(ptr2, sep->arg[2], len);
  9263. }
  9264. }
  9265. DumpPacket(app);
  9266. client->QueuePacket(app);
  9267. safe_delete(packet2);
  9268. }
  9269. }
  9270. else if (atoi(sep->arg[0]) == 13) {
  9271. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  9272. if (packet2 && sep->IsSet(7)) {
  9273. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  9274. char blah[128];
  9275. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  9276. packet2->setDataByName("text", blah);
  9277. packet2->setDataByName("message_type", sep->arg[3]);
  9278. packet2->setDataByName("size", atof(sep->arg[4]));
  9279. packet2->setDataByName("red", atoi(sep->arg[5]));
  9280. packet2->setDataByName("green", atoi(sep->arg[6]));
  9281. packet2->setDataByName("blue", atoi(sep->arg[7]));
  9282. EQ2Packet* app = packet2->serialize();
  9283. DumpPacket(app);
  9284. client->QueuePacket(app);
  9285. safe_delete(packet2);
  9286. }
  9287. }
  9288. else if (atoi(sep->arg[0]) == 14) {
  9289. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  9290. if (packet2 && sep->IsSet(3)) {
  9291. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  9292. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  9293. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  9294. 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.");
  9295. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  9296. packet2->setArrayLengthByName("num_goals", 1);
  9297. //packet2->setArrayDataByName("goal_text", )
  9298. packet2->setSubArrayLengthByName("num_tasks", 1);
  9299. packet2->setSubArrayDataByName("task_text", "continue");
  9300. packet2->setDataByName("complete_sound", "click");
  9301. packet2->setDataByName("signal", "introduction");
  9302. packet2->setDataByName("voice_key1", 0xcda65173);
  9303. packet2->setDataByName("voice_key2", 0x984bfc6d);
  9304. EQ2Packet* app = packet2->serialize();
  9305. DumpPacket(app);
  9306. client->QueuePacket(app);
  9307. safe_delete(packet2);
  9308. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  9309. packet2->setDataByName("window", "MainHUD.StartMenu");
  9310. packet2->setDataByName("show", 1);
  9311. app = packet2->serialize();
  9312. DumpPacket(app);
  9313. client->QueuePacket(app);
  9314. safe_delete(packet2);
  9315. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  9316. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  9317. packet2->setDataByName("flash_seconds", 10);
  9318. app = packet2->serialize();
  9319. DumpPacket(app);
  9320. client->QueuePacket(app);
  9321. safe_delete(packet2);
  9322. }
  9323. }
  9324. else if (atoi(sep->arg[0]) == 15) {
  9325. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9326. if (packet2) {
  9327. packet2->setArrayLengthByName("loot_count", 1);
  9328. packet2->setArrayDataByName("name", "Test");
  9329. packet2->setArrayDataByName("item_id", 1234);
  9330. packet2->setArrayDataByName("count", 1);
  9331. packet2->setArrayDataByName("icon", 258);
  9332. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  9333. Spawn* spawn = client->GetPlayer()->GetTarget();
  9334. if (spawn)
  9335. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9336. packet2->setDataByName("unknown3", 1);
  9337. packet2->setDataByName("unknown4", 1);
  9338. packet2->setDataByName("unknown5", 60);
  9339. EQ2Packet* app = packet2->serialize();
  9340. DumpPacket(app);
  9341. client->QueuePacket(app);
  9342. safe_delete(packet2);
  9343. }
  9344. }
  9345. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  9346. char blah[32];
  9347. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  9348. client->SimpleMessage(atoi(sep->arg[1]), blah);
  9349. }
  9350. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  9351. if (sep->IsSet(2)) {
  9352. int16 offset = atoi(sep->arg[1]);
  9353. if (sep->IsNumber(2)) {
  9354. int32 value1 = atol(sep->arg[2]);
  9355. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  9356. cout << "Sent" << endl;
  9357. }
  9358. }
  9359. }
  9360. else if (atoi(sep->arg[0]) == 18) {
  9361. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  9362. if (packet2) {
  9363. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9364. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9365. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9366. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9367. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9368. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  9369. Item* item = new Item(master_item_list.GetItem(36212));
  9370. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9371. item->stack_count = 20;
  9372. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9373. safe_delete(item);
  9374. item = new Item(master_item_list.GetItem(36685));
  9375. item->stack_count = 20;
  9376. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9377. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  9378. safe_delete(item);
  9379. item = master_item_list.GetItem(1414);
  9380. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9381. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  9382. item = master_item_list.GetItem(75057);
  9383. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9384. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  9385. EQ2Packet* app = packet2->serialize();
  9386. if (sep->IsSet(2)) {
  9387. int16 offset = atoi(sep->arg[1]);
  9388. uchar* ptr2 = app->pBuffer;
  9389. ptr2 += offset;
  9390. if (sep->IsNumber(2)) {
  9391. int32 value1 = atol(sep->arg[2]);
  9392. if (value1 > 0xFFFF)
  9393. memcpy(ptr2, (uchar*)&value1, 4);
  9394. else if (value1 > 0xFF)
  9395. memcpy(ptr2, (uchar*)&value1, 2);
  9396. else
  9397. memcpy(ptr2, (uchar*)&value1, 1);
  9398. }
  9399. else {
  9400. int16 len = strlen(sep->arg[2]);
  9401. memcpy(ptr2, (uchar*)&len, 2);
  9402. ptr2 += 2;
  9403. memcpy(ptr2, sep->arg[2], len);
  9404. }
  9405. }
  9406. DumpPacket(app);
  9407. client->QueuePacket(app);
  9408. safe_delete(packet2);
  9409. }
  9410. }
  9411. else if (atoi(sep->arg[0]) == 19) {
  9412. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9413. Spawn* spawn = client->GetPlayer()->GetTarget();
  9414. if (packet2 && spawn) {
  9415. Item* item = master_item_list.GetItem(130053);
  9416. packet2->setArrayLengthByName("loot_count", 1);
  9417. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9418. packet2->setArrayDataByName("unknown2", 1);
  9419. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9420. packet2->setDataByName("display", 1);
  9421. packet2->setDataByName("unknown2b", 1);
  9422. packet2->setDataByName("unknown3", 0x3c);
  9423. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9424. packet2->PrintPacket();
  9425. EQ2Packet* app = packet2->serialize();
  9426. if (sep->IsSet(2)) {
  9427. int16 offset = atoi(sep->arg[1]);
  9428. int16 offset2 = 0;
  9429. int32 value1 = 0;
  9430. if (sep->IsSet(3)) {
  9431. offset2 = atoi(sep->arg[2]);
  9432. value1 = atol(sep->arg[3]);
  9433. }
  9434. else
  9435. value1 = atol(sep->arg[2]);
  9436. int16 offset3 = 0;
  9437. int16 offset4 = 0;
  9438. int32 value2 = 0;
  9439. if (sep->IsSet(6)) {
  9440. offset3 = atoi(sep->arg[4]);
  9441. offset4 = atoi(sep->arg[5]);
  9442. value2 = atol(sep->arg[6]);
  9443. }
  9444. offset--;
  9445. if (offset2 > 0 && offset2 >= offset) {
  9446. offset2--;
  9447. uchar* ptr2 = app->pBuffer;
  9448. ptr2 += offset;
  9449. for (int i = offset; i <= offset2; i++) {
  9450. if (value1 > 0xFFFF) {
  9451. memcpy(ptr2, (uchar*)&value1, 4);
  9452. i += 3;
  9453. ptr2 += 3;
  9454. }
  9455. else if (value1 > 0xFF) {
  9456. memcpy(ptr2, (uchar*)&value1, 2);
  9457. i++;
  9458. ptr2++;
  9459. }
  9460. else
  9461. memcpy(ptr2, (uchar*)&value1, 1);
  9462. ptr2++;
  9463. }
  9464. }
  9465. if (offset4 > 0 && offset4 >= offset3) {
  9466. offset3--;
  9467. offset4--;
  9468. uchar* ptr2 = app->pBuffer;
  9469. ptr2 += offset3;
  9470. for (int i = offset3; i <= offset4; i++) {
  9471. if (value2 > 0xFFFF) {
  9472. memcpy(ptr2, (uchar*)&value2, 4);
  9473. i += 3;
  9474. ptr2 += 3;
  9475. }
  9476. else if (value2 > 0xFF) {
  9477. memcpy(ptr2, (uchar*)&value2, 2);
  9478. i++;
  9479. ptr2++;
  9480. }
  9481. else
  9482. memcpy(ptr2, (uchar*)&value2, 1);
  9483. ptr2++;
  9484. }
  9485. }
  9486. }
  9487. DumpPacket(app);
  9488. client->QueuePacket(app);
  9489. safe_delete(packet2);
  9490. }
  9491. }
  9492. else if (atoi(sep->arg[0]) == 21) {
  9493. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9494. if (packet2) {
  9495. packet2->setDataByName("unknown0", 255);
  9496. packet2->setDataByName("reward", "New Quest");
  9497. packet2->setDataByName("title", "Title");
  9498. packet2->setDataByName("description", "description");
  9499. packet2->setDataByName("quest_difficulty", 3);
  9500. packet2->setDataByName("unknown1", 5);
  9501. packet2->setDataByName("level", 3);
  9502. packet2->setDataByName("coin", 150);
  9503. packet2->setDataByName("status_points", 5);
  9504. packet2->setDataByName("exp_bonus", 10);
  9505. packet2->setArrayLengthByName("num_rewards", 1);
  9506. Item* item = new Item(master_item_list.GetItem(36212));
  9507. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9508. item->stack_count = 20;
  9509. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9510. safe_delete(item);
  9511. char accept[35] = { 0 };
  9512. char decline[35] = { 0 };
  9513. sprintf(accept, "q_accept_pending_quest %u", 0);
  9514. sprintf(decline, "q_deny_pending_quest %u", 0);
  9515. packet2->setDataByName("accept_command", accept);
  9516. packet2->setDataByName("decline_command", decline);
  9517. EQ2Packet* app = packet2->serialize();
  9518. if (sep->IsSet(2)) {
  9519. int16 offset = atoi(sep->arg[1]);
  9520. uchar* ptr2 = app->pBuffer;
  9521. ptr2 += offset;
  9522. if (sep->IsNumber(2)) {
  9523. int32 value1 = atol(sep->arg[2]);
  9524. if (value1 > 0xFFFF)
  9525. memcpy(ptr2, (uchar*)&value1, 4);
  9526. else if (value1 > 0xFF)
  9527. memcpy(ptr2, (uchar*)&value1, 2);
  9528. else
  9529. memcpy(ptr2, (uchar*)&value1, 1);
  9530. }
  9531. DumpPacket(app);
  9532. client->QueuePacket(app);
  9533. safe_delete(packet2);
  9534. }
  9535. }
  9536. }
  9537. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9538. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9539. if (packet2) {
  9540. packet2->setDataByName("unknown0", 255);
  9541. packet2->setDataByName("reward", "New Quest");
  9542. packet2->setDataByName("title", "Title");
  9543. packet2->setDataByName("description", "description");
  9544. packet2->setDataByName("quest_difficulty", 3);
  9545. packet2->setDataByName("unknown1", 5);
  9546. packet2->setDataByName("level", 3);
  9547. packet2->setDataByName("coin", 150);
  9548. packet2->setDataByName("status_points", 5);
  9549. packet2->setDataByName("exp_bonus", 10);
  9550. packet2->setArrayLengthByName("num_rewards", 1);
  9551. Item* item = new Item(master_item_list.GetItem(36212));
  9552. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9553. item->stack_count = 20;
  9554. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9555. safe_delete(item);
  9556. char accept[35] = { 0 };
  9557. char decline[35] = { 0 };
  9558. sprintf(accept, "q_accept_pending_quest %u", 0);
  9559. sprintf(decline, "q_deny_pending_quest %u", 0);
  9560. packet2->setDataByName("accept_command", accept);
  9561. packet2->setDataByName("decline_command", decline);
  9562. EQ2Packet* app = packet2->serialize();
  9563. if (sep->IsSet(2)) {
  9564. int16 offset = atoi(sep->arg[1]);
  9565. uchar* ptr2 = app->pBuffer;
  9566. ptr2 += offset;
  9567. if (sep->IsNumber(2)) {
  9568. int32 value1 = atol(sep->arg[2]);
  9569. if (value1 > 0xFFFF)
  9570. memcpy(ptr2, (uchar*)&value1, 4);
  9571. else if (value1 > 0xFF)
  9572. memcpy(ptr2, (uchar*)&value1, 2);
  9573. else
  9574. memcpy(ptr2, (uchar*)&value1, 1);
  9575. }
  9576. else {
  9577. int8 len = strlen(sep->arg[2]);
  9578. memcpy(ptr2, (uchar*)&len, 1);
  9579. ptr2 += 1;
  9580. memcpy(ptr2, sep->arg[2], len);
  9581. }
  9582. }
  9583. DumpPacket(app);
  9584. client->QueuePacket(app);
  9585. safe_delete(packet2);
  9586. }
  9587. }
  9588. else if (atoi(sep->arg[0]) == 23) {
  9589. if (client->GetPlayer()->GetTarget()) {
  9590. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9591. if (packet2) {
  9592. Spawn* target = client->GetPlayer()->GetTarget();
  9593. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9594. Item* item = new Item(master_item_list.GetItem(12565));
  9595. int8 i = 0;
  9596. packet2->setArrayLengthByName("num_items", 1);
  9597. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9598. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9599. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9600. packet2->setArrayDataByName("icon", item->details.icon, i);
  9601. int8 tmp_level = 0;
  9602. if (item->generic_info.adventure_default_level > 0)
  9603. tmp_level = item->generic_info.adventure_default_level;
  9604. else
  9605. tmp_level = item->generic_info.tradeskill_default_level;
  9606. packet2->setArrayDataByName("level", tmp_level, i);
  9607. packet2->setArrayDataByName("tier", item->details.tier, i);
  9608. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9609. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9610. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9611. item_difficulty = ARROW_COLOR_WHITE;
  9612. item_difficulty -= 6;
  9613. if (item_difficulty < 0)
  9614. item_difficulty *= -1;
  9615. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9616. packet2->setArrayDataByName("quantity", 2, i);
  9617. packet2->setArrayDataByName("unknown5", 255, i);
  9618. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9619. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9620. packet2->setDataByName("type", 2);
  9621. EQ2Packet* app = packet2->serialize();
  9622. if (sep->IsSet(2)) {
  9623. int16 offset = atoi(sep->arg[1]);
  9624. uchar* ptr2 = app->pBuffer;
  9625. ptr2 += offset;
  9626. if (sep->IsNumber(2)) {
  9627. int32 value1 = atol(sep->arg[2]);
  9628. if (value1 > 0xFFFF)
  9629. memcpy(ptr2, (uchar*)&value1, 4);
  9630. else if (value1 > 0xFF)
  9631. memcpy(ptr2, (uchar*)&value1, 2);
  9632. else
  9633. memcpy(ptr2, (uchar*)&value1, 1);
  9634. }
  9635. else {
  9636. int8 len = strlen(sep->arg[2]);
  9637. memcpy(ptr2, (uchar*)&len, 1);
  9638. ptr2 += 1;
  9639. memcpy(ptr2, sep->arg[2], len);
  9640. }
  9641. }
  9642. DumpPacket(app);
  9643. client->QueuePacket(app);
  9644. safe_delete(packet2);
  9645. }
  9646. }
  9647. }
  9648. else if (atoi(sep->arg[0]) == 24) {
  9649. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  9650. if (packet2) {
  9651. if (sep->IsSet(2)) {
  9652. packet2->setDataByName("event_name", sep->arg[1]);
  9653. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  9654. EQ2Packet* app = packet2->serialize();
  9655. DumpPacket(app);
  9656. client->QueuePacket(app);
  9657. safe_delete(packet2);
  9658. }
  9659. }
  9660. }
  9661. else if (atoi(sep->arg[0]) == 25) {
  9662. if (sep->IsSet(1)) {
  9663. Widget* new_spawn = new Widget();
  9664. int32 id = atoul(sep->arg[1]);
  9665. new_spawn->SetWidgetID(id);
  9666. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9667. client->QueuePacket(ret);
  9668. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  9669. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  9670. if (packet2) {
  9671. packet2->setDataByName("spawn_index", index);
  9672. packet2->setDataByName("delete", 1);
  9673. EQ2Packet* app = packet2->serialize();
  9674. client->QueuePacket(app);
  9675. safe_delete(packet2);
  9676. }
  9677. }
  9678. }
  9679. else if (atoi(sep->arg[0]) == 26) {
  9680. if (sep->IsSet(4)) {
  9681. Widget* new_spawn = new Widget();
  9682. int32 id = atoul(sep->arg[1]);
  9683. new_spawn->SetWidgetID(id);
  9684. float x = atof(sep->arg[2]);
  9685. float y = atof(sep->arg[3]);
  9686. float z = atof(sep->arg[4]);
  9687. new_spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9688. new_spawn->SetWidgetX(x);
  9689. new_spawn->SetWidgetY(y);
  9690. new_spawn->SetWidgetZ(z);
  9691. new_spawn->SetX(x);
  9692. new_spawn->SetY(y);
  9693. new_spawn->SetZ(z);
  9694. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9695. client->QueuePacket(ret);
  9696. }
  9697. }
  9698. else if (atoi(sep->arg[0]) == 27) {
  9699. Spawn* target = client->GetPlayer()->GetTarget();
  9700. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  9701. if (packet2 && target && sep->IsSet(2)) {
  9702. packet2->setSubstructDataByName("header", "defender", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9703. packet2->setSubstructDataByName("header", "defender_proxy", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9704. packet2->setSubstructDataByName("header", "attacker", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  9705. packet2->setArrayLengthByName("num_dmg", 1);
  9706. packet2->setArrayDataByName("damage_type", atoi(sep->arg[1]));
  9707. packet2->setArrayDataByName("damage", atoi(sep->arg[2]));
  9708. packet2->setDataByName("spell", 1);
  9709. packet2->setDataByName("spell_name", "Testing");
  9710. EQ2Packet* app = packet2->serialize();
  9711. if (sep->IsSet(4)) {
  9712. int16 offset = atoi(sep->arg[3]);
  9713. uchar* ptr2 = app->pBuffer;
  9714. ptr2 += offset;
  9715. if (sep->IsNumber(4)) {
  9716. int32 value1 = atol(sep->arg[4]);
  9717. if (value1 > 0xFFFF)
  9718. memcpy(ptr2, (uchar*)&value1, 4);
  9719. else if (value1 > 0xFF)
  9720. memcpy(ptr2, (uchar*)&value1, 2);
  9721. else
  9722. memcpy(ptr2, (uchar*)&value1, 1);
  9723. }
  9724. else {
  9725. int8 len = strlen(sep->arg[4]);
  9726. memcpy(ptr2, (uchar*)&len, 1);
  9727. ptr2 += 1;
  9728. memcpy(ptr2, sep->arg[4], len);
  9729. }
  9730. }
  9731. if (sep->IsSet(6)) {
  9732. int16 offset = atoi(sep->arg[5]);
  9733. uchar* ptr2 = app->pBuffer;
  9734. ptr2 += offset;
  9735. if (sep->IsNumber(6)) {
  9736. int32 value1 = atol(sep->arg[6]);
  9737. if (value1 > 0xFFFF)
  9738. memcpy(ptr2, (uchar*)&value1, 4);
  9739. else if (value1 > 0xFF)
  9740. memcpy(ptr2, (uchar*)&value1, 2);
  9741. else
  9742. memcpy(ptr2, (uchar*)&value1, 1);
  9743. }
  9744. else {
  9745. int8 len = strlen(sep->arg[6]);
  9746. memcpy(ptr2, (uchar*)&len, 1);
  9747. ptr2 += 1;
  9748. memcpy(ptr2, sep->arg[6], len);
  9749. }
  9750. }
  9751. DumpPacket(app);
  9752. client->QueuePacket(app);
  9753. safe_delete(packet2);
  9754. }
  9755. }
  9756. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  9757. World::newValue = strtoull(sep->arg[1], NULL, 0);
  9758. }
  9759. }
  9760. else {
  9761. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  9762. if (packet2) {
  9763. packet2->setSubstructDataByName("info_header", "show_name", 1);
  9764. packet2->setSubstructDataByName("info_header", "unknown", 7);
  9765. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  9766. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  9767. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  9768. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  9769. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  9770. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  9771. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  9772. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  9773. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  9774. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  9775. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  9776. packet2->setSubstructDataByName("info_header", "packettype", 3);
  9777. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  9778. packet2->setSubstructDataByName("spell_info", "level", 19);
  9779. packet2->setSubstructDataByName("spell_info", "tier", 1);
  9780. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  9781. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  9782. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  9783. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  9784. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  9785. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  9786. packet2->setSubstructDataByName("spell_info", "recast", 280);
  9787. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  9788. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  9789. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  9790. packet2->setSubstructDataByName("spell_info", "quality", 3);
  9791. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  9792. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  9793. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  9794. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  9795. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  9796. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  9797. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  9798. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  9799. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  9800. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  9801. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  9802. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  9803. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  9804. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  9805. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  9806. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  9807. packet2->setArrayDataByName("reagent", "Alcohol");
  9808. packet2->setArrayDataByName("consumed", "123");
  9809. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  9810. packet2->setSubstructDataByName("spell_info", "id", 8308);
  9811. packet2->setSubstructDataByName("spell_info", "icon", 303);
  9812. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  9813. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  9814. packet2->setSubstructDataByName("spell_info", "type", 2);
  9815. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  9816. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  9817. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  9818. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  9819. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  9820. EQ2Packet* outapp = packet2->serialize();
  9821. DumpPacket(outapp);
  9822. client->QueuePacket(outapp);
  9823. safe_delete(packet2);
  9824. }
  9825. }
  9826. return;
  9827. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  9828. if (!p) return;
  9829. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9830. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  9831. //}
  9832. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9833. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  9834. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  9835. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  9836. if (packet) {
  9837. client->QueuePacket(packet->serialize());
  9838. safe_delete(packet);
  9839. }
  9840. }*/
  9841. /*if (client->GetCurrentZone()->Grid != nullptr) {
  9842. int32 numFaces = 0;
  9843. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  9844. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  9845. map<int32, vector<Face*> >::iterator itr;
  9846. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  9847. numFaces += (*itr).second.size();
  9848. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  9849. }*/
  9850. //uchar blah[] = {
  9851. // 1208 - OP_EQUpdateStoreCmd
  9852. // /*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
  9853. // /*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
  9854. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  9855. // /*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
  9856. /*};
  9857. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9858. int8 val = 0;
  9859. int16 pos = 0;
  9860. int idx = 0;
  9861. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  9862. pos = atoi(sep2->arg[idx]);
  9863. val = atoi(sep2->arg[idx+1]);
  9864. memset(blah+pos, val, 1);
  9865. idx+=2;
  9866. }
  9867. DumpPacket(blah, sizeof(blah));
  9868. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  9869. if (client->GetPlayer()->GetTarget()) {
  9870. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  9871. if (packet) {
  9872. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  9873. packet->setDataByName("size", 0);
  9874. packet->setDataByName("unknown2", 0);
  9875. EQ2Packet* app = packet->serialize();
  9876. client->QueuePacket(app);
  9877. safe_delete(packet);
  9878. }
  9879. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  9880. if (set_pov) {
  9881. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  9882. EQ2Packet* app_pov = set_pov->serialize();
  9883. client->QueuePacket(app_pov);
  9884. safe_delete(set_pov);
  9885. }
  9886. }
  9887. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9888. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  9889. if (packet) {
  9890. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  9891. packet->setDataByName("Type", atoi(sep2->arg[0]));
  9892. else
  9893. packet->setDataByName("Type", 2);
  9894. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  9895. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  9896. else
  9897. packet->setDataByName("race_id", 0);
  9898. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  9899. packet->setDataByName("gender", atoi(sep2->arg[2]));
  9900. else
  9901. packet->setDataByName("gender", 2);
  9902. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  9903. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  9904. else
  9905. packet->setDataByName("unknown", 0, 0);
  9906. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  9907. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  9908. else
  9909. packet->setDataByName("unknown", 0, 1);
  9910. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  9911. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  9912. else
  9913. packet->setDataByName("unknown", 0, 2);
  9914. client->QueuePacket(packet->serialize());
  9915. }
  9916. safe_delete(packet);
  9917. safe_delete(sep2);
  9918. }
  9919. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  9920. const char *channel_name;
  9921. if (sep == NULL || !sep->IsSet(0)) {
  9922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  9923. PrintSep(sep);
  9924. return;
  9925. }
  9926. channel_name = sep->arg[0];
  9927. if (!chat.IsInChannel(client, channel_name))
  9928. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  9929. else if (!chat.LeaveChannel(client, channel_name))
  9930. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  9931. }
  9932. /*
  9933. Function:
  9934. Purpose :
  9935. Params :
  9936. Dev :
  9937. Example :
  9938. */
  9939. void Commands::Command_WeaponStats(Client* client)
  9940. {
  9941. Player* player = client->GetPlayer();
  9942. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  9943. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  9944. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  9945. client->SimpleMessage(0, "Primary:");
  9946. if (primary) {
  9947. client->Message(0, "Name: %s", primary->name.c_str());
  9948. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  9949. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  9950. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  9951. client->Message(0, "Proc Percent: %d%%", 0);
  9952. client->Message(0, "Procs Per Minute: %d", 0);
  9953. }
  9954. else {
  9955. client->SimpleMessage(0, "Name: fist");
  9956. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  9957. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  9958. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  9959. client->Message(0, "Proc Percent: %d%%", 0);
  9960. client->Message(0, "Procs Per Minute: %d", 0);
  9961. }
  9962. client->SimpleMessage(0, " ");
  9963. client->SimpleMessage(0, " ");
  9964. if (secondary) {
  9965. client->SimpleMessage(0, "Secondary:");
  9966. client->Message(0, "Name: %s", secondary->name.c_str());
  9967. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  9968. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  9969. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  9970. client->Message(0, "Proc Percent: %d%%", 0);
  9971. client->Message(0, "Procs Per Minute: %d", 0);
  9972. client->SimpleMessage(0, " ");
  9973. client->SimpleMessage(0, " ");
  9974. }
  9975. client->SimpleMessage(0, "Ranged:");
  9976. if (ranged) {
  9977. client->Message(0, "Name: %s", ranged->name.c_str());
  9978. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  9979. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  9980. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  9981. client->Message(0, "Proc Percent: %d%%", 0);
  9982. client->Message(0, "Procs Per Minute: %d", 0);
  9983. }
  9984. else
  9985. client->SimpleMessage(0, "None");
  9986. }
  9987. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  9988. const char *channel_name;
  9989. if (sep == NULL || !sep->IsSet(0)) {
  9990. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  9991. return;
  9992. }
  9993. channel_name = sep->arg[0];
  9994. if (!chat.ChannelExists(channel_name))
  9995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  9996. else
  9997. chat.SendChannelUserList(client, channel_name);
  9998. }
  9999. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  10000. {
  10001. ZoneServer* zone = 0;
  10002. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  10003. if (zone_id > 0)
  10004. {
  10005. zone = zone_list.Get(zone_id, false);
  10006. if (zone)
  10007. {
  10008. zone->SetSafeX(client->GetPlayer()->GetX());
  10009. zone->SetSafeY(client->GetPlayer()->GetY());
  10010. zone->SetSafeZ(client->GetPlayer()->GetZ());
  10011. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  10012. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  10013. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  10014. else
  10015. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  10016. }
  10017. }
  10018. }
  10019. /*
  10020. Function:
  10021. Purpose :
  10022. Params :
  10023. Dev :
  10024. Example :
  10025. */
  10026. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  10027. {
  10028. ZoneInfo* zone_info = new ZoneInfo;
  10029. if (sep && sep->arg[0])
  10030. {
  10031. if (sep->IsNumber(0))
  10032. zone_info->id = atoi(sep->arg[0]);
  10033. else
  10034. zone_info->id = database.GetZoneID(sep->arg[0]);
  10035. if (zone_info->id > 0)
  10036. {
  10037. database.LoadZoneInfo(zone_info);
  10038. 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);
  10039. 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);
  10040. 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);
  10041. 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);
  10042. 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);
  10043. 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);
  10044. 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);
  10045. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  10046. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  10047. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  10048. }
  10049. else
  10050. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10051. }
  10052. else
  10053. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  10054. safe_delete(zone_info);
  10055. }
  10056. /*
  10057. Function:
  10058. Purpose :
  10059. Params :
  10060. Dev :
  10061. Example :
  10062. */
  10063. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  10064. {
  10065. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  10066. {
  10067. ZoneServer* zone = 0;
  10068. int32 zone_id = 0;
  10069. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  10070. {
  10071. zone_id = atoi(sep->arg[0]);
  10072. zone = zone_list.Get(atoi(sep->arg[0]), false);
  10073. }
  10074. else
  10075. {
  10076. zone_id = database.GetZoneID(sep->arg[0]);
  10077. if (zone_id > 0)
  10078. zone = zone_list.Get(sep->arg[0], false);
  10079. }
  10080. if (zone_id > 0)
  10081. {
  10082. if (zone_set_values.count(string(sep->arg[1])) > 0)
  10083. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  10084. else
  10085. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  10086. }
  10087. else
  10088. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10089. }
  10090. else
  10091. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  10092. }
  10093. void Commands::Command_Rain(Client* client, Seperator* sep) {
  10094. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10095. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  10096. return;
  10097. }
  10098. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  10099. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  10100. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  10101. }
  10102. void Commands::Command_Wind(Client* client, Seperator* sep) {
  10103. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10104. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  10105. return;
  10106. }
  10107. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  10108. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  10109. }
  10110. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  10111. Spawn* spawn = client->GetPlayer()->GetTarget();
  10112. if(spawn) {
  10113. client->SetMerchantTransaction(spawn);
  10114. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  10115. client->SendHailCommand(spawn);
  10116. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  10117. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  10118. client->SendBuyMerchantList(sell);
  10119. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  10120. client->SendSellMerchantList(sell);
  10121. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  10122. client->SendBuyBackList(sell);
  10123. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10124. if (packet) {
  10125. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  10126. packet->setDataByName("type", 16);
  10127. EQ2Packet* outapp = packet->serialize();
  10128. if (outapp)
  10129. client->QueuePacket(outapp);
  10130. safe_delete(packet);
  10131. }
  10132. }
  10133. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  10134. client->SendRepairList();
  10135. }
  10136. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  10137. }
  10138. void Commands::Command_Weather(Client* client, Seperator* sep)
  10139. {
  10140. //PrintSep(sep, "Weather");
  10141. if( sep && sep->arg[0] )
  10142. {
  10143. ZoneServer* zsZone = client->GetCurrentZone();
  10144. const char* value = sep->arg[0];
  10145. // process single-param commands first
  10146. if( strncasecmp(value, "details", strlen(value)) == 0 )
  10147. {
  10148. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  10149. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  10150. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  10151. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  10152. }
  10153. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  10154. {
  10155. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10156. zsZone->ProcessWeather();
  10157. }
  10158. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  10159. {
  10160. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  10161. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  10162. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  10163. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  10164. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  10165. zsZone->SetWeatherPattern(1);
  10166. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  10167. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  10168. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  10169. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10170. zsZone->ProcessWeather();
  10171. }
  10172. // process commands with params
  10173. if( sep->arg[1] )
  10174. {
  10175. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  10176. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  10177. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  10178. zsZone->SetWeatherType(atoi(sep->arg[1]));
  10179. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  10180. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  10181. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  10182. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  10183. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  10184. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  10185. }
  10186. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  10187. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  10188. zsZone->SetRain(zsZone->GetCurrentWeather());
  10189. }
  10190. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  10191. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  10192. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  10193. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  10194. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10195. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  10196. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10197. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  10198. }
  10199. }
  10200. else
  10201. {
  10202. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  10203. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  10204. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  10205. return;
  10206. }
  10207. }
  10208. void Commands::Command_Select(Client* client, Seperator* sep) {
  10209. if (sep && sep->arg[1]) {
  10210. Spawn* spawn = client->GetPlayer()->GetTarget();
  10211. if (spawn && strlen(sep->arg[1]) > 0)
  10212. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  10213. }
  10214. }
  10215. /*
  10216. Function: Command_ConsumeFood()
  10217. Purpose : Consume Food/Drink and apply mods
  10218. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  10219. Dev : Zcoretri
  10220. Example : /consume_food 22
  10221. */
  10222. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  10223. if (sep && sep->arg[0] && sep->IsNumber(0))
  10224. {
  10225. Player* player = client->GetPlayer();
  10226. int8 slot = atoi(sep->arg[0]);
  10227. Item* item = player->GetEquipmentList()->GetItem(slot);
  10228. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  10229. {
  10230. client->Message(CHANNEL_NARRATIVE, "If you ate anymore you would explode!");
  10231. return;
  10232. }
  10233. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  10234. {
  10235. client->Message(CHANNEL_NARRATIVE, "If you drank anymore you would explode!");
  10236. return;
  10237. }
  10238. client->ConsumeFoodDrink(item, slot);
  10239. }
  10240. }
  10241. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  10242. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10243. if (atoi(sep->arg[0]) == 1) {
  10244. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  10245. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  10246. client->GetPlayer()->SetCharSheetChanged(true);
  10247. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  10248. }
  10249. else {
  10250. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  10251. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  10252. client->GetPlayer()->SetCharSheetChanged(true);
  10253. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  10254. }
  10255. }
  10256. else
  10257. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  10258. }
  10259. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  10260. {
  10261. if(sep)
  10262. {
  10263. string data;
  10264. if(sep->arg[0]){
  10265. data = string(sep->arg[0]);
  10266. }
  10267. for(int i=1;i<sep->GetMaxArgNum();i++){
  10268. if(sep->arg[i])
  10269. data.append(" ").append(sep->arg[i]);
  10270. }
  10271. const char* target_name = 0;
  10272. int32 spawn_id = 0;
  10273. if(client->GetPlayer()->GetTarget())
  10274. {
  10275. target_name = client->GetPlayer()->GetTarget()->GetName();
  10276. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10277. }
  10278. else
  10279. target_name = "N/A";
  10280. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  10281. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  10282. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  10283. else
  10284. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  10285. }
  10286. }
  10287. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  10288. PrintSep(sep, "Command_Attune_Inv");
  10289. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10290. // Get the item index from the first parameter
  10291. int16 index = atoi(sep->arg[0]);
  10292. // Check to see if this is a valid item index for the player, if not exit out of the function
  10293. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  10294. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  10295. return;
  10296. }
  10297. // Get the item
  10298. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  10299. if(item) {
  10300. // Valid item lets check to make sure this item is attunable, if not return out
  10301. if (!item->CheckFlag(ATTUNEABLE)) {
  10302. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  10303. return;
  10304. }
  10305. // Remove the attunable flag
  10306. item->generic_info.item_flags -= ATTUNEABLE;
  10307. // Set the attuned flag
  10308. item->generic_info.item_flags += ATTUNED;
  10309. // Flag this item for saving
  10310. item->save_needed = true;
  10311. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  10312. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  10313. EQ2Packet* outapp = 0;
  10314. for (int32 i=0;i<packets.size();i++) {
  10315. outapp = packets[i];
  10316. if(outapp)
  10317. client->QueuePacket(outapp);
  10318. }
  10319. }
  10320. }
  10321. }
  10322. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  10323. PrintSep(sep, "Command_Reset_Zone_Timer");
  10324. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10325. int32 db_id = atoul(sep->arg[0]);
  10326. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  10327. if (data) {
  10328. // TODO: add a check to timers to ensure it can be reset
  10329. // Delete the character from the instance
  10330. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  10331. data->instance_id = 0;
  10332. // Update the success time and set to 0 so the player can enter it again
  10333. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  10334. data->last_success_timestamp = 0;
  10335. }
  10336. }*/
  10337. }
  10338. void Commands::Command_Player(Client* client, Seperator* sep) {
  10339. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  10340. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  10341. }
  10342. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  10343. // /player coins add 10
  10344. // /player coins add plat 10
  10345. Player* player = client->GetPlayer();
  10346. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  10347. player = (Player*)player->GetTarget();
  10348. if (sep && sep->arg[0] && sep->arg[1]) {
  10349. const char* action = sep->arg[0];
  10350. int64 value = 0;
  10351. if (strncasecmp(action, "add", strlen(action)) == 0) {
  10352. if (sep->IsNumber(1)) {
  10353. value = atoi64(sep->arg[1]);
  10354. player->AddCoins(value);
  10355. if (client->GetPlayer() == player)
  10356. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10357. else {
  10358. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10359. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10360. }
  10361. return;
  10362. }
  10363. else if (sep->arg[2] && sep->IsNumber(2)) {
  10364. const char* type = sep->arg[1];
  10365. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  10366. value = atoi64(sep->arg[2]);
  10367. }
  10368. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  10369. value = atoi64(sep->arg[2]) * 100;
  10370. }
  10371. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  10372. value = atoi64(sep->arg[2]) * 10000;
  10373. }
  10374. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  10375. value = atoi64(sep->arg[2]) * 1000000;
  10376. }
  10377. player->AddCoins(value);
  10378. if (client->GetPlayer() == player)
  10379. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10380. else {
  10381. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10382. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10383. }
  10384. return;
  10385. }
  10386. }
  10387. }
  10388. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  10389. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  10390. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  10391. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  10392. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  10393. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  10394. }
  10395. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  10396. PrintSep(sep, "ACHIEVEMENT_ADD");
  10397. if (sep && sep->IsSet(0)) {
  10398. int32 spell_id = atoul(sep->arg[1]);
  10399. int8 spell_tier = 0;
  10400. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10401. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10402. // addspellbookentry here
  10403. if (spell_tier >= data->maxRank) {
  10404. return;
  10405. }
  10406. if (!spell_tier) {
  10407. spell_tier = 1;
  10408. }
  10409. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10410. {
  10411. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10412. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10413. client->GetPlayer()->UnlockSpell(spell);
  10414. client->SendSpellUpdate(spell);
  10415. }
  10416. else
  10417. {
  10418. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  10419. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10420. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10421. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10422. client->GetPlayer()->UnlockSpell(spell);
  10423. client->SendSpellUpdate(spell);
  10424. }
  10425. // cast spell here
  10426. if (!spell_tier)
  10427. spell_tier = 1;
  10428. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10429. if (spell) {
  10430. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10431. }
  10432. }
  10433. else {
  10434. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10435. }
  10436. master_aa_list.DisplayAA(client, 0, 0);
  10437. }
  10438. void Commands::Command_Editor(Client* client, Seperator* sep) {
  10439. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  10440. if (packet) {
  10441. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  10442. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  10443. char command[255];
  10444. url = "browser " + url;
  10445. int32 spawn_id = 0;
  10446. int32 zone_id = 0;
  10447. string type;
  10448. if (client->GetCurrentZone())
  10449. zone_id = client->GetCurrentZone()->GetZoneID();
  10450. if (client->GetPlayer()->GetTarget()) {
  10451. Spawn* target = client->GetPlayer()->GetTarget();
  10452. if (target->IsWidget())
  10453. type = "widgets";
  10454. else if (target->IsSign())
  10455. type = "signs";
  10456. else if (target->IsObject())
  10457. type = "objects";
  10458. else if (target->IsNPC())
  10459. type = "npcs";
  10460. else if (target->IsGroundSpawn())
  10461. type = "ground";
  10462. else
  10463. type = "spawn";
  10464. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10465. }
  10466. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  10467. packet->setDataByName("accept_command", command);
  10468. }
  10469. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  10470. char command[255];
  10471. url = "browser " + url;
  10472. if (client->GetPlayer()->GetTarget())
  10473. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  10474. packet->setDataByName("accept_command", command);
  10475. }
  10476. else {
  10477. string command = "browser " + url;
  10478. packet->setDataByName("accept_command", command.c_str());
  10479. }
  10480. packet->setDataByName("text", "Open the web editor?");
  10481. packet->setDataByName("accept_text", "Open");
  10482. packet->setDataByName("cancel_text", "Cancel");
  10483. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  10484. packet->setDataByName("unknown2", 50);
  10485. packet->setDataByName("unknown4", 1);
  10486. client->QueuePacket(packet->serialize());
  10487. safe_delete(packet);
  10488. }
  10489. }
  10490. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  10491. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10492. return;
  10493. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10494. if(client->GetCurrentRez()->active)
  10495. client->AcceptResurrection();
  10496. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10497. }
  10498. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  10499. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10500. return;
  10501. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10502. if(client->GetCurrentRez()->active)
  10503. client->GetCurrentRez()->should_delete = true;
  10504. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10505. }
  10506. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  10507. PrintSep(sep, "Switch_AA_Profile");
  10508. if (sep && sep->IsSet(0)) {
  10509. string type = sep->arg[0];
  10510. int8 newtemplate = atoul(sep->arg[1]);
  10511. master_aa_list.DisplayAA(client, newtemplate, 1);
  10512. }
  10513. }
  10514. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  10515. PrintSep(sep, "Get_AA_Xml");
  10516. if (sep && sep->IsSet(0)) {
  10517. string tabnum = sep->arg[0];
  10518. string spellid = sep->arg[1];
  10519. }
  10520. }
  10521. void Commands::Add_AA(Client* client, Seperator* sep) {
  10522. PrintSep(sep, "Add_AA");
  10523. if (sep && sep->IsSet(0)) {
  10524. int32 spell_id = atoul(sep->arg[1]);
  10525. int8 spell_tier = 0;
  10526. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10527. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10528. // addspellbookentry here
  10529. if(!data) {
  10530. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  10531. return;
  10532. }
  10533. if (spell_tier >= data->maxRank) {
  10534. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  10535. return;
  10536. }
  10537. if (!spell_tier) {
  10538. spell_tier = 1;
  10539. }
  10540. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10541. {
  10542. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10543. if(spell)
  10544. {
  10545. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10546. client->GetPlayer()->UnlockSpell(spell);
  10547. client->SendSpellUpdate(spell);
  10548. }
  10549. }
  10550. else
  10551. {
  10552. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10553. if(spell)
  10554. {
  10555. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10556. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10557. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10558. client->GetPlayer()->UnlockSpell(spell);
  10559. client->SendSpellUpdate(spell);
  10560. }
  10561. }
  10562. // cast spell here
  10563. if (!spell_tier)
  10564. spell_tier = 1;
  10565. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10566. if (spell) {
  10567. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10568. }
  10569. }
  10570. else {
  10571. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10572. }
  10573. master_aa_list.DisplayAA(client, 0, 0);
  10574. }
  10575. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  10576. PrintSep(sep, "Commit_AA_Profile");
  10577. if (sep && sep->IsSet(0)) {
  10578. }
  10579. }
  10580. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  10581. PrintSep(sep, "Begin_AA_Profile");
  10582. if (sep && sep->IsSet(0)) {
  10583. master_aa_list.DisplayAA(client, 100, 2);
  10584. }
  10585. }
  10586. void Commands::Back_AA(Client* client, Seperator* sep) {
  10587. if (sep && sep->IsSet(0)) {
  10588. PrintSep(sep, "Back_AA");
  10589. }
  10590. }
  10591. void Commands::Remove_AA(Client* client, Seperator* sep) {
  10592. if (sep && sep->IsSet(0)) {
  10593. PrintSep(sep, "Remove_AA");
  10594. }
  10595. }
  10596. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  10597. MasterAAList master_aa_list;
  10598. PrintSep(sep, "Cancel_AA_Profile");
  10599. master_aa_list.DisplayAA(client, 0, 0);
  10600. }
  10601. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  10602. if (sep && sep->IsSet(0)) {
  10603. PrintSep(sep, "Save_AA_Profile");
  10604. }
  10605. }
  10606. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  10607. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  10608. if (!sep->IsNumber(0)) return;
  10609. int32 request_id = atoul(sep->arg[0]);
  10610. if (!sep->IsNumber(1)) return;
  10611. sint32 item_id = atoi(sep->arg[1]);
  10612. if (client->IsCurrentTransmuteID(request_id)) {
  10613. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  10614. }
  10615. else if (client->IsCurrentTransmuteID(item_id)) {
  10616. if (!sep->IsSet(2)) return;
  10617. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  10618. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  10619. }
  10620. }
  10621. }
  10622. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  10623. if(sep)
  10624. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  10625. }
  10626. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  10627. if(sep && sep->arg[0][0] && sep->arg[1][0])
  10628. {
  10629. char* name = sep->arg[0];
  10630. char* zoneName = sep->arg[1];
  10631. char query[256];
  10632. 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);
  10633. if (database.RunQuery(query, strnlen(query, 256)))
  10634. {
  10635. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  10636. }
  10637. else
  10638. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  10639. }
  10640. }