Commands.cpp 389 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include "Commands.h"
  18. #include "../ClientPacketFunctions.h"
  19. #include "../../common/version.h"
  20. #include "../../common/seperator.h"
  21. #include "../../common/servertalk.h"
  22. #include "../WorldDatabase.h"
  23. #include "../World.h"
  24. #include "../../common/ConfigReader.h"
  25. #include "../VisualStates.h"
  26. #include "../../common/debug.h"
  27. #include "../LuaInterface.h"
  28. #include "../Quests.h"
  29. #include "../client.h"
  30. #include "../NPC.h"
  31. #include "../Guilds/Guild.h"
  32. #include "../SpellProcess.h"
  33. #include "../Tradeskills/Tradeskills.h"
  34. #include "../../common/Log.h"
  35. #include "../../common/MiscFunctions.h"
  36. #include "../Languages.h"
  37. #include "../IRC/IRC.h"
  38. #include "../Traits/Traits.h"
  39. #include "../Chat/Chat.h"
  40. #include "../Rules/Rules.h"
  41. #include "../AltAdvancement/AltAdvancement.h"
  42. #include "../RaceTypes/RaceTypes.h"
  43. #include "../classes.h"
  44. #include "../Transmute.h"
  45. #include "../Zone/SPGrid.h"
  46. extern WorldDatabase database;
  47. extern MasterSpellList master_spell_list;
  48. extern MasterTraitList master_trait_list;
  49. extern MasterRecipeList master_recipe_list;
  50. extern MasterRecipeBookList master_recipebook_list;
  51. extern World world;
  52. extern ClientList client_list;
  53. extern ConfigReader configReader;
  54. extern VisualStates visual_states;
  55. extern ZoneList zone_list;
  56. extern LuaInterface* lua_interface;
  57. extern MasterQuestList master_quest_list;
  58. extern MasterCollectionList master_collection_list;
  59. extern MasterSkillList master_skill_list;
  60. extern MasterFactionList master_faction_list;
  61. extern GuildList guild_list;
  62. extern MasterLanguagesList master_languages_list;
  63. extern IRC irc;
  64. extern Chat chat;
  65. extern RuleManager rule_manager;
  66. extern MasterAAList master_aa_list;
  67. extern MasterRaceTypeList race_types_list;
  68. extern Classes classes;
  69. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  70. #if defined(__GNUC__)
  71. #define stricmp strcasecmp
  72. #define strnicmp strncasecmp
  73. #endif
  74. EQ2Packet* RemoteCommands::serialize(){
  75. buffer.clear();
  76. vector<EQ2_RemoteCommandString>::iterator command_list;
  77. buffer.append((char*)&num_commands, sizeof(int16));
  78. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  79. AddDataCommand(&(*command_list));
  80. }
  81. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  82. return app;
  83. }
  84. Commands::Commands(){
  85. remote_commands = new RemoteCommands();
  86. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  87. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  88. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  89. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  90. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  91. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  92. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  93. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  94. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  95. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  96. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  97. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  98. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  99. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  100. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  101. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  102. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  103. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  104. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  105. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  106. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  107. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  108. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  109. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  110. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  111. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  112. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  113. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  114. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  115. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  116. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  117. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  118. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  119. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  120. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  121. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  122. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  123. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  124. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  125. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  126. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  127. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  128. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  129. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  130. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  131. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  132. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  133. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  134. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  135. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  136. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  137. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  138. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  139. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  140. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  141. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  142. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  143. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  144. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  145. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  146. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  147. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  148. spawn_set_values["skin_color"] = SPAWN_SET_SKIN_COLOR;
  149. spawn_set_values["aaxp_rewards"] = SPAWN_SET_AAXP_REWARDS;
  150. spawn_set_values["hair_color1"] = SPAWN_SET_HAIR_COLOR1;
  151. spawn_set_values["hair_color2"] = SPAWN_SET_HAIR_COLOR2;
  152. spawn_set_values["hair_type_color"] = SPAWN_SET_HAIR_TYPE_COLOR;
  153. spawn_set_values["hair_face_color"] = SPAWN_SET_HAIR_FACE_COLOR;
  154. spawn_set_values["hair_type_highlight_color"] = SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR;
  155. spawn_set_values["face_hairlight_color"] = SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR;
  156. spawn_set_values["hair_highlight"] = SPAWN_SET_HAIR_HIGHLIGHT;
  157. spawn_set_values["model_color"] = SPAWN_SET_MODEL_COLOR;
  158. spawn_set_values["eye_color"] = SPAWN_SET_EYE_COLOR;
  159. spawn_set_values["soga_skin_color"] = SPAWN_SET_SOGA_SKIN_COLOR;
  160. spawn_set_values["soga_hair_color1"] = SPAWN_SET_SOGA_HAIR_COLOR1;
  161. spawn_set_values["soga_hair_color2"] = SPAWN_SET_SOGA_HAIR_COLOR2;
  162. spawn_set_values["soga_hair_type_color"] = SPAWN_SET_SOGA_HAIR_TYPE_COLOR;
  163. spawn_set_values["soga_hair_face_color"] = SPAWN_SET_SOGA_HAIR_FACE_COLOR;
  164. spawn_set_values["soga_hair_type_highlight_color"] = SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR;
  165. spawn_set_values["soga_face_hairlight_color"] = SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR;
  166. spawn_set_values["soga_hair_highlight"] = SPAWN_SET_SOGA_HAIR_HIGHLIGHT;
  167. spawn_set_values["soga_model_color"] = SPAWN_SET_SOGA_MODEL_COLOR;
  168. spawn_set_values["soga_eye_color"] = SPAWN_SET_SOGA_EYE_COLOR;
  169. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  170. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  171. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  172. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  173. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  174. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  175. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  176. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  177. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  178. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  179. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  180. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  181. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  182. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  183. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  184. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  185. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  186. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  187. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  188. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  189. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  190. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  191. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  192. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  193. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  194. }
  195. Commands::~Commands() {
  196. safe_delete(remote_commands);
  197. }
  198. int32 Commands::GetSpawnSetType(string val){
  199. if(spawn_set_values.count(val) > 0)
  200. return spawn_set_values[val];
  201. return 0xFFFFFFFF;
  202. }
  203. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  204. if(!target)
  205. return false;
  206. int32 val = 0;
  207. try{
  208. if(type != SPAWN_SET_VALUE_NAME &&
  209. !(type >= SPAWN_SET_VALUE_SPAWN_SCRIPT && type <= SPAWN_SET_VALUE_SUB_TITLE) && !(type >= SPAWN_SET_VALUE_PREFIX && type <= SPAWN_SET_VALUE_EXPANSION_FLAG || type == SPAWN_SET_VALUE_HOLIDAY_FLAG))
  210. {
  211. switch(type)
  212. {
  213. case SPAWN_SET_SKIN_COLOR:
  214. case SPAWN_SET_HAIR_COLOR1:
  215. case SPAWN_SET_HAIR_COLOR2:
  216. case SPAWN_SET_HAIR_TYPE_COLOR:
  217. case SPAWN_SET_HAIR_FACE_COLOR:
  218. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  219. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  220. case SPAWN_SET_HAIR_HIGHLIGHT:
  221. case SPAWN_SET_EYE_COLOR:
  222. case SPAWN_SET_SOGA_SKIN_COLOR:
  223. case SPAWN_SET_SOGA_HAIR_COLOR1:
  224. case SPAWN_SET_SOGA_HAIR_COLOR2:
  225. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  226. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  227. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  228. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  229. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  230. case SPAWN_SET_SOGA_EYE_COLOR:
  231. // ignore these are colors can't pass as a integer value
  232. break;
  233. default:
  234. val = atoul(value);
  235. }
  236. }
  237. }
  238. catch(...){
  239. if(client)
  240. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  241. return false;
  242. }
  243. if(temporary){
  244. char tmp[128] = {0};
  245. switch(type){
  246. case SPAWN_SET_VALUE_NAME:{
  247. sprintf(tmp, "%s", target->GetName());
  248. target->SetName(value);
  249. if(target->GetZone())
  250. target->GetZone()->SendUpdateTitles(target);
  251. break;
  252. }
  253. case SPAWN_SET_VALUE_X_OFFSET:
  254. {
  255. sprintf(tmp, "%f", target->GetXOffset());
  256. target->SetXOffset(float(val));
  257. break;
  258. }
  259. case SPAWN_SET_VALUE_Y_OFFSET:
  260. {
  261. sprintf(tmp, "%f", target->GetYOffset());
  262. target->SetYOffset(float(val));
  263. break;
  264. }
  265. case SPAWN_SET_VALUE_Z_OFFSET:
  266. {
  267. sprintf(tmp, "%f", target->GetZOffset());
  268. target->SetZOffset(float(val));
  269. break;
  270. }
  271. case SPAWN_SET_VALUE_EXPIRE: {
  272. sprintf(tmp, "%u", target->GetExpireTime());
  273. target->SetExpireTime(val);
  274. break;
  275. }
  276. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  277. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  278. target->SetExpireOffsetTime(val);
  279. break;
  280. }
  281. case SPAWN_SET_VALUE_SUB_TITLE: {
  282. sprintf(tmp, "%s", target->GetSubTitle());
  283. target->SetSubTitle(value);
  284. if(target->GetZone())
  285. target->GetZone()->SendUpdateTitles(target);
  286. break;
  287. }
  288. case SPAWN_SET_VALUE_LEVEL:{
  289. sprintf(tmp, "%i", target->GetLevel());
  290. target->SetLevel(val, send_update);
  291. break;
  292. }
  293. case SPAWN_SET_VALUE_DIFFICULTY:{
  294. sprintf(tmp, "%i", target->GetEncounterLevel());
  295. target->SetEncounterLevel(val, send_update);
  296. break;
  297. }
  298. case SPAWN_SET_VALUE_MODEL_TYPE:{
  299. sprintf(tmp, "%i", target->GetModelType());
  300. target->SetModelType(val, send_update);
  301. break;
  302. }
  303. case SPAWN_SET_VALUE_CLASS:{
  304. sprintf(tmp, "%i", target->GetAdventureClass());
  305. target->SetAdventureClass(val, send_update);
  306. break;
  307. }
  308. case SPAWN_SET_VALUE_GENDER:{
  309. sprintf(tmp, "%i", target->GetGender());
  310. target->SetGender(val, send_update);
  311. break;
  312. }
  313. case SPAWN_SET_VALUE_SHOW_NAME:{
  314. sprintf(tmp, "%i", target->GetShowName());
  315. target->SetShowName(val, send_update);
  316. break;
  317. }
  318. case SPAWN_SET_VALUE_ATTACKABLE:{
  319. sprintf(tmp, "%i", target->GetAttackable());
  320. target->SetAttackable(val, send_update);
  321. break;
  322. }
  323. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  324. sprintf(tmp, "%i", target->GetShowLevel());
  325. target->SetShowLevel(val, send_update);
  326. break;
  327. }
  328. case SPAWN_SET_VALUE_TARGETABLE:{
  329. sprintf(tmp, "%i", target->GetTargetable());
  330. target->SetTargetable(val, send_update);
  331. break;
  332. }
  333. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  334. sprintf(tmp, "%i", target->GetShowCommandIcon());
  335. target->SetShowCommandIcon(val, send_update);
  336. break;
  337. }
  338. case SPAWN_SET_VALUE_HAND_ICON:{
  339. sprintf(tmp, "%i", target->GetShowHandIcon());
  340. target->SetShowHandIcon(val, send_update);
  341. break;
  342. }
  343. case SPAWN_SET_VALUE_HAIR_TYPE:{
  344. if(target->IsEntity()){
  345. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  346. ((Entity*)target)->SetHairType(val, send_update);
  347. }
  348. break;
  349. }
  350. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  351. if(target->IsEntity()){
  352. sprintf(tmp, "%i", ((Entity*)target)->GetFacialHairType());
  353. ((Entity*)target)->SetFacialHairType(val, send_update);
  354. }
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_WING_TYPE:{
  358. if(target->IsEntity()){
  359. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  360. ((Entity*)target)->SetWingType(val, send_update);
  361. }
  362. break;
  363. }
  364. case SPAWN_SET_VALUE_CHEST_TYPE:{
  365. if(target->IsEntity()){
  366. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  367. ((Entity*)target)->SetChestType(val, send_update);
  368. }
  369. break;
  370. }
  371. case SPAWN_SET_VALUE_LEGS_TYPE:{
  372. if(target->IsEntity()){
  373. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  374. ((Entity*)target)->SetLegsType(val, send_update);
  375. }
  376. break;
  377. }
  378. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  379. if(target->IsEntity()){
  380. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  381. ((Entity*)target)->SetSogaHairType(val, send_update);
  382. }
  383. break;
  384. }
  385. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  386. if(target->IsEntity()){
  387. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  388. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  389. }
  390. break;
  391. }
  392. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  393. sprintf(tmp, "%i", target->GetSogaModelType());
  394. target->SetSogaModelType(val, send_update);
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_SIZE:{
  398. sprintf(tmp, "%i", target->GetSize());
  399. target->SetSize(val, send_update);
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_HP:{
  403. sprintf(tmp, "%i", target->GetHP());
  404. target->SetHP(val, send_update);
  405. break;
  406. }
  407. case SPAWN_SET_VALUE_POWER:{
  408. sprintf(tmp, "%i", target->GetPower());
  409. target->SetPower(val, send_update);
  410. break;
  411. }
  412. case SPAWN_SET_VALUE_HEROIC:{
  413. sprintf(tmp, "%i", target->GetHeroic());
  414. target->SetHeroic(val, send_update);
  415. break;
  416. }
  417. case SPAWN_SET_VALUE_RESPAWN:{
  418. sprintf(tmp, "%u", target->GetRespawnTime());
  419. target->SetRespawnTime(val);
  420. break;
  421. }
  422. case SPAWN_SET_VALUE_X:{
  423. sprintf(tmp, "%f", target->GetX());
  424. target->SetX(atof(value), send_update);
  425. break;
  426. }
  427. case SPAWN_SET_VALUE_Y:{
  428. sprintf(tmp, "%f", target->GetY());
  429. target->SetY(atof(value), send_update);
  430. break;
  431. }
  432. case SPAWN_SET_VALUE_Z:{
  433. sprintf(tmp, "%f", target->GetZ());
  434. target->SetZ(atof(value), send_update);
  435. break;
  436. }
  437. case SPAWN_SET_VALUE_HEADING:{
  438. sprintf(tmp, "%f", target->GetHeading());
  439. target->SetHeading(atof(value) + 360, send_update);
  440. break;
  441. }
  442. case SPAWN_SET_VALUE_VISUAL_STATE:{
  443. sprintf(tmp, "%i", target->GetVisualState());
  444. target->SetVisualState(val, send_update);
  445. break;
  446. }
  447. case SPAWN_SET_VALUE_ACTION_STATE:{
  448. sprintf(tmp, "%i", target->GetActionState());
  449. target->SetActionState(val, send_update);
  450. break;
  451. }
  452. case SPAWN_SET_VALUE_MOOD_STATE:{
  453. sprintf(tmp, "%i", target->GetMoodState());
  454. target->SetMoodState(val, send_update);
  455. break;
  456. }
  457. case SPAWN_SET_VALUE_INITIAL_STATE:{
  458. sprintf(tmp, "%i", target->GetInitialState());
  459. target->SetInitialState(val, send_update);
  460. break;
  461. }
  462. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  463. sprintf(tmp, "%i", target->GetActivityStatus());
  464. target->SetActivityStatus(val, send_update);
  465. break;
  466. }
  467. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  468. sprintf(tmp, "%i", target->GetCollisionRadius());
  469. target->SetCollisionRadius(val, send_update);
  470. break;
  471. }
  472. case SPAWN_SET_VALUE_DEVICE_ID: {
  473. if (target->IsObject()) {
  474. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  475. ((Object*)target)->SetDeviceID(val);
  476. }
  477. break;
  478. }
  479. case SPAWN_SET_VALUE_PITCH: {
  480. sprintf(tmp, "%f", target->GetPitch());
  481. target->SetPitch(atof(value), send_update);
  482. break;
  483. }
  484. case SPAWN_SET_VALUE_ROLL: {
  485. sprintf(tmp, "%f", target->GetRoll());
  486. target->SetRoll(atof(value), send_update);
  487. break;
  488. }
  489. case SPAWN_SET_VALUE_HIDE_HOOD: {
  490. sprintf(tmp, "%i", target->appearance.hide_hood);
  491. target->SetHideHood(val);
  492. break;
  493. }
  494. case SPAWN_SET_VALUE_EMOTE_STATE: {
  495. sprintf(tmp, "%i", target->appearance.emote_state);
  496. target->SetEmoteState(val);
  497. break;
  498. }
  499. case SPAWN_SET_VALUE_ICON: {
  500. sprintf(tmp, "%i", target->GetIconValue());
  501. target->SetIcon(val);
  502. break;
  503. }
  504. case SPAWN_SET_VALUE_PREFIX: {
  505. sprintf(tmp, "%s", target->GetPrefixTitle());
  506. target->SetPrefixTitle(value);
  507. if(target->GetZone())
  508. target->GetZone()->SendUpdateTitles(target);
  509. break;
  510. }
  511. case SPAWN_SET_VALUE_SUFFIX: {
  512. sprintf(tmp, "%s", target->GetSuffixTitle());
  513. target->SetSuffixTitle(value);
  514. if(target->GetZone())
  515. target->GetZone()->SendUpdateTitles(target);
  516. break;
  517. }
  518. case SPAWN_SET_VALUE_LASTNAME: {
  519. sprintf(tmp, "%s", target->GetLastName());
  520. target->SetLastName(value);
  521. if(target->GetZone())
  522. target->GetZone()->SendUpdateTitles(target);
  523. break;
  524. }
  525. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  526. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  527. // nothing to do must reload spawns
  528. break;
  529. }
  530. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  531. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  532. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  533. break;
  534. }
  535. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  536. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  537. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  538. break;
  539. }
  540. case SPAWN_SET_VALUE_FACTION:{
  541. sprintf(tmp, "%i", target->faction_id);
  542. ZoneServer* zone = target->GetZone();
  543. if (!zone && client)
  544. zone = client->GetCurrentZone();
  545. target->faction_id = atoul(value);
  546. if(zone)
  547. {
  548. zone->RemoveDeadEnemyList(target);
  549. if(target->IsNPC())
  550. zone->AddEnemyList((NPC*)target);
  551. }
  552. break;
  553. }
  554. case SPAWN_SET_SKIN_COLOR:
  555. case SPAWN_SET_HAIR_COLOR1:
  556. case SPAWN_SET_HAIR_COLOR2:
  557. case SPAWN_SET_HAIR_TYPE_COLOR:
  558. case SPAWN_SET_HAIR_FACE_COLOR:
  559. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  560. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  561. case SPAWN_SET_HAIR_HIGHLIGHT:
  562. case SPAWN_SET_MODEL_COLOR:
  563. case SPAWN_SET_EYE_COLOR:
  564. case SPAWN_SET_SOGA_SKIN_COLOR:
  565. case SPAWN_SET_SOGA_HAIR_COLOR1:
  566. case SPAWN_SET_SOGA_HAIR_COLOR2:
  567. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  568. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  569. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  570. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  571. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  572. case SPAWN_SET_SOGA_MODEL_COLOR:
  573. case SPAWN_SET_SOGA_EYE_COLOR:
  574. {
  575. if (target->IsEntity())
  576. {
  577. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  578. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  579. {
  580. EQ2_Color clr;
  581. clr.red = atoul(skinsep->arg[0]);
  582. clr.green = atoul(skinsep->arg[1]);
  583. clr.blue = atoul(skinsep->arg[2]);
  584. switch(type)
  585. {
  586. case SPAWN_SET_SKIN_COLOR:
  587. ((Entity*)target)->SetSkinColor(clr);
  588. break;
  589. case SPAWN_SET_HAIR_COLOR1:
  590. ((Entity*)target)->SetHairColor1(clr);
  591. break;
  592. case SPAWN_SET_HAIR_COLOR2:
  593. ((Entity*)target)->SetHairColor2(clr);
  594. break;
  595. case SPAWN_SET_HAIR_TYPE_COLOR:
  596. ((Entity*)target)->SetHairColor(clr);
  597. break;
  598. case SPAWN_SET_HAIR_FACE_COLOR:
  599. ((Entity*)target)->SetFacialHairColor(clr);
  600. break;
  601. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  602. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  603. break;
  604. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  605. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  606. break;
  607. case SPAWN_SET_HAIR_HIGHLIGHT:
  608. ((Entity*)target)->SetHairHighlightColor(clr);
  609. break;
  610. case SPAWN_SET_MODEL_COLOR:
  611. ((Entity*)target)->SetModelColor(clr);
  612. break;
  613. case SPAWN_SET_EYE_COLOR:
  614. ((Entity*)target)->SetEyeColor(clr);
  615. break;
  616. case SPAWN_SET_SOGA_SKIN_COLOR:
  617. ((Entity*)target)->SetSogaSkinColor(clr);
  618. break;
  619. case SPAWN_SET_SOGA_HAIR_COLOR1:
  620. ((Entity*)target)->SetSogaHairColor1(clr);
  621. break;
  622. case SPAWN_SET_SOGA_HAIR_COLOR2:
  623. ((Entity*)target)->SetSogaHairColor2(clr);
  624. break;
  625. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  626. ((Entity*)target)->SetSogaHairColor(clr);
  627. break;
  628. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  629. ((Entity*)target)->SetSogaFacialHairColor(clr);
  630. break;
  631. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  632. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  633. break;
  634. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  635. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  636. break;
  637. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  638. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  639. break;
  640. case SPAWN_SET_SOGA_MODEL_COLOR:
  641. ((Entity*)target)->SetSogaModelColor(clr);
  642. break;
  643. case SPAWN_SET_SOGA_EYE_COLOR:
  644. ((Entity*)target)->SetSogaEyeColor(clr);
  645. break;
  646. }
  647. }
  648. safe_delete(skinsep);
  649. }
  650. break;
  651. }
  652. case SPAWN_SET_AAXP_REWARDS: {
  653. target->SetAAXPRewards(atoul(value));
  654. break;
  655. }
  656. if(temp_value)
  657. *temp_value = string(tmp);
  658. }
  659. }
  660. else{
  661. switch(type){
  662. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  663. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  664. break;
  665. }
  666. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  667. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  668. break;
  669. }
  670. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  671. if (target->GetDatabaseID() > 0)
  672. {
  673. char query[256];
  674. snprintf(query, 256, "update spawn set expansion_flag=%u where id=%i", atoul(value), target->GetDatabaseID());
  675. if (database.RunQuery(query, strnlen(query, 256)))
  676. {
  677. if(client)
  678. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  679. }
  680. }
  681. break;
  682. }
  683. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  684. if (target->GetDatabaseID() > 0)
  685. {
  686. char query[256];
  687. snprintf(query, 256, "update spawn set holiday_flag=%u where id=%i", atoul(value), target->GetDatabaseID());
  688. if (database.RunQuery(query, strnlen(query, 256)))
  689. {
  690. if(client)
  691. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  692. }
  693. }
  694. break;
  695. }
  696. case SPAWN_SET_AAXP_REWARDS: {
  697. if (target->GetDatabaseID() > 0)
  698. {
  699. char query[256];
  700. snprintf(query, 256, "update spawn set aaxp_rewards=%u where id=%i", atoul(value), target->GetDatabaseID());
  701. if (database.RunQuery(query, strnlen(query, 256)))
  702. {
  703. if(client)
  704. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  705. }
  706. }
  707. break;
  708. }
  709. case SPAWN_SET_VALUE_NAME:{
  710. target->SetName(value);
  711. if(target->GetZone())
  712. target->GetZone()->SendUpdateTitles(target);
  713. break;
  714. }
  715. case SPAWN_SET_VALUE_SUB_TITLE: {
  716. target->SetSubTitle(value);
  717. if(target->GetZone())
  718. target->GetZone()->SendUpdateTitles(target);
  719. break;
  720. }
  721. case SPAWN_SET_VALUE_X_OFFSET:
  722. {
  723. target->SetXOffset(atof(value));
  724. break;
  725. }
  726. case SPAWN_SET_VALUE_Y_OFFSET:
  727. {
  728. target->SetYOffset(atof(value));
  729. break;
  730. }
  731. case SPAWN_SET_VALUE_Z_OFFSET:
  732. {
  733. target->SetZOffset(atof(value));
  734. break;
  735. }
  736. case SPAWN_SET_VALUE_EXPIRE: {
  737. target->SetExpireTime(val);
  738. break;
  739. }
  740. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  741. target->SetExpireOffsetTime(val);
  742. break;
  743. }
  744. case SPAWN_SET_VALUE_LEVEL:{
  745. target->SetLevel(val, send_update);
  746. break;
  747. }
  748. case SPAWN_SET_VALUE_DIFFICULTY:{
  749. target->SetEncounterLevel(val, send_update);
  750. break;
  751. }
  752. case SPAWN_SET_VALUE_MODEL_TYPE:{
  753. target->SetModelType(val, send_update);
  754. break;
  755. }
  756. case SPAWN_SET_VALUE_CLASS:{
  757. target->SetAdventureClass(val, send_update);
  758. break;
  759. }
  760. case SPAWN_SET_VALUE_GENDER:{
  761. target->SetGender(val, send_update);
  762. break;
  763. }
  764. case SPAWN_SET_VALUE_SHOW_NAME:{
  765. target->SetShowName(val, send_update);
  766. break;
  767. }
  768. case SPAWN_SET_VALUE_ATTACKABLE:{
  769. target->SetAttackable(val, send_update);
  770. break;
  771. }
  772. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  773. target->SetShowLevel(val, send_update);
  774. break;
  775. }
  776. case SPAWN_SET_VALUE_TARGETABLE:{
  777. target->SetTargetable(val, send_update);
  778. break;
  779. }
  780. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  781. target->SetShowCommandIcon(val, send_update);
  782. break;
  783. }
  784. case SPAWN_SET_VALUE_HAND_ICON:{
  785. target->SetShowHandIcon(val, send_update);
  786. break;
  787. }
  788. case SPAWN_SET_VALUE_HAIR_TYPE:{
  789. if(target->IsEntity())
  790. ((Entity*)target)->SetHairType(val, send_update);
  791. break;
  792. }
  793. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  794. if(target->IsEntity())
  795. ((Entity*)target)->SetFacialHairType(val, send_update);
  796. break;
  797. }
  798. case SPAWN_SET_VALUE_WING_TYPE:{
  799. if(target->IsEntity())
  800. ((Entity*)target)->SetWingType(val, send_update);
  801. break;
  802. }
  803. case SPAWN_SET_VALUE_CHEST_TYPE:{
  804. if(target->IsEntity())
  805. ((Entity*)target)->SetChestType(val, send_update);
  806. break;
  807. }
  808. case SPAWN_SET_VALUE_LEGS_TYPE:{
  809. if(target->IsEntity())
  810. ((Entity*)target)->SetLegsType(val, send_update);
  811. break;
  812. }
  813. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  814. if(target->IsEntity())
  815. ((Entity*)target)->SetSogaHairType(val, send_update);
  816. break;
  817. }
  818. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  819. if(target->IsEntity())
  820. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  821. break;
  822. }
  823. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  824. target->SetSogaModelType(val, send_update);
  825. break;
  826. }
  827. case SPAWN_SET_VALUE_SIZE:{
  828. target->SetSize(val, send_update);
  829. break;
  830. }
  831. case SPAWN_SET_VALUE_HP:{
  832. target->SetHP(val, send_update);
  833. break;
  834. }
  835. case SPAWN_SET_VALUE_POWER:{
  836. target->SetPower(val, send_update);
  837. break;
  838. }
  839. case SPAWN_SET_VALUE_HEROIC:{
  840. target->SetHeroic(val, send_update);
  841. break;
  842. }
  843. case SPAWN_SET_VALUE_RESPAWN:{
  844. target->SetRespawnTime(val);
  845. break;
  846. }
  847. case SPAWN_SET_VALUE_X:{
  848. target->SetX(atof(value), send_update);
  849. target->SetSpawnOrigX(target->GetX());
  850. break;
  851. }
  852. case SPAWN_SET_VALUE_Y:{
  853. target->SetY(atof(value), send_update);
  854. target->SetSpawnOrigY(target->GetY());
  855. break;
  856. }
  857. case SPAWN_SET_VALUE_Z:{
  858. target->SetZ(atof(value), send_update);
  859. target->SetSpawnOrigZ(target->GetZ());
  860. break;
  861. }
  862. case SPAWN_SET_VALUE_HEADING:{
  863. target->SetHeading(atof(value), send_update);
  864. target->SetSpawnOrigHeading(target->GetHeading());
  865. break;
  866. }
  867. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  868. ZoneServer* zone = target->GetZone();
  869. if (!zone && client)
  870. zone = client->GetCurrentZone();
  871. if(zone && zone->GetEntityCommandList(val))
  872. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  873. target->primary_command_list_id = val;
  874. break;
  875. }
  876. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  877. ZoneServer* zone = target->GetZone();
  878. if (!zone && client)
  879. zone = client->GetCurrentZone();
  880. if (zone && zone->GetEntityCommandList(val))
  881. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  882. target->secondary_command_list_id = val;
  883. break;
  884. }
  885. case SPAWN_SET_VALUE_VISUAL_STATE:{
  886. target->SetVisualState(val, send_update);
  887. break;
  888. }
  889. case SPAWN_SET_VALUE_ACTION_STATE:{
  890. target->SetActionState(val, send_update);
  891. break;
  892. }
  893. case SPAWN_SET_VALUE_MOOD_STATE:{
  894. target->SetMoodState(val, send_update);
  895. break;
  896. }
  897. case SPAWN_SET_VALUE_INITIAL_STATE:{
  898. target->SetInitialState(val, send_update);
  899. break;
  900. }
  901. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  902. target->SetActivityStatus(val, send_update);
  903. break;
  904. }
  905. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  906. target->SetCollisionRadius(val, send_update);
  907. break;
  908. }
  909. case SPAWN_SET_VALUE_FACTION:{
  910. ZoneServer* zone = target->GetZone();
  911. if (!zone && client)
  912. zone = client->GetCurrentZone();
  913. target->faction_id = val;
  914. if(zone)
  915. {
  916. zone->RemoveDeadEnemyList(target);
  917. if(target->IsNPC())
  918. zone->AddEnemyList((NPC*)target);
  919. }
  920. break;
  921. }
  922. case SPAWN_SET_VALUE_DEVICE_ID:{
  923. if (target->IsObject())
  924. ((Object*)target)->SetDeviceID(val);
  925. break;
  926. }
  927. case SPAWN_SET_VALUE_PITCH: {
  928. target->SetPitch(atof(value), send_update);
  929. target->SetSpawnOrigPitch(atof(value));
  930. break;
  931. }
  932. case SPAWN_SET_VALUE_ROLL: {
  933. target->SetRoll(atof(value), send_update);
  934. target->SetSpawnOrigRoll(atof(value));
  935. break;
  936. }
  937. case SPAWN_SET_VALUE_HIDE_HOOD: {
  938. target->SetHideHood(val);
  939. break;
  940. }
  941. case SPAWN_SET_VALUE_EMOTE_STATE: {
  942. target->SetEmoteState(val);
  943. break;
  944. }
  945. case SPAWN_SET_VALUE_ICON: {
  946. target->SetIcon(val);
  947. break;
  948. }
  949. case SPAWN_SET_VALUE_PREFIX: {
  950. target->SetPrefixTitle(value);
  951. if(target->GetZone())
  952. target->GetZone()->SendUpdateTitles(target);
  953. break;
  954. }
  955. case SPAWN_SET_VALUE_SUFFIX: {
  956. target->SetSuffixTitle(value);
  957. if(target->GetZone())
  958. target->GetZone()->SendUpdateTitles(target);
  959. break;
  960. }
  961. case SPAWN_SET_VALUE_LASTNAME: {
  962. target->SetLastName(value);
  963. if(target->GetZone())
  964. target->GetZone()->SendUpdateTitles(target);
  965. break;
  966. }
  967. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  968. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  969. if(client){
  970. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  971. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  972. }
  973. return false;
  974. }
  975. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  976. return false;
  977. else{
  978. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  979. target->SetSpawnScript(value);
  980. }
  981. break;
  982. }
  983. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  984. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  985. if(client){
  986. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  987. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  988. }
  989. return false;
  990. }
  991. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  992. return false;
  993. else{
  994. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  995. target->SetSpawnScript(value);
  996. }
  997. break;
  998. }
  999. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  1000. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1001. if(client){
  1002. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1003. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  1004. }
  1005. return false;
  1006. }
  1007. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  1008. return false;
  1009. else
  1010. target->SetSpawnScript(value);
  1011. break;
  1012. }
  1013. case SPAWN_SET_SKIN_COLOR:
  1014. case SPAWN_SET_HAIR_COLOR1:
  1015. case SPAWN_SET_HAIR_COLOR2:
  1016. case SPAWN_SET_HAIR_TYPE_COLOR:
  1017. case SPAWN_SET_HAIR_FACE_COLOR:
  1018. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1019. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1020. case SPAWN_SET_HAIR_HIGHLIGHT:
  1021. case SPAWN_SET_MODEL_COLOR:
  1022. case SPAWN_SET_EYE_COLOR:
  1023. case SPAWN_SET_SOGA_SKIN_COLOR:
  1024. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1025. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1026. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1027. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1028. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1029. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1030. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1031. case SPAWN_SET_SOGA_MODEL_COLOR:
  1032. case SPAWN_SET_SOGA_EYE_COLOR: {
  1033. if (target->IsNPC())
  1034. {
  1035. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  1036. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  1037. {
  1038. EQ2_Color clr;
  1039. clr.red = atoul(skinsep->arg[0]);
  1040. clr.green = atoul(skinsep->arg[1]);
  1041. clr.blue = atoul(skinsep->arg[2]);
  1042. Query replaceSkinQuery;
  1043. string fieldName("");
  1044. switch(type)
  1045. {
  1046. case SPAWN_SET_SKIN_COLOR:
  1047. ((Entity*)target)->SetSkinColor(clr);
  1048. fieldName.append("skin_color");
  1049. break;
  1050. case SPAWN_SET_HAIR_COLOR1:
  1051. ((Entity*)target)->SetHairColor1(clr);
  1052. fieldName.append("hair_color1");
  1053. break;
  1054. case SPAWN_SET_HAIR_COLOR2:
  1055. ((Entity*)target)->SetHairColor2(clr);
  1056. fieldName.append("hair_color2");
  1057. break;
  1058. case SPAWN_SET_HAIR_TYPE_COLOR:
  1059. ((Entity*)target)->SetHairColor(clr);
  1060. fieldName.append("hair_type_color");
  1061. break;
  1062. case SPAWN_SET_HAIR_FACE_COLOR:
  1063. ((Entity*)target)->SetFacialHairColor(clr);
  1064. fieldName.append("hair_face_color");
  1065. break;
  1066. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1067. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  1068. fieldName.append("hair_type_highlight_color");
  1069. break;
  1070. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1071. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  1072. fieldName.append("hair_face_highlight_color");
  1073. break;
  1074. case SPAWN_SET_HAIR_HIGHLIGHT:
  1075. ((Entity*)target)->SetHairHighlightColor(clr);
  1076. fieldName.append("hair_highlight");
  1077. break;
  1078. case SPAWN_SET_MODEL_COLOR:
  1079. ((Entity*)target)->SetModelColor(clr);
  1080. fieldName.append("model_color");
  1081. break;
  1082. case SPAWN_SET_EYE_COLOR:
  1083. ((Entity*)target)->SetEyeColor(clr);
  1084. fieldName.append("eye_color");
  1085. break;
  1086. case SPAWN_SET_SOGA_SKIN_COLOR:
  1087. ((Entity*)target)->SetSogaSkinColor(clr);
  1088. fieldName.append("soga_skin_color");
  1089. break;
  1090. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1091. ((Entity*)target)->SetSogaHairColor1(clr);
  1092. fieldName.append("soga_hair_color1");
  1093. break;
  1094. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1095. ((Entity*)target)->SetSogaHairColor2(clr);
  1096. fieldName.append("soga_hair_color2");
  1097. break;
  1098. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1099. ((Entity*)target)->SetSogaHairColor(clr);
  1100. fieldName.append("soga_hair_type_color");
  1101. break;
  1102. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1103. ((Entity*)target)->SetSogaFacialHairColor(clr);
  1104. fieldName.append("soga_hair_face_color");
  1105. break;
  1106. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1107. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  1108. fieldName.append("soga_hair_type_highlight_color");
  1109. break;
  1110. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1111. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  1112. fieldName.append("soga_hair_face_highlight_color");
  1113. break;
  1114. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1115. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  1116. fieldName.append("soga_hair_highlight");
  1117. break;
  1118. case SPAWN_SET_SOGA_MODEL_COLOR:
  1119. ((Entity*)target)->SetSogaModelColor(clr);
  1120. fieldName.append("soga_model_color");
  1121. break;
  1122. case SPAWN_SET_SOGA_EYE_COLOR:
  1123. ((Entity*)target)->SetSogaEyeColor(clr);
  1124. fieldName.append("soga_eye_color");
  1125. break;
  1126. }
  1127. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1128. replaceSkinQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into npc_appearance set spawn_id=%u, type='%s', red=%u, green=%u, blue=%u", target->GetDatabaseID(), fieldName.c_str(), clr.red, clr.green, clr.blue);
  1129. }
  1130. safe_delete(skinsep);
  1131. }
  1132. break;
  1133. }
  1134. }
  1135. }
  1136. return true;
  1137. }
  1138. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  1139. the database fields always and also update the zone in memory if it's running. */
  1140. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  1141. if (client && zone_id > 0 && type > 0 && value) {
  1142. sint32 int_value = 0;
  1143. float float_value = 0;
  1144. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  1145. try {
  1146. float_value = atof(value);
  1147. }
  1148. catch (...) {
  1149. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  1150. return false;
  1151. }
  1152. }
  1153. else if (type != ZONE_SET_VALUE_NAME && type != ZONE_SET_VALUE_FILE && type != ZONE_SET_VALUE_DESCRIPTION && type != ZONE_SET_VALUE_ZONE_TYPE && type != ZONE_SET_VALUE_LUA_SCRIPT && type != ZONE_SET_VALUE_ZONE_MOTD) {
  1154. try {
  1155. int_value = atoi(value);
  1156. }
  1157. catch (...) {
  1158. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  1159. return false;
  1160. }
  1161. }
  1162. switch (type) {
  1163. case ZONE_SET_VALUE_EXPANSION_ID: {
  1164. break;
  1165. }
  1166. case ZONE_SET_VALUE_NAME: {
  1167. if (zone)
  1168. zone->SetZoneName(const_cast<char*>(value));
  1169. database.SaveZoneInfo(zone_id, "name", value);
  1170. break;
  1171. }
  1172. case ZONE_SET_VALUE_FILE: {
  1173. if (zone)
  1174. zone->SetZoneFile(const_cast<char*>(value));
  1175. database.SaveZoneInfo(zone_id, "file", value);
  1176. break;
  1177. }
  1178. case ZONE_SET_VALUE_DESCRIPTION: {
  1179. if (zone)
  1180. zone->SetZoneDescription(const_cast<char*>(value));
  1181. database.SaveZoneInfo(zone_id, "description", value);
  1182. break;
  1183. }
  1184. case ZONE_SET_VALUE_SAFE_X: {
  1185. if (zone)
  1186. zone->SetSafeX(float_value);
  1187. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  1188. break;
  1189. }
  1190. case ZONE_SET_VALUE_SAFE_Y: {
  1191. if (zone)
  1192. zone->SetSafeY(float_value);
  1193. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  1194. break;
  1195. }
  1196. case ZONE_SET_VALUE_SAFE_Z: {
  1197. if (zone)
  1198. zone->SetSafeZ(float_value);
  1199. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  1200. break;
  1201. }
  1202. case ZONE_SET_VALUE_UNDERWORLD: {
  1203. if (zone)
  1204. zone->SetUnderWorld(float_value);
  1205. database.SaveZoneInfo(zone_id, "underworld", float_value);
  1206. break;
  1207. }
  1208. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  1209. break;
  1210. }
  1211. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  1212. break;
  1213. }
  1214. case ZONE_SET_VALUE_ZONE_TYPE: {
  1215. break;
  1216. }
  1217. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  1218. if (zone)
  1219. zone->SetAlwaysLoaded(int_value == 1);
  1220. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  1221. break;
  1222. }
  1223. case ZONE_SET_VALUE_CITY_ZONE: {
  1224. if (zone)
  1225. zone->SetCityZone(int_value == 1);
  1226. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  1227. break;
  1228. }
  1229. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  1230. if (zone)
  1231. zone->SetWeatherAllowed(int_value == 1);
  1232. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  1233. break;
  1234. }
  1235. case ZONE_SET_VALUE_MIN_STATUS: {
  1236. if (zone)
  1237. zone->SetMinimumStatus(int_value);
  1238. database.SaveZoneInfo(zone_id, "min_status", int_value);
  1239. break;
  1240. }
  1241. case ZONE_SET_VALUE_MIN_LEVEL: {
  1242. if (zone)
  1243. zone->SetMinimumLevel(int_value);
  1244. database.SaveZoneInfo(zone_id, "min_level", int_value);
  1245. break;
  1246. }
  1247. case ZONE_SET_VALUE_MAX_LEVEL: {
  1248. if (zone)
  1249. zone->SetMaximumLevel(int_value);
  1250. database.SaveZoneInfo(zone_id, "max_level", int_value);
  1251. break;
  1252. }
  1253. case ZONE_SET_VALUE_START_ZONE: {
  1254. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  1255. break;
  1256. }
  1257. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  1258. if (zone)
  1259. zone->SetInstanceType(int_value);
  1260. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  1261. break;
  1262. }
  1263. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  1264. if (zone)
  1265. zone->SetDefaultReenterTime(int_value);
  1266. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  1267. break;
  1268. }
  1269. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  1270. if (zone)
  1271. zone->SetDefaultResetTime(int_value);
  1272. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  1273. break;
  1274. }
  1275. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1276. if (zone)
  1277. zone->SetDefaultLockoutTime(int_value);
  1278. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1279. break;
  1280. }
  1281. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1282. if (zone)
  1283. zone->SetForceGroupZoneOption(int_value);
  1284. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1285. break;
  1286. }
  1287. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1288. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1289. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1290. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1291. return false;
  1292. }
  1293. else {
  1294. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1295. database.SaveZoneInfo(zone_id, "lua_script", value);
  1296. }
  1297. break;
  1298. }
  1299. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1300. if (zone)
  1301. zone->SetShutdownTimer(int_value);
  1302. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1303. break;
  1304. }
  1305. case ZONE_SET_VALUE_ZONE_MOTD: {
  1306. if (zone)
  1307. zone->SetZoneMOTD(string(value));
  1308. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1309. break;
  1310. }
  1311. default: {
  1312. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1313. return false;
  1314. }
  1315. }
  1316. }
  1317. else {
  1318. if (client)
  1319. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1320. return false;
  1321. }
  1322. return true;
  1323. }
  1324. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1325. if (index >= remote_commands->commands.size()) {
  1326. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1327. return;
  1328. }
  1329. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1330. EQ2_RemoteCommandString* parent_command = 0;
  1331. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1332. Seperator* sep = 0;
  1333. if (command_parms->size > 0) {
  1334. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1335. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1336. parent_command = command;
  1337. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1338. safe_delete(sep);
  1339. if (command_parms->data.length() > (command->command.data.length() + 1))
  1340. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1341. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1342. }
  1343. else
  1344. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1345. }
  1346. int ndx = 0;
  1347. if (command->required_status > client->GetAdminStatus())
  1348. {
  1349. LogWrite(COMMAND__ERROR, 0, "Command", "Player '%s' (%u) needs status %i to use command: %s", client->GetPlayer()->GetName(), client->GetAccountID(), command->required_status, command->command.data.c_str());
  1350. safe_delete(sep);
  1351. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1352. return;
  1353. }
  1354. Player* player = client->GetPlayer();
  1355. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1356. switch (command->handler) {
  1357. case COMMAND_RELOAD: {
  1358. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1359. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1360. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1361. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1362. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1363. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1364. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1365. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1366. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1367. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1368. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1369. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1370. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1371. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1372. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1373. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1374. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1375. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1376. break;
  1377. }
  1378. case COMMAND_RELOADSTRUCTS: {
  1379. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1380. world.SetReloadingSubsystem("Structs");
  1381. configReader.ReloadStructs();
  1382. world.RemoveReloadingSubSystem("Structs");
  1383. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1384. break;
  1385. }
  1386. case COMMAND_RELOAD_QUESTS: {
  1387. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1388. world.SetReloadingSubsystem("Quests");
  1389. master_quest_list.Reload();
  1390. client_list.ReloadQuests();
  1391. zone_list.ReloadClientQuests();
  1392. world.RemoveReloadingSubSystem("Quests");
  1393. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1394. break;
  1395. }
  1396. case COMMAND_RELOAD_SPAWNS: {
  1397. client->GetCurrentZone()->ReloadSpawns();
  1398. break;
  1399. }
  1400. case COMMAND_RELOAD_SPELLS: {
  1401. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1402. world.SetReloadingSubsystem("Spells");
  1403. zone_list.DeleteSpellProcess();
  1404. master_spell_list.Reload();
  1405. if (lua_interface)
  1406. lua_interface->ReloadSpells();
  1407. zone_list.LoadSpellProcess();
  1408. world.RemoveReloadingSubSystem("Spells");
  1409. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1410. break;
  1411. }
  1412. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1413. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1414. world.SetReloadingSubsystem("GroundSpawns");
  1415. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1416. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1417. world.RemoveReloadingSubSystem("GroundSpawns");
  1418. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1419. break;
  1420. }
  1421. case COMMAND_RELOAD_ZONESCRIPTS: {
  1422. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1423. world.SetReloadingSubsystem("ZoneScripts");
  1424. world.ResetZoneScripts();
  1425. database.LoadZoneScriptData();
  1426. if (lua_interface)
  1427. lua_interface->DestroyZoneScripts();
  1428. world.RemoveReloadingSubSystem("ZoneScripts");
  1429. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1430. break;
  1431. }
  1432. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1433. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1434. world.SetReloadingSubsystem("EntityCommands");
  1435. client->GetCurrentZone()->ClearEntityCommands();
  1436. database.LoadEntityCommands(client->GetCurrentZone());
  1437. world.RemoveReloadingSubSystem("EntityCommands");
  1438. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1439. break;
  1440. }
  1441. case COMMAND_RELOAD_FACTIONS: {
  1442. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1443. world.SetReloadingSubsystem("Factions");
  1444. master_faction_list.Clear();
  1445. database.LoadFactionList();
  1446. world.RemoveReloadingSubSystem("Factions");
  1447. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1448. break;
  1449. }
  1450. case COMMAND_RELOAD_MAIL: {
  1451. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1452. zone_list.ReloadMail();
  1453. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1454. break;
  1455. }
  1456. case COMMAND_RELOAD_GUILDS: {
  1457. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1458. world.ReloadGuilds();
  1459. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1460. break;
  1461. }
  1462. case COMMAND_RELOAD_LOCATIONS: {
  1463. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1464. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1465. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1466. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1467. break;
  1468. }
  1469. case COMMAND_RELOAD_RULES: {
  1470. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1471. database.LoadRuleSets(true);
  1472. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1473. break;
  1474. }
  1475. case COMMAND_RELOAD_TRANSPORTERS: {
  1476. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1477. database.LoadTransporters(client->GetCurrentZone());
  1478. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1479. break;
  1480. }
  1481. case COMMAND_RELOAD_STARTABILITIES: {
  1482. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1483. world.PurgeStartingLists();
  1484. world.LoadStartingLists();
  1485. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1486. break;
  1487. }
  1488. case COMMAND_READ: {
  1489. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1490. if (strcmp(sep->arg[0], "read") == 0) {
  1491. int32 item_index = atol(sep->arg[1]);
  1492. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1493. if (item) {
  1494. Spawn* spawn = cmdTarget;
  1495. client->SendShowBook(client->GetPlayer(), item->name, item->book_pages);
  1496. break;
  1497. }
  1498. }
  1499. }
  1500. break;
  1501. }
  1502. case COMMAND_USEABILITY:{
  1503. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1504. if (client->GetPlayer()->GetHP() == 0) {
  1505. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1506. }
  1507. else {
  1508. int32 spell_id = atoul(sep->arg[0]);
  1509. int8 spell_tier = 0;
  1510. if (sep->arg[1][0] && sep->IsNumber(1))
  1511. spell_tier = atoi(sep->arg[1]);
  1512. else
  1513. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1514. if (!spell_tier)
  1515. spell_tier = 1;
  1516. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1517. if (spell) {
  1518. if (strncmp(spell->GetName(), "Gathering", 9) == 0 || strncmp(spell->GetName(), "Mining", 6) == 0 || strncmp(spell->GetName(), "Trapping", 8) == 0 || strncmp(spell->GetName(), "Foresting", 9) == 0 || strncmp(spell->GetName(), "Fishing", 7) == 0 || strncmp(spell->GetName(), "Collecting", 10) == 0)
  1519. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1520. else
  1521. {
  1522. if (cmdTarget)
  1523. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1524. else
  1525. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1526. }
  1527. }
  1528. }
  1529. }
  1530. else if (cmdTarget && cmdTarget->IsWidget())
  1531. {
  1532. Widget* widget = (Widget*)cmdTarget;
  1533. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1534. }
  1535. else
  1536. {
  1537. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1538. }
  1539. break;
  1540. }
  1541. case COMMAND_INFO:{
  1542. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1543. if(strcmp(sep->arg[0], "inventory") == 0){
  1544. int32 item_index = atol(sep->arg[1]);
  1545. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1546. if(item){
  1547. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1548. break;
  1549. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1550. //DumpPacket(app);
  1551. client->QueuePacket(app);
  1552. if(item->GetItemScript() && lua_interface)
  1553. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1554. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1555. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  1556. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1557. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  1558. }
  1559. }
  1560. else
  1561. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1562. }
  1563. else if(strcmp(sep->arg[0], "equipment") == 0){
  1564. int32 item_index = atol(sep->arg[1]);
  1565. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1566. if(item){
  1567. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1568. client->QueuePacket(app);
  1569. if(item->GetItemScript() && lua_interface)
  1570. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1571. }
  1572. else
  1573. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1574. }
  1575. else if(strcmp(sep->arg[0], "item") == 0 || strcmp(sep->arg[0], "merchant") == 0 || strcmp(sep->arg[0], "store") == 0 || strcmp(sep->arg[0], "buyback") == 0 || strcmp(sep->arg[0], "consignment") == 0){
  1576. int32 item_id = atoul(sep->arg[1]);
  1577. Item* item = master_item_list.GetItem(item_id);
  1578. if(item){
  1579. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1580. client->QueuePacket(app);
  1581. }
  1582. else
  1583. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1584. }
  1585. else if (strcmp(sep->arg[0], "spell") == 0) {
  1586. sint32 spell_id = atol(sep->arg[1]);
  1587. int8 tier = atoi(sep->arg[3]);
  1588. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1589. if (outapp)
  1590. client->QueuePacket(outapp);
  1591. else
  1592. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1593. }
  1594. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1595. sint32 spell_id = atol(sep->arg[2]);
  1596. int8 group = atoi(sep->arg[1]);
  1597. AltAdvanceData* data = 0;
  1598. SpellBookEntry* spellentry = 0;
  1599. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1600. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1601. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1602. if (outapp)
  1603. client->QueuePacket(outapp);
  1604. else
  1605. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1606. }
  1607. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1608. sint32 spell_id = atol(sep->arg[1]);
  1609. int32 tier = atoi(sep->arg[2]);
  1610. if (tier > 255) {
  1611. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  1612. if (ent)
  1613. tier = ent->tier;
  1614. }
  1615. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  1616. if (outapp)
  1617. client->QueuePacket(outapp);
  1618. else
  1619. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1620. }
  1621. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1622. sint32 recipe_id = atol(sep->arg[1]);
  1623. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1624. if(outapp)
  1625. client->QueuePacket(outapp);
  1626. else
  1627. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1628. }
  1629. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1630. int32 slot = atol(sep->arg[1]);
  1631. int32 spell_id = atol(sep->arg[2]);
  1632. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1633. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1634. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1635. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1636. if(outapp)
  1637. client->QueuePacket(outapp);
  1638. else
  1639. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1640. }
  1641. else if (strcmp(sep->arg[0], "effect") == 0) {
  1642. int32 spell_id = atol(sep->arg[1]);
  1643. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1644. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1645. int8 type = 0;
  1646. if (client->GetVersion() <= 546)
  1647. type = 1;
  1648. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  1649. if (outapp){
  1650. client->QueuePacket(outapp);
  1651. }
  1652. else
  1653. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1654. }
  1655. }
  1656. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1657. Item* item = player->item_list.GetOverflowItem();
  1658. if(item) {
  1659. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1660. client->QueuePacket(app);
  1661. }
  1662. else
  1663. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1664. }
  1665. else
  1666. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1667. break;
  1668. }
  1669. case COMMAND_USE_EQUIPPED_ITEM:{
  1670. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1671. int32 slot_id = atoul(sep->arg[0]);
  1672. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1673. if (item && item->generic_info.usable && item->GetItemScript())
  1674. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1675. }
  1676. break;
  1677. }
  1678. case COMMAND_USE_ITEM: {
  1679. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1680. int32 item_index = atoul(sep->arg[0]);
  1681. Item* item = player->item_list.GetItemFromIndex(item_index);
  1682. if (item && item->GetItemScript()) {
  1683. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1684. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1685. else {
  1686. if (item->generic_info.display_charges > 0) {
  1687. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1688. item->generic_info.display_charges -= 1;
  1689. item->save_needed = true;
  1690. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1691. }
  1692. else
  1693. LogWrite(PLAYER__ERROR, 0, "Command", "%s: Item %s (%i) attempted to be used, however display_charges is 0.", client->GetPlayer()->GetName(), item->name.c_str(), item->details.item_id);
  1694. }
  1695. }
  1696. }
  1697. break;
  1698. }
  1699. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1700. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1701. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1702. if (item) {
  1703. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1704. if(item->generic_info.item_type == 6) {
  1705. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1706. int8 old_slot = 0;
  1707. if (spell) {
  1708. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1709. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1710. player->RemoveSpellBookEntry(spell->GetSpellID());
  1711. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1712. player->UnlockSpell(spell);
  1713. client->SendSpellUpdate(spell);
  1714. database.DeleteItem(client->GetCharacterID(), item, 0);
  1715. player->item_list.RemoveItem(item, true);
  1716. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1717. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1718. }
  1719. }
  1720. else
  1721. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1722. }
  1723. else if(item->generic_info.item_type == 7){
  1724. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1725. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1726. // if valid recipe book and the player doesn't have it
  1727. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1728. client->Message(CHANNEL_NARRATIVE, "Your tradeskill level is not high enough to scribe this book.");
  1729. safe_delete(recipe_book);
  1730. }
  1731. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1732. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1733. // Add recipe book to the players list
  1734. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1735. // Get a list of all recipes this book contains
  1736. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1737. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1738. // Create the packet to send to update the players recipe list
  1739. PacketStruct* packet = 0;
  1740. if (client->GetRecipeListSent()) {
  1741. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1742. if (packet)
  1743. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1744. }
  1745. // loop through the list
  1746. vector<Recipe*>::iterator itr;
  1747. int16 i = 0;
  1748. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1749. // check to see if the player already has this recipe some how
  1750. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1751. // Player doesn't already have this recipe so lets add it
  1752. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1753. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1754. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1755. client->Message(CHANNEL_NARRATIVE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1756. if (packet && client->GetRecipeListSent()) {
  1757. packet->setArrayDataByName("id", recipe->GetID(), i);
  1758. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1759. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1760. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1761. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1762. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1763. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1764. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1765. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1766. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1767. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1768. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1769. i++;
  1770. }
  1771. }
  1772. }
  1773. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1774. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1775. database.DeleteItem(client->GetCharacterID(), item, 0);
  1776. client->GetPlayer()->item_list.RemoveItem(item, true);
  1777. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1778. if (packet && client->GetRecipeListSent())
  1779. client->QueuePacket(packet->serialize());
  1780. safe_delete(packet);
  1781. }
  1782. else {
  1783. if (recipe_book)
  1784. client->Message(CHANNEL_NARRATIVE, "You have already learned all you can from this item.");
  1785. safe_delete(recipe_book);
  1786. }
  1787. }
  1788. }
  1789. else
  1790. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1791. }
  1792. break;
  1793. }
  1794. case COMMAND_SUMMONITEM: {
  1795. if (sep && sep->IsNumber(0)) {
  1796. int32 item_id = atol(sep->arg[0]);
  1797. int32 quantity = 1;
  1798. if (sep->arg[1] && sep->IsNumber(1))
  1799. quantity = atoi(sep->arg[1]);
  1800. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1801. client->AddItemToBank(item_id,quantity);
  1802. }
  1803. else {
  1804. client->AddItem(item_id, quantity);
  1805. }
  1806. }
  1807. else {
  1808. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1809. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1810. }
  1811. break;
  1812. }
  1813. case COMMAND_COLLECTION_ADDITEM: {
  1814. // takes 2 params: collection_id, slot
  1815. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1816. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1817. if (item)
  1818. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1819. else
  1820. LogWrite(COLLECTION__ERROR, 0, "Collect", "Error in 'COMMAND_COLLECTION_ADDITEM'. Unable to get item from player '%s' at index %u", client->GetPlayer()->GetName(), atoul(sep->arg[0]));
  1821. }
  1822. else
  1823. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1824. break;
  1825. }
  1826. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1827. // takes 1 param: slot
  1828. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1829. int i = 0;
  1830. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1831. printf("\t%u: %s\n", i, sep->arg[i]);
  1832. i++;
  1833. }
  1834. break;
  1835. }
  1836. case COMMAND_WAYPOINT: {
  1837. bool success = false;
  1838. client->ClearWaypoint();
  1839. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  1840. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  1841. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  1842. }
  1843. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  1844. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  1845. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  1846. }
  1847. else {
  1848. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  1849. }
  1850. break;
  1851. }
  1852. case COMMAND_WHO:{
  1853. const char* who = 0;
  1854. if(sep && sep->arg[0]){
  1855. //cout << "Who query: \n";
  1856. who = sep->argplus[0];
  1857. //cout << who << endl;
  1858. }
  1859. zone_list.ProcessWhoQuery(who, client);
  1860. break;
  1861. }
  1862. case COMMAND_SELECT_JUNCTION:{
  1863. LogWrite(MISC__TODO, 1, "TODO", "For access/travel selections (i.e. Mariner Bells, Player Death Window, etc.)\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1864. int32 choice = 0;
  1865. if(sep && sep->arg[0] && sep->IsNumber(0))
  1866. choice = atoul(sep->arg[0]);
  1867. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1868. client->HandlePlayerRevive(choice);
  1869. }
  1870. break;
  1871. }
  1872. case COMMAND_SPAWN_MOVE: {
  1873. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  1874. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1875. if (packet) {
  1876. float unknown2_3 = 0;
  1877. int8 placement_mode = 0;
  1878. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1879. if (sep && sep->arg[0][0]) {
  1880. if (strcmp(sep->arg[0], "wall") == 0) {
  1881. placement_mode = 2;
  1882. unknown2_3 = 150;
  1883. }
  1884. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1885. placement_mode = 1;
  1886. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1887. {
  1888. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1889. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1890. }
  1891. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1892. {
  1893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1894. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1895. }
  1896. else if (strcmp(sep->arg[0], "myloc") == 0)
  1897. {
  1898. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1899. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1900. safe_delete(packet);
  1901. break;
  1902. }
  1903. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1904. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1905. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1906. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1907. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1908. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1909. safe_delete(packet);
  1910. break;
  1911. }
  1912. }
  1913. packet->setDataByName("placement_mode", placement_mode);
  1914. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1915. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1916. packet->setDataByName("unknown", 1); //size
  1917. packet->setDataByName("unknown2", 1); //size 2
  1918. packet->setDataByName("unknown2", .5, 1); //size 3
  1919. packet->setDataByName("unknown2", 3, 2);
  1920. packet->setDataByName("unknown2", unknown2_3, 3);
  1921. packet->setDataByName("max_distance", 500);
  1922. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1923. client->QueuePacket(packet->serialize());
  1924. safe_delete(packet);
  1925. }
  1926. }
  1927. else {
  1928. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1929. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1930. }
  1931. break;
  1932. }
  1933. case COMMAND_HAIL:{
  1934. Spawn* spawn = cmdTarget;
  1935. if(spawn && spawn->GetTargetable())
  1936. {
  1937. char tmp[75] = {0};
  1938. sprintf(tmp, "Hail, %s", spawn->GetName());
  1939. bool show_bubble = true;
  1940. if (spawn->IsNPC())
  1941. show_bubble = false;
  1942. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1943. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetGlobalRule(R_Spawn, HailDistance)->GetInt32()){
  1944. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1945. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1946. else
  1947. {
  1948. bool pauseRunback = false;
  1949. // prime runback as the heading or anything can be altered when hailing succeeds
  1950. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  1951. {
  1952. ((NPC*)spawn)->StartRunback();
  1953. pauseRunback = true;
  1954. }
  1955. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  1956. spawn->PauseMovement(rule_manager.GetGlobalRule(R_Spawn, HailMovementPause)->GetInt32());
  1957. else if(spawn->IsNPC() && pauseRunback)
  1958. ((NPC*)spawn)->ClearRunback();
  1959. }
  1960. }
  1961. }
  1962. else {
  1963. string tmp = "Hail";
  1964. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1965. }
  1966. break;
  1967. }
  1968. case COMMAND_SAY:{
  1969. if (sep && sep->arg[0][0]) {
  1970. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1971. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1972. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1973. }
  1974. else
  1975. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1976. break;
  1977. }
  1978. case COMMAND_TELL:{
  1979. if(sep && sep->arg[0] && sep->argplus[1]){
  1980. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1]))
  1981. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1982. }else
  1983. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1984. break;
  1985. }
  1986. case COMMAND_SHOUT:{
  1987. if(sep && sep->arg[0][0])
  1988. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1989. else
  1990. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1991. break;
  1992. }
  1993. case COMMAND_AUCTION:{
  1994. if(sep && sep->arg[0][0])
  1995. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1996. else
  1997. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1998. break;
  1999. }
  2000. case COMMAND_OOC:{
  2001. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2002. if(sep && sep->arg[0][0])
  2003. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0]);
  2004. else
  2005. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2006. break;
  2007. }
  2008. case COMMAND_EMOTE:{
  2009. if(sep && sep->arg[0][0])
  2010. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2011. else
  2012. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2013. break;
  2014. }
  2015. case COMMAND_RACE:{
  2016. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2017. if(sep->arg[1][0] && sep->IsNumber(1)){
  2018. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2019. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2020. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2021. client->GetPlayer()->SetCharSheetChanged(true);
  2022. }
  2023. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2024. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2025. //client->QueuePacket(outapp);
  2026. }
  2027. else{
  2028. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2029. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2030. }
  2031. break;
  2032. }
  2033. case COMMAND_BANK_DEPOSIT:{
  2034. if(client->GetBanker() && sep && sep->arg[0]){
  2035. int64 amount = 0;
  2036. string deposit = string(sep->arg[0]);
  2037. amount = atoi64(deposit.c_str());
  2038. client->BankDeposit(amount);
  2039. }
  2040. break;
  2041. }
  2042. case COMMAND_BANK_WITHDRAWAL:{
  2043. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2044. int64 amount = 0;
  2045. string deposit = string(sep->arg[0]);
  2046. amount = atoi64(deposit.c_str());
  2047. client->BankWithdrawal(amount);
  2048. }
  2049. break;
  2050. }
  2051. case COMMAND_BANK_CANCEL:{
  2052. Spawn* banker = cmdTarget;
  2053. client->Bank(banker, true);
  2054. break;
  2055. }
  2056. case COMMAND_BANK:{
  2057. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2058. Spawn* banker = cmdTarget;
  2059. client->Bank(banker);
  2060. break;
  2061. }
  2062. case COMMAND_GUILD_BANK:{
  2063. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2064. //Spawn* banker = client->GetPlayer()->GetTarget();
  2065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2066. break;
  2067. }
  2068. case COMMAND_START_MAIL: {
  2069. client->SetMailTransaction(cmdTarget);
  2070. client->SendMailList();
  2071. break;
  2072. }
  2073. case COMMAND_CANCEL_MAIL: {
  2074. client->SetMailTransaction(0);
  2075. break;
  2076. }
  2077. case COMMAND_GET_MAIL_MESSAGE: {
  2078. if (sep && sep->arg[0] && sep->IsNumber(0))
  2079. client->DisplayMailMessage(atoul(sep->arg[0]));
  2080. break;
  2081. }
  2082. case COMMAND_ADD_MAIL_PLAT: {
  2083. if (sep && sep->arg[0] && sep->IsNumber(0))
  2084. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2085. break;
  2086. }
  2087. case COMMAND_ADD_MAIL_GOLD: {
  2088. if (sep && sep->arg[0] && sep->IsNumber(0))
  2089. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2090. break;
  2091. }
  2092. case COMMAND_ADD_MAIL_SILVER: {
  2093. if (sep && sep->arg[0] && sep->IsNumber(0))
  2094. client->AddMailCoin(0, atoul(sep->arg[0]));
  2095. break;
  2096. }
  2097. case COMMAND_ADD_MAIL_COPPER: {
  2098. if (sep && sep->arg[0] && sep->IsNumber(0))
  2099. client->AddMailCoin(atoul(sep->arg[0]));
  2100. break;
  2101. }
  2102. case COMMAND_SET_MAIL_ITEM: {
  2103. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2104. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2105. break;
  2106. }
  2107. case COMMAND_REMOVE_MAIL_PLAT: {
  2108. if (sep && sep->arg[0] && sep->IsNumber(0))
  2109. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2110. break;
  2111. }
  2112. case COMMAND_REMOVE_MAIL_GOLD: {
  2113. if (sep && sep->arg[0] && sep->IsNumber(0))
  2114. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2115. break;
  2116. }
  2117. case COMMAND_REMOVE_MAIL_SILVER: {
  2118. if (sep && sep->arg[0] && sep->IsNumber(0))
  2119. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2120. break;
  2121. }
  2122. case COMMAND_REMOVE_MAIL_COPPER: {
  2123. if (sep && sep->arg[0] && sep->IsNumber(0))
  2124. client->RemoveMailCoin(atoul(sep->arg[0]));
  2125. break;
  2126. }
  2127. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2128. if (sep && sep->arg[0] && sep->IsNumber(0))
  2129. client->TakeMailAttachments(atoul(sep->arg[0]));
  2130. break;
  2131. }
  2132. case COMMAND_CANCEL_SEND_MAIL: {
  2133. client->CancelSendMail();
  2134. break;
  2135. }
  2136. case COMMAND_DELETE_MAIL_MESSAGE: {
  2137. if (sep && sep->arg[0] && sep->IsNumber(0))
  2138. client->DeleteMail(atoul(sep->arg[0]), true);
  2139. break;
  2140. }
  2141. case COMMAND_REPORT_SPAM: {
  2142. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2143. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2144. break;
  2145. }
  2146. case COMMAND_KILL:{
  2147. Spawn* dead = 0;
  2148. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2149. dead=client->GetPlayer();
  2150. client->GetPlayer()->SetHP(0);
  2151. client->GetPlayer()->KillSpawn(dead);
  2152. }else{
  2153. dead= cmdTarget;
  2154. if(dead && dead->IsPlayer() == false){
  2155. dead->SetHP(0);
  2156. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2157. client->GetCurrentZone()->RemoveSpawn(dead, true);
  2158. else
  2159. client->GetPlayer()->KillSpawn(dead);
  2160. }else{
  2161. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2162. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2163. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2164. }
  2165. }
  2166. break;
  2167. }
  2168. case COMMAND_LEVEL:{
  2169. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2170. int16 new_level = atoi(sep->arg[ndx]);
  2171. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2172. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2173. else {
  2174. if (new_level < 1)
  2175. new_level = 1;
  2176. if (new_level > 255)
  2177. new_level = 255;
  2178. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2179. }
  2180. }else
  2181. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2182. break;
  2183. }
  2184. case COMMAND_SIT: {
  2185. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2186. if(client->GetPlayer()->GetHP() > 0){
  2187. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2188. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2189. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2190. }
  2191. break;
  2192. }
  2193. case COMMAND_STAND: {
  2194. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2195. if(client->GetPlayer()->GetHP() > 0){
  2196. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2197. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2198. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2199. }
  2200. break;
  2201. }
  2202. case COMMAND_CLASS:{
  2203. if(sep && sep->arg[ndx][0]){
  2204. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2205. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2206. }else
  2207. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2208. break;
  2209. }
  2210. case COMMAND_GENDER:{
  2211. if(sep && sep->arg[ndx][0]){
  2212. client->GetPlayer()->GetInfoStruct()->set_gender(atoi(sep->arg[ndx]));
  2213. client->GetPlayer()->SetCharSheetChanged(true);
  2214. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  2215. }else{
  2216. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  2217. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  2218. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  2219. }
  2220. break;
  2221. }
  2222. case COMMAND_FLYMODE:{
  2223. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2224. PrintSep(sep, "COMMAND_FLYMODE");
  2225. int8 val = atoi(sep->arg[0]);
  2226. ClientPacketFunctions::SendFlyMode(client, val);
  2227. }
  2228. else{
  2229. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  2230. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2231. }
  2232. break;
  2233. }
  2234. case COMMAND_LOOT_LIST:{
  2235. Spawn* spawn = cmdTarget;
  2236. if(spawn && spawn->IsEntity()){
  2237. if (sep && sep->arg[0]) {
  2238. if (!spawn->GetDatabaseID())
  2239. {
  2240. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  2241. break;
  2242. }
  2243. else if (!spawn->IsNPC())
  2244. {
  2245. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2246. break;
  2247. }
  2248. bool reloadLoot = false;
  2249. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2250. {
  2251. int32 loottable_id = atoul(sep->arg[1]);
  2252. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2253. {
  2254. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2255. reloadLoot = true;
  2256. }
  2257. else
  2258. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2259. }
  2260. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2261. {
  2262. int32 loottable_id = atoul(sep->arg[1]);
  2263. if (loottable_id > 0)
  2264. {
  2265. database.AddLootTableToSpawn(spawn, loottable_id);
  2266. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2267. reloadLoot = true;
  2268. }
  2269. else
  2270. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2271. }
  2272. else if (!stricmp(sep->arg[0], "clearall"))
  2273. {
  2274. if (database.RemoveSpawnLootTable(spawn, 0))
  2275. {
  2276. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2277. reloadLoot = true;
  2278. }
  2279. else
  2280. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2281. }
  2282. else
  2283. {
  2284. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2285. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2286. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2287. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2288. break;
  2289. }
  2290. if (reloadLoot)
  2291. {
  2292. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2293. if (spawn->IsNPC())
  2294. {
  2295. Entity* ent = (Entity*)spawn;
  2296. ent->SetLootCoins(0);
  2297. ent->ClearLootList();
  2298. spawn->GetZone()->AddLoot((NPC*)spawn);
  2299. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2300. }
  2301. }
  2302. break; // nothing further this is the end of these sub commands
  2303. }
  2304. else
  2305. {
  2306. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  2307. if (loot_list.size() > 0) {
  2308. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2309. vector<int32>::iterator list_itr;
  2310. LootTable* table = 0;
  2311. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2312. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2313. if (table)
  2314. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2315. }
  2316. }
  2317. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2318. vector<Item*>* items = spawn->GetLootItems();
  2319. if (items) {
  2320. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2321. vector<Item*>::iterator itr;
  2322. Item* item = 0;
  2323. for (itr = items->begin(); itr != items->end(); itr++) {
  2324. item = *itr;
  2325. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2326. }
  2327. }
  2328. else
  2329. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2330. }
  2331. }
  2332. break;
  2333. }
  2334. case COMMAND_LOOT_SETCOIN:{
  2335. Spawn* spawn = cmdTarget;
  2336. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2337. spawn->SetLootCoins(atoul(sep->arg[0]));
  2338. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2339. }
  2340. else
  2341. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2342. break;
  2343. }
  2344. case COMMAND_LOOT_ADDITEM:{
  2345. Spawn* spawn = cmdTarget;
  2346. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2347. int16 charges = 1;
  2348. if(sep->arg[1] && sep->IsNumber(1))
  2349. charges = atoi(sep->arg[1]);
  2350. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2351. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2352. }
  2353. else
  2354. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2355. break;
  2356. }
  2357. case COMMAND_LOOT_REMOVEITEM:{
  2358. Spawn* spawn = cmdTarget;
  2359. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2360. spawn->LootItem(atoul(sep->arg[0]));
  2361. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2362. }
  2363. else
  2364. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2365. break;
  2366. }
  2367. case COMMAND_LOOT_CORPSE:
  2368. case COMMAND_DISARM:
  2369. case COMMAND_LOOT:{
  2370. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2371. {
  2372. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2373. break;
  2374. }
  2375. if(cmdTarget && cmdTarget->IsEntity()){
  2376. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2377. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2378. client->OpenChest(cmdTarget, true);
  2379. else
  2380. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2381. if (!(cmdTarget)->HasLoot()){
  2382. if (((Entity*)cmdTarget)->IsNPC())
  2383. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2384. }
  2385. }
  2386. else
  2387. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2388. }
  2389. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2390. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2391. break;
  2392. }
  2393. case COMMAND_RELOADSPAWNSCRIPTS:{
  2394. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2395. if (lua_interface)
  2396. lua_interface->SetSpawnScriptsReloading(true);
  2397. world.ResetSpawnScripts();
  2398. database.LoadSpawnScriptData();
  2399. if(lua_interface) {
  2400. lua_interface->DestroySpawnScripts();
  2401. lua_interface->SetSpawnScriptsReloading(false);
  2402. }
  2403. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2404. break;
  2405. }
  2406. case COMMAND_RELOADREGIONSCRIPTS:{
  2407. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2408. if(lua_interface) {
  2409. lua_interface->DestroyRegionScripts();
  2410. }
  2411. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2412. break;
  2413. }
  2414. case COMMAND_RELOADLUASYSTEM:{
  2415. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2416. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2417. safe_delete(lua_interface);
  2418. lua_interface = new LuaInterface();
  2419. if(lua_interface)
  2420. lua_interface->SetSpawnScriptsReloading(true);
  2421. if(lua_interface && debug_clients.size() > 0){
  2422. map<Client*, int32>::iterator itr;
  2423. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2424. if(lua_interface)
  2425. lua_interface->UpdateDebugClients(itr->first);
  2426. }
  2427. }
  2428. world.ResetSpawnScripts();
  2429. database.LoadSpawnScriptData();
  2430. world.ResetZoneScripts();
  2431. database.LoadZoneScriptData();
  2432. int32 quest_count = database.LoadQuests();
  2433. zone_list.DeleteSpellProcess();
  2434. master_spell_list.Reload();
  2435. int32 spell_count = 0;
  2436. if(lua_interface) {
  2437. lua_interface->DestroySpawnScripts();
  2438. lua_interface->DestroySpells();
  2439. spell_count = database.LoadSpellScriptData();
  2440. lua_interface->SetSpawnScriptsReloading(false);
  2441. }
  2442. zone_list.LoadSpellProcess();
  2443. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2444. break;
  2445. }
  2446. case COMMAND_DECLINE_QUEST:{
  2447. int32 quest_id = 0;
  2448. if(sep && sep->arg[0] && sep->IsNumber(0))
  2449. quest_id = atoul(sep->arg[0]);
  2450. if(quest_id > 0){
  2451. Quest* quest = client->GetPendingQuest(quest_id);
  2452. if(quest){
  2453. client->RemovePendingQuest(quest);
  2454. if(lua_interface)
  2455. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2456. safe_delete(quest);
  2457. client->GetCurrentZone()->SendQuestUpdates(client);
  2458. }
  2459. }
  2460. break;
  2461. }
  2462. case COMMAND_DELETE_QUEST:{
  2463. int32 quest_id = 0;
  2464. if(sep && sep->arg[0] && sep->IsNumber(0))
  2465. quest_id = atoul(sep->arg[0]);
  2466. if(quest_id > 0){
  2467. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2468. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2469. if (quest)
  2470. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2471. }
  2472. client->RemovePlayerQuest(quest_id);
  2473. client->GetCurrentZone()->SendQuestUpdates(client);
  2474. }
  2475. break;
  2476. }
  2477. case COMMAND_ACCEPT_QUEST:{
  2478. int32 quest_id = 0;
  2479. if(sep && sep->arg[0] && sep->IsNumber(0))
  2480. quest_id = atoul(sep->arg[0]);
  2481. if(quest_id > 0){
  2482. client->AcceptQuest(quest_id);
  2483. }
  2484. break;
  2485. }
  2486. case COMMAND_NAME:{
  2487. if(sep && sep->arg[ndx][0]){
  2488. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  2489. client->GetPlayer()->SetCharSheetChanged(true);
  2490. }else
  2491. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2492. break;
  2493. }
  2494. case COMMAND_GROUPSAY:{
  2495. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2496. if(sep && sep->arg[0] && gmi)
  2497. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2498. break;
  2499. }
  2500. case COMMAND_GROUPINVITE: {
  2501. Entity* target = 0;
  2502. Client* target_client = 0;
  2503. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2504. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2505. return;
  2506. }
  2507. // name provided with command so it has to be a player, npc not supported here
  2508. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2509. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2510. if (target_client) {
  2511. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2512. target = 0;
  2513. else
  2514. target = target_client->GetPlayer();
  2515. }
  2516. }
  2517. // if name was not provided use the players target, npc or player supported here
  2518. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2519. target = (Entity*)client->GetPlayer()->GetTarget();
  2520. if (target->IsPlayer()) {
  2521. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2522. }
  2523. }
  2524. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2525. if (result == 0) {
  2526. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2527. if (target_client) {
  2528. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2529. if (packet) {
  2530. packet->setDataByName("type", 1);
  2531. packet->setDataByName("name", client->GetPlayer()->GetName());
  2532. packet->setDataByName("unknown2", 1);
  2533. target_client->QueuePacket(packet->serialize());
  2534. safe_delete(packet);
  2535. }
  2536. }
  2537. }
  2538. else if (result == 1)
  2539. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2540. else if (result == 2)
  2541. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2542. else if (result == 3)
  2543. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2544. else if (result == 4)
  2545. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2546. else if (result == 5)
  2547. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2548. else if (result == 6)
  2549. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2550. else
  2551. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2552. break;
  2553. }
  2554. case COMMAND_GROUPDISBAND: {
  2555. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2556. if (gmi) { // TODO: Leader check
  2557. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2558. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2559. }
  2560. break;
  2561. }
  2562. case COMMAND_GROUP_LEAVE: {
  2563. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2564. if (gmi) {
  2565. int32 group_id = gmi->group_id;
  2566. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2567. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2568. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2569. }
  2570. else {
  2571. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2572. }
  2573. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  2574. }
  2575. break;
  2576. }
  2577. case COMMAND_FRIEND_ADD:{
  2578. string name = "";
  2579. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2580. name = database.GetPlayerName(sep->arg[0]);
  2581. else if(cmdTarget && cmdTarget->IsPlayer())
  2582. name = string(cmdTarget->GetName());
  2583. if(name.length() > 0){
  2584. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2585. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2586. client->GetPlayer()->RemoveIgnore(name.c_str());
  2587. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2588. client->SendChatRelationship(3, name.c_str());
  2589. }
  2590. client->GetPlayer()->AddFriend(name.c_str(), true);
  2591. client->SendChatRelationship(0, name.c_str());
  2592. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2593. if(zone_list.GetClientByCharName(name))
  2594. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2595. }
  2596. else
  2597. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2598. }
  2599. else
  2600. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2601. break;
  2602. }
  2603. case COMMAND_FRIEND_REMOVE:{
  2604. string name = "";
  2605. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2606. name = database.GetPlayerName(sep->arg[0]);
  2607. else if(cmdTarget && cmdTarget->IsPlayer())
  2608. name = string(cmdTarget->GetName());
  2609. if(name.length() > 0){
  2610. client->GetPlayer()->RemoveFriend(name.c_str());
  2611. client->SendChatRelationship(1, name.c_str());
  2612. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2613. }
  2614. else
  2615. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2616. break;
  2617. }
  2618. case COMMAND_FRIENDS:{
  2619. break;
  2620. }
  2621. case COMMAND_IGNORE_ADD:{
  2622. string name = "";
  2623. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2624. name = database.GetPlayerName(sep->arg[0]);
  2625. else if(cmdTarget && cmdTarget->IsPlayer())
  2626. name = string(cmdTarget->GetName());
  2627. if(name.length() > 0){
  2628. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2629. if(client->GetPlayer()->IsFriend(name.c_str())){
  2630. client->GetPlayer()->RemoveFriend(name.c_str());
  2631. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2632. client->SendChatRelationship(1, name.c_str());
  2633. }
  2634. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2635. client->SendChatRelationship(2, name.c_str());
  2636. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2637. }
  2638. else
  2639. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2640. }
  2641. else
  2642. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2643. break;
  2644. }
  2645. case COMMAND_IGNORE_REMOVE:{
  2646. string name = "";
  2647. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2648. name = database.GetPlayerName(sep->arg[0]);
  2649. else if(cmdTarget && cmdTarget->IsPlayer())
  2650. name = string(cmdTarget->GetName());
  2651. if(name.length() > 0){
  2652. client->GetPlayer()->RemoveIgnore(name.c_str());
  2653. client->SendChatRelationship(3, name.c_str());
  2654. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2655. }
  2656. break;
  2657. }
  2658. case COMMAND_IGNORES:{
  2659. break;
  2660. }
  2661. case COMMAND_GROUP_KICK:{
  2662. Entity* kicked = 0;
  2663. Client* kicked_client = 0;
  2664. int32 group_id = 0;
  2665. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2666. return;
  2667. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2668. if (sep && sep->arg[0]) {
  2669. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2670. if (kicked_client)
  2671. kicked = kicked_client->GetPlayer();
  2672. }
  2673. else if (cmdTarget && cmdTarget->IsEntity()) {
  2674. kicked = (Entity*)cmdTarget;
  2675. }
  2676. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2677. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2678. if (kicked)
  2679. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2680. if(send_kicked_message)
  2681. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2682. else
  2683. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  2684. if (kicked_client)
  2685. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  2686. break;
  2687. }
  2688. case COMMAND_GROUP_MAKE_LEADER:{
  2689. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2690. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2691. return;
  2692. }
  2693. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2694. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2695. if (new_leader) {
  2696. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2697. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2698. }
  2699. }
  2700. else
  2701. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2702. }
  2703. else if (cmdTarget && cmdTarget->IsPlayer())
  2704. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2705. else
  2706. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2707. break;
  2708. }
  2709. case COMMAND_GROUP_ACCEPT_INVITE: {
  2710. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2711. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2712. if (result == 0)
  2713. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  2714. else if (result == 1)
  2715. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  2716. else if (result == 2)
  2717. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  2718. else
  2719. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  2720. }
  2721. break;
  2722. }
  2723. case COMMAND_GROUP_DECLINE_INVITE: {
  2724. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2725. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2726. }
  2727. break;
  2728. }
  2729. case COMMAND_SUMMON:{
  2730. char* search_name = 0;
  2731. if(sep && sep->arg[0][0])
  2732. search_name = sep->arg[0];
  2733. if(!search_name && !cmdTarget){
  2734. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2735. 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.");
  2736. }
  2737. else{
  2738. if(!client->Summon(search_name))
  2739. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2740. }
  2741. break;
  2742. }
  2743. case COMMAND_GOTO:{
  2744. const char* search_name = 0;
  2745. if(sep && sep->arg[0][0])
  2746. search_name = sep->argplus[0];
  2747. if(!search_name && !cmdTarget){
  2748. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2749. 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.");
  2750. }
  2751. else{
  2752. if(!client->GotoSpawn(search_name))
  2753. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2754. }
  2755. break;
  2756. }
  2757. case COMMAND_MOVE:{
  2758. bool success = false;
  2759. try{
  2760. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2761. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2762. if(app){
  2763. client->QueuePacket(app);
  2764. success = true;
  2765. }
  2766. }
  2767. }
  2768. catch(...){}
  2769. if(!success){
  2770. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2771. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2772. }
  2773. break;
  2774. }
  2775. case COMMAND_SETTIME:{
  2776. if(sep && sep->arg[0]){
  2777. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2778. if(sep->arg[1] && sep->IsNumber(1))
  2779. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2780. if(sep->arg[2] && sep->IsNumber(2))
  2781. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2782. if(sep->arg[3] && sep->IsNumber(3))
  2783. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2784. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2785. }
  2786. else{
  2787. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2788. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2789. }
  2790. break;
  2791. }
  2792. case COMMAND_VERSION:{
  2793. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2794. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2795. break;
  2796. }
  2797. case COMMAND_ZONE:{
  2798. int32 instanceID = 0;
  2799. string zone;
  2800. int32 zone_id = 0;
  2801. bool listSearch = false;
  2802. bool isInstance = false;
  2803. ZoneServer* zsZone = 0;
  2804. if(sep && sep->arg[0][0])
  2805. {
  2806. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2807. listSearch = true;
  2808. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2809. {
  2810. zone_list.SendZoneList(client);
  2811. break;
  2812. }
  2813. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2814. {
  2815. if(sep->IsNumber(1))
  2816. instanceID = atol(sep->arg[1]);
  2817. }
  2818. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2819. {
  2820. PrintSep(sep, "ZONE LOCK");
  2821. if(sep->IsNumber(1))
  2822. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2823. else
  2824. zsZone = zone_list.Get(sep->arg[1], false);
  2825. if( zsZone )
  2826. {
  2827. zsZone->SetZoneLockState(true);
  2828. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2829. }
  2830. else
  2831. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2832. break;
  2833. }
  2834. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2835. {
  2836. PrintSep(sep, "ZONE UNLOCK");
  2837. if(sep->IsNumber(1))
  2838. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2839. else
  2840. zsZone = zone_list.Get(sep->arg[1], false);
  2841. if( zsZone )
  2842. {
  2843. zsZone->SetZoneLockState(false);
  2844. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2845. }
  2846. else
  2847. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2848. break;
  2849. }
  2850. else
  2851. {
  2852. if(sep->IsNumber(0))
  2853. {
  2854. zone_id = atoul(sep->arg[0]);
  2855. string zonename = database.GetZoneName(zone_id);
  2856. if(zonename.length() > 0)
  2857. zone = zonename;
  2858. }
  2859. else
  2860. zone = sep->arg[0];
  2861. }
  2862. if(instanceID > 0)
  2863. {
  2864. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2865. if(zsInstance != NULL)
  2866. {
  2867. instanceID = zsInstance->GetInstanceID();
  2868. zone = zsInstance->GetZoneName();
  2869. zone_id = zsInstance->GetZoneID();
  2870. isInstance = true;
  2871. }
  2872. }
  2873. }
  2874. if(!listSearch)
  2875. {
  2876. if(zone.length() == 0)
  2877. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2878. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2879. zone_id != client->GetCurrentZone()->GetZoneID())
  2880. {
  2881. const char* zonestr = zone.c_str();
  2882. if(database.VerifyZone(zonestr))
  2883. {
  2884. if(client->CheckZoneAccess(zonestr))
  2885. {
  2886. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  2887. if(isInstance)
  2888. client->Zone(instanceID,true,true);
  2889. else
  2890. client->Zone(zonestr);
  2891. }
  2892. }
  2893. else
  2894. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  2895. }
  2896. else
  2897. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2898. }
  2899. else
  2900. {
  2901. const char* name = 0;
  2902. if(sep && sep->arg[1][0])
  2903. {
  2904. map<int32, string>* zone_names;
  2905. name = sep->argplus[1];
  2906. sint16 status = client->GetAdminStatus();
  2907. if( status > 0 )
  2908. {
  2909. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2910. zone_names = database.GetZoneList(name, true);
  2911. }
  2912. else
  2913. zone_names = database.GetZoneList(name);
  2914. if(!zone_names)
  2915. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2916. else
  2917. {
  2918. map<int32, string>::iterator itr;
  2919. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2920. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2921. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2922. safe_delete(zone_names);
  2923. }
  2924. }
  2925. else
  2926. {
  2927. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2928. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2929. }
  2930. }
  2931. break;
  2932. }
  2933. case COMMAND_USE: {
  2934. Spawn* target = cmdTarget;
  2935. if (target->IsWidget())
  2936. ((Widget*)target)->HandleUse(client, "use");
  2937. break;
  2938. }
  2939. case COMMAND_OPEN: {
  2940. Spawn* target = cmdTarget;
  2941. if (target->IsWidget())
  2942. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2943. break;
  2944. }
  2945. case COMMAND_CASTSPELL: {
  2946. if (sep && sep->arg[0] && sep->IsNumber(0))
  2947. {
  2948. int8 tier = 1;
  2949. if (sep->arg[1] && sep->IsNumber(1))
  2950. tier = atoul(sep->arg[1]);
  2951. int8 self = 1;
  2952. if (sep->arg[1] && sep->IsNumber(2))
  2953. {
  2954. self = atoul(sep->arg[2]);
  2955. if(self != 1 && !cmdTarget->IsEntity())
  2956. {
  2957. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  2958. self = 1;
  2959. }
  2960. }
  2961. int32 spellid = atoul(sep->arg[0]);
  2962. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2963. if (spell)
  2964. {
  2965. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2966. SpellProcess* spellProcess = 0;
  2967. // Get the current zones spell process
  2968. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2969. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2970. }
  2971. else
  2972. {
  2973. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2974. }
  2975. }
  2976. else if (sep && sep->arg[0])
  2977. {
  2978. database.FindSpell(client, (char*)sep->argplus[0]);
  2979. }
  2980. else
  2981. {
  2982. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2983. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2984. }
  2985. break;
  2986. }
  2987. case COMMAND_KNOWLEDGEWINDOWSORT: {
  2988. if (client->GetVersion() <= 546)
  2989. break;
  2990. if (sep && sep->GetArgNumber() == 4)
  2991. {
  2992. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  2993. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  2994. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  2995. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  2996. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  2997. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  2998. ClientPacketFunctions::SendSkillSlotMappings(client);
  2999. }
  3000. else
  3001. {
  3002. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3003. }
  3004. break;
  3005. }
  3006. case COMMAND_MOVE_ITEM:
  3007. {
  3008. int32 id = 0;
  3009. if (sep->IsNumber(0))
  3010. id = atoul(sep->arg[0]);
  3011. Spawn* spawn = 0;
  3012. if (id == 0)
  3013. {
  3014. spawn = cmdTarget;
  3015. }
  3016. else
  3017. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3018. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3019. break;
  3020. client->SendMoveObjectMode(spawn, 0);
  3021. break;
  3022. }
  3023. case COMMAND_PICKUP:
  3024. {
  3025. int32 id = 0;
  3026. if (sep->IsNumber(0))
  3027. id = atoul(sep->arg[0]);
  3028. Spawn* spawn = 0;
  3029. if (id == 0)
  3030. {
  3031. spawn = cmdTarget;
  3032. }
  3033. else
  3034. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3035. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3036. break;
  3037. client->AddItem(spawn->GetPickupItemID(), 1);
  3038. Query query;
  3039. 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());
  3040. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3041. client->GetCurrentZone()->RemoveSpawn(spawn, true, true);
  3042. }
  3043. // we had a UI Window displayed, update the house items
  3044. if ( id > 0 )
  3045. client->GetCurrentZone()->SendHouseItems(client);
  3046. break;
  3047. }
  3048. case COMMAND_HOUSE_DEPOSIT:
  3049. {
  3050. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3051. // arg0 = ??? (set to 3)
  3052. // arg1 = coin (in copper)
  3053. // arg2 = status? (not implemented yet)
  3054. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3055. if (ph && sep && sep->IsNumber(1))
  3056. {
  3057. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3058. int32 outValStatus = 0;
  3059. if(sep->IsNumber(2))
  3060. {
  3061. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3062. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3063. outValStatus = 0; // cheat check
  3064. }
  3065. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3066. {
  3067. if(outValStatus)
  3068. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3069. char query[256];
  3070. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3071. if (itr != ph->depositsMap.end())
  3072. {
  3073. 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());
  3074. }
  3075. else
  3076. 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);
  3077. if (database.RunQuery(query, strnlen(query, 256)))
  3078. {
  3079. ph->escrow_coins += outValCoin;
  3080. ph->escrow_status += outValStatus;
  3081. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3082. database.LoadDeposits(ph);
  3083. client->PlaySound("coin_cha_ching");
  3084. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3085. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3086. }
  3087. else
  3088. {
  3089. if(outValCoin)
  3090. client->GetPlayer()->AddCoins(outValCoin);
  3091. if(outValStatus)
  3092. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3093. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3094. }
  3095. }
  3096. }
  3097. break;
  3098. }
  3099. case COMMAND_HOUSE:
  3100. {
  3101. if (sep && sep->IsNumber(0))
  3102. {
  3103. int32 unique_id = atoi(sep->arg[0]);
  3104. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3105. HouseZone* hz = 0;
  3106. if (ph)
  3107. hz = world.GetHouseZone(ph->house_id);
  3108. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3109. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3110. }
  3111. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3112. {
  3113. // inside a house or something? Send the access window
  3114. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3115. HouseZone* hz = 0;
  3116. if ( ph )
  3117. hz = world.GetHouseZone(ph->house_id);
  3118. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3119. client->GetCurrentZone()->SendHouseItems(client);
  3120. }
  3121. break;
  3122. }
  3123. case COMMAND_HOUSE_UI:
  3124. {
  3125. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3126. {
  3127. int32 unique_id = atoi(sep->arg[0]);
  3128. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3129. HouseZone* hz = 0;
  3130. if ( ph )
  3131. hz = world.GetHouseZone(ph->house_id);
  3132. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3133. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  3134. }
  3135. break;
  3136. }
  3137. case COMMAND_PLACE_HOUSE_ITEM: {
  3138. if (sep && sep->IsNumber(0))
  3139. {
  3140. int32 uniqueid = atoi(sep->arg[0]);
  3141. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3142. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3143. if (item && item->IsHouseItem())
  3144. {
  3145. if (!client->HasOwnerOrEditAccess())
  3146. {
  3147. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3148. break;
  3149. }
  3150. else if (!item->generic_info.appearance_id)
  3151. {
  3152. 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);
  3153. break;
  3154. }
  3155. if (client->GetTempPlacementSpawn())
  3156. {
  3157. Spawn* tmp = client->GetTempPlacementSpawn();
  3158. client->GetCurrentZone()->RemoveSpawn(tmp);
  3159. client->SetTempPlacementSpawn(nullptr);
  3160. }
  3161. Spawn* spawn = new Object();
  3162. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3163. spawn->SetID(Spawn::NextID());
  3164. spawn->SetX(client->GetPlayer()->GetX());
  3165. spawn->SetY(client->GetPlayer()->GetY());
  3166. spawn->SetZ(client->GetPlayer()->GetZ());
  3167. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3168. spawn->SetSpawnOrigX(spawn->GetX());
  3169. spawn->SetSpawnOrigY(spawn->GetY());
  3170. spawn->SetSpawnOrigZ(spawn->GetZ());
  3171. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3172. spawn->appearance.targetable = 1;
  3173. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3174. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3175. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3176. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3177. spawn->SetZone(client->GetCurrentZone());
  3178. client->GetCurrentZone()->SendSpawn(spawn, client);
  3179. client->SetTempPlacementSpawn(spawn);
  3180. client->SetPlacementUniqueItemID(uniqueid);
  3181. client->SendMoveObjectMode(spawn, 0);
  3182. }
  3183. }
  3184. break;
  3185. }
  3186. case COMMAND_GM:
  3187. {
  3188. if (sep && sep->arg[0] && sep->arg[1])
  3189. {
  3190. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3191. if (strcmp(sep->arg[0], "vision") == 0)
  3192. {
  3193. client->GetPlayer()->SetGMVision(onOff);
  3194. #if defined(__GNUC__)
  3195. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3196. #else
  3197. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3198. #endif
  3199. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3200. if (onOff)
  3201. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3202. else
  3203. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3204. }
  3205. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3206. {
  3207. client->SetRegionDebug(onOff);
  3208. #if defined(__GNUC__)
  3209. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3210. #else
  3211. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3212. #endif
  3213. if (onOff)
  3214. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  3215. else
  3216. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  3217. }
  3218. else if (strcmp(sep->arg[0], "luadebug") == 0)
  3219. {
  3220. client->SetLuaDebugClient(onOff);
  3221. #if defined(__GNUC__)
  3222. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3223. #else
  3224. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  3225. #endif
  3226. if (onOff)
  3227. {
  3228. if (lua_interface)
  3229. lua_interface->UpdateDebugClients(client);
  3230. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3231. }
  3232. else
  3233. {
  3234. if (lua_interface)
  3235. lua_interface->RemoveDebugClients(client);
  3236. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3237. }
  3238. }
  3239. }
  3240. break;
  3241. }
  3242. case COMMAND_ATTACK:
  3243. case COMMAND_AUTO_ATTACK:{
  3244. int8 type = 1;
  3245. Player* player = client->GetPlayer();
  3246. if(!player)
  3247. break;
  3248. bool incombat = player->EngagedInCombat();
  3249. if(sep && sep->arg[0] && sep->IsNumber(0))
  3250. type = atoi(sep->arg[0]);
  3251. if(client->GetPlayer()->GetHP() == 0){
  3252. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  3253. break;
  3254. }
  3255. if(type == 0){
  3256. if(incombat)
  3257. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3258. player->StopCombat(type);
  3259. }
  3260. else {
  3261. if(type == 2){
  3262. player->InCombat(false);
  3263. if(incombat && player->GetRangeAttack()){
  3264. player->StopCombat(type);
  3265. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3266. }
  3267. else{
  3268. player->SetRangeAttack(true);
  3269. player->InCombat(true, true);
  3270. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3271. }
  3272. }
  3273. else {
  3274. player->InCombat(false, true);
  3275. player->SetRangeAttack(false);
  3276. player->InCombat(true);
  3277. if(!incombat)
  3278. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3279. }
  3280. /*else
  3281. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  3282. }
  3283. player->SetCharSheetChanged(true);
  3284. break;
  3285. }
  3286. case COMMAND_DEPOP:{
  3287. bool allow_respawns = false;
  3288. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3289. if(atoi(sep->arg[0]) == 1)
  3290. allow_respawns = true;
  3291. }
  3292. client->GetCurrentZone()->Depop(allow_respawns);
  3293. break;
  3294. }
  3295. case COMMAND_REPOP:{
  3296. client->GetCurrentZone()->Depop(false, true);
  3297. break;
  3298. }
  3299. case COMMAND_BUYBACK:{
  3300. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3301. // 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
  3302. int64 id = atoi64(sep->arg[0]);
  3303. // get the first int32, the item id
  3304. //int32 item_id = (int32)id;
  3305. // get the second int32, the unique id
  3306. int32 unique_id = (int32)(id>>32);
  3307. int8 quantity = atoi(sep->arg[1]);
  3308. if(quantity == 255)
  3309. quantity = 1;
  3310. client->BuyBack(unique_id, quantity);
  3311. }
  3312. break;
  3313. }
  3314. case COMMAND_MERCHANT_BUY:{
  3315. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3316. int32 item_id = atoul(sep->arg[0]);
  3317. int8 quantity = atoi(sep->arg[1]);
  3318. client->BuyItem(item_id, quantity);
  3319. }
  3320. else
  3321. Command_SendMerchantWindow(client, sep);
  3322. break;
  3323. }
  3324. case COMMAND_MERCHANT_SELL:{
  3325. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3326. // 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
  3327. int64 id = atoi64(sep->arg[0]);
  3328. // get the first int32, the item id
  3329. int32 item_id = (int32)id;
  3330. // get the second int32, the unique id
  3331. int32 unique_id = (int32)(id>>32);
  3332. int8 quantity = atoi(sep->arg[1]);
  3333. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  3334. client->SellItem(item_id, quantity, unique_id);
  3335. }
  3336. break;
  3337. }
  3338. case COMMAND_MENDER_REPAIR: {
  3339. if (sep && sep->arg[0] && sep->IsNumber(0))
  3340. client->RepairItem(atoul(sep->arg[0]));
  3341. break;
  3342. }
  3343. case COMMAND_MENDER_REPAIR_ALL: {
  3344. client->RepairAllItems();
  3345. break;
  3346. }
  3347. case COMMAND_CANCEL_MERCHANT:{
  3348. client->SetMerchantTransaction(0);
  3349. break;
  3350. }
  3351. case COMMAND_START_MERCHANT:{
  3352. break;
  3353. }
  3354. case COMMAND_INVULNERABLE:{
  3355. sint8 val = -1;
  3356. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3357. val = atoi(sep->arg[0]);
  3358. //devn00b: Fix for linux builds
  3359. #if defined(__GNUC__)
  3360. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  3361. #else
  3362. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3363. #endif
  3364. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3365. client->GetPlayer()->SetInvulnerable(val==1);
  3366. if(client->GetPlayer()->GetInvulnerable())
  3367. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  3368. else
  3369. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  3370. }
  3371. if(val == -1)
  3372. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  3373. break;
  3374. }
  3375. case COMMAND_REPAIR: {
  3376. Spawn* spawn = cmdTarget;
  3377. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  3378. client->SendHailCommand(spawn);
  3379. client->SetMerchantTransaction(spawn);
  3380. client->SendRepairList();
  3381. }
  3382. break;
  3383. }
  3384. case COMMAND_LOTTO: {
  3385. Spawn* spawn = cmdTarget;
  3386. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  3387. client->SetMerchantTransaction(spawn);
  3388. client->ShowLottoWindow();
  3389. }
  3390. break;
  3391. }
  3392. case COMMAND_ACCEPT_REWARD:{
  3393. int32 unknown = 0;
  3394. int32 selectable_item_id = 0;
  3395. //Quest *quest = 0;
  3396. Collection *collection = 0;
  3397. /* no idea what the first argument is for (faction maybe?)
  3398. if the reward has a selectable item reward, it's sent as the second argument
  3399. if neither of these are included in the reward, there is no sep
  3400. 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
  3401. only 1 quest or collection reward may be displayed at a time */
  3402. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3403. unknown = atoul(sep->arg[0]);
  3404. selectable_item_id = atoul(sep->arg[1]);
  3405. }
  3406. //if ((quest = player->GetPendingQuestReward()))
  3407. // client->AcceptQuestRewards(quest, selectable_item_id);
  3408. /* the below needs to go away eventually and be redone */
  3409. int32 item_id = 0;
  3410. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3411. item_id = atoul(sep->arg[0]);
  3412. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3413. if(quest){
  3414. client->AcceptQuestReward(quest, item_id);
  3415. break;
  3416. }
  3417. bool collectedItems = false;
  3418. if (collection = player->GetPendingCollectionReward())
  3419. client->AcceptCollectionRewards(collection, selectable_item_id);
  3420. else if (client->GetPlayer()->HasPendingItemRewards()) {
  3421. vector<Item*> items = client->GetPlayer()->GetPendingItemRewards();
  3422. if (items.size() > 0) {
  3423. collectedItems = true;
  3424. for (int i = 0; i < items.size(); i++) {
  3425. client->GetPlayer()->AddItem(new Item(items[i]));
  3426. }
  3427. client->GetPlayer()->ClearPendingItemRewards();
  3428. }
  3429. map<int32, Item*> selectable_item = client->GetPlayer()->GetPendingSelectableItemReward(item_id);
  3430. if (selectable_item.size() > 0) {
  3431. collectedItems = true;
  3432. map<int32, Item*>::iterator itr;
  3433. for (itr = selectable_item.begin(); itr != selectable_item.end(); itr++) {
  3434. client->GetPlayer()->AddItem(new Item(itr->second));
  3435. client->GetPlayer()->ClearPendingSelectableItemRewards(itr->first);
  3436. }
  3437. }
  3438. }
  3439. if (collectedItems) {
  3440. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  3441. if (outapp)
  3442. client->QueuePacket(outapp);
  3443. }
  3444. else
  3445. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  3446. break;
  3447. }
  3448. case COMMAND_BUY_FROM_BROKER:{
  3449. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3450. int32 item_id = atoul(sep->arg[0]);
  3451. int16 quantity = atoul(sep->arg[1]);
  3452. client->AddItem(item_id, quantity);
  3453. }
  3454. break;
  3455. }
  3456. case COMMAND_SEARCH_STORES_PAGE:{
  3457. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3458. int32 page = atoul(sep->arg[0]);
  3459. client->SearchStore(page);
  3460. }
  3461. break;
  3462. }
  3463. case COMMAND_SEARCH_STORES:{
  3464. if(sep && sep->arg[0][0]){
  3465. const char* values = sep->argplus[0];
  3466. if(values){
  3467. map<string, string> str_values = TranslateBrokerRequest(values);
  3468. vector<Item*>* items = master_item_list.GetItems(str_values);
  3469. if(items){
  3470. client->SetItemSearch(items);
  3471. client->SearchStore(0);
  3472. }
  3473. }
  3474. }
  3475. break;
  3476. }
  3477. case COMMAND_LUADEBUG:{
  3478. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  3479. client->SetLuaDebugClient(true);
  3480. if(lua_interface)
  3481. lua_interface->UpdateDebugClients(client);
  3482. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3483. }
  3484. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  3485. client->SetLuaDebugClient(false);
  3486. if(lua_interface)
  3487. lua_interface->RemoveDebugClients(client);
  3488. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3489. }
  3490. else{
  3491. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  3492. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  3493. }
  3494. break;
  3495. }
  3496. case COMMAND_SPAWN_GROUP:
  3497. {
  3498. Spawn* target = cmdTarget;
  3499. if(target && target->IsPlayer() == false)
  3500. {
  3501. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  3502. {
  3503. if(target->GetSpawnLocationPlacementID() > 0)
  3504. {
  3505. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  3506. {
  3507. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  3508. if(id > 0)
  3509. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  3510. else
  3511. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  3512. target->SetSpawnGroupID(id);
  3513. target->AddSpawnToGroup(target);
  3514. }
  3515. else
  3516. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  3517. }
  3518. else
  3519. 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.");
  3520. }
  3521. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  3522. {
  3523. if(sep->arg[1] && sep->IsNumber(1))
  3524. {
  3525. int32 group_id = atoul(sep->arg[1]);
  3526. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  3527. if(leader)
  3528. {
  3529. leader->AddSpawnToGroup(target);
  3530. target->SetSpawnGroupID(group_id);
  3531. if(database.SpawnGroupAddSpawn(target, group_id))
  3532. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  3533. else
  3534. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  3535. }
  3536. else
  3537. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  3538. }
  3539. else
  3540. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  3541. }
  3542. else if(target->GetSpawnGroupID() == 0)
  3543. {
  3544. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  3545. }
  3546. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  3547. {
  3548. int32 group_id = target->GetSpawnGroupID();
  3549. target->RemoveSpawnFromGroup();
  3550. if(database.SpawnGroupRemoveSpawn(target, group_id))
  3551. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  3552. else
  3553. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  3554. }
  3555. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  3556. {
  3557. int32 group_id = target->GetSpawnGroupID();
  3558. if(sep->arg[1] && sep->IsNumber(1))
  3559. {
  3560. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  3561. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  3562. else
  3563. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  3564. }
  3565. else
  3566. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  3567. }
  3568. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  3569. {
  3570. int32 group_id = target->GetSpawnGroupID();
  3571. if(sep->arg[1] && sep->IsNumber(1))
  3572. {
  3573. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  3574. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  3575. else
  3576. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  3577. }
  3578. else
  3579. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  3580. }
  3581. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  3582. {
  3583. if(sep->arg[1] && sep->IsNumber(1))
  3584. {
  3585. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  3586. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  3587. else
  3588. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  3589. }
  3590. else
  3591. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  3592. }
  3593. else
  3594. {
  3595. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  3596. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  3597. }
  3598. }
  3599. else
  3600. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  3601. break;
  3602. }
  3603. case COMMAND_SPAWN_COMBINE:{
  3604. Spawn* spawn = cmdTarget;
  3605. float radius = 0;
  3606. bool failed = true;
  3607. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  3608. failed = false;
  3609. if(spawn->GetSpawnGroupID() > 0){
  3610. 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.");
  3611. }
  3612. else if(sep->IsNumber(0)){
  3613. radius = atof(sep->arg[0]);
  3614. client->CombineSpawns(radius, spawn);
  3615. }
  3616. else{
  3617. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  3618. client->AddCombineSpawn(spawn);
  3619. }
  3620. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  3621. client->RemoveCombineSpawn(spawn);
  3622. }
  3623. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  3624. const char* name = 0;
  3625. if(sep->arg[1] && sep->arg[1][0])
  3626. name = sep->argplus[1];
  3627. client->SaveCombineSpawns(name);
  3628. }
  3629. else
  3630. failed = true;
  3631. }
  3632. }
  3633. if(failed){
  3634. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  3635. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  3636. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  3637. }
  3638. break;
  3639. }
  3640. case COMMAND_SPAWN_CREATE:{
  3641. Spawn* spawn = 0;
  3642. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3643. spawn = new Object();
  3644. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3645. }
  3646. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3647. spawn = new GroundSpawn();
  3648. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3649. }
  3650. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3651. spawn = new Sign();
  3652. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3653. }
  3654. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3655. spawn = new NPC();
  3656. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3657. spawn->appearance.pos.collision_radius = 32;
  3658. spawn->secondary_command_list_id = 0;
  3659. spawn->primary_command_list_id = 0;
  3660. spawn->appearance.display_name = 1;
  3661. spawn->appearance.show_level = 1;
  3662. spawn->appearance.attackable = 1;
  3663. }
  3664. else{
  3665. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  3666. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  3667. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  3668. break;
  3669. }
  3670. spawn->SetID(Spawn::NextID());
  3671. spawn->SetX(client->GetPlayer()->GetX());
  3672. spawn->SetY(client->GetPlayer()->GetY());
  3673. spawn->SetZ(client->GetPlayer()->GetZ());
  3674. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3675. spawn->SetSpawnOrigX(spawn->GetX());
  3676. spawn->SetSpawnOrigY(spawn->GetY());
  3677. spawn->SetSpawnOrigZ(spawn->GetZ());
  3678. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3679. if(spawn->IsSign())
  3680. {
  3681. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  3682. ((Sign*)spawn)->SetSignDistance(20.0f);
  3683. ((Sign*)spawn)->SetIncludeLocation(1);
  3684. ((Sign*)spawn)->SetIncludeHeading(1);
  3685. ((Sign*)spawn)->SetInitialState(1);
  3686. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  3687. ((Sign*)spawn)->SetActivityStatus(64);
  3688. spawn->appearance.race = 0;
  3689. spawn->SetLevel(0);
  3690. spawn->SetHP(0);
  3691. spawn->SetTotalHP(0);
  3692. spawn->SetPower(0);
  3693. spawn->SetTotalPower(0);
  3694. spawn->SetEncounterLevel(0);
  3695. spawn->SetTargetable(0);
  3696. spawn->SetSogaModelType(0);
  3697. spawn->SetCollisionRadius(19);
  3698. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  3699. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  3700. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  3701. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3702. spawn->appearance.model_type = atoul(sep->arg[1]);
  3703. }
  3704. else
  3705. {
  3706. spawn->appearance.targetable = 1;
  3707. spawn->appearance.race = 255;
  3708. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3709. spawn->SetModelType(atoi(sep->arg[1]));
  3710. spawn->SetAdventureClass(atoi(sep->arg[2]));
  3711. spawn->SetLevel(atoi(sep->arg[3]));
  3712. spawn->SetName(sep->arg[4]);
  3713. if(sep->arg[5][0] && sep->IsNumber(5))
  3714. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  3715. if(sep->arg[6][0] && sep->IsNumber(6))
  3716. spawn->size = atoi(sep->arg[6]);
  3717. if(spawn->GetTotalHP() == 0){
  3718. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  3719. spawn->SetHP(25*spawn->GetLevel() + 1);
  3720. }
  3721. if(spawn->GetTotalPower() == 0){
  3722. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3723. spawn->SetPower(25*spawn->GetLevel() + 1);
  3724. }
  3725. }
  3726. client->GetCurrentZone()->AddSpawn(spawn);
  3727. break;
  3728. }
  3729. case COMMAND_SPAWN_EQUIPMENT:{
  3730. Spawn* spawn = cmdTarget;
  3731. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3732. int8 slot = atoi(sep->arg[0]);
  3733. int16 type = atoi(sep->arg[1]);
  3734. int8 red = 0;
  3735. int8 green = 0;
  3736. int8 blue = 0;
  3737. int8 h_red = 0;
  3738. int8 h_green = 0;
  3739. int8 h_blue = 0;
  3740. if(sep->arg[2])
  3741. red = atoi(sep->arg[2]);
  3742. if(sep->arg[3])
  3743. green = atoi(sep->arg[3]);
  3744. if(sep->arg[4])
  3745. blue = atoi(sep->arg[4]);
  3746. if(sep->arg[5])
  3747. h_red = atoi(sep->arg[5]);
  3748. if(sep->arg[6])
  3749. h_green = atoi(sep->arg[6]);
  3750. if(sep->arg[7])
  3751. h_blue = atoi(sep->arg[7]);
  3752. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3753. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3754. }
  3755. else{
  3756. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3757. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3758. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3759. }
  3760. break;
  3761. }
  3762. case COMMAND_SPAWN_DETAILS: {
  3763. Spawn* spawn = cmdTarget;
  3764. if (sep && sep->arg[0][0]) {
  3765. if (cmdTarget)
  3766. {
  3767. if (ToLower(string(sep->arg[0])) == "los")
  3768. {
  3769. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3770. if (hasLOS)
  3771. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3772. else
  3773. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3774. break;
  3775. }
  3776. else if (ToLower(string(sep->arg[0])) == "bestz")
  3777. {
  3778. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3779. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3780. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3781. break;
  3782. }
  3783. else if (ToLower(string(sep->arg[0])) == "inwater")
  3784. {
  3785. if (cmdTarget->GetRegionMap() == nullptr)
  3786. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  3787. else
  3788. {
  3789. bool inWater = cmdTarget->InWater();
  3790. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  3791. }
  3792. break;
  3793. }
  3794. else if (ToLower(string(sep->arg[0])) == "inlava")
  3795. {
  3796. if (cmdTarget->GetRegionMap() == nullptr)
  3797. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  3798. else
  3799. {
  3800. bool inLava = cmdTarget->InLava();
  3801. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  3802. }
  3803. break;
  3804. }
  3805. else if (ToLower(string(sep->arg[0])) == "regions")
  3806. {
  3807. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  3808. if (cmdTarget->GetRegionMap() == nullptr)
  3809. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  3810. else
  3811. {
  3812. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  3813. }
  3814. break;
  3815. }
  3816. else if (ToLower(string(sep->arg[0])) == "behind")
  3817. {
  3818. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  3819. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  3820. break;
  3821. }
  3822. else if (ToLower(string(sep->arg[0])) == "infront")
  3823. {
  3824. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  3825. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  3826. break;
  3827. }
  3828. else if (ToLower(string(sep->arg[0])) == "flank")
  3829. {
  3830. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  3831. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  3832. break;
  3833. }
  3834. }
  3835. if (sep->IsNumber(0))
  3836. {
  3837. float radius = atof(sep->arg[0]);
  3838. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3840. break;
  3841. }
  3842. }
  3843. if (spawn) {
  3844. const char* type = "NPC";
  3845. if (spawn->IsObject())
  3846. type = "Object";
  3847. else if (spawn->IsSign())
  3848. type = "Sign";
  3849. else if (spawn->IsWidget())
  3850. type = "Widget";
  3851. else if (spawn->IsGroundSpawn())
  3852. type = "GroundSpawn";
  3853. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3854. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3855. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3856. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3857. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3858. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3859. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3860. 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());
  3861. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3862. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3863. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3864. if (spawn->IsEntity()) {
  3865. 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());
  3866. 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());
  3867. }
  3868. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3869. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3870. 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());
  3871. 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);
  3872. if (spawn->IsNPC())
  3873. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3874. string details;
  3875. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3876. details += "Type: " + string(type) + "\n";
  3877. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3878. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3879. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3880. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3881. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3882. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3883. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3884. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3885. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3886. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3887. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3888. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3889. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3890. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3891. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3892. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3893. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3894. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3895. char x[16];
  3896. sprintf(x, "%.2f", spawn->GetX());
  3897. char y[16];
  3898. sprintf(y, "%.2f", spawn->GetY());
  3899. char z[16];
  3900. sprintf(z, "%.2f", spawn->GetZ());
  3901. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3902. string details2;
  3903. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3904. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3905. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3906. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3907. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3908. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3909. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3910. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3911. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3912. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3913. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3914. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3915. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3916. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3917. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3918. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3919. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3920. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3921. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3922. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3923. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3924. string details3;
  3925. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3926. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3927. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3928. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  3929. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  3930. string details4;
  3931. if (spawn->IsEntity()) {
  3932. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3933. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3934. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3935. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3936. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3937. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3938. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3939. if (spawn->IsNPC()) {
  3940. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3941. }
  3942. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  3943. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  3944. }
  3945. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3946. client->SendShowBook(client->GetPlayer(), title, 4, details, details2, details3, details4);
  3947. }
  3948. else {
  3949. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3950. 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.");
  3951. }
  3952. break;
  3953. }
  3954. case COMMAND_SPAWN_TARGET:{
  3955. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3956. int32 spawn_id = atoul(sep->arg[0]);
  3957. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3958. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3959. }
  3960. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3961. float distance = atof(sep->arg[1]);
  3962. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3963. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3964. }
  3965. else{
  3966. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3967. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3968. }
  3969. break;
  3970. }
  3971. case COMMAND_SPAWN_SET:
  3972. {
  3973. Spawn* spawn = cmdTarget;
  3974. sint16 set_type = -1;
  3975. string type_str;
  3976. if (spawn)
  3977. {
  3978. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3979. 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)
  3980. {
  3981. // set the type, which will be 0 if location or list or invalid
  3982. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3983. }
  3984. if(set_type > 0)
  3985. {
  3986. // check if spawn set is NOT a char update, or not location, or isn't a number
  3987. 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)
  3988. {
  3989. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3990. }
  3991. else
  3992. {
  3993. string name = string(spawn->GetName());
  3994. if(SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  3995. {
  3996. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  3997. {
  3998. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  3999. }
  4000. else if (set_type == SPAWN_SET_VALUE_NAME)
  4001. {
  4002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4003. }
  4004. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4005. {
  4006. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4007. }
  4008. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4009. {
  4010. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4011. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  4012. }
  4013. else
  4014. {
  4015. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  4016. }
  4017. switch (set_type)
  4018. {
  4019. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4020. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4021. case SPAWN_SET_VALUE_FACTION:
  4022. case SPAWN_SET_AAXP_REWARDS:
  4023. {
  4024. // not applicable already ran db command
  4025. break;
  4026. }
  4027. default:
  4028. {
  4029. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4030. break;
  4031. }
  4032. }
  4033. 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))
  4034. {
  4035. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4036. {
  4037. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  4038. }
  4039. else if(spawn->GetSpawnLocationID() > 0)
  4040. {
  4041. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4042. }
  4043. }
  4044. else
  4045. {
  4046. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4047. {
  4048. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  4049. }
  4050. else if(spawn->GetDatabaseID() > 0)
  4051. {
  4052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4053. }
  4054. }
  4055. }
  4056. }
  4057. }
  4058. else if(set_type == 0)
  4059. {
  4060. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4061. map<string, int8>::iterator itr;
  4062. int i=0;
  4063. string list;
  4064. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4065. {
  4066. if(i==10)
  4067. {
  4068. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4069. i = 0;
  4070. }
  4071. if(i>0)
  4072. {
  4073. list.append(", ").append(itr->first);
  4074. }
  4075. else
  4076. {
  4077. list = itr->first;
  4078. }
  4079. }
  4080. if(list.length() > 0)
  4081. {
  4082. // if 1 or more, display in client.
  4083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4084. }
  4085. }
  4086. else
  4087. {
  4088. // syntax fail
  4089. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4090. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4091. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4093. }
  4094. }
  4095. break;
  4096. }
  4097. case COMMAND_SPAWN_REMOVE:{
  4098. Spawn* spawn = cmdTarget;
  4099. if(spawn && !spawn->IsPlayer()){
  4100. if(spawn->GetSpawnLocationID() > 0){
  4101. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4102. client->GetCurrentZone()->RemoveSpawn(spawn, true, false);
  4103. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  4104. }
  4105. else
  4106. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4107. }
  4108. else
  4109. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4110. }
  4111. else{
  4112. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4113. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4114. }
  4115. break;
  4116. }
  4117. case COMMAND_SPAWN_LIST:{
  4118. if(sep && sep->arg[0][0]){
  4119. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4120. vector<string>::iterator itr;
  4121. if(results){
  4122. for(itr=results->begin();itr!=results->end();itr++){
  4123. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4124. }
  4125. safe_delete(results);
  4126. }
  4127. else
  4128. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4129. }
  4130. else{
  4131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4132. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4133. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4134. }
  4135. break;
  4136. }
  4137. case COMMAND_SPAWN_ADD:{
  4138. Spawn* spawn = cmdTarget;
  4139. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  4140. if(spawn->GetSpawnLocationID() > 0){
  4141. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4142. break;
  4143. }
  4144. if(spawn->GetDatabaseID() == 0){
  4145. if(database.SaveSpawnInfo(spawn)) {
  4146. char spawn_type[32];
  4147. memset(spawn_type, 0, sizeof(spawn_type));
  4148. if (spawn->IsNPC())
  4149. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4150. else if (spawn->IsObject())
  4151. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4152. else if (spawn->IsSign())
  4153. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4154. else if (spawn->IsGroundSpawn())
  4155. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4156. else
  4157. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4158. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4159. }
  4160. else
  4161. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4162. }
  4163. int32 spawn_group_id = 0;
  4164. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4165. spawn_group_id = database.GetNextSpawnLocation();
  4166. else
  4167. spawn_group_id = atol(sep->arg[0]);
  4168. int8 percent = 100;
  4169. if(sep->arg[2] && sep->IsNumber(2))
  4170. percent = atoi(sep->arg[2]);
  4171. spawn->SetSpawnLocationID(spawn_group_id);
  4172. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4173. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4174. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4175. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4176. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4177. else
  4178. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  4179. }
  4180. else{
  4181. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  4182. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  4183. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  4184. }
  4185. break;
  4186. }
  4187. case COMMAND_SPAWN:{
  4188. int32 id = 0;
  4189. Spawn* spawn = 0;
  4190. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4191. id = atol(sep->arg[0]);
  4192. spawn = client->GetCurrentZone()->GetSpawn(id);
  4193. }
  4194. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  4195. id = 0;
  4196. if(!id || !spawn){
  4197. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  4198. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  4199. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  4200. safe_delete(sep);
  4201. return;
  4202. }
  4203. if(sep && sep->arg[1][0]){
  4204. float x = atof(sep->arg[1]);
  4205. spawn->appearance.pos.X = x;
  4206. }
  4207. else
  4208. spawn->SetX(client->GetPlayer()->GetX(), false);
  4209. if(sep && sep->arg[2][0]){
  4210. float y = atof(sep->arg[2]);
  4211. spawn->appearance.pos.Y = y;
  4212. }
  4213. else
  4214. spawn->SetY(client->GetPlayer()->GetY(), false);
  4215. if(sep && sep->arg[3][0]){
  4216. float z = atof(sep->arg[3]);
  4217. spawn->appearance.pos.Z = z;
  4218. }
  4219. else
  4220. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  4221. if(sep && sep->arg[4][0]){
  4222. float heading = atof(sep->arg[4]);
  4223. spawn->SetHeading(heading);
  4224. }
  4225. else
  4226. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  4227. spawn->SetSpawnOrigX(spawn->GetX());
  4228. spawn->SetSpawnOrigY(spawn->GetY());
  4229. spawn->SetSpawnOrigZ(spawn->GetZ());
  4230. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4231. if(sep && sep->arg[5][0])
  4232. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  4233. else
  4234. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4235. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  4236. spawn->SetTotalHP(spawn->GetLevel() * 15);
  4237. spawn->SetHP(spawn->GetTotalHP());
  4238. }
  4239. if(spawn->GetTotalPower() == 0){
  4240. spawn->SetTotalPower(spawn->GetLevel() * 15);
  4241. spawn->SetPower(spawn->GetTotalPower());
  4242. }
  4243. const char* script = world.GetSpawnScript(id);
  4244. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  4245. spawn->SetSpawnScript(string(script));
  4246. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  4247. client->GetCurrentZone()->AddSpawn(spawn);
  4248. if(spawn->IsNPC())
  4249. spawn->GetZone()->AddLoot((NPC*)spawn);
  4250. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  4251. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  4252. break;
  4253. }
  4254. case COMMAND_ADMINFLAG:
  4255. {
  4256. if(sep && sep->arg[0]){
  4257. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  4258. sint16 new_status = atoi(sep->arg[1]);
  4259. if(tmp_status == -10)
  4260. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  4261. else if(tmp_status >= client->GetAdminStatus())
  4262. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  4263. else if (new_status > client->GetAdminStatus())
  4264. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  4265. else{
  4266. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  4267. if (!client2)
  4268. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  4269. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  4270. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  4271. if (client2) {
  4272. client2->SetAdminStatus(new_status);
  4273. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  4274. }
  4275. }
  4276. else
  4277. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  4278. }
  4279. }else{
  4280. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  4281. if(status != client->GetAdminStatus())
  4282. {
  4283. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  4284. client->SetAdminStatus(status);
  4285. }
  4286. else
  4287. {
  4288. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  4289. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  4290. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  4291. }
  4292. }
  4293. break;
  4294. }
  4295. case COMMAND_CANNEDEMOTE:{
  4296. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  4297. break;
  4298. }
  4299. case COMMAND_BROADCAST: {
  4300. if (sep && sep->arg[0])
  4301. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  4302. else
  4303. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  4304. break;
  4305. }
  4306. case COMMAND_ANNOUNCE: {
  4307. if (sep && sep->arg[0])
  4308. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  4309. else
  4310. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  4311. break;
  4312. }
  4313. case COMMAND_RELOAD_ITEMS:{
  4314. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  4315. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  4316. database.ReloadItemList();
  4317. database.LoadMerchantInformation();
  4318. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  4319. break;
  4320. }
  4321. case COMMAND_ENABLE_ABILITY_QUE:{
  4322. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  4323. if(app)
  4324. client->QueuePacket(app);
  4325. break;
  4326. }
  4327. case COMMAND_ITEMSEARCH:{
  4328. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  4329. if (packet) {
  4330. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  4331. //packet->setDataByName("unknown", 1);
  4332. packet->setDataByName("unknown2", 5, 0);
  4333. packet->setDataByName("unknown2", 20, 1);
  4334. packet->setDataByName("unknown2", 58, 3);
  4335. packet->setDataByName("unknown2", 40, 4);
  4336. client->QueuePacket(packet->serialize());
  4337. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  4338. if (packet2) {
  4339. packet2->setDataByName("char_id", client->GetCharacterID());
  4340. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  4341. safe_delete(packet2);
  4342. }
  4343. safe_delete(packet);
  4344. }
  4345. break;
  4346. }
  4347. case COMMAND_ANIMTEST:{
  4348. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  4349. if(command_packet){
  4350. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  4351. if (cmdTarget)
  4352. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  4353. command_packet->setDataByName ( "spawn_id" , id);
  4354. int animID = 1;
  4355. if(sep && sep->arg[0] && sep->IsNumber(0))
  4356. animID = atoi(sep->arg[0]);
  4357. VisualState* vs = NULL;
  4358. if(animID == 0)
  4359. {
  4360. vs = visual_states.FindVisualState(sep->arg[0]);
  4361. }
  4362. char msg[128];
  4363. sprintf(msg,"Animation Test ID: %i",animID);
  4364. command_packet->setMediumStringByName ( "emote_msg" , msg );
  4365. if(vs != NULL)
  4366. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  4367. else
  4368. command_packet->setDataByName ( "anim_type", animID );
  4369. command_packet->setDataByName ( "unknown0", 0 );
  4370. EQ2Packet* outapp = command_packet->serialize();
  4371. client->QueuePacket(outapp);
  4372. safe_delete(command_packet);
  4373. }
  4374. break;
  4375. }
  4376. case COMMAND_KICK:
  4377. {
  4378. if( sep == 0 || sep->arg[0] == 0)
  4379. {
  4380. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  4381. }
  4382. else
  4383. {
  4384. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  4385. if ( kickClient == client )
  4386. {
  4387. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  4388. break;
  4389. }
  4390. else if(kickClient != NULL)
  4391. {
  4392. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  4393. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  4394. {
  4395. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  4396. break;
  4397. }
  4398. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  4399. kickClient->Disconnect();
  4400. }
  4401. else
  4402. {
  4403. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  4404. }
  4405. }
  4406. break;
  4407. }
  4408. case COMMAND_LOCK:
  4409. {
  4410. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  4411. int worldLocked = atoi(sep->arg[0]);
  4412. net.world_locked = worldLocked;
  4413. if ( worldLocked )
  4414. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  4415. else
  4416. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  4417. }
  4418. else
  4419. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  4420. break;
  4421. }
  4422. case COMMAND_BAN:{
  4423. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  4424. {
  4425. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  4426. }
  4427. else
  4428. {
  4429. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  4430. if ( kickClient == client )
  4431. {
  4432. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  4433. break;
  4434. }
  4435. else if(kickClient != NULL)
  4436. {
  4437. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  4438. if ( maxStatus > client->GetAdminStatus( ) ||
  4439. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  4440. {
  4441. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  4442. break;
  4443. }
  4444. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  4445. int perm = atol(sep->arg[1]);
  4446. if ( perm == 1 )
  4447. database.UpdateAdminStatus(sep->arg[0],-2);
  4448. else
  4449. database.UpdateAdminStatus(sep->arg[0],-1);
  4450. kickClient->Disconnect();
  4451. }
  4452. else
  4453. {
  4454. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  4455. }
  4456. }
  4457. break;
  4458. }
  4459. case COMMAND_SET_COMBAT_VOICE:{
  4460. int32 value = 0;
  4461. if(sep && sep->arg[0] && sep->IsNumber(0))
  4462. value = atoi(sep->arg[0]);
  4463. client->GetPlayer()->SetCombatVoice(value);
  4464. break;
  4465. }
  4466. case COMMAND_SET_EMOTE_VOICE:{
  4467. int32 value = 0;
  4468. if(sep && sep->arg[0] && sep->IsNumber(0))
  4469. value = atoi(sep->arg[0]);
  4470. client->GetPlayer()->SetEmoteVoice(value);
  4471. break;
  4472. }
  4473. case COMMAND_GIVEITEM:{
  4474. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  4475. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  4476. if ( itemToClient == NULL )
  4477. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  4478. else
  4479. {
  4480. int32 item_id = atol(sep->arg[1]);
  4481. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  4482. itemToClient->AddItem(item_id);
  4483. }
  4484. }
  4485. else
  4486. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  4487. break;
  4488. }
  4489. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  4490. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  4491. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  4492. case COMMAND_SKILL :
  4493. case COMMAND_SKILL_ADD :
  4494. case COMMAND_SKILL_REMOVE :
  4495. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  4496. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  4497. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  4498. case COMMAND_ENTITYCOMMAND :
  4499. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  4500. case COMMAND_MERCHANT :
  4501. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  4502. case COMMAND_APPEARANCE :
  4503. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  4504. case COMMAND_TRACK : { Command_Track(client); break; }
  4505. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  4506. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  4507. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  4508. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  4509. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  4510. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  4511. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  4512. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  4513. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  4514. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  4515. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  4516. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  4517. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  4518. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  4519. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  4520. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  4521. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  4522. case COMMAND_LOCATION : { Command_Location(client); break; }
  4523. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  4524. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  4525. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  4526. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  4527. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  4528. case COMMAND_GRID : { Command_Grid(client); break; }
  4529. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  4530. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  4531. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  4532. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  4533. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  4534. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  4535. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  4536. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  4537. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  4538. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  4539. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  4540. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  4541. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  4542. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  4543. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  4544. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  4545. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  4546. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  4547. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  4548. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  4549. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  4550. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  4551. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  4552. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  4553. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  4554. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  4555. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  4556. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  4557. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  4558. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  4559. case COMMAND_MOTD : { Command_MOTD(client); break; }
  4560. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  4561. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  4562. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  4563. case COMMAND_TITLE : { Command_Title(client); break; }
  4564. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  4565. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  4566. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  4567. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  4568. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  4569. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  4570. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  4571. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  4572. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  4573. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  4574. case COMMAND_PET : { Command_Pet(client, sep); break; }
  4575. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  4576. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  4577. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  4578. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  4579. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  4580. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  4581. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  4582. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  4583. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  4584. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  4585. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  4586. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  4587. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  4588. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  4589. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  4590. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  4591. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  4592. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  4593. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  4594. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  4595. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  4596. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  4597. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  4598. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  4599. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  4600. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  4601. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  4602. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  4603. case COMMAND_MODIFY : { Command_Modify(client); break; }
  4604. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  4605. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  4606. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  4607. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  4608. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  4609. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  4610. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  4611. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  4612. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  4613. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  4614. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  4615. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  4616. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  4617. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  4618. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  4619. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  4620. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  4621. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  4622. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  4623. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  4624. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  4625. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  4626. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  4627. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  4628. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  4629. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  4630. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  4631. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  4632. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  4633. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  4634. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  4635. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  4636. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  4637. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  4638. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  4639. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  4640. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  4641. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  4642. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  4643. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  4644. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  4645. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  4646. case ADD_AA : { Add_AA(client, sep); break; }
  4647. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  4648. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  4649. case BACK_AA : { Back_AA(client, sep); break; }
  4650. case REMOVE_AA : { Remove_AA(client, sep); break; }
  4651. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  4652. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  4653. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  4654. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  4655. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  4656. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  4657. case COMMAND_CRAFTITEM: {
  4658. Item* item = 0;
  4659. if (sep && sep->IsNumber(0)) {
  4660. int32 item_id = atol(sep->arg[0]);
  4661. int32 quantity = 1;
  4662. if (sep->arg[1] && sep->IsNumber(1))
  4663. quantity = atoi(sep->arg[1]);
  4664. item = new Item(master_item_list.GetItem(item_id));
  4665. if (!item) {
  4666. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  4667. }
  4668. else {
  4669. item->details.count = quantity;
  4670. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  4671. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  4672. client->AddItem(item);
  4673. //Check for crafting quest updates
  4674. int8 update_amt = 0;
  4675. if (item->stack_count > 1)
  4676. update_amt = 1;
  4677. else
  4678. update_amt = quantity;
  4679. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  4680. }
  4681. }
  4682. else {
  4683. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  4684. }
  4685. break;
  4686. }
  4687. default:
  4688. {
  4689. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  4690. break;
  4691. }
  4692. }
  4693. safe_delete(sep);
  4694. }
  4695. /******************** New COMMAND Handler Functions ********************/
  4696. /*
  4697. Started breaking apart the huge switch() for commands into sepErate
  4698. functions so it is easier to locate the blocks of code by command
  4699. -- JA 2012.03.03
  4700. */
  4701. // sample function header
  4702. /*
  4703. Function:
  4704. Purpose :
  4705. Params :
  4706. Dev :
  4707. Example :
  4708. */
  4709. //void Commands::Command()
  4710. //{
  4711. //}
  4712. /*
  4713. Function: Command_AcceptAdvancement()
  4714. Purpose : Player accepts a new advancement option
  4715. Params : Spell ID
  4716. Dev : Jabantiz
  4717. */
  4718. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4719. {
  4720. Player *player = client->GetPlayer();
  4721. if (sep && sep->IsSet(0)) {
  4722. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4723. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4724. if (!player->HasSpell(trait->spellID, 0, true))
  4725. {
  4726. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4727. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4728. }
  4729. else
  4730. {
  4731. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4732. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4733. player->RemoveSpellBookEntry(spell->GetSpellID());
  4734. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4735. player->UnlockSpell(spell);
  4736. client->SendSpellUpdate(spell);
  4737. }
  4738. // Spell book update
  4739. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4740. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4741. }
  4742. }
  4743. /*
  4744. Function:
  4745. Purpose :
  4746. Params :
  4747. Dev :
  4748. Example :
  4749. */
  4750. void Commands::Command_AFK(Client* client, Seperator* sep)
  4751. {
  4752. Player* player = client->GetPlayer();
  4753. player->toggle_character_flag(CF_AFK);
  4754. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4755. if (player->get_character_flag(CF_AFK))
  4756. {
  4757. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4758. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  4759. if (sep && sep->argplus[0])
  4760. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4761. else
  4762. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4763. string message = string(player->GetName()) + " is going afk.";
  4764. Spawn* target = player->GetTarget();
  4765. if (target && target != player)
  4766. {
  4767. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4768. player->GetGender() == 1 ? message += "he" : message += "she";
  4769. message += " is going afk.";
  4770. }
  4771. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4772. }
  4773. /*else
  4774. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  4775. }
  4776. /*
  4777. Function: Command_Appearance()
  4778. Purpose : Handles /appearance commands
  4779. Params : list
  4780. Dev : Scatman
  4781. Example : /appearance list
  4782. */
  4783. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4784. {
  4785. if( handler == COMMAND_APPEARANCE )
  4786. {
  4787. // /appearance command by itself shows help (to be extended)
  4788. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4789. return;
  4790. }
  4791. else if( handler == COMMAND_APPEARANCE_LIST )
  4792. {
  4793. // /appearance list command expects "name" param
  4794. if (sep && sep->arg[0])
  4795. {
  4796. const char* appearance_name = sep->argplus[0];
  4797. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4798. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4799. if (appearances)
  4800. {
  4801. vector<int16>::iterator itr;
  4802. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4803. {
  4804. int16 id = *itr;
  4805. string name = database.GetAppearanceName(id);
  4806. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4807. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4808. }
  4809. safe_delete(appearances);
  4810. }
  4811. }
  4812. else // no param
  4813. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4814. }
  4815. }
  4816. /*
  4817. Function: Command_Claim()
  4818. Purpose :
  4819. Params :
  4820. Dev :
  4821. Example :
  4822. */
  4823. void Commands::Command_Claim(Client* client, Seperator* sep)
  4824. {
  4825. if (sep && sep->arg[0] && sep->IsNumber(0))
  4826. {
  4827. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4829. }
  4830. else
  4831. client->ShowClaimWindow();
  4832. }
  4833. /*
  4834. Function: Command_ClearAllQueued()
  4835. Purpose :
  4836. Params :
  4837. Dev :
  4838. Example :
  4839. */
  4840. void Commands::Command_ClearAllQueued(Client* client)
  4841. {
  4842. ZoneServer* zone = client->GetPlayer()->GetZone();
  4843. if (zone && zone->GetSpellProcess())
  4844. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4845. }
  4846. /*
  4847. Function: Command_CancelMaintained()
  4848. Purpose : Cancels maintained spells
  4849. Params : Maintained Spell Index
  4850. Dev : Zcoretri
  4851. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4852. */
  4853. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4854. {
  4855. if (sep && sep->arg[0] && sep->IsNumber(0))
  4856. {
  4857. int32 spell_index = atoul(sep->arg[0]);
  4858. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4859. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4860. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4861. // just not spelleffects/dets - Foof
  4862. //{
  4863. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled"))
  4864. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4865. // }
  4866. //else
  4867. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4868. }
  4869. }
  4870. /*
  4871. Function: Command_Create()
  4872. Purpose : Handler for starting Tradeskilling table
  4873. Params :
  4874. Dev : Zcoretri
  4875. Example :
  4876. */
  4877. void Commands::Command_Create(Client* client, Seperator* sep)
  4878. {
  4879. PrintSep(sep, "COMMAND_CREATE");
  4880. client->SendRecipeList();
  4881. client->ShowRecipeBook();
  4882. }
  4883. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4884. {
  4885. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4886. if (sep && sep->arg[0] && sep->IsNumber(0))
  4887. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4888. }
  4889. /*
  4890. Function: Command_Distance()
  4891. Purpose : Displays distance from targeted spawn
  4892. Params :
  4893. Dev : Scatman
  4894. Example : /distance
  4895. */
  4896. void Commands::Command_Distance(Client* client)
  4897. {
  4898. Spawn* target = client->GetPlayer()->GetTarget();
  4899. if (target)
  4900. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4901. else
  4902. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4903. }
  4904. /*
  4905. Function: Command_Duel()
  4906. Purpose : Handle the /duel commands - not yet implemented
  4907. Params : unknown
  4908. Dev :
  4909. Example :
  4910. */
  4911. void Commands::Command_Duel(Client* client, Seperator* sep)
  4912. {
  4913. PrintSep(sep, "COMMAND_DUEL");
  4914. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4915. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4916. }
  4917. /*
  4918. Function: Command_DuelBet()
  4919. Purpose : Handle the /duel commands - not yet implemented
  4920. Params : unknown
  4921. Dev :
  4922. Example :
  4923. */
  4924. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4925. {
  4926. PrintSep(sep, "COMMAND_DUELBET");
  4927. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4928. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4929. }
  4930. /*
  4931. Function: Command_DuelAccept()
  4932. Purpose : Handle the /duel commands - not yet implemented
  4933. Params : unknown
  4934. Dev :
  4935. Example :
  4936. */
  4937. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4938. {
  4939. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4940. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4941. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4942. }
  4943. /*
  4944. Function: Command_DuelDecline()
  4945. Purpose : Handle the /duel commands - not yet implemented
  4946. Params : unknown
  4947. Dev :
  4948. Example :
  4949. */
  4950. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4951. {
  4952. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4953. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4954. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4955. }
  4956. /*
  4957. Function: Command_DuelSurrender()
  4958. Purpose : Handle the /duel commands - not yet implemented
  4959. Params : unknown
  4960. Dev :
  4961. Example :
  4962. */
  4963. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4964. {
  4965. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4966. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4967. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4968. // JA, just messin around ;)
  4969. char surrender[64];
  4970. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4971. zone_list.HandleGlobalAnnouncement(surrender);
  4972. }
  4973. /*
  4974. Function: Command_DuelToggle()
  4975. Purpose : Handle the /duel commands - not yet implemented
  4976. Params : unknown
  4977. Dev :
  4978. Example :
  4979. */
  4980. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4981. {
  4982. PrintSep(sep, "COMMAND_DUEL");
  4983. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4984. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4985. }
  4986. /*
  4987. Function:
  4988. Purpose :
  4989. Params :
  4990. Dev :
  4991. Example :
  4992. */
  4993. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4994. {
  4995. if( handler == COMMAND_ENTITYCOMMAND )
  4996. {
  4997. // /entitycommand command by itself shows help (to be extended)
  4998. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4999. return;
  5000. }
  5001. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5002. {
  5003. // /entitycommand list command expects "name" param
  5004. if (sep && sep->arg[0])
  5005. {
  5006. const char* entity_command_name = sep->argplus[0];
  5007. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5008. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5009. map<int32, vector<EntityCommand*>*>::iterator itr;
  5010. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5011. {
  5012. vector<EntityCommand*>* entity_command_list = itr->second;
  5013. vector<EntityCommand*>::iterator itr2;
  5014. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5015. {
  5016. EntityCommand* entity_command = *itr2;
  5017. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5018. 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);
  5019. }
  5020. }
  5021. }
  5022. else // no command name
  5023. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5024. }
  5025. }
  5026. /*
  5027. Function: Command_Follow()
  5028. Purpose : Handle the /follow command - not yet implemented
  5029. Params :
  5030. Dev :
  5031. Example :
  5032. */
  5033. void Commands::Command_Follow(Client* client, Seperator* sep)
  5034. {
  5035. PrintSep(sep, "COMMAND_FOLLOW");
  5036. // flag to toggle if the players target is in the players group
  5037. bool targetInGroup = false;
  5038. // get a pointer to the players group
  5039. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5040. // If the player has a group and has a target
  5041. if (gmi && client->GetPlayer()->GetTarget()) {
  5042. deque<GroupMemberInfo*>::iterator itr;
  5043. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5044. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5045. if (group)
  5046. {
  5047. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5048. deque<GroupMemberInfo*>* members = group->GetMembers();
  5049. // Loop through the group members
  5050. for (itr = members->begin(); itr != members->end(); itr++) {
  5051. // If a group member matches a target
  5052. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  5053. // toggle the flag and break the loop
  5054. targetInGroup = true;
  5055. break;
  5056. }
  5057. }
  5058. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5059. }
  5060. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5061. }
  5062. if (targetInGroup) {
  5063. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5064. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5065. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5066. client->GetPlayer()->info_changed = true;
  5067. client->GetPlayer()->changed = true;
  5068. }
  5069. else
  5070. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5071. }
  5072. /*
  5073. Function: Command_StopFollow()
  5074. Purpose : Handle the /stop_follow command - not yet implemented
  5075. Params :
  5076. Dev :
  5077. Example :
  5078. */
  5079. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5080. {
  5081. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5082. if (client->GetPlayer()->GetFollowTarget()) {
  5083. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5084. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5085. client->GetPlayer()->SetFollowTarget(0);
  5086. client->GetPlayer()->info_changed = true;
  5087. client->GetPlayer()->changed = true;
  5088. }
  5089. }
  5090. #include "../Zone/SPGrid.h"
  5091. /*
  5092. Function: Command_Grid()
  5093. Purpose : Show player's current Grid ID
  5094. Params :
  5095. Dev : Scatman
  5096. Example : /grid
  5097. */
  5098. void Commands::Command_Grid(Client* client)
  5099. {
  5100. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  5101. if (client->GetPlayer()->GetMap() != nullptr) {
  5102. int32 grid = client->GetPlayer()->GetMap()->GetGrid()->GetGridID(client->GetPlayer());
  5103. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  5104. }
  5105. }
  5106. /*
  5107. Function: Command_Guild()
  5108. Purpose : Handler for all UI-related guild commands
  5109. Dev : Scatman
  5110. */
  5111. void Commands::Command_Guild(Client* client, Seperator* sep)
  5112. {
  5113. Guild* guild = client->GetPlayer()->GetGuild();
  5114. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  5115. {
  5116. const char* command = sep->arg[0];
  5117. int32 length = strlen(command);
  5118. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  5119. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  5120. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  5121. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5122. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5123. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5124. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5125. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  5126. guild->KickGuildMember(client, sep->arg[1]);
  5127. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  5128. guild->DemoteGuildMember(client, sep->arg[1]);
  5129. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  5130. guild->PromoteGuildMember(client, sep->arg[1]);
  5131. else if (strncmp(command, "points", length) == 0 && guild)
  5132. {
  5133. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  5134. {
  5135. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5136. {
  5137. float points = atof(sep->arg[2]);
  5138. const char* option = sep->arg[3];
  5139. const char* comment = sep->argplus[4];
  5140. if (strncmp(option, "all", strlen(option)) == 0)
  5141. guild->AddPointsToAll(client, points, comment);
  5142. else if (strncmp(option, "online", strlen(option)) == 0)
  5143. guild->AddPointsToAllOnline(client, points, comment);
  5144. else if (strncmp(option, "group", strlen(option)) == 0)
  5145. guild->AddPointsToGroup(client, points, comment);
  5146. else if (strncmp(option, "raid", strlen(option)) == 0)
  5147. guild->AddPointsToRaid(client, points, comment);
  5148. else
  5149. guild->AddPointsToGuildMember(client, points, option, comment);
  5150. }
  5151. }
  5152. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  5153. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  5154. else
  5155. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  5156. }
  5157. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  5158. guild->SetMOTD(sep->argplus[1]);
  5159. else if (strncmp(command, "recruiting", length) == 0 && guild)
  5160. {
  5161. if (sep->arg[1])
  5162. {
  5163. const char* option = sep->arg[1];
  5164. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  5165. guild->SetRecruitingShortDesc(sep->argplus[2]);
  5166. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  5167. guild->SetRecruitingFullDesc(sep->argplus[2]);
  5168. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5169. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5170. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5171. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  5172. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5173. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  5174. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  5175. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  5176. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  5177. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5178. else
  5179. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5180. }
  5181. else
  5182. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5183. }
  5184. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  5185. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5186. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  5187. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5188. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5189. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5190. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  5191. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  5192. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5193. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5194. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  5195. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  5196. else if (strncmp(command, "invite", length) == 0 && guild)
  5197. {
  5198. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5199. guild->InvitePlayer(client, sep->arg[1]);
  5200. else
  5201. {
  5202. Spawn* target = client->GetPlayer()->GetTarget();
  5203. if (target)
  5204. {
  5205. if (target->IsPlayer())
  5206. guild->InvitePlayer(client, target->GetName());
  5207. else
  5208. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  5209. }
  5210. }
  5211. }
  5212. else if (strncmp(command, "accept", length) == 0)
  5213. {
  5214. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5215. if (pgi && pgi->guild && pgi->invited_by)
  5216. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  5217. client->SetPendingGuildInvite(0);
  5218. }
  5219. else if (strncmp(command, "decline", length) == 0)
  5220. {
  5221. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5222. if (pgi && pgi->guild && pgi->invited_by)
  5223. {
  5224. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  5225. if (client_inviter)
  5226. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  5227. }
  5228. client->SetPendingGuildInvite(0);
  5229. }
  5230. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  5231. {
  5232. const char* guild_name = sep->argplus[1];
  5233. if (!guild_list.GetGuild(guild_name))
  5234. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  5235. else
  5236. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  5237. }
  5238. else if (strncmp(command, "search", length) == 0)
  5239. client->ShowGuildSearchWindow();
  5240. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  5241. {
  5242. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  5243. if (to_guild)
  5244. to_guild->SendGuildRecruitingDetails(client);
  5245. }
  5246. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  5247. {
  5248. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  5249. if (to_guild)
  5250. to_guild->SendGuildRecruitingImages(client);
  5251. }
  5252. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  5253. {
  5254. if (sep->arg[1])
  5255. {
  5256. const char* option = sep->arg[1];
  5257. if (strncmp(option, "toggle", strlen(option)) == 0)
  5258. guild->ToggleGuildRecruiterAdventureClass(client);
  5259. }
  5260. else
  5261. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  5262. }
  5263. else if (strncmp(command, "display_heraldry", length) == 0)
  5264. {
  5265. // JA: not sure this is right...
  5266. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  5267. client->GetPlayer()->SetCharSheetChanged(true);
  5268. }
  5269. else
  5270. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  5271. }
  5272. }
  5273. /*
  5274. Function: Command_GuildCreate()
  5275. Purpose : Display's in-game Guild Creation window
  5276. Dev : Scatman
  5277. */
  5278. void Commands::Command_CreateGuild(Client* client)
  5279. {
  5280. client->SendGuildCreateWindow();
  5281. }
  5282. /*
  5283. Function: Command_SetGuildOfficerNote()
  5284. Purpose :
  5285. Dev : Scatman
  5286. */
  5287. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  5288. {
  5289. if (sep && sep->arg[0] && sep->arg[1])
  5290. {
  5291. Guild* guild = client->GetPlayer()->GetGuild();
  5292. if (guild)
  5293. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  5294. }
  5295. }
  5296. /*
  5297. Function: Command_SetGuildMemberNote()
  5298. Purpose :
  5299. Dev : Scatman
  5300. */
  5301. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  5302. {
  5303. if (sep && sep->arg[0] && sep->arg[1])
  5304. {
  5305. Guild* guild = client->GetPlayer()->GetGuild();
  5306. if (guild)
  5307. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  5308. }
  5309. }
  5310. /*
  5311. Function: Command_GuildSay()
  5312. Purpose :
  5313. Dev : Scatman
  5314. */
  5315. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  5316. {
  5317. Guild* guild = client->GetPlayer()->GetGuild();
  5318. if (guild)
  5319. {
  5320. if (sep && sep->arg[0])
  5321. guild->HandleGuildSay(client, sep->argplus[0]);
  5322. }
  5323. else
  5324. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  5325. }
  5326. /*
  5327. Function: Command_OfficerSay()
  5328. Purpose :
  5329. Dev : Scatman
  5330. */
  5331. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  5332. {
  5333. Guild* guild = client->GetPlayer()->GetGuild();
  5334. if (guild)
  5335. {
  5336. if (sep && sep->arg[0])
  5337. guild->HandleOfficerSay(client, sep->argplus[0]);
  5338. }
  5339. else
  5340. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  5341. }
  5342. /*
  5343. Function: Command_Guilds()
  5344. Purpose : Shows help for /guild command
  5345. Params :
  5346. Dev : Scatman
  5347. Example :
  5348. */
  5349. void Commands::Command_Guilds(Client* client)
  5350. {
  5351. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  5352. }
  5353. /*
  5354. Function: Command_GuildsAdd()
  5355. Purpose : Add's players to a guild
  5356. Params : guild_name|guild_id, player name
  5357. Dev : Scatman
  5358. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  5359. */
  5360. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  5361. {
  5362. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5363. {
  5364. Guild* guild = 0;
  5365. bool found = true;
  5366. if (sep->IsNumber(0))
  5367. {
  5368. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5369. if (!guild)
  5370. {
  5371. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5372. found = false;
  5373. }
  5374. }
  5375. else
  5376. {
  5377. guild = guild_list.GetGuild(sep->arg[0]);
  5378. if (!guild)
  5379. {
  5380. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5381. found = false;
  5382. }
  5383. }
  5384. if (found)
  5385. {
  5386. Client* to_client = 0;
  5387. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5388. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5389. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5390. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5391. if (to_client)
  5392. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  5393. else
  5394. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5395. }
  5396. }
  5397. else
  5398. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  5399. }
  5400. /*
  5401. Function: Command_GuildsCreate()
  5402. Purpose : Creates a guild
  5403. Params : guild_name, player_name (optional)
  5404. Dev : Scatman
  5405. Example : /guilds create [guild name] (player name)
  5406. */
  5407. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  5408. {
  5409. if (sep && sep->arg[0])
  5410. {
  5411. const char* guild_name = sep->arg[0];
  5412. if (!guild_list.GetGuild(guild_name))
  5413. {
  5414. bool ret = false;
  5415. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5416. {
  5417. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5418. if (to_client)
  5419. {
  5420. world.CreateGuild(guild_name, to_client);
  5421. ret = true;
  5422. }
  5423. else
  5424. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  5425. }
  5426. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5427. {
  5428. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5429. if (to_client)
  5430. {
  5431. world.CreateGuild(guild_name, to_client);
  5432. ret = true;
  5433. }
  5434. }
  5435. else
  5436. {
  5437. world.CreateGuild(guild_name);
  5438. ret = true;
  5439. }
  5440. if (ret)
  5441. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  5442. else
  5443. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  5444. }
  5445. else
  5446. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  5447. }
  5448. else
  5449. 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.");
  5450. }
  5451. /*
  5452. Function: Command_GuildsDelete()
  5453. Purpose : Delete's a guild
  5454. Params : guild name
  5455. Dev : Scatman
  5456. Example : /guilds delete Test
  5457. */
  5458. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  5459. {
  5460. if (sep && sep->arg[0])
  5461. {
  5462. Guild* guild = 0;
  5463. bool found = true;
  5464. if (sep->IsNumber(0))
  5465. {
  5466. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5467. if (!guild)
  5468. {
  5469. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5470. found = false;
  5471. }
  5472. }
  5473. else
  5474. {
  5475. guild = guild_list.GetGuild(sep->arg[0]);
  5476. if (!guild)
  5477. {
  5478. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5479. found = false;
  5480. }
  5481. }
  5482. if (found)
  5483. {
  5484. guild->RemoveAllGuildMembers();
  5485. database.DeleteGuild(guild);
  5486. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  5487. guild_list.RemoveGuild(guild, true);
  5488. }
  5489. }
  5490. else
  5491. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  5492. }
  5493. /*
  5494. Function: Command_GuildsList()
  5495. Purpose : Lists current guilds on server
  5496. Params :
  5497. Dev : Scatman
  5498. Example : /guilds list
  5499. */
  5500. void Commands::Command_GuildsList(Client* client)
  5501. {
  5502. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  5503. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  5504. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  5505. if (guilds->size() == 0)
  5506. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  5507. else {
  5508. while (itr.Next()) {
  5509. Guild* guild = itr.second;
  5510. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  5511. }
  5512. }
  5513. }
  5514. /*
  5515. Function: Command_GuildsRemove()
  5516. Purpose : Removes a player from a guild
  5517. Params : guild name|guild id, player name
  5518. Dev : Scatman
  5519. Example : /guilds remove 1 Admin = removes Admin from guild 1
  5520. */
  5521. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  5522. {
  5523. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5524. {
  5525. Guild* guild = 0;
  5526. bool found = true;
  5527. if (sep->IsNumber(0))
  5528. {
  5529. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5530. if (!guild)
  5531. {
  5532. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5533. found = false;
  5534. }
  5535. }
  5536. else
  5537. {
  5538. guild = guild_list.GetGuild(sep->arg[0]);
  5539. if (!guild)
  5540. {
  5541. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5542. found = false;
  5543. }
  5544. }
  5545. if (found)
  5546. {
  5547. Client* to_client = 0;
  5548. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5549. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5550. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5551. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5552. if (to_client)
  5553. {
  5554. Player* to_player = to_client->GetPlayer();
  5555. if (to_player->GetGuild())
  5556. {
  5557. if (to_player->GetGuild() == guild)
  5558. {
  5559. guild->KickGuildMember(client, to_player->GetName());
  5560. }
  5561. else
  5562. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  5563. }
  5564. else
  5565. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  5566. }
  5567. else
  5568. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5569. }
  5570. }
  5571. else
  5572. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  5573. }
  5574. /*
  5575. Function: Command_InspectPlayer()
  5576. Purpose : Handle the Inspect functions
  5577. Params : Client to inspect
  5578. Dev : Scatman
  5579. Example : /inspect Scatman
  5580. */
  5581. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  5582. {
  5583. if (sep && sep->arg[0])
  5584. {
  5585. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  5586. if (inspect_client)
  5587. client->InspectPlayer(inspect_client->GetPlayer());
  5588. }
  5589. else
  5590. {
  5591. Spawn* target = client->GetPlayer()->GetTarget();
  5592. if (target && target->IsPlayer())
  5593. client->InspectPlayer((Player*)target);
  5594. }
  5595. }
  5596. /*
  5597. Function: Command_Inventory()
  5598. Purpose : Handle changes in player inventory
  5599. Params : <TBD>
  5600. Dev : All
  5601. Example : /inventory delete item_id
  5602. */
  5603. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  5604. {
  5605. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  5606. Player* player = client->GetPlayer();
  5607. if(sep && sep->arg[0][0])
  5608. {
  5609. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  5610. if(client->GetPlayer()->GetHP() == 0)
  5611. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  5612. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5613. {
  5614. int16 index = atoi(sep->arg[1]);
  5615. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5616. if(item)
  5617. {
  5618. if(item->GetItemScript() && lua_interface)
  5619. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  5620. int32 bag_id = item->details.inv_slot_id;
  5621. database.DeleteItem(client->GetCharacterID(), item, 0);
  5622. client->GetPlayer()->item_list.DestroyItem(index);
  5623. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  5624. client->QueuePacket(outapp);
  5625. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  5626. if (outapp)
  5627. client->QueuePacket(outapp);
  5628. }
  5629. }
  5630. 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))
  5631. {
  5632. int16 from_index = atoi(sep->arg[1]);
  5633. sint16 to_slot = atoi(sep->arg[2]);
  5634. sint32 bag_id = atol(sep->arg[3]);
  5635. int8 charges = atoi(sep->arg[4]);
  5636. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  5637. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  5638. {
  5639. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  5640. return;
  5641. }
  5642. sint32 old_inventory_id = 0;
  5643. if(item)
  5644. old_inventory_id = item->details.inv_slot_id;
  5645. //autobank
  5646. if (bag_id == -3 && to_slot == -1)
  5647. {
  5648. if (player->HasFreeBankSlot())
  5649. to_slot = player->FindFreeBankSlot();
  5650. else
  5651. {
  5652. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  5653. return;
  5654. }
  5655. }
  5656. //auto inventory
  5657. if (bag_id == 0 && to_slot == -1)
  5658. {
  5659. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5660. {
  5661. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  5662. return;
  5663. }
  5664. }
  5665. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  5666. client->QueuePacket(outapp);
  5667. //removed from bag send update
  5668. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  5669. {
  5670. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  5671. if(outapp)
  5672. client->QueuePacket(outapp);
  5673. }
  5674. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  5675. {
  5676. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  5677. if(outapp)
  5678. client->QueuePacket(outapp);
  5679. }
  5680. }
  5681. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  5682. {
  5683. if(client->GetPlayer()->EngagedInCombat())
  5684. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  5685. else
  5686. {
  5687. int16 index = atoi(sep->arg[1]);
  5688. int8 slot_id = 255;
  5689. if(sep->arg[2][0] && sep->IsNumber(2))
  5690. slot_id = atoi(sep->arg[2]);
  5691. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  5692. EQ2Packet* outapp = 0;
  5693. for(int32 i=0;i<packets.size();i++)
  5694. {
  5695. outapp = packets[i];
  5696. if(outapp)
  5697. client->QueuePacket(outapp);
  5698. }
  5699. client->GetPlayer()->ChangePrimaryWeapon();
  5700. client->GetPlayer()->ChangeSecondaryWeapon();
  5701. client->GetPlayer()->ChangeRangedWeapon();
  5702. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5703. client->QueuePacket(characterSheetPackets);
  5704. }
  5705. }
  5706. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5707. {
  5708. if (client->GetPlayer()->EngagedInCombat())
  5709. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5710. else {
  5711. int16 index = atoi(sep->arg[1]);
  5712. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5713. if (item) {
  5714. // client->GetPlayer()->item_list.DestroyItem(index);
  5715. if (item->item_sets.size() > 0) {
  5716. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5717. ItemSet* set = item->item_sets[i];
  5718. if (set->item_stack_size == 0)
  5719. set->item_stack_size += 1;
  5720. client->AddItem(set->item_id, set->item_stack_size);
  5721. }
  5722. }
  5723. }
  5724. client->RemoveItem(item, 1);
  5725. }
  5726. }
  5727. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5728. {
  5729. if(client->GetPlayer()->EngagedInCombat())
  5730. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5731. else
  5732. {
  5733. int16 index = atoi(sep->arg[1]);
  5734. sint32 bag_id = -999;
  5735. int8 to_slot = 255;
  5736. if(sep->arg[3][0])
  5737. {
  5738. if(sep->IsNumber(2))
  5739. bag_id = atol(sep->arg[2]);
  5740. if(sep->IsNumber(3))
  5741. to_slot = atoi(sep->arg[3]);
  5742. }
  5743. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  5744. EQ2Packet* outapp = 0;
  5745. for(int32 i=0;i<packets.size();i++)
  5746. {
  5747. outapp = packets[i];
  5748. if(outapp)
  5749. client->QueuePacket(outapp);
  5750. }
  5751. client->GetPlayer()->ChangePrimaryWeapon();
  5752. client->GetPlayer()->ChangeSecondaryWeapon();
  5753. client->GetPlayer()->ChangeRangedWeapon();
  5754. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5755. client->QueuePacket(characterSheetPackets);
  5756. }
  5757. }
  5758. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5759. {
  5760. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5761. int16 index1 = atoi(sep->arg[1]);
  5762. int16 index2 = atoi(sep->arg[2]);
  5763. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  5764. if(outapp)
  5765. client->QueuePacket(outapp);
  5766. else
  5767. {
  5768. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5769. return;
  5770. }
  5771. }
  5772. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5773. {
  5774. sint16 to_slot = atoi(sep->arg[1]);
  5775. sint32 bag_id = atoi(sep->arg[2]);
  5776. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5777. if (item) {
  5778. //auto inventory
  5779. if (bag_id == 0 && to_slot == -1)
  5780. {
  5781. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5782. {
  5783. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5784. return;
  5785. }
  5786. // Set the slot for the item
  5787. item->details.inv_slot_id = bag_id;
  5788. item->details.slot_id = to_slot;
  5789. // Flag the item so it gets saved in its new location
  5790. item->save_needed = true;
  5791. // Add the item to its new location
  5792. player->item_list.AddItem(item);
  5793. // Remove the item from the overflow list
  5794. player->item_list.RemoveOverflowItem(item);
  5795. // Send the inventory update packet
  5796. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5797. return;
  5798. }
  5799. else if (bag_id == -3 && to_slot == -1) {
  5800. // Auto Bank
  5801. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5802. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5803. return;
  5804. }
  5805. item->details.inv_slot_id = bag_id;
  5806. item->details.slot_id = to_slot;
  5807. item->save_needed = true;
  5808. player->item_list.AddItem(item);
  5809. player->item_list.RemoveOverflowItem(item);
  5810. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5811. }
  5812. else if (bag_id == -4) {
  5813. // Shared Bank
  5814. if (!player->item_list.SharedBankAddAllowed(item)) {
  5815. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5816. return;
  5817. }
  5818. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5819. if (tmp_item) {
  5820. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5821. return;
  5822. }
  5823. else {
  5824. item->details.inv_slot_id = bag_id;
  5825. item->details.slot_id = to_slot;
  5826. item->save_needed = true;
  5827. player->item_list.AddItem(item);
  5828. player->item_list.RemoveOverflowItem(item);
  5829. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5830. return;
  5831. }
  5832. }
  5833. else {
  5834. // Try to get an item from the given bag id and slot id
  5835. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5836. // Check to see if we got an item, if we do send an error,
  5837. // if we don't put the overflow item into this slot
  5838. if (tmp_item) {
  5839. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5840. }
  5841. else {
  5842. item->details.inv_slot_id = bag_id;
  5843. item->details.slot_id = to_slot;
  5844. item->save_needed = true;
  5845. player->item_list.AddItem(item);
  5846. player->item_list.RemoveOverflowItem(item);
  5847. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5848. return;
  5849. }
  5850. }
  5851. }
  5852. }
  5853. }
  5854. else
  5855. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5856. }
  5857. /*
  5858. Function: Command_IRC()
  5859. Purpose : Handle the IRC functions
  5860. Params : IRC Commands
  5861. Dev : Scatman
  5862. Example : /irc say #Channel Hello World!
  5863. */
  5864. void Commands::Command_IRC(Client* client, Seperator* sep)
  5865. {
  5866. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5867. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5868. return;
  5869. }
  5870. if (sep && sep->arg[0][0]) {
  5871. if (strcasecmp(sep->arg[0], "say") == 0) {
  5872. if (sep->arg[1][0] && sep->arg[2][0]) {
  5873. if (sep->IsNumber(sep->arg[1]))
  5874. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5875. else
  5876. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5877. }
  5878. else
  5879. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5880. }
  5881. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5882. if (sep->arg[1][0])
  5883. irc.JoinChannel(client, sep->arg[1]);
  5884. else
  5885. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5886. }
  5887. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5888. if (sep->arg[1][0])
  5889. irc.LeaveChannel(client, sep->arg[1]);
  5890. else
  5891. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5892. }
  5893. else if (strcasecmp(sep->arg[0], "list") == 0)
  5894. irc.ListChannels(client);
  5895. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5896. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5897. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5898. else
  5899. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5900. }
  5901. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5902. irc.DisconnectFromServer(client);
  5903. else
  5904. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5905. }
  5906. else
  5907. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5908. }
  5909. /*
  5910. Function: Command_Languages()
  5911. Purpose : Show's languages the player knows
  5912. Params :
  5913. Dev : Zcoretri
  5914. Example :
  5915. */
  5916. void Commands::Command_Languages(Client* client, Seperator* sep)
  5917. {
  5918. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5919. list<Language*>::iterator itr;
  5920. Language* language;
  5921. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  5922. for(itr = languages->begin(); itr != languages->end(); itr++)
  5923. {
  5924. language = *itr;
  5925. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  5926. }
  5927. }
  5928. /*
  5929. Function: Command_SetLanguage()
  5930. Purpose : Handles language commands
  5931. Params : Language ID
  5932. Dev : Zcoretri
  5933. Example :
  5934. */
  5935. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5936. {
  5937. Player* player = client->GetPlayer();
  5938. if (sep && sep->arg[0])
  5939. {
  5940. if(!sep->IsNumber(0))
  5941. {
  5942. //String passed in
  5943. const char* value = sep->arg[0];
  5944. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5945. {
  5946. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5947. client->SendLanguagesUpdate(0);
  5948. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  5949. }
  5950. else
  5951. {
  5952. if(player->HasLanguage(value))
  5953. {
  5954. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5955. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5956. client->SendLanguagesUpdate(language->GetID());
  5957. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  5958. }
  5959. else
  5960. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  5961. }
  5962. }
  5963. else
  5964. {
  5965. //Number passed in
  5966. int32 id = atoul(sep->arg[0]);
  5967. if(player->HasLanguage(id))
  5968. {
  5969. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5970. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5971. client->SendLanguagesUpdate(id);
  5972. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  5973. }
  5974. else
  5975. {
  5976. Language* language = master_languages_list.GetLanguage(id);
  5977. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  5978. }
  5979. }
  5980. }
  5981. else
  5982. {
  5983. //No value was passed in
  5984. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5985. if(id > 0)
  5986. {
  5987. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5988. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  5989. }
  5990. else
  5991. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  5992. }
  5993. }
  5994. /*
  5995. Function: Command_LastName()
  5996. Purpose : Sets player surname
  5997. Params : Name text
  5998. Dev : theFoof
  5999. Example :
  6000. */
  6001. void Commands::Command_LastName(Client* client, Seperator* sep)
  6002. {
  6003. if (!client)
  6004. return;
  6005. if (sep && sep->arg[0])
  6006. {
  6007. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6008. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6009. return;
  6010. }
  6011. client->RemovePendingLastName();
  6012. uchar* checkname = (uchar*)sep->arg[0];
  6013. bool valid_name = true;
  6014. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6015. if (!alpha_check(checkname[i])) {
  6016. valid_name = false;
  6017. break;
  6018. }
  6019. }
  6020. if (!valid_name) {
  6021. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6022. return;
  6023. }
  6024. string last_name = (string)sep->arg[0];
  6025. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6026. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6027. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6028. client->SetPendingLastName(last_name);
  6029. client->SendLastNameConfirmation();
  6030. }
  6031. else
  6032. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6033. }
  6034. }
  6035. /*
  6036. Function: Command_ConfirmLastName()
  6037. Purpose : Confirms setting of player surname
  6038. Params : Name text
  6039. Dev : theFoof
  6040. Example :
  6041. */
  6042. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6043. {
  6044. if (!client)
  6045. return;
  6046. string* name = client->GetPendingLastName();
  6047. if (name){
  6048. Player* player = client->GetPlayer();
  6049. player->SetLastName(name->c_str(), false);
  6050. client->SendTitleUpdate();
  6051. player->SetCharSheetChanged(true);
  6052. client->RemovePendingLastName();
  6053. }
  6054. }
  6055. /*
  6056. Function: Command_Location()
  6057. Purpose : Display's Help for /location commands
  6058. Params :
  6059. Dev : Scatman
  6060. Example : /location = show's help for command
  6061. */
  6062. void Commands::Command_Location(Client* client)
  6063. {
  6064. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6066. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6067. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6068. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6069. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6070. }
  6071. /*
  6072. Function: Command_LocationAdd()
  6073. Purpose : Add's a location to an existing location config
  6074. Params : location_id
  6075. Dev : Scatman
  6076. Example : /location add {location_id}
  6077. */
  6078. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6079. {
  6080. if (sep && sep->arg[0] && sep->IsNumber(0))
  6081. {
  6082. int32 location_id = atoul(sep->arg[0]);
  6083. float x = client->GetPlayer()->GetX();
  6084. float y = client->GetPlayer()->GetY();
  6085. float z = client->GetPlayer()->GetZ();
  6086. if (database.AddLocationPoint(location_id, x, y, z))
  6087. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6088. else
  6089. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6090. }
  6091. else
  6092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6093. }
  6094. /*
  6095. Function: Command_LocationCreate()
  6096. Purpose : Creates a new location config
  6097. Params : location name, 0/1 for include_y (optional)
  6098. Dev : Scatman
  6099. Example : /location create Test 1 = creates a new location named Test with include_y True
  6100. */
  6101. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6102. {
  6103. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6104. {
  6105. const char* name = sep->arg[0];
  6106. bool include_y = false;
  6107. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6108. include_y = true;
  6109. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  6110. if (location_id > 0)
  6111. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6112. else
  6113. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6114. }
  6115. else
  6116. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6117. }
  6118. /*
  6119. Function: Command_LocationDelete()
  6120. Purpose : Delete's a location config and all it's location points
  6121. Params : location_id
  6122. Dev : Scatman
  6123. Example : /location delete {location_id}
  6124. */
  6125. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6126. {
  6127. if (sep && sep->arg[0] && sep->IsNumber(0))
  6128. {
  6129. int32 location_id = atoul(sep->arg[0]);
  6130. if (database.DeleteLocation(location_id))
  6131. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6132. else
  6133. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6134. }
  6135. else
  6136. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6137. }
  6138. /*
  6139. Function: Command_LocationList()
  6140. Purpose : Display's a list of location points
  6141. Params : location_id
  6142. Dev : Scatman
  6143. Example : /location list {location_id}
  6144. */
  6145. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6146. {
  6147. if (sep && sep->arg[0])
  6148. {
  6149. const char* option = sep->arg[0];
  6150. if (strncmp(option, "locations", strlen(option)) == 0)
  6151. database.ListLocations(client);
  6152. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  6153. {
  6154. int32 location_id = atoul(sep->arg[1]);
  6155. database.ListLocationPoints(client, location_id);
  6156. }
  6157. else
  6158. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6159. }
  6160. else
  6161. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6162. }
  6163. /*
  6164. Function: Command_LocationRemove()
  6165. Purpose : Removes a single location point from a location config
  6166. Params : location_point_id (gotten from /location list {id})
  6167. Dev : Scatman
  6168. Example : /location remove 1 = will remove location_point_id 1
  6169. */
  6170. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  6171. {
  6172. if (sep && sep->arg[0] && sep->IsNumber(0))
  6173. {
  6174. int32 location_point_id = atoul(sep->arg[0]);
  6175. if (database.DeleteLocationPoint(location_point_id))
  6176. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  6177. else
  6178. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  6179. }
  6180. else
  6181. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  6182. }
  6183. /*
  6184. Function: Command_Merchant()
  6185. Purpose : Handles Merchant commands
  6186. Params : list
  6187. Dev : Scatman
  6188. Example : /merchant list
  6189. */
  6190. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  6191. {
  6192. if( handler == COMMAND_MERCHANT )
  6193. {
  6194. // /merchant command by itself shows help (to be extended)
  6195. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6196. return;
  6197. }
  6198. else if( handler == COMMAND_MERCHANT_LIST )
  6199. {
  6200. // /merchant list command expects "description" param
  6201. if (sep && sep->arg[0])
  6202. {
  6203. const char* merchant_description = sep->argplus[0];
  6204. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  6205. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  6206. map<int32, MerchantInfo*>::iterator itr;
  6207. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  6208. {
  6209. string description = database.GetMerchantDescription(itr->first);
  6210. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  6211. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  6212. }
  6213. }
  6214. else // no description
  6215. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6216. }
  6217. }
  6218. /*
  6219. Function: Command_Modify()
  6220. Purpose : to replace our other "set" commands
  6221. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  6222. Dev : John Adams
  6223. Example : /modify spell set name "Aegolism III"
  6224. */
  6225. void Commands::Command_Modify(Client* client)
  6226. {
  6227. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  6228. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  6229. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  6230. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  6231. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  6232. }
  6233. /*
  6234. Function: Command_ModifySpawn()
  6235. Purpose : replace "spawn set" commands
  6236. Params : Action : the action to perform (or special handler)
  6237. : Field : the DB field to change
  6238. : Value : what to set the value to
  6239. : Target : what object to change (my target, or spawn_id)
  6240. Dev : John Adams
  6241. Example : /modify spawn set name "Lady Vox"
  6242. :
  6243. Note : Special Handlers, like "zoneto" for Signs
  6244. : /modify spawn zoneto
  6245. : Will set a sign's zone x/y/z to my current coords
  6246. */
  6247. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  6248. {
  6249. PrintSep(sep, "COMMAND_MODIFY");
  6250. // need at least 2 args for a valid command
  6251. if( sep && sep->arg[1] )
  6252. {
  6253. // JA: just a quick implementation because I need it :)
  6254. if (strcmp(sep->arg[0], "zoneto") == 0)
  6255. {
  6256. if( sep->IsNumber(1) )
  6257. {
  6258. int32 spawn_id = atoul(sep->arg[1]);
  6259. float x_coord = client->GetPlayer()->GetX();
  6260. float y_coord = client->GetPlayer()->GetY();
  6261. float z_coord = client->GetPlayer()->GetZ();
  6262. float h_coord = client->GetPlayer()->GetHeading();
  6263. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  6264. }
  6265. else
  6266. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  6267. }
  6268. }
  6269. else
  6270. Command_Modify(client);
  6271. }
  6272. /*
  6273. Function: Command_ModifyCharacter()
  6274. Purpose : to replace our other "set" commands
  6275. Params : Action : Add, Remove
  6276. : Field : copper, silver, gold, plat
  6277. : Value : min 1, max unlimited
  6278. : Target : Self, Player
  6279. Dev : Cynnar
  6280. Example : /modify character add gold 50
  6281. : /modify character remove silver 25
  6282. */
  6283. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  6284. {
  6285. PrintSep(sep, "COMMAND_MODIFY");
  6286. int64 value = 0;
  6287. Player* player = client->GetPlayer();
  6288. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  6289. player = (Player*)player->GetTarget();
  6290. // need at least 2 args for a valid command
  6291. if( sep && sep->arg[1] )
  6292. {
  6293. if (strcmp(sep->arg[0], "add") == 0)
  6294. {
  6295. if (strcmp(sep->arg[1], "copper") == 0)
  6296. {
  6297. value = atoi64(sep->arg[2]);
  6298. player->AddCoins(value);
  6299. if (client->GetPlayer() == player)
  6300. {
  6301. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  6302. }
  6303. else {
  6304. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  6305. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  6306. }
  6307. }
  6308. else if (strcmp(sep->arg[1], "silver") == 0)
  6309. {
  6310. value = atoi64(sep->arg[2]) * 100;
  6311. player->AddCoins(value);
  6312. if (client->GetPlayer() == player)
  6313. {
  6314. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  6315. }
  6316. else {
  6317. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  6318. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  6319. }
  6320. }
  6321. else if (strcmp(sep->arg[1], "gold") == 0)
  6322. {
  6323. value = atoi64(sep->arg[2]) * 10000;
  6324. player->AddCoins(value);
  6325. if (client->GetPlayer() == player)
  6326. {
  6327. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  6328. }
  6329. else {
  6330. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6331. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6332. }
  6333. }
  6334. else if (strcmp(sep->arg[1], "plat") == 0)
  6335. {
  6336. value = atoi64(sep->arg[2]) * 1000000;
  6337. player->AddCoins(value);
  6338. if (client->GetPlayer() == player)
  6339. {
  6340. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  6341. }
  6342. else {
  6343. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  6344. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  6345. }
  6346. }
  6347. else
  6348. {
  6349. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  6350. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  6351. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  6352. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  6353. }
  6354. }
  6355. else if (strcmp(sep->arg[0], "remove") == 0)
  6356. {
  6357. if (strcmp(sep->arg[1], "copper") == 0)
  6358. {
  6359. value = atoi64(sep->arg[2]);
  6360. player->RemoveCoins(value);
  6361. if (client->GetPlayer() == player)
  6362. {
  6363. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  6364. }
  6365. else {
  6366. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  6367. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  6368. }
  6369. }
  6370. else if (strcmp(sep->arg[1], "silver") == 0)
  6371. {
  6372. value = atoi64(sep->arg[2]) * 100;
  6373. player->RemoveCoins(value);
  6374. if (client->GetPlayer() == player)
  6375. {
  6376. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  6377. }
  6378. else {
  6379. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  6380. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  6381. }
  6382. }
  6383. else if (strcmp(sep->arg[1], "gold") == 0)
  6384. {
  6385. value = atoi64(sep->arg[2]) * 10000;
  6386. player->RemoveCoins(value);
  6387. if (client->GetPlayer() == player)
  6388. {
  6389. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  6390. }
  6391. else {
  6392. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  6393. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6394. }
  6395. }
  6396. else if (strcmp(sep->arg[1], "plat") == 0)
  6397. {
  6398. value = atoi64(sep->arg[2]) * 1000000;
  6399. player->RemoveCoins(value);
  6400. if (client->GetPlayer() == player)
  6401. {
  6402. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  6403. }
  6404. else {
  6405. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  6406. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  6407. }
  6408. }
  6409. else
  6410. {
  6411. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  6412. }
  6413. }
  6414. else if (strcmp(sep->arg[0], "set") == 0) {
  6415. if (strcmp(sep->arg[1], "tslevel") == 0) {
  6416. int8 level = atoi(sep->arg[2]);
  6417. if (level > 0 && level < 256) {
  6418. if (player) {
  6419. if (client->GetPlayer() == player)
  6420. client->ChangeTSLevel(player->GetTSLevel(), level);
  6421. else
  6422. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  6423. }
  6424. }
  6425. else
  6426. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  6427. }
  6428. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  6429. int8 tsclass = atoi(sep->arg[2]);
  6430. player->SetTradeskillClass(tsclass);
  6431. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  6432. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  6433. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  6434. player->SetCharSheetChanged(true);
  6435. }
  6436. }
  6437. }
  6438. else
  6439. {
  6440. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  6441. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  6442. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  6443. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  6444. }
  6445. }
  6446. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  6447. {
  6448. PrintSep(sep, "COMMAND_MODIFY");
  6449. // need at least 2 args for a valid command
  6450. if( sep && sep->arg[1] )
  6451. {
  6452. }
  6453. else
  6454. Command_Modify(client);
  6455. }
  6456. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  6457. {
  6458. PrintSep(sep, "COMMAND_MODIFY");
  6459. // need at least 2 args for a valid command
  6460. if( sep && sep->arg[1] )
  6461. {
  6462. }
  6463. else
  6464. Command_Modify(client);
  6465. }
  6466. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  6467. {
  6468. PrintSep(sep, "COMMAND_MODIFY");
  6469. // need at least 2 args for a valid command
  6470. if( sep && sep->arg[1] )
  6471. {
  6472. }
  6473. else
  6474. Command_Modify(client);
  6475. }
  6476. /*
  6477. Function: Command_ModifyQuest()
  6478. Purpose : to list players quest and completed quests
  6479. Params : Action : list, completed
  6480. : Target : Self, Player
  6481. Dev : Cynnar
  6482. Example : /modify quest list
  6483. : /modify quest completed
  6484. */
  6485. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  6486. {
  6487. PrintSep(sep, "COMMAND_MODIFY");
  6488. int64 value = 0;
  6489. Player* player = client->GetPlayer();
  6490. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  6491. player = (Player*)player->GetTarget();
  6492. // need at least 2 args for a valid command
  6493. if (sep && sep->arg[1])
  6494. {
  6495. if (strcmp(sep->arg[0], "list") == 0)
  6496. {
  6497. map<int32, Quest*>* quests = player->GetPlayerQuests();
  6498. map<int32, Quest*>::iterator itr;
  6499. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  6500. if (quests->size() == 0)
  6501. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  6502. else
  6503. {
  6504. for (itr = quests->begin(); itr != quests->end(); itr++)
  6505. {
  6506. Quest* quest = itr->second;
  6507. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6508. }
  6509. }
  6510. }
  6511. else if (strcmp(sep->arg[0], "completed") == 0)
  6512. {
  6513. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  6514. map<int32, Quest*>::iterator itr;
  6515. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  6516. if (quests->size() == 0)
  6517. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  6518. else
  6519. {
  6520. for (itr = quests->begin(); itr != quests->end(); itr++)
  6521. {
  6522. Quest* quest = itr->second;
  6523. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6524. }
  6525. }
  6526. }
  6527. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  6528. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  6529. else if (strcmp(sep->arg[0], "remove") == 0)
  6530. {
  6531. int32 quest_id = 0;
  6532. if (sep && sep->arg[1] && sep->IsNumber(1))
  6533. quest_id = atoul(sep->arg[1]);
  6534. if (quest_id > 0)
  6535. {
  6536. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  6537. {
  6538. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6539. if (quest)
  6540. if (client->GetPlayer() == player)
  6541. {
  6542. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  6543. }
  6544. else
  6545. {
  6546. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  6547. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  6548. }
  6549. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  6550. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  6551. }
  6552. client->RemovePlayerQuest(quest_id);
  6553. client->GetCurrentZone()->SendQuestUpdates(client);
  6554. }
  6555. }
  6556. else if (strcmp(sep->arg[0], "advance") == 0)
  6557. {
  6558. int32 quest_id = 0;
  6559. int32 step = 0;
  6560. if (sep && sep->arg[1] && sep->IsNumber(1))
  6561. {
  6562. quest_id = atoul(sep->arg[1]);
  6563. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6564. if (sep && sep->arg[2] && sep->IsNumber(1))
  6565. {
  6566. step = atoul(sep->arg[2]);
  6567. if (quest_id > 0 && step > 0)
  6568. {
  6569. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  6570. {
  6571. if (client)
  6572. {
  6573. client->AddPendingQuestUpdate(quest_id, step);
  6574. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  6575. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  6576. }
  6577. }
  6578. }
  6579. else
  6580. {
  6581. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  6582. }
  6583. }
  6584. else
  6585. {
  6586. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  6587. }
  6588. }
  6589. else
  6590. {
  6591. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  6592. }
  6593. }
  6594. else
  6595. {
  6596. Command_Modify(client);
  6597. }
  6598. }
  6599. else
  6600. {
  6601. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  6602. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  6603. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  6604. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  6605. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  6606. }
  6607. }
  6608. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  6609. {
  6610. PrintSep(sep, "COMMAND_MODIFY");
  6611. // need at least 2 args for a valid command
  6612. if( sep && sep->arg[1] )
  6613. {
  6614. if (strcmp(sep->arg[0], "add") == 0) {
  6615. const char* skill_name = sep->argplus[1];
  6616. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6617. if (skill) {
  6618. Player* player = 0;
  6619. Client* to_client = 0;
  6620. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6621. player = (Player*)client->GetPlayer()->GetTarget();
  6622. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6623. }
  6624. else {
  6625. player = client->GetPlayer();
  6626. to_client = client;
  6627. }
  6628. if (player)
  6629. {
  6630. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6631. {
  6632. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6633. if (to_client == client) {
  6634. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  6635. }
  6636. else {
  6637. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6638. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6639. }
  6640. }
  6641. else
  6642. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  6643. }
  6644. }
  6645. else
  6646. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6647. }
  6648. else if (strcmp(sep->arg[0], "remove") == 0) {
  6649. const char* skill_name = sep->argplus[1];
  6650. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6651. if (skill) {
  6652. Player* player = 0;
  6653. Client* to_client = 0;
  6654. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6655. player = (Player*)client->GetPlayer()->GetTarget();
  6656. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6657. }
  6658. else {
  6659. player = client->GetPlayer();
  6660. to_client = client;
  6661. }
  6662. if (player)
  6663. {
  6664. if (player->GetSkills()->HasSkill(skill->skill_id))
  6665. {
  6666. player->RemoveSkillFromDB(skill, true);
  6667. if (client == to_client) {
  6668. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  6669. }
  6670. else {
  6671. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6672. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6673. }
  6674. }
  6675. else {
  6676. if (client == to_client)
  6677. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  6678. else
  6679. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6680. }
  6681. }
  6682. }
  6683. else
  6684. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6685. }
  6686. else if (strcmp(sep->arg[0], "set") == 0) {
  6687. if (!sep->IsNumber(2)) {
  6688. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  6689. return;
  6690. }
  6691. const char* skill_name = sep->arg[1];
  6692. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6693. if (skill) {
  6694. int16 val = atoi(sep->arg[2]);
  6695. Player* player = 0;
  6696. Client* to_client = 0;
  6697. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6698. player = (Player*)client->GetPlayer()->GetTarget();
  6699. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6700. }
  6701. else {
  6702. player = client->GetPlayer();
  6703. to_client = client;
  6704. }
  6705. if (player)
  6706. {
  6707. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6708. player->GetSkills()->SetSkill(skill->skill_id, val);
  6709. if (client != to_client)
  6710. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6711. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6712. }
  6713. else {
  6714. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6715. }
  6716. }
  6717. }
  6718. else {
  6719. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6720. }
  6721. }
  6722. else {
  6723. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6724. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6725. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6726. }
  6727. }
  6728. else {
  6729. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6730. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6731. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6732. }
  6733. }
  6734. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6735. {
  6736. PrintSep(sep, "COMMAND_MODIFY");
  6737. // need at least 2 args for a valid command
  6738. if( sep && sep->arg[1] )
  6739. {
  6740. }
  6741. else
  6742. Command_Modify(client);
  6743. }
  6744. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6745. {
  6746. PrintSep(sep, "COMMAND_MODIFY");
  6747. // need at least 2 args for a valid command
  6748. if( sep && sep->arg[1] )
  6749. {
  6750. }
  6751. else
  6752. Command_Modify(client);
  6753. }
  6754. /*
  6755. Function: Command_MOTD()
  6756. Purpose : Displays server MOTD
  6757. Params :
  6758. Dev : LethalEncounter
  6759. Example : /motd
  6760. */
  6761. void Commands::Command_MOTD(Client* client)
  6762. {
  6763. if (client)
  6764. ClientPacketFunctions::SendMOTD(client);
  6765. }
  6766. /*
  6767. Function: Command_Pet()
  6768. Purpose : Handle Pet {Command} commands
  6769. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6770. Dev :
  6771. Example : /pet preserve_master
  6772. */
  6773. void Commands::Command_Pet(Client* client, Seperator* sep)
  6774. {
  6775. PrintSep(sep, "COMMAND_PET");
  6776. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6777. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6778. if (!sep || !sep->arg[0])
  6779. return; // should have sep->arg[0] filled
  6780. if (strcmp(sep->arg[0], "hide") == 0) {
  6781. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6782. Entity* pet = client->GetPlayer()->GetDeityPet();
  6783. if (pet) {
  6784. if (pet->IsPrivateSpawn())
  6785. client->GetPlayer()->HideDeityPet(false);
  6786. else
  6787. client->GetPlayer()->HideDeityPet(true);
  6788. }
  6789. pet = client->GetPlayer()->GetCosmeticPet();
  6790. if (pet) {
  6791. if (pet->IsPrivateSpawn())
  6792. client->GetPlayer()->HideCosmeticPet(false);
  6793. else
  6794. client->GetPlayer()->HideCosmeticPet(true);
  6795. }
  6796. return;
  6797. }
  6798. // below is for all combat pets
  6799. if (!client->GetPlayer()->HasPet()) {
  6800. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6801. return;
  6802. }
  6803. if (strcmp(sep->arg[0], "stay") == 0) {
  6804. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6805. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  6806. client->GetPlayer()->SetCharSheetChanged(true);
  6807. if (client->GetPlayer()->GetPet())
  6808. client->GetPlayer()->GetPet()->following = false;
  6809. if (client->GetPlayer()->GetCharmedPet())
  6810. client->GetPlayer()->GetCharmedPet()->following = false;
  6811. }
  6812. else if (strcmp(sep->arg[0], "follow") == 0) {
  6813. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6814. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  6815. client->GetPlayer()->SetCharSheetChanged(true);
  6816. }
  6817. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6818. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  6819. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6820. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  6821. }
  6822. else {
  6823. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6824. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  6825. }
  6826. client->GetPlayer()->SetCharSheetChanged(true);
  6827. }
  6828. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6829. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  6830. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6831. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  6832. }
  6833. else {
  6834. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6835. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  6836. }
  6837. client->GetPlayer()->SetCharSheetChanged(true);
  6838. }
  6839. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6840. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6841. if (client->GetPlayer()->GetPet())
  6842. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6843. if (client->GetPlayer()->GetCharmedPet())
  6844. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6845. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  6846. client->GetPlayer()->SetCharSheetChanged(true);
  6847. }
  6848. else if (strcmp(sep->arg[0], "attack") == 0) {
  6849. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6850. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6851. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6852. if (client->GetPlayer()->GetPet())
  6853. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6854. if (client->GetPlayer()->GetCharmedPet())
  6855. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6856. }
  6857. else
  6858. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6859. }
  6860. else
  6861. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6862. }
  6863. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6864. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6865. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6866. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6867. }
  6868. else
  6869. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6870. }
  6871. /*
  6872. Function: Command_PetName()
  6873. Purpose : Pet your name (???)
  6874. Params :
  6875. Dev :
  6876. Example :
  6877. */
  6878. void Commands::Command_PetName(Client* client, Seperator* sep)
  6879. {
  6880. PrintSep(sep, "COMMAND_PETNAME");
  6881. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6882. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6883. }
  6884. /*
  6885. Function: Command_NamePet()
  6886. Purpose : Name your pet
  6887. Params :
  6888. Dev :
  6889. Example :
  6890. */
  6891. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6892. {
  6893. PrintSep(sep, "COMMAND_NAME_PET");
  6894. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6895. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6896. }
  6897. /*
  6898. Function: Command_Rename()
  6899. Purpose : Renames existing pet
  6900. Params :
  6901. Dev :
  6902. Example :
  6903. */
  6904. void Commands::Command_Rename(Client* client, Seperator* sep)
  6905. {
  6906. PrintSep(sep, "COMMAND_RENAME");
  6907. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6908. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6909. }
  6910. /*
  6911. Function: Command_ConfirmRename()
  6912. Purpose : Confirms renaming your pet
  6913. Params :
  6914. Dev :
  6915. Example :
  6916. */
  6917. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6918. {
  6919. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6920. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6921. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6922. }
  6923. /*
  6924. Function: Command_PetOptions()
  6925. Purpose : Sets various pet options
  6926. Params :
  6927. Dev :
  6928. Example :
  6929. */
  6930. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6931. {
  6932. PrintSep(sep, "COMMAND_PETOPTIONS");
  6933. Player* player = client->GetPlayer();
  6934. Spawn* target = player->GetTarget();
  6935. if (!target)
  6936. return;
  6937. if (target == player->GetPet())
  6938. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6939. else if (target == player->GetCharmedPet())
  6940. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6941. else if (target == player->GetCosmeticPet())
  6942. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6943. else if (target == player->GetDeityPet())
  6944. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6945. }
  6946. /*
  6947. Function: Command_Random()
  6948. Purpose : Handles /random dice roll in-game
  6949. Params : 1-100
  6950. Dev : Scatman
  6951. Example : /randon 1 100
  6952. */
  6953. void Commands::Command_Random(Client* client, Seperator* sep)
  6954. {
  6955. char message[256] = {0};
  6956. if (sep)
  6957. {
  6958. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6959. 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])));
  6960. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6961. 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])));
  6962. else
  6963. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6964. }
  6965. else
  6966. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6967. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6968. }
  6969. /*
  6970. Function: Command_Randomize()
  6971. Purpose : Sets randomize (appearance) values for NPCs
  6972. Params : Attrib Name
  6973. Dev : Scatman
  6974. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6975. */
  6976. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6977. {
  6978. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6979. if (target)
  6980. {
  6981. if (target->IsNPC())
  6982. {
  6983. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6984. {
  6985. const char* value = sep->arg[0];
  6986. if (strncasecmp(value, "show", strlen(value)) == 0)
  6987. {
  6988. client->DisplayRandomizeFeatures(target->GetRandomize());
  6989. }
  6990. else
  6991. {
  6992. if (sep->arg[1] && sep->IsNumber(1))
  6993. {
  6994. int8 option = atoi(sep->arg[1]);
  6995. if (option == 0 || option == 1)
  6996. {
  6997. int32 feature = 0;
  6998. char feature_text[32] = {0};
  6999. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7000. feature = RANDOMIZE_GENDER;
  7001. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7002. }
  7003. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7004. feature = RANDOMIZE_RACE;
  7005. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7006. }
  7007. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7008. feature = RANDOMIZE_MODEL_TYPE;
  7009. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7010. }
  7011. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7012. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7013. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7014. }
  7015. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7016. feature = RANDOMIZE_HAIR_TYPE;
  7017. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7018. }
  7019. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7020. feature = RANDOMIZE_WING_TYPE;
  7021. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7022. }
  7023. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7024. feature = RANDOMIZE_CHEEK_TYPE;
  7025. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7026. }
  7027. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7028. feature = RANDOMIZE_CHIN_TYPE;
  7029. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7030. }
  7031. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7032. feature = RANDOMIZE_EAR_TYPE;
  7033. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7034. }
  7035. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7036. feature = RANDOMIZE_EYE_BROW_TYPE;
  7037. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7038. }
  7039. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7040. feature = RANDOMIZE_EYE_TYPE;
  7041. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7042. }
  7043. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7044. feature = RANDOMIZE_LIP_TYPE;
  7045. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7046. }
  7047. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7048. feature = RANDOMIZE_NOSE_TYPE;
  7049. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7050. }
  7051. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7052. feature = RANDOMIZE_EYE_COLOR;
  7053. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7054. }
  7055. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7056. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7057. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7058. }
  7059. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7060. feature = RANDOMIZE_HAIR_COLOR1;
  7061. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7062. }
  7063. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7064. feature = RANDOMIZE_HAIR_COLOR2;
  7065. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7066. }
  7067. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7068. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7069. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7070. }
  7071. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7072. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7073. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7074. }
  7075. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7076. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7077. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7078. }
  7079. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7080. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7081. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7082. }
  7083. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7084. feature = RANDOMIZE_SKIN_COLOR;
  7085. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7086. }
  7087. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7088. feature = RANDOMIZE_WING_COLOR1;
  7089. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7090. }
  7091. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7092. feature = RANDOMIZE_WING_COLOR2;
  7093. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7094. }
  7095. else {
  7096. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7097. 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'.");
  7098. }
  7099. if (feature > 0) {
  7100. if (option == 1) {
  7101. if (target->GetRandomize() & feature)
  7102. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  7103. else {
  7104. target->AddRandomize(feature);
  7105. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  7106. database.UpdateRandomize(target->GetDatabaseID(), feature);
  7107. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  7108. }
  7109. }
  7110. else {
  7111. if (target->GetRandomize() & feature) {
  7112. target->AddRandomize(-feature);
  7113. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  7114. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  7115. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  7116. }
  7117. else
  7118. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  7119. }
  7120. }
  7121. }
  7122. else
  7123. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7124. }
  7125. else
  7126. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7127. }
  7128. }
  7129. else {
  7130. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  7131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  7132. 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'.");
  7133. }
  7134. }
  7135. else
  7136. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  7137. }
  7138. else
  7139. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  7140. }
  7141. /*
  7142. Function: Command_ShowCloak()
  7143. Purpose : Character Settings combo box for Show Cloak
  7144. Params : true/false
  7145. Dev : John Adams
  7146. Example :
  7147. */
  7148. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  7149. {
  7150. Player* player = client->GetPlayer();
  7151. if (sep && sep->arg[0])
  7152. {
  7153. const char* value = sep->arg[0];
  7154. if (strncasecmp(value, "true", strlen(value)) == 0)
  7155. {
  7156. player->set_character_flag(CF_SHOW_CLOAK);
  7157. player->reset_character_flag(CF2_SHOW_RANGED);
  7158. }
  7159. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7160. player->reset_character_flag(CF_SHOW_CLOAK);
  7161. else
  7162. {
  7163. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7164. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7165. }
  7166. }
  7167. }
  7168. /*
  7169. Function: Command_ShowHelm()
  7170. Purpose : Character Settings combo box for Show Helm
  7171. Params : true/false
  7172. Dev : John Adams
  7173. Example :
  7174. */
  7175. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  7176. {
  7177. Player* player = client->GetPlayer();
  7178. if (sep && sep->arg[0])
  7179. {
  7180. const char* value = sep->arg[0];
  7181. if (strncasecmp(value, "true", strlen(value)) == 0)
  7182. {
  7183. player->reset_character_flag(CF_HIDE_HELM);
  7184. player->set_character_flag(CF_HIDE_HOOD);
  7185. }
  7186. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7187. player->set_character_flag(CF_HIDE_HELM);
  7188. else
  7189. {
  7190. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7191. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7192. }
  7193. }
  7194. }
  7195. /*
  7196. Function: Command_ShowHood()
  7197. Purpose : Character Settings combo box for Show Hood
  7198. Params : true/false
  7199. Dev : John Adams
  7200. Example :
  7201. */
  7202. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  7203. {
  7204. Player* player = client->GetPlayer();
  7205. if (sep && sep->arg[0])
  7206. {
  7207. const char* value = sep->arg[0];
  7208. if (strncasecmp(value, "true", strlen(value)) == 0)
  7209. {
  7210. player->reset_character_flag(CF_HIDE_HOOD);
  7211. player->set_character_flag(CF_HIDE_HELM);
  7212. }
  7213. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7214. player->set_character_flag(CF_HIDE_HOOD);
  7215. else
  7216. {
  7217. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7218. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7219. }
  7220. }
  7221. }
  7222. /*
  7223. Function: Command_ShowHoodHelm()
  7224. Purpose : Character Settings combo box for Show Helm or Hood
  7225. Params : true/false
  7226. Dev : John Adams
  7227. Example :
  7228. */
  7229. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  7230. {
  7231. Player* player = client->GetPlayer();
  7232. if (sep && sep->arg[0])
  7233. {
  7234. const char* value = sep->arg[0];
  7235. if (strncasecmp(value, "true", strlen(value)) == 0)
  7236. {
  7237. player->reset_character_flag(CF_HIDE_HOOD);
  7238. player->reset_character_flag(CF_HIDE_HELM);
  7239. }
  7240. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7241. {
  7242. // don't think we ever wind up in here...
  7243. player->set_character_flag(CF_HIDE_HOOD);
  7244. player->set_character_flag(CF_HIDE_HELM);
  7245. }
  7246. else
  7247. {
  7248. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7249. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7250. }
  7251. }
  7252. }
  7253. /*
  7254. Function: Command_ShowRanged()
  7255. Purpose : Character Settings combo box for Show Ranged weapon
  7256. Params : true/false
  7257. Dev : John Adams
  7258. Example :
  7259. */
  7260. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  7261. {
  7262. Player* player = client->GetPlayer();
  7263. if (sep && sep->arg[0])
  7264. {
  7265. const char* value = sep->arg[0];
  7266. if (strncasecmp(value, "true", strlen(value)) == 0)
  7267. {
  7268. player->set_character_flag(CF2_SHOW_RANGED);
  7269. player->reset_character_flag(CF_SHOW_CLOAK);
  7270. }
  7271. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7272. player->reset_character_flag(CF2_SHOW_RANGED);
  7273. else
  7274. {
  7275. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7276. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7277. }
  7278. }
  7279. }
  7280. /*
  7281. Function:
  7282. Purpose :
  7283. Params :
  7284. Dev :
  7285. Example :
  7286. */
  7287. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  7288. {
  7289. Player* player = 0;
  7290. Client* to_client = 0;
  7291. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  7292. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  7293. switch(handler)
  7294. {
  7295. case COMMAND_SKILL:
  7296. {
  7297. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  7298. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  7299. break;
  7300. }
  7301. case COMMAND_SKILL_ADD:
  7302. {
  7303. if (sep && sep->arg[0])
  7304. {
  7305. const char* skill_name = sep->argplus[0];
  7306. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7307. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  7308. {
  7309. player = to_client->GetPlayer();
  7310. if (player)
  7311. {
  7312. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7313. {
  7314. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7315. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7316. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7317. }
  7318. else
  7319. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  7320. }
  7321. }
  7322. else if (skill) // add skill to yourself
  7323. {
  7324. player = client->GetPlayer();
  7325. if (player)
  7326. {
  7327. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7328. {
  7329. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7330. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  7331. }
  7332. else
  7333. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  7334. }
  7335. }
  7336. else
  7337. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  7338. }
  7339. else
  7340. {
  7341. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  7342. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  7343. }
  7344. break;
  7345. }
  7346. case COMMAND_SKILL_REMOVE:
  7347. {
  7348. if (sep && sep->arg[0])
  7349. {
  7350. const char* skill_name = sep->argplus[0];
  7351. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7352. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  7353. {
  7354. player = to_client->GetPlayer();
  7355. if (player)
  7356. {
  7357. if (player->GetSkills()->HasSkill(skill->skill_id))
  7358. {
  7359. player->RemoveSkillFromDB(skill, true);
  7360. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7361. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7362. }
  7363. else
  7364. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7365. }
  7366. }
  7367. else if(skill) // remove skill from yourself
  7368. {
  7369. Player* player = client->GetPlayer();
  7370. if (player)
  7371. {
  7372. if (player->GetSkills()->HasSkill(skill->skill_id))
  7373. {
  7374. player->RemoveSkillFromDB(skill, true);
  7375. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  7376. }
  7377. else
  7378. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  7379. }
  7380. }
  7381. else
  7382. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  7383. }
  7384. else
  7385. {
  7386. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  7387. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  7388. }
  7389. break;
  7390. }
  7391. case COMMAND_SKILL_LIST:
  7392. {
  7393. if (sep && sep->arg[0])
  7394. {
  7395. const char* skill_name = sep->argplus[0];
  7396. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  7397. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  7398. map<int32, Skill*>::iterator itr;
  7399. if (skills && skills->size() > 0)
  7400. {
  7401. for (itr = skills->begin(); itr != skills->end(); itr++)
  7402. {
  7403. Skill* skill = itr->second;
  7404. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  7405. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  7406. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  7407. }
  7408. }
  7409. }
  7410. else
  7411. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  7412. break;
  7413. }
  7414. }
  7415. }
  7416. /*
  7417. Function: Command_SpawnTemplate()
  7418. Purpose : Create or Use defined Spawn Templates
  7419. Params : create, save, rempve, list
  7420. Dev : John Adams
  7421. Example : /spawn template create "Test"
  7422. */
  7423. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  7424. {
  7425. if (sep == NULL || sep->arg[0] == NULL)
  7426. {
  7427. 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.");
  7428. return;
  7429. }
  7430. // got params, continue
  7431. const char * template_cmd = sep->arg[0];
  7432. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  7433. {
  7434. if (!sep->IsSet(1))
  7435. {
  7436. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  7437. 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.");
  7438. return;
  7439. }
  7440. map<int32, string>* template_names = 0;
  7441. if (sep->IsNumber(1))
  7442. {
  7443. int32 location_id = 0;
  7444. location_id = atoi(sep->arg[1]);
  7445. template_names = database.GetSpawnTemplateListByID(location_id);
  7446. }
  7447. else
  7448. {
  7449. const char* name = 0;
  7450. name = sep->argplus[1];
  7451. template_names = database.GetSpawnTemplateListByName(name);
  7452. }
  7453. if(!template_names)
  7454. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  7455. else
  7456. {
  7457. map<int32, string>::iterator itr;
  7458. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  7459. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  7460. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  7461. safe_delete(template_names);
  7462. }
  7463. }
  7464. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  7465. {
  7466. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7467. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  7468. {
  7469. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  7470. {
  7471. // first, lookup to see if template name already exists
  7472. const char* name = 0;
  7473. name = sep->argplus[1];
  7474. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  7475. if(!template_names)
  7476. {
  7477. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  7478. if( new_template_id > 0 )
  7479. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  7480. else
  7481. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  7482. }
  7483. else
  7484. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  7485. }
  7486. else
  7487. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  7488. }
  7489. else
  7490. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  7491. }
  7492. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  7493. {
  7494. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  7495. {
  7496. int32 template_id = 0;
  7497. template_id = atoi(sep->arg[1]);
  7498. if (database.RemoveSpawnTemplate(template_id))
  7499. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  7500. else
  7501. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  7502. }
  7503. else
  7504. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  7505. }
  7506. // Renamed create to spawn
  7507. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  7508. {
  7509. if (sep && sep->arg[1][0])
  7510. {
  7511. int32 new_location = 0;
  7512. if (sep->IsNumber(1))
  7513. {
  7514. int32 template_id = 0;
  7515. template_id = atoi(sep->arg[1]);
  7516. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  7517. if( new_location > 0 )
  7518. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  7519. else
  7520. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  7521. }
  7522. else
  7523. {
  7524. const char* name = 0;
  7525. name = sep->argplus[1];
  7526. new_location = database.CreateSpawnFromTemplateByName(client, name);
  7527. if( new_location > 0 )
  7528. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  7529. else
  7530. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  7531. }
  7532. }
  7533. else
  7534. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  7535. }
  7536. else
  7537. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  7538. }
  7539. void Commands::Command_Speed(Client* client, Seperator* sep) {
  7540. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  7541. float new_speed = atof(sep->arg[0]);
  7542. if (new_speed > 0.0f)
  7543. {
  7544. client->GetPlayer()->SetSpeed(new_speed, true);
  7545. client->GetPlayer()->SetCharSheetChanged(true);
  7546. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  7547. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  7548. }
  7549. else
  7550. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  7551. }
  7552. else{
  7553. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  7554. }
  7555. }
  7556. /*
  7557. Function: Command_StationMarketPlace()
  7558. Purpose : just trying to eat the console spam for now
  7559. Params :
  7560. Dev : John
  7561. */
  7562. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  7563. {
  7564. PrintSep(sep, "COMMAND_SMP");
  7565. // This will reduce the spam from once every 10 sec to once every 30 sec,
  7566. // can't seem to reduce it any more get rid of it completely...
  7567. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  7568. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  7569. if (packet) {
  7570. packet->setDataByName("account_id", client->GetAccountID());
  7571. packet->setDataByName("character_id", client->GetCharacterID());
  7572. packet->setDataByName("unknown1", 1, 5);
  7573. packet->setDataByName("unknown1", 26, 6);
  7574. packet->setDataByName("unknown2", 0xFFFFFFFF);
  7575. packet->setDataByName("unknown3", 248, 1);
  7576. client->QueuePacket(packet->serialize());
  7577. }
  7578. safe_delete(packet);
  7579. }
  7580. }
  7581. /*
  7582. Function: Command_StopDrinking()
  7583. Purpose : Stops player from auto-consuming drink
  7584. Params :
  7585. Dev : Zcoretri
  7586. Example : /stopdrinking
  7587. */
  7588. void Commands::Command_StopDrinking(Client* client)
  7589. {
  7590. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  7591. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  7592. }
  7593. /*
  7594. Function: Command_StopEating()
  7595. Purpose : Stops player from auto-consuming food
  7596. Params :
  7597. Dev : Zcoretri
  7598. Example : /stopeating
  7599. */
  7600. void Commands::Command_StopEating(Client* client)
  7601. {
  7602. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  7603. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  7604. }
  7605. /*
  7606. Function: Command_Title()
  7607. Purpose : Help for /title command
  7608. Params : n/a
  7609. Dev : Zcoretri
  7610. Example : /title
  7611. */
  7612. void Commands::Command_Title(Client* client)
  7613. {
  7614. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  7615. }
  7616. /*
  7617. Function: Command_TitleList()
  7618. Purpose : List available titles for player
  7619. Params : n/a
  7620. Dev : Zcoretri
  7621. Example : /title list
  7622. */
  7623. void Commands::Command_TitleList(Client* client)
  7624. {
  7625. // must call release read lock before leaving function on GetPlayerTitles
  7626. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  7627. vector<Title*>::iterator itr;
  7628. Title* title;
  7629. sint32 i = 0;
  7630. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  7631. for(itr = titles->begin(); itr != titles->end(); itr++)
  7632. {
  7633. title = *itr;
  7634. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  7635. i++;
  7636. }
  7637. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  7638. }
  7639. /*
  7640. Function: Command_TitleSetPrefix()
  7641. Purpose : Set Prefix title for player
  7642. Params : Title ID
  7643. Dev : Zcoretri
  7644. Example : /title setprefix 1
  7645. */
  7646. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  7647. {
  7648. if (sep && sep->arg[0] && sep->IsNumber(0))
  7649. {
  7650. sint32 index = atoul(sep->arg[0]);
  7651. if(index > -1)
  7652. {
  7653. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  7654. if(!title)
  7655. {
  7656. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  7657. return;
  7658. }
  7659. else if(!title->GetPrefix())
  7660. {
  7661. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  7662. return;
  7663. }
  7664. }
  7665. else // make sure client doesn't pass some bogus negative index
  7666. index = -1;
  7667. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  7668. client->SendTitleUpdate();
  7669. }
  7670. }
  7671. /*
  7672. Function: Command_TitleSetSuffix()
  7673. Purpose : Set Suffix title for player
  7674. Params : Title ID
  7675. Dev : Zcoretri
  7676. Example : /title setsuffix 1
  7677. */
  7678. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  7679. {
  7680. if (sep && sep->arg[0] && sep->IsNumber(0))
  7681. {
  7682. sint32 index = atoul(sep->arg[0]);
  7683. if(index > -1)
  7684. {
  7685. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  7686. if(!title)
  7687. {
  7688. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  7689. return;
  7690. }
  7691. else if(title->GetPrefix())
  7692. {
  7693. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  7694. return;
  7695. }
  7696. }
  7697. else // make sure client doesn't pass some bogus negative index
  7698. index = -1;
  7699. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  7700. client->SendTitleUpdate();
  7701. }
  7702. }
  7703. /*
  7704. Function: Command_TitleFix()
  7705. Purpose : Fix title for player (???)
  7706. Params :
  7707. Dev : Zcoretri
  7708. Example :
  7709. */
  7710. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  7711. {
  7712. PrintSep(sep, "COMMAND_TITLE_FIX");
  7713. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  7714. }
  7715. /*
  7716. Function: Command_Toggle_Anonymous()
  7717. Purpose : Toggles player Anonymous
  7718. Params :
  7719. Dev : paulgh
  7720. Example : /anon
  7721. */
  7722. void Commands::Command_Toggle_Anonymous(Client* client)
  7723. {
  7724. Player* player = client->GetPlayer();
  7725. player->toggle_character_flag(CF_ANONYMOUS);
  7726. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  7727. if (player->get_character_flag(CF_ANONYMOUS))
  7728. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  7729. else
  7730. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  7731. }
  7732. /*
  7733. Function: Command_Toggle_AutoConsume()
  7734. Purpose : Toggles player food/drink auto consume
  7735. Params : unknown
  7736. Dev : paulgh
  7737. Example : /set_auto_consume
  7738. */
  7739. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7740. {
  7741. Player* player = client->GetPlayer();
  7742. if (sep && sep->arg[0])
  7743. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7744. if (sep && sep->arg[0] && sep->IsNumber(0))
  7745. {
  7746. int8 slot = atoi(sep->arg[0]);
  7747. int8 flag = atoi(sep->arg[1]);
  7748. if (client->GetVersion() <= 283) {
  7749. slot += 4;
  7750. }
  7751. else if (client->GetVersion() <= 546) {
  7752. slot += 2;
  7753. }
  7754. if (slot == EQ2_FOOD_SLOT)
  7755. {
  7756. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7757. player->SetCharSheetChanged(true);
  7758. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7759. if (flag == 1)
  7760. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  7761. else
  7762. {
  7763. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  7764. return;
  7765. }
  7766. }
  7767. else
  7768. {
  7769. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7770. player->SetCharSheetChanged(true);
  7771. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7772. if (flag == 1)
  7773. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  7774. else
  7775. {
  7776. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  7777. return;
  7778. }
  7779. }
  7780. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  7781. return;
  7782. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  7783. return;
  7784. Item* item = player->GetEquipmentList()->GetItem(slot);
  7785. if(item)
  7786. client->ConsumeFoodDrink(item, slot);
  7787. }
  7788. }
  7789. /*
  7790. Function: Command_Toggle_BonusXP()
  7791. Purpose : Toggles player Bonus XP
  7792. Params :
  7793. Dev : John Adams
  7794. Example : /disable_char_bonus_exp
  7795. */
  7796. void Commands::Command_Toggle_BonusXP(Client* client)
  7797. {
  7798. Player* player = client->GetPlayer();
  7799. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7800. player->SetCharSheetChanged(true);
  7801. }
  7802. /*
  7803. Function: Command_Toggle_CombatXP()
  7804. Purpose : Toggles player Adventure XP
  7805. Params :
  7806. Dev : John Adams
  7807. Example : /disable_combat_exp
  7808. */
  7809. void Commands::Command_Toggle_CombatXP(Client* client)
  7810. {
  7811. Player* player = client->GetPlayer();
  7812. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7813. player->SetCharSheetChanged(true);
  7814. }
  7815. /*
  7816. Function: Command_Toggle_GMHide()
  7817. Purpose : Toggles hiding player GM status
  7818. Params :
  7819. Dev : Scatman
  7820. Example : /gm_hide
  7821. */
  7822. void Commands::Command_Toggle_GMHide(Client* client)
  7823. {
  7824. Player* player = client->GetPlayer();
  7825. player->toggle_character_flag(CF_HIDE_STATUS);
  7826. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7827. }
  7828. /*
  7829. Function: Command_Toggle_GMVanish()
  7830. Purpose : Toggles hiding GM players from /who searches
  7831. Params :
  7832. Dev : Scatman
  7833. Example : /gm_vanish
  7834. */
  7835. void Commands::Command_Toggle_GMVanish(Client* client)
  7836. {
  7837. Player* player = client->GetPlayer();
  7838. player->toggle_character_flag(CF_GM_HIDDEN);
  7839. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7840. }
  7841. /*
  7842. Function: Command_Toggle_Illusions()
  7843. Purpose : Toggles player illusion form
  7844. Params : not sure sep is needed, testing
  7845. Dev : paulgh
  7846. Example : /hide_illusions
  7847. */
  7848. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7849. {
  7850. if (sep && sep->arg[0])
  7851. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7852. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7853. }
  7854. /*
  7855. Function: Command_Toggle_LFG()
  7856. Purpose : Toggles player LFG Flag
  7857. Params :
  7858. Dev : paulgh
  7859. Example : /lfg
  7860. */
  7861. void Commands::Command_Toggle_LFG(Client* client)
  7862. {
  7863. Player* player = client->GetPlayer();
  7864. player->toggle_character_flag(CF_LFG);
  7865. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7866. if (player->get_character_flag(CF_LFG))
  7867. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7868. else
  7869. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7870. }
  7871. /*
  7872. Function: Command_Toggle_LFW()
  7873. Purpose : Toggles player LFW Flag
  7874. Params :
  7875. Dev : paulgh
  7876. Example : /lfw
  7877. */
  7878. void Commands::Command_Toggle_LFW(Client* client)
  7879. {
  7880. Player* player = client->GetPlayer();
  7881. player->toggle_character_flag(CF_LFW);
  7882. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7883. if (player->get_character_flag(CF_LFW))
  7884. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7885. else
  7886. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7887. }
  7888. /*
  7889. Function: Command_Toggle_QuestXP()
  7890. Purpose : Toggles player Quest XP
  7891. Params :
  7892. Dev : John Adams
  7893. Example : /disable_quest_exp
  7894. */
  7895. void Commands::Command_Toggle_QuestXP(Client* client)
  7896. {
  7897. Player* player = client->GetPlayer();
  7898. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7899. player->SetCharSheetChanged(true);
  7900. }
  7901. /*
  7902. Function: Command_Toggle_Roleplaying()
  7903. Purpose : Toggles player Roleplaying flag
  7904. Params :
  7905. Dev : paulgh
  7906. Example : /role
  7907. */
  7908. void Commands::Command_Toggle_Roleplaying(Client* client)
  7909. {
  7910. Player* player = client->GetPlayer();
  7911. player->toggle_character_flag(CF_ROLEPLAYING);
  7912. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  7913. if (player->get_character_flag(CF_ROLEPLAYING))
  7914. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  7915. else
  7916. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  7917. }
  7918. void Commands::Command_Toggle_Duels(Client* client)
  7919. {
  7920. Player* player = client->GetPlayer();
  7921. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7922. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7923. }
  7924. void Commands::Command_Toggle_Trades(Client* client)
  7925. {
  7926. Player* player = client->GetPlayer();
  7927. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7928. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7929. }
  7930. void Commands::Command_Toggle_Guilds(Client* client)
  7931. {
  7932. Player* player = client->GetPlayer();
  7933. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7934. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7935. }
  7936. void Commands::Command_Toggle_Groups(Client* client)
  7937. {
  7938. Player* player = client->GetPlayer();
  7939. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7940. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7941. }
  7942. void Commands::Command_Toggle_Raids(Client* client)
  7943. {
  7944. Player* player = client->GetPlayer();
  7945. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7946. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7947. }
  7948. void Commands::Command_Toggle_LON(Client* client)
  7949. {
  7950. Player* player = client->GetPlayer();
  7951. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7952. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7953. }
  7954. void Commands::Command_Toggle_VoiceChat(Client* client)
  7955. {
  7956. Player* player = client->GetPlayer();
  7957. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7958. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7959. }
  7960. /*
  7961. Function: Command_TradeStart()
  7962. Purpose : Starts item/coin trade between players
  7963. Params :
  7964. Dev :
  7965. Example :
  7966. */
  7967. #include "../Trade.h"
  7968. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7969. {
  7970. PrintSep(sep, "COMMAND_START_TRADE");
  7971. Entity* trader = client->GetPlayer();
  7972. Entity* trader2 = 0;
  7973. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7974. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7975. if (spawn) {
  7976. if (spawn->IsEntity())
  7977. trader2 = (Entity*)spawn;
  7978. }
  7979. }
  7980. else if (client->GetPlayer()->GetTarget()) {
  7981. if (client->GetPlayer()->GetTarget()->IsEntity())
  7982. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7983. }
  7984. // can only trade with player or bots
  7985. if (trader && trader2) {
  7986. if (trader == trader2) {
  7987. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7988. }
  7989. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7990. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7991. if (trader->trade)
  7992. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7993. else if (trader2->trade)
  7994. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7995. else {
  7996. Trade* trade = new Trade(trader, trader2);
  7997. trader->trade = trade;
  7998. trader2->trade = trade;
  7999. }
  8000. }
  8001. else {
  8002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8003. }
  8004. }
  8005. else
  8006. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8007. }
  8008. /*
  8009. Function: Command_Track()
  8010. Purpose : Starts/Stops Tracking for a player
  8011. Params :
  8012. Dev : Scatman
  8013. Example : /track
  8014. */
  8015. void Commands::Command_Track(Client* client)
  8016. {
  8017. if (!client->GetPlayer()->GetIsTracking())
  8018. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8019. else
  8020. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8021. }
  8022. /*
  8023. Function: Command_TradeAccept()
  8024. Purpose : Accepts item/coin trade between players
  8025. Params :
  8026. Dev :
  8027. Example :
  8028. */
  8029. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8030. {
  8031. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8032. Trade* trade = client->GetPlayer()->trade;
  8033. if (trade) {
  8034. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8035. if (trade_complete)
  8036. safe_delete(trade);
  8037. }
  8038. else
  8039. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8040. }
  8041. /*
  8042. Function: Command_TradeReject()
  8043. Purpose : Rejects item/coin trade between players
  8044. Params :
  8045. Dev :
  8046. Example :
  8047. */
  8048. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8049. {
  8050. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8051. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  8052. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8053. }
  8054. /*
  8055. Function: Command_TradeCancel()
  8056. Purpose : Cancels item/coin trade between players
  8057. Params :
  8058. Dev :
  8059. Example :
  8060. */
  8061. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8062. {
  8063. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8064. Trade* trade = client->GetPlayer()->trade;
  8065. if (trade) {
  8066. trade->CancelTrade(client->GetPlayer());
  8067. safe_delete(trade);
  8068. }
  8069. else
  8070. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8071. }
  8072. /*
  8073. Function: Command_TradeSetCoin()
  8074. Purpose : Sets coin trade between players
  8075. Params :
  8076. Dev :
  8077. Example :
  8078. */
  8079. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8080. {
  8081. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8082. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8083. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8084. }
  8085. /*
  8086. Function: Command_TradeAddCoin()
  8087. Purpose : Adds coin to trade between players
  8088. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8089. Dev :
  8090. Example :
  8091. */
  8092. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  8093. {
  8094. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  8095. Trade* trade = client->GetPlayer()->trade;
  8096. if (trade) {
  8097. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8098. int32 amount = atoi(sep->arg[0]);
  8099. int64 val = 0;
  8100. switch (handler) {
  8101. case COMMAND_ADD_TRADE_COPPER:
  8102. {
  8103. val = amount;
  8104. trade->AddCoinToTrade(client->GetPlayer(), val);
  8105. break;
  8106. }
  8107. case COMMAND_ADD_TRADE_SILVER:
  8108. {
  8109. val = amount * 100;
  8110. trade->AddCoinToTrade(client->GetPlayer(), val);
  8111. break;
  8112. }
  8113. case COMMAND_ADD_TRADE_GOLD:
  8114. {
  8115. val = amount * 10000;
  8116. trade->AddCoinToTrade(client->GetPlayer(), val);
  8117. break;
  8118. }
  8119. case COMMAND_ADD_TRADE_PLAT:
  8120. {
  8121. val = amount * 1000000;
  8122. trade->AddCoinToTrade(client->GetPlayer(), val);
  8123. break;
  8124. }
  8125. default:
  8126. {
  8127. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8128. break;
  8129. }
  8130. }
  8131. }
  8132. else
  8133. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  8134. }
  8135. else
  8136. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8137. }
  8138. /*
  8139. Function: Command_TradeRemoveCoin()
  8140. Purpose : Removes coin from trade between players
  8141. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8142. Dev :
  8143. Example :
  8144. */
  8145. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  8146. {
  8147. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  8148. Trade* trade = client->GetPlayer()->trade;
  8149. if (trade) {
  8150. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8151. int32 amount = atoi(sep->arg[0]);
  8152. int64 val = 0;
  8153. switch (handler) {
  8154. case COMMAND_REMOVE_TRADE_COPPER:
  8155. {
  8156. val = amount;
  8157. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8158. break;
  8159. }
  8160. case COMMAND_REMOVE_TRADE_SILVER:
  8161. {
  8162. val = amount * 100;
  8163. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8164. break;
  8165. }
  8166. case COMMAND_REMOVE_TRADE_GOLD:
  8167. {
  8168. val = amount * 10000;
  8169. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8170. break;
  8171. }
  8172. case COMMAND_REMOVE_TRADE_PLAT:
  8173. {
  8174. val = amount * 1000000;
  8175. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8176. break;
  8177. }
  8178. default:
  8179. {
  8180. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8181. break;
  8182. }
  8183. }
  8184. }
  8185. else
  8186. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  8187. }
  8188. else
  8189. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8190. }
  8191. /*
  8192. Function: Command_TradeAddItem()
  8193. Purpose : Adds item to trade between players
  8194. Params :
  8195. Dev :
  8196. Example :
  8197. */
  8198. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  8199. {
  8200. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  8201. /*
  8202. arg[0] = item index
  8203. arg[1] = slot
  8204. arg[2] = quantity
  8205. */
  8206. if (!client->GetPlayer()->trade) {
  8207. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  8208. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8209. return;
  8210. }
  8211. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  8212. Item* item = 0;
  8213. int32 index = atoi(sep->arg[0]);
  8214. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  8215. if (item) {
  8216. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  8217. if (result == 1)
  8218. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  8219. else if (result == 2)
  8220. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  8221. else if (result == 3)
  8222. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  8223. else if (result == 255)
  8224. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  8225. }
  8226. else {
  8227. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  8228. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  8229. }
  8230. }
  8231. else
  8232. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  8233. }
  8234. /*
  8235. Function: Command_TradeRemoveItem()
  8236. Purpose : Removes item from trade between players
  8237. Params :
  8238. Dev :
  8239. Example :
  8240. */
  8241. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  8242. {
  8243. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  8244. /*
  8245. arg[0] = trade window slot
  8246. */
  8247. Trade* trade = client->GetPlayer()->trade;
  8248. if (trade) {
  8249. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8250. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  8251. }
  8252. else
  8253. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  8254. }
  8255. else
  8256. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8257. }
  8258. void Commands::Command_TryOn(Client* client, Seperator* sep)
  8259. {
  8260. Item *item = 0;
  8261. sint32 crc;
  8262. if (sep) {
  8263. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  8264. if (client->GetVersion() < 1096) {
  8265. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  8266. {
  8267. item = master_item_list.GetItem(atoul(sep->arg[1]));
  8268. crc = atol(sep->arg[2]);
  8269. }
  8270. }
  8271. else {
  8272. // From the broker and links in chat
  8273. if (strcmp(sep->arg[0], "crc") == 0) {
  8274. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  8275. item = master_item_list.GetItem(atoul(sep->arg[2]));
  8276. crc = atol(sep->arg[3]);
  8277. }
  8278. }
  8279. // From inventory
  8280. if (strcmp(sep->arg[0], "dbid") == 0) {
  8281. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  8282. item = master_item_list.GetItem(atoul(sep->arg[2]));
  8283. crc = atol(sep->arg[4]);
  8284. }
  8285. }
  8286. }
  8287. if (item)
  8288. client->ShowDressingRoom(item, crc);
  8289. }
  8290. }
  8291. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  8292. const char *channel_name, *password = NULL;
  8293. if (sep == NULL || !sep->IsSet(0)) {
  8294. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  8295. return;
  8296. }
  8297. channel_name = sep->arg[0];
  8298. if (sep->IsSet(1))
  8299. password = sep->arg[1];
  8300. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  8301. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  8302. return;
  8303. }
  8304. if (chat.IsInChannel(client, channel_name)) {
  8305. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  8306. return;
  8307. }
  8308. if (chat.HasPassword(channel_name)) {
  8309. if (password == NULL) {
  8310. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  8311. return;
  8312. }
  8313. if (!chat.PasswordMatches(channel_name, password)) {
  8314. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  8315. return;
  8316. }
  8317. }
  8318. if (!chat.JoinChannel(client, channel_name))
  8319. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  8320. }
  8321. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  8322. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  8323. Command_JoinChannel(client, sep);
  8324. }
  8325. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  8326. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  8327. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  8328. PrintSep(sep, "tellchannel");
  8329. return;
  8330. }
  8331. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  8332. }
  8333. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  8334. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8335. if (sep->IsSet(0)) {
  8336. if (atoi(sep->arg[0]) == 1) {
  8337. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  8338. if (packet2) {
  8339. packet2->setDataByName("spell_type", 2);
  8340. packet2->setDataByName("spell_id", 8308);
  8341. packet2->setDataByName("spell_name", "Sprint");
  8342. packet2->setDataByName("add_silently", 0);
  8343. packet2->setDataByName("tier", 1);
  8344. packet2->setDataByName("blah1", 1);
  8345. packet2->setDataByName("blah2", 1);
  8346. EQ2Packet* outapp = packet2->serialize();
  8347. DumpPacket(outapp);
  8348. client->QueuePacket(outapp);
  8349. safe_delete(packet2);
  8350. }
  8351. }
  8352. else if (atoi(sep->arg[0]) == 2) {
  8353. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  8354. if (packet2) {
  8355. packet2->setDataByName("guild_name", "Test");
  8356. packet2->setDataByName("guild_motd", "Test MOTD");
  8357. packet2->setDataByName("guild_id", 1234);
  8358. packet2->setDataByName("guild_level", 1);
  8359. packet2->setDataByName("unknown", 2);
  8360. packet2->setDataByName("unknown2", 3);
  8361. packet2->setDataByName("exp_current", 1);
  8362. packet2->setDataByName("exp_to_next_level", 4);
  8363. EQ2Packet* outapp = packet2->serialize();
  8364. DumpPacket(outapp);
  8365. client->QueuePacket(outapp);
  8366. safe_delete(packet2);
  8367. }
  8368. }
  8369. else if (atoi(sep->arg[0]) == 3) {
  8370. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  8371. if (packet2) {
  8372. packet2->setDataByName("guild_id", 1234);
  8373. packet2->setDataByName("character_id", 1);
  8374. packet2->setDataByName("account_id", 2);
  8375. packet2->setDataByName("guild_level", 1);
  8376. packet2->setDataByName("name", "Test");
  8377. packet2->setDataByName("unknown2", 0);
  8378. packet2->setDataByName("unknown3", 1);
  8379. packet2->setDataByName("adventure_class", 6);
  8380. packet2->setDataByName("adventure_level", 7);
  8381. packet2->setDataByName("tradeskill_class", 4);
  8382. packet2->setDataByName("tradeskill_level", 5);
  8383. packet2->setDataByName("rank", 0);
  8384. packet2->setDataByName("member_flags", 2);
  8385. packet2->setDataByName("join_date", 1591112273);
  8386. packet2->setDataByName("guild_status", 2);
  8387. packet2->setDataByName("last_login", 1591132273);
  8388. packet2->setDataByName("recruiter_id", 1);
  8389. packet2->setDataByName("points", 2345);
  8390. packet2->setDataByName("note", "note");
  8391. packet2->setMediumStringByName("officer_note", "O note");
  8392. packet2->setMediumStringByName("zone", "Blah");
  8393. EQ2Packet* outapp = packet2->serialize();
  8394. DumpPacket(outapp);
  8395. client->QueuePacket(outapp);
  8396. safe_delete(packet2);
  8397. }
  8398. }
  8399. else if (atoi(sep->arg[0]) == 5) {
  8400. int16 offset = atoi(sep->arg[1]);
  8401. int32 value1 = atol(sep->arg[2]);
  8402. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  8403. client->QueuePacket(outapp);
  8404. }
  8405. else if (atoi(sep->arg[0]) == 6) {
  8406. Spawn* spawn = client->GetPlayer()->GetTarget();
  8407. if (!spawn)
  8408. spawn = client->GetPlayer();
  8409. else if (spawn->IsEntity())
  8410. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  8411. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  8412. }
  8413. else if (atoi(sep->arg[0]) == 7) {
  8414. int32 id = 0;
  8415. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  8416. if (spawn) {
  8417. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  8418. spawn->SetY(client->GetPlayer()->GetY(), false);
  8419. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  8420. float heading = client->GetPlayer()->GetHeading() + 180;
  8421. if (heading > 360)
  8422. heading -= 360;
  8423. spawn->SetLevel(5);
  8424. spawn->SetAdventureClass(4);
  8425. spawn->SetHeading(heading, false);
  8426. spawn->SetSpawnOrigX(spawn->GetX());
  8427. spawn->SetSpawnOrigY(spawn->GetY());
  8428. spawn->SetSpawnOrigZ(spawn->GetZ());
  8429. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  8430. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8431. spawn->appearance.targetable = 1;
  8432. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  8433. spawn->SetTotalHP(spawn->GetLevel() * 15);
  8434. spawn->SetHP(spawn->GetTotalHP());
  8435. }
  8436. if (spawn->GetTotalPower() == 0) {
  8437. spawn->SetTotalPower(spawn->GetLevel() * 15);
  8438. spawn->SetPower(spawn->GetTotalPower());
  8439. }
  8440. int16 offset = atoi(sep->arg[1]);
  8441. int32 value1 = atol(sep->arg[2]);
  8442. sprintf(spawn->appearance.name, "Offset %i", offset);
  8443. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  8444. DumpPacket(ret);
  8445. client->QueuePacket(ret);
  8446. }
  8447. }
  8448. else if (atoi(sep->arg[0]) == 8) {
  8449. int32 id = atoi(sep->arg[1]);
  8450. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  8451. if (spawn) {
  8452. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  8453. spawn->SetY(client->GetPlayer()->GetY(), false);
  8454. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  8455. float heading = client->GetPlayer()->GetHeading() + 180;
  8456. if (heading > 360)
  8457. heading -= 360;
  8458. spawn->SetLevel(5);
  8459. spawn->SetAdventureClass(4);
  8460. spawn->SetHeading(heading, false);
  8461. spawn->SetSpawnOrigX(spawn->GetX());
  8462. spawn->SetSpawnOrigY(spawn->GetY());
  8463. spawn->SetSpawnOrigZ(spawn->GetZ());
  8464. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  8465. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8466. spawn->appearance.targetable = 1;
  8467. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  8468. spawn->SetTotalHP(spawn->GetLevel() * 15);
  8469. spawn->SetHP(spawn->GetTotalHP());
  8470. }
  8471. if (spawn->GetTotalPower() == 0) {
  8472. spawn->SetTotalPower(spawn->GetLevel() * 15);
  8473. spawn->SetPower(spawn->GetTotalPower());
  8474. }
  8475. int16 offset = atoi(sep->arg[2]);
  8476. int16 offset2 = atoi(sep->arg[3]);
  8477. int32 value1 = atol(sep->arg[4]);
  8478. int16 offset3 = 0;
  8479. int16 offset4 = 0;
  8480. int32 value2 = 0;
  8481. if (sep->IsSet(7)) {
  8482. offset3 = atoi(sep->arg[5]);
  8483. offset4 = atoi(sep->arg[6]);
  8484. value2 = atol(sep->arg[7]);
  8485. }
  8486. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  8487. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  8488. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  8489. DumpPacket(ret);
  8490. client->QueuePacket(ret);
  8491. }
  8492. }
  8493. else if (atoi(sep->arg[0]) == 9) {
  8494. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  8495. if (packet2) {
  8496. packet2->setArrayLengthByName("location_count", 1);
  8497. packet2->setArrayDataByName("location_ida", 1234);
  8498. packet2->setArrayDataByName("unknown2a", 3);
  8499. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  8500. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  8501. packet2->setArrayDataByName("distance", 134);
  8502. EQ2Packet* app = packet2->serialize();
  8503. if (sep->IsSet(2)) {
  8504. int8 offset = atoi(sep->arg[1]);
  8505. uchar* ptr2 = app->pBuffer;
  8506. ptr2 += offset;
  8507. if (sep->IsNumber(2)) {
  8508. int32 value1 = atol(sep->arg[2]);
  8509. if (value1 > 0xFFFF)
  8510. memcpy(ptr2, (uchar*)&value1, 4);
  8511. else if (value1 > 0xFF)
  8512. memcpy(ptr2, (uchar*)&value1, 2);
  8513. else
  8514. memcpy(ptr2, (uchar*)&value1, 1);
  8515. }
  8516. else {
  8517. int8 len = strlen(sep->arg[2]);
  8518. memcpy(ptr2, (uchar*)&len, 1);
  8519. ptr2 += 1;
  8520. memcpy(ptr2, sep->arg[2], len);
  8521. }
  8522. }
  8523. DumpPacket(app);
  8524. client->QueuePacket(app);
  8525. safe_delete(packet2);
  8526. }
  8527. }
  8528. else if (atoi(sep->arg[0]) == 10) {
  8529. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  8530. if (packet2) {
  8531. packet2->setArrayLengthByName("num_quests", 1);
  8532. packet2->setArrayDataByName("active", 1);
  8533. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  8534. packet2->setArrayDataByName("quest_type", "Hallmark");
  8535. packet2->setArrayDataByName("quest_zone", "Hallmark");
  8536. packet2->setArrayDataByName("journal_updated", 1);
  8537. packet2->setArrayDataByName("quest_id", 524);
  8538. packet2->setArrayDataByName("day", 19);
  8539. packet2->setArrayDataByName("month", 6);
  8540. packet2->setArrayDataByName("year", 20);
  8541. packet2->setArrayDataByName("level", 2);
  8542. packet2->setArrayDataByName("encounter_level", 4);
  8543. packet2->setArrayDataByName("difficulty", 3);
  8544. packet2->setArrayDataByName("visible", 1);
  8545. packet2->setDataByName("visible_quest_id", 524);
  8546. packet2->setDataByName("player_crc", 2900677088);
  8547. packet2->setDataByName("player_name", "LethalEncounter");
  8548. EQ2Packet* app = packet2->serialize();
  8549. if (sep->IsSet(2)) {
  8550. int8 offset = atoi(sep->arg[1]);
  8551. uchar* ptr2 = app->pBuffer;
  8552. ptr2 += offset;
  8553. if (sep->IsNumber(2)) {
  8554. int32 value1 = atol(sep->arg[2]);
  8555. if (value1 > 0xFFFF)
  8556. memcpy(ptr2, (uchar*)&value1, 4);
  8557. else if (value1 > 0xFF)
  8558. memcpy(ptr2, (uchar*)&value1, 2);
  8559. else
  8560. memcpy(ptr2, (uchar*)&value1, 1);
  8561. }
  8562. else {
  8563. int8 len = strlen(sep->arg[2]);
  8564. memcpy(ptr2, (uchar*)&len, 1);
  8565. ptr2 += 1;
  8566. memcpy(ptr2, sep->arg[2], len);
  8567. }
  8568. }
  8569. DumpPacket(app);
  8570. client->QueuePacket(app);
  8571. safe_delete(packet2);
  8572. }
  8573. }
  8574. else if (atoi(sep->arg[0]) == 11) {
  8575. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8576. if (packet2) {
  8577. packet2->setDataByName("quest_id", 524);
  8578. packet2->setDataByName("player_crc", 2900677088);
  8579. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  8580. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  8581. packet2->setDataByName("type", "Hallmark");
  8582. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8583. packet2->setDataByName("day", 19);
  8584. packet2->setDataByName("month", 6);
  8585. packet2->setDataByName("year", 20);
  8586. packet2->setDataByName("level", 1);
  8587. packet2->setDataByName("encounter_level", 1);
  8588. packet2->setDataByName("difficulty", 1);
  8589. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8590. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8591. //packet2->setDataByName("timer_duration", 300);
  8592. //packet2->setDataByName("timer_running", 1);
  8593. packet2->setArrayLengthByName("task_groups_completed", 9);
  8594. packet2->setArrayLengthByName("num_task_groups", 10);
  8595. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  8596. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  8597. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  8598. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  8599. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  8600. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  8601. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  8602. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  8603. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  8604. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  8605. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  8606. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8607. packet2->setSubArrayLengthByName("num_updates", 1);
  8608. packet2->setSubArrayDataByName("update_currentval", 0);
  8609. packet2->setSubArrayDataByName("update_maxval", 1);
  8610. packet2->setSubArrayDataByName("icon", 11);
  8611. */
  8612. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8613. packet2->setDataByName("journal_updated", 1);
  8614. packet2->setDataByName("bullets", 1);
  8615. EQ2Packet* app = packet2->serialize();
  8616. if (sep->IsSet(2)) {
  8617. int16 offset = atoi(sep->arg[1]);
  8618. uchar* ptr2 = app->pBuffer;
  8619. ptr2 += offset;
  8620. if (sep->IsNumber(2)) {
  8621. int32 value1 = atol(sep->arg[2]);
  8622. if (value1 > 0xFFFF)
  8623. memcpy(ptr2, (uchar*)&value1, 4);
  8624. else if (value1 > 0xFF)
  8625. memcpy(ptr2, (uchar*)&value1, 2);
  8626. else
  8627. memcpy(ptr2, (uchar*)&value1, 1);
  8628. }
  8629. else {
  8630. int16 len = strlen(sep->arg[2]);
  8631. memcpy(ptr2, (uchar*)&len, 2);
  8632. ptr2 += 2;
  8633. memcpy(ptr2, sep->arg[2], len);
  8634. }
  8635. }
  8636. DumpPacket(app);
  8637. client->QueuePacket(app);
  8638. safe_delete(packet2);
  8639. }
  8640. }
  8641. else if (atoi(sep->arg[0]) == 12) {
  8642. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8643. if (packet2) {
  8644. packet2->setDataByName("quest_id", 524);
  8645. packet2->setDataByName("player_crc", 2900677088);
  8646. packet2->setDataByName("name", "Archetype Selection");
  8647. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  8648. packet2->setDataByName("type", "Hallmark");
  8649. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8650. packet2->setDataByName("day", 19);
  8651. packet2->setDataByName("month", 6);
  8652. packet2->setDataByName("year", 20);
  8653. packet2->setDataByName("level", 2);
  8654. packet2->setDataByName("encounter_level", 4);
  8655. packet2->setDataByName("difficulty", 3);
  8656. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8657. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8658. packet2->setDataByName("timer_duration", 300);
  8659. packet2->setDataByName("timer_running", 1);
  8660. packet2->setArrayLengthByName("task_groups_completed", 0);
  8661. packet2->setArrayLengthByName("num_task_groups", 1);
  8662. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8663. packet2->setSubArrayLengthByName("num_tasks", 1);
  8664. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8665. packet2->setSubArrayLengthByName("num_updates", 1);
  8666. packet2->setSubArrayDataByName("update_currentval", 0);
  8667. packet2->setSubArrayDataByName("update_maxval", 1);
  8668. packet2->setSubArrayDataByName("icon", 11);
  8669. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8670. packet2->setDataByName("journal_updated", 1);
  8671. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8672. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8673. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  8674. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8675. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8676. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8677. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  8678. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  8679. Item* item = master_item_list.GetItem(152755);
  8680. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8681. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8682. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  8683. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  8684. packet2->setSubstructDataByName("item", "icon", 0xe7);
  8685. packet2->setSubstructDataByName("item", "tier", 4);
  8686. packet2->setSubstructDataByName("item", "flags", 0x60);
  8687. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  8688. packet2->setSubstructDataByName("item", "stat_type", 1);
  8689. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  8690. packet2->setSubstructDataByName("item", "value", 3);
  8691. packet2->setSubstructDataByName("item", "condition", 100);
  8692. packet2->setSubstructDataByName("item", "weight", 1);
  8693. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  8694. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  8695. packet2->setSubstructDataByName("item", "skill_min", 1);
  8696. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  8697. packet2->setSubstructDataByName("item", "adventure_class", 1);
  8698. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  8699. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  8700. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  8701. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  8702. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  8703. packet2->setSubstructDataByName("item", "level", 0x1e);
  8704. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  8705. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  8706. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  8707. //packet2->PrintPacket();
  8708. EQ2Packet* app = packet2->serialize();
  8709. if (sep->IsSet(2)) {
  8710. int16 offset = atoi(sep->arg[1]);
  8711. uchar* ptr2 = app->pBuffer;
  8712. ptr2 += offset;
  8713. if (sep->IsNumber(2)) {
  8714. int32 value1 = atol(sep->arg[2]);
  8715. if (value1 > 0xFFFF)
  8716. memcpy(ptr2, (uchar*)&value1, 4);
  8717. else if (value1 > 0xFF)
  8718. memcpy(ptr2, (uchar*)&value1, 2);
  8719. else
  8720. memcpy(ptr2, (uchar*)&value1, 1);
  8721. }
  8722. else {
  8723. int16 len = strlen(sep->arg[2]);
  8724. memcpy(ptr2, (uchar*)&len, 2);
  8725. ptr2 += 2;
  8726. memcpy(ptr2, sep->arg[2], len);
  8727. }
  8728. }
  8729. DumpPacket(app);
  8730. client->QueuePacket(app);
  8731. safe_delete(packet2);
  8732. }
  8733. }
  8734. else if (atoi(sep->arg[0]) == 13) {
  8735. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  8736. if (packet2 && sep->IsSet(7)) {
  8737. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  8738. char blah[128];
  8739. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  8740. packet2->setDataByName("text", blah);
  8741. packet2->setDataByName("message_type", sep->arg[3]);
  8742. packet2->setDataByName("size", atof(sep->arg[4]));
  8743. packet2->setDataByName("red", atoi(sep->arg[5]));
  8744. packet2->setDataByName("green", atoi(sep->arg[6]));
  8745. packet2->setDataByName("blue", atoi(sep->arg[7]));
  8746. EQ2Packet* app = packet2->serialize();
  8747. DumpPacket(app);
  8748. client->QueuePacket(app);
  8749. safe_delete(packet2);
  8750. }
  8751. }
  8752. else if (atoi(sep->arg[0]) == 14) {
  8753. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  8754. if (packet2 && sep->IsSet(3)) {
  8755. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  8756. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  8757. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  8758. 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.");
  8759. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  8760. packet2->setArrayLengthByName("num_goals", 1);
  8761. //packet2->setArrayDataByName("goal_text", )
  8762. packet2->setSubArrayLengthByName("num_tasks", 1);
  8763. packet2->setSubArrayDataByName("task_text", "continue");
  8764. packet2->setDataByName("complete_sound", "click");
  8765. packet2->setDataByName("signal", "introduction");
  8766. packet2->setDataByName("voice_key1", 0xcda65173);
  8767. packet2->setDataByName("voice_key2", 0x984bfc6d);
  8768. EQ2Packet* app = packet2->serialize();
  8769. DumpPacket(app);
  8770. client->QueuePacket(app);
  8771. safe_delete(packet2);
  8772. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  8773. packet2->setDataByName("window", "MainHUD.StartMenu");
  8774. packet2->setDataByName("show", 1);
  8775. app = packet2->serialize();
  8776. DumpPacket(app);
  8777. client->QueuePacket(app);
  8778. safe_delete(packet2);
  8779. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  8780. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  8781. packet2->setDataByName("flash_seconds", 10);
  8782. app = packet2->serialize();
  8783. DumpPacket(app);
  8784. client->QueuePacket(app);
  8785. safe_delete(packet2);
  8786. }
  8787. }
  8788. else if (atoi(sep->arg[0]) == 15) {
  8789. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8790. if (packet2) {
  8791. packet2->setArrayLengthByName("loot_count", 1);
  8792. packet2->setArrayDataByName("name", "Test");
  8793. packet2->setArrayDataByName("item_id", 1234);
  8794. packet2->setArrayDataByName("count", 1);
  8795. packet2->setArrayDataByName("icon", 258);
  8796. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  8797. Spawn* spawn = client->GetPlayer()->GetTarget();
  8798. if (spawn)
  8799. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8800. packet2->setDataByName("unknown3", 1);
  8801. packet2->setDataByName("unknown4", 1);
  8802. packet2->setDataByName("unknown5", 60);
  8803. EQ2Packet* app = packet2->serialize();
  8804. DumpPacket(app);
  8805. client->QueuePacket(app);
  8806. safe_delete(packet2);
  8807. }
  8808. }
  8809. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  8810. char blah[32];
  8811. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  8812. client->SimpleMessage(atoi(sep->arg[1]), blah);
  8813. }
  8814. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  8815. if (sep->IsSet(2)) {
  8816. int16 offset = atoi(sep->arg[1]);
  8817. if (sep->IsNumber(2)) {
  8818. int32 value1 = atol(sep->arg[2]);
  8819. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  8820. cout << "Sent" << endl;
  8821. }
  8822. }
  8823. }
  8824. else if (atoi(sep->arg[0]) == 18) {
  8825. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  8826. if (packet2) {
  8827. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8828. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8829. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8830. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8831. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8832. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  8833. Item* item = new Item(master_item_list.GetItem(36212));
  8834. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8835. item->stack_count = 20;
  8836. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8837. safe_delete(item);
  8838. item = new Item(master_item_list.GetItem(36685));
  8839. item->stack_count = 20;
  8840. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8841. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  8842. safe_delete(item);
  8843. item = master_item_list.GetItem(1414);
  8844. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8845. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  8846. item = master_item_list.GetItem(75057);
  8847. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8848. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  8849. EQ2Packet* app = packet2->serialize();
  8850. if (sep->IsSet(2)) {
  8851. int16 offset = atoi(sep->arg[1]);
  8852. uchar* ptr2 = app->pBuffer;
  8853. ptr2 += offset;
  8854. if (sep->IsNumber(2)) {
  8855. int32 value1 = atol(sep->arg[2]);
  8856. if (value1 > 0xFFFF)
  8857. memcpy(ptr2, (uchar*)&value1, 4);
  8858. else if (value1 > 0xFF)
  8859. memcpy(ptr2, (uchar*)&value1, 2);
  8860. else
  8861. memcpy(ptr2, (uchar*)&value1, 1);
  8862. }
  8863. else {
  8864. int16 len = strlen(sep->arg[2]);
  8865. memcpy(ptr2, (uchar*)&len, 2);
  8866. ptr2 += 2;
  8867. memcpy(ptr2, sep->arg[2], len);
  8868. }
  8869. }
  8870. DumpPacket(app);
  8871. client->QueuePacket(app);
  8872. safe_delete(packet2);
  8873. }
  8874. }
  8875. else if (atoi(sep->arg[0]) == 19) {
  8876. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8877. Spawn* spawn = client->GetPlayer()->GetTarget();
  8878. if (packet2 && spawn) {
  8879. Item* item = master_item_list.GetItem(130053);
  8880. packet2->setArrayLengthByName("loot_count", 1);
  8881. packet2->setArrayDataByName("loot_id", item->details.item_id);
  8882. packet2->setArrayDataByName("unknown2", 1);
  8883. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  8884. packet2->setDataByName("display", 1);
  8885. packet2->setDataByName("unknown2b", 1);
  8886. packet2->setDataByName("unknown3", 0x3c);
  8887. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8888. packet2->PrintPacket();
  8889. EQ2Packet* app = packet2->serialize();
  8890. if (sep->IsSet(2)) {
  8891. int16 offset = atoi(sep->arg[1]);
  8892. int16 offset2 = 0;
  8893. int32 value1 = 0;
  8894. if (sep->IsSet(3)) {
  8895. offset2 = atoi(sep->arg[2]);
  8896. value1 = atol(sep->arg[3]);
  8897. }
  8898. else
  8899. value1 = atol(sep->arg[2]);
  8900. int16 offset3 = 0;
  8901. int16 offset4 = 0;
  8902. int32 value2 = 0;
  8903. if (sep->IsSet(6)) {
  8904. offset3 = atoi(sep->arg[4]);
  8905. offset4 = atoi(sep->arg[5]);
  8906. value2 = atol(sep->arg[6]);
  8907. }
  8908. offset--;
  8909. if (offset2 > 0 && offset2 >= offset) {
  8910. offset2--;
  8911. uchar* ptr2 = app->pBuffer;
  8912. ptr2 += offset;
  8913. for (int i = offset; i <= offset2; i++) {
  8914. if (value1 > 0xFFFF) {
  8915. memcpy(ptr2, (uchar*)&value1, 4);
  8916. i += 3;
  8917. ptr2 += 3;
  8918. }
  8919. else if (value1 > 0xFF) {
  8920. memcpy(ptr2, (uchar*)&value1, 2);
  8921. i++;
  8922. ptr2++;
  8923. }
  8924. else
  8925. memcpy(ptr2, (uchar*)&value1, 1);
  8926. ptr2++;
  8927. }
  8928. }
  8929. if (offset4 > 0 && offset4 >= offset3) {
  8930. offset3--;
  8931. offset4--;
  8932. uchar* ptr2 = app->pBuffer;
  8933. ptr2 += offset3;
  8934. for (int i = offset3; i <= offset4; i++) {
  8935. if (value2 > 0xFFFF) {
  8936. memcpy(ptr2, (uchar*)&value2, 4);
  8937. i += 3;
  8938. ptr2 += 3;
  8939. }
  8940. else if (value2 > 0xFF) {
  8941. memcpy(ptr2, (uchar*)&value2, 2);
  8942. i++;
  8943. ptr2++;
  8944. }
  8945. else
  8946. memcpy(ptr2, (uchar*)&value2, 1);
  8947. ptr2++;
  8948. }
  8949. }
  8950. }
  8951. DumpPacket(app);
  8952. client->QueuePacket(app);
  8953. safe_delete(packet2);
  8954. }
  8955. }
  8956. else if (atoi(sep->arg[0]) == 21) {
  8957. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8958. if (packet2) {
  8959. packet2->setDataByName("unknown0", 255);
  8960. packet2->setDataByName("reward", "New Quest");
  8961. packet2->setDataByName("title", "Title");
  8962. packet2->setDataByName("description", "description");
  8963. packet2->setDataByName("quest_difficulty", 3);
  8964. packet2->setDataByName("unknown1", 5);
  8965. packet2->setDataByName("level", 3);
  8966. packet2->setDataByName("coin", 150);
  8967. packet2->setDataByName("status_points", 5);
  8968. packet2->setDataByName("exp_bonus", 10);
  8969. packet2->setArrayLengthByName("num_rewards", 1);
  8970. Item* item = new Item(master_item_list.GetItem(36212));
  8971. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8972. item->stack_count = 20;
  8973. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8974. safe_delete(item);
  8975. char accept[35] = { 0 };
  8976. char decline[35] = { 0 };
  8977. sprintf(accept, "q_accept_pending_quest %u", 0);
  8978. sprintf(decline, "q_deny_pending_quest %u", 0);
  8979. packet2->setDataByName("accept_command", accept);
  8980. packet2->setDataByName("decline_command", decline);
  8981. EQ2Packet* app = packet2->serialize();
  8982. if (sep->IsSet(2)) {
  8983. int16 offset = atoi(sep->arg[1]);
  8984. uchar* ptr2 = app->pBuffer;
  8985. ptr2 += offset;
  8986. if (sep->IsNumber(2)) {
  8987. int32 value1 = atol(sep->arg[2]);
  8988. if (value1 > 0xFFFF)
  8989. memcpy(ptr2, (uchar*)&value1, 4);
  8990. else if (value1 > 0xFF)
  8991. memcpy(ptr2, (uchar*)&value1, 2);
  8992. else
  8993. memcpy(ptr2, (uchar*)&value1, 1);
  8994. }
  8995. DumpPacket(app);
  8996. client->QueuePacket(app);
  8997. safe_delete(packet2);
  8998. }
  8999. }
  9000. }
  9001. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9002. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9003. if (packet2) {
  9004. packet2->setDataByName("unknown0", 255);
  9005. packet2->setDataByName("reward", "New Quest");
  9006. packet2->setDataByName("title", "Title");
  9007. packet2->setDataByName("description", "description");
  9008. packet2->setDataByName("quest_difficulty", 3);
  9009. packet2->setDataByName("unknown1", 5);
  9010. packet2->setDataByName("level", 3);
  9011. packet2->setDataByName("coin", 150);
  9012. packet2->setDataByName("status_points", 5);
  9013. packet2->setDataByName("exp_bonus", 10);
  9014. packet2->setArrayLengthByName("num_rewards", 1);
  9015. Item* item = new Item(master_item_list.GetItem(36212));
  9016. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9017. item->stack_count = 20;
  9018. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9019. safe_delete(item);
  9020. char accept[35] = { 0 };
  9021. char decline[35] = { 0 };
  9022. sprintf(accept, "q_accept_pending_quest %u", 0);
  9023. sprintf(decline, "q_deny_pending_quest %u", 0);
  9024. packet2->setDataByName("accept_command", accept);
  9025. packet2->setDataByName("decline_command", decline);
  9026. EQ2Packet* app = packet2->serialize();
  9027. if (sep->IsSet(2)) {
  9028. int16 offset = atoi(sep->arg[1]);
  9029. uchar* ptr2 = app->pBuffer;
  9030. ptr2 += offset;
  9031. if (sep->IsNumber(2)) {
  9032. int32 value1 = atol(sep->arg[2]);
  9033. if (value1 > 0xFFFF)
  9034. memcpy(ptr2, (uchar*)&value1, 4);
  9035. else if (value1 > 0xFF)
  9036. memcpy(ptr2, (uchar*)&value1, 2);
  9037. else
  9038. memcpy(ptr2, (uchar*)&value1, 1);
  9039. }
  9040. else {
  9041. int8 len = strlen(sep->arg[2]);
  9042. memcpy(ptr2, (uchar*)&len, 1);
  9043. ptr2 += 1;
  9044. memcpy(ptr2, sep->arg[2], len);
  9045. }
  9046. }
  9047. DumpPacket(app);
  9048. client->QueuePacket(app);
  9049. safe_delete(packet2);
  9050. }
  9051. }
  9052. else if (atoi(sep->arg[0]) == 23) {
  9053. if (client->GetPlayer()->GetTarget()) {
  9054. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9055. if (packet2) {
  9056. Spawn* target = client->GetPlayer()->GetTarget();
  9057. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9058. Item* item = new Item(master_item_list.GetItem(12565));
  9059. int8 i = 0;
  9060. packet2->setArrayLengthByName("num_items", 1);
  9061. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9062. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9063. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9064. packet2->setArrayDataByName("icon", item->details.icon, i);
  9065. int8 tmp_level = 0;
  9066. if (item->generic_info.adventure_default_level > 0)
  9067. tmp_level = item->generic_info.adventure_default_level;
  9068. else
  9069. tmp_level = item->generic_info.tradeskill_default_level;
  9070. packet2->setArrayDataByName("level", tmp_level, i);
  9071. packet2->setArrayDataByName("tier", item->details.tier, i);
  9072. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9073. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9074. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9075. item_difficulty = ARROW_COLOR_WHITE;
  9076. item_difficulty -= 6;
  9077. if (item_difficulty < 0)
  9078. item_difficulty *= -1;
  9079. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9080. packet2->setArrayDataByName("quantity", 2, i);
  9081. packet2->setArrayDataByName("unknown5", 255, i);
  9082. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9083. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9084. packet2->setDataByName("type", 2);
  9085. EQ2Packet* app = packet2->serialize();
  9086. if (sep->IsSet(2)) {
  9087. int16 offset = atoi(sep->arg[1]);
  9088. uchar* ptr2 = app->pBuffer;
  9089. ptr2 += offset;
  9090. if (sep->IsNumber(2)) {
  9091. int32 value1 = atol(sep->arg[2]);
  9092. if (value1 > 0xFFFF)
  9093. memcpy(ptr2, (uchar*)&value1, 4);
  9094. else if (value1 > 0xFF)
  9095. memcpy(ptr2, (uchar*)&value1, 2);
  9096. else
  9097. memcpy(ptr2, (uchar*)&value1, 1);
  9098. }
  9099. else {
  9100. int8 len = strlen(sep->arg[2]);
  9101. memcpy(ptr2, (uchar*)&len, 1);
  9102. ptr2 += 1;
  9103. memcpy(ptr2, sep->arg[2], len);
  9104. }
  9105. }
  9106. DumpPacket(app);
  9107. client->QueuePacket(app);
  9108. safe_delete(packet2);
  9109. }
  9110. }
  9111. }
  9112. else if (atoi(sep->arg[0]) == 24) {
  9113. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  9114. if (packet2) {
  9115. if (sep->IsSet(2)) {
  9116. packet2->setDataByName("event_name", sep->arg[1]);
  9117. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  9118. EQ2Packet* app = packet2->serialize();
  9119. DumpPacket(app);
  9120. client->QueuePacket(app);
  9121. safe_delete(packet2);
  9122. }
  9123. }
  9124. }
  9125. else if (atoi(sep->arg[0]) == 25) {
  9126. if (sep->IsSet(1)) {
  9127. Widget* new_spawn = new Widget();
  9128. int32 id = atoul(sep->arg[1]);
  9129. new_spawn->SetWidgetID(id);
  9130. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9131. client->QueuePacket(ret);
  9132. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  9133. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  9134. if (packet2) {
  9135. packet2->setDataByName("spawn_index", index);
  9136. packet2->setDataByName("delete", 1);
  9137. EQ2Packet* app = packet2->serialize();
  9138. client->QueuePacket(app);
  9139. safe_delete(packet2);
  9140. }
  9141. }
  9142. }
  9143. else if (atoi(sep->arg[0]) == 26) {
  9144. if (sep->IsSet(4)) {
  9145. Widget* new_spawn = new Widget();
  9146. int32 id = atoul(sep->arg[1]);
  9147. new_spawn->SetWidgetID(id);
  9148. float x = atof(sep->arg[2]);
  9149. float y = atof(sep->arg[3]);
  9150. float z = atof(sep->arg[4]);
  9151. new_spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9152. new_spawn->SetWidgetX(x);
  9153. new_spawn->SetWidgetY(y);
  9154. new_spawn->SetWidgetZ(z);
  9155. new_spawn->SetX(x);
  9156. new_spawn->SetY(y);
  9157. new_spawn->SetZ(z);
  9158. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9159. client->QueuePacket(ret);
  9160. }
  9161. }
  9162. else if (atoi(sep->arg[0]) == 27) {
  9163. Spawn* target = client->GetPlayer()->GetTarget();
  9164. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  9165. if (packet2 && target && sep->IsSet(2)) {
  9166. packet2->setSubstructDataByName("header", "defender", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9167. packet2->setSubstructDataByName("header", "defender_proxy", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9168. packet2->setSubstructDataByName("header", "attacker", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  9169. packet2->setArrayLengthByName("num_dmg", 1);
  9170. packet2->setArrayDataByName("damage_type", atoi(sep->arg[1]));
  9171. packet2->setArrayDataByName("damage", atoi(sep->arg[2]));
  9172. packet2->setDataByName("spell", 1);
  9173. packet2->setDataByName("spell_name", "Testing");
  9174. EQ2Packet* app = packet2->serialize();
  9175. if (sep->IsSet(4)) {
  9176. int16 offset = atoi(sep->arg[3]);
  9177. uchar* ptr2 = app->pBuffer;
  9178. ptr2 += offset;
  9179. if (sep->IsNumber(4)) {
  9180. int32 value1 = atol(sep->arg[4]);
  9181. if (value1 > 0xFFFF)
  9182. memcpy(ptr2, (uchar*)&value1, 4);
  9183. else if (value1 > 0xFF)
  9184. memcpy(ptr2, (uchar*)&value1, 2);
  9185. else
  9186. memcpy(ptr2, (uchar*)&value1, 1);
  9187. }
  9188. else {
  9189. int8 len = strlen(sep->arg[4]);
  9190. memcpy(ptr2, (uchar*)&len, 1);
  9191. ptr2 += 1;
  9192. memcpy(ptr2, sep->arg[4], len);
  9193. }
  9194. }
  9195. if (sep->IsSet(6)) {
  9196. int16 offset = atoi(sep->arg[5]);
  9197. uchar* ptr2 = app->pBuffer;
  9198. ptr2 += offset;
  9199. if (sep->IsNumber(6)) {
  9200. int32 value1 = atol(sep->arg[6]);
  9201. if (value1 > 0xFFFF)
  9202. memcpy(ptr2, (uchar*)&value1, 4);
  9203. else if (value1 > 0xFF)
  9204. memcpy(ptr2, (uchar*)&value1, 2);
  9205. else
  9206. memcpy(ptr2, (uchar*)&value1, 1);
  9207. }
  9208. else {
  9209. int8 len = strlen(sep->arg[6]);
  9210. memcpy(ptr2, (uchar*)&len, 1);
  9211. ptr2 += 1;
  9212. memcpy(ptr2, sep->arg[6], len);
  9213. }
  9214. }
  9215. DumpPacket(app);
  9216. client->QueuePacket(app);
  9217. safe_delete(packet2);
  9218. }
  9219. }
  9220. }
  9221. else {
  9222. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  9223. if (packet2) {
  9224. packet2->setSubstructDataByName("info_header", "show_name", 1);
  9225. packet2->setSubstructDataByName("info_header", "unknown", 7);
  9226. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  9227. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  9228. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  9229. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  9230. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  9231. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  9232. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  9233. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  9234. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  9235. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  9236. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  9237. packet2->setSubstructDataByName("info_header", "packettype", 3);
  9238. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  9239. packet2->setSubstructDataByName("spell_info", "level", 19);
  9240. packet2->setSubstructDataByName("spell_info", "tier", 1);
  9241. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  9242. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  9243. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  9244. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  9245. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  9246. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  9247. packet2->setSubstructDataByName("spell_info", "recast", 280);
  9248. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  9249. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  9250. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  9251. packet2->setSubstructDataByName("spell_info", "quality", 3);
  9252. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  9253. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  9254. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  9255. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  9256. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  9257. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  9258. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  9259. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  9260. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  9261. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  9262. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  9263. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  9264. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  9265. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  9266. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  9267. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  9268. packet2->setArrayDataByName("reagent", "Alcohol");
  9269. packet2->setArrayDataByName("consumed", "123");
  9270. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  9271. packet2->setSubstructDataByName("spell_info", "id", 8308);
  9272. packet2->setSubstructDataByName("spell_info", "icon", 303);
  9273. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  9274. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  9275. packet2->setSubstructDataByName("spell_info", "type", 2);
  9276. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  9277. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  9278. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  9279. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  9280. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  9281. EQ2Packet* outapp = packet2->serialize();
  9282. DumpPacket(outapp);
  9283. client->QueuePacket(outapp);
  9284. safe_delete(packet2);
  9285. }
  9286. }
  9287. return;
  9288. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  9289. if (!p) return;
  9290. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9291. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  9292. //}
  9293. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9294. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  9295. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  9296. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  9297. if (packet) {
  9298. client->QueuePacket(packet->serialize());
  9299. safe_delete(packet);
  9300. }
  9301. }*/
  9302. /*if (client->GetCurrentZone()->Grid != nullptr) {
  9303. int32 numFaces = 0;
  9304. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  9305. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  9306. map<int32, vector<Face*> >::iterator itr;
  9307. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  9308. numFaces += (*itr).second.size();
  9309. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  9310. }*/
  9311. //uchar blah[] = {
  9312. // 1208 - OP_EQUpdateStoreCmd
  9313. // /*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
  9314. // /*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
  9315. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  9316. // /*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
  9317. /*};
  9318. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9319. int8 val = 0;
  9320. int16 pos = 0;
  9321. int idx = 0;
  9322. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  9323. pos = atoi(sep2->arg[idx]);
  9324. val = atoi(sep2->arg[idx+1]);
  9325. memset(blah+pos, val, 1);
  9326. idx+=2;
  9327. }
  9328. DumpPacket(blah, sizeof(blah));
  9329. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  9330. if (client->GetPlayer()->GetTarget()) {
  9331. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  9332. if (packet) {
  9333. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  9334. packet->setDataByName("size", 0);
  9335. packet->setDataByName("unknown2", 0);
  9336. EQ2Packet* app = packet->serialize();
  9337. client->QueuePacket(app);
  9338. safe_delete(packet);
  9339. }
  9340. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  9341. if (set_pov) {
  9342. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  9343. EQ2Packet* app_pov = set_pov->serialize();
  9344. client->QueuePacket(app_pov);
  9345. safe_delete(set_pov);
  9346. }
  9347. }
  9348. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9349. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  9350. if (packet) {
  9351. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  9352. packet->setDataByName("Type", atoi(sep2->arg[0]));
  9353. else
  9354. packet->setDataByName("Type", 2);
  9355. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  9356. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  9357. else
  9358. packet->setDataByName("race_id", 0);
  9359. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  9360. packet->setDataByName("gender", atoi(sep2->arg[2]));
  9361. else
  9362. packet->setDataByName("gender", 2);
  9363. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  9364. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  9365. else
  9366. packet->setDataByName("unknown", 0, 0);
  9367. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  9368. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  9369. else
  9370. packet->setDataByName("unknown", 0, 1);
  9371. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  9372. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  9373. else
  9374. packet->setDataByName("unknown", 0, 2);
  9375. client->QueuePacket(packet->serialize());
  9376. }
  9377. safe_delete(packet);
  9378. safe_delete(sep2);
  9379. }
  9380. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  9381. const char *channel_name;
  9382. if (sep == NULL || !sep->IsSet(0)) {
  9383. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  9384. PrintSep(sep);
  9385. return;
  9386. }
  9387. channel_name = sep->arg[0];
  9388. if (!chat.IsInChannel(client, channel_name))
  9389. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  9390. else if (!chat.LeaveChannel(client, channel_name))
  9391. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  9392. }
  9393. /*
  9394. Function:
  9395. Purpose :
  9396. Params :
  9397. Dev :
  9398. Example :
  9399. */
  9400. void Commands::Command_WeaponStats(Client* client)
  9401. {
  9402. Player* player = client->GetPlayer();
  9403. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  9404. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  9405. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  9406. client->SimpleMessage(0, "Primary:");
  9407. if (primary) {
  9408. client->Message(0, "Name: %s", primary->name.c_str());
  9409. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  9410. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  9411. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  9412. client->Message(0, "Proc Percent: %d%%", 0);
  9413. client->Message(0, "Procs Per Minute: %d", 0);
  9414. }
  9415. else {
  9416. client->SimpleMessage(0, "Name: fist");
  9417. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  9418. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  9419. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  9420. client->Message(0, "Proc Percent: %d%%", 0);
  9421. client->Message(0, "Procs Per Minute: %d", 0);
  9422. }
  9423. client->SimpleMessage(0, " ");
  9424. client->SimpleMessage(0, " ");
  9425. if (secondary) {
  9426. client->SimpleMessage(0, "Secondary:");
  9427. client->Message(0, "Name: %s", secondary->name.c_str());
  9428. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  9429. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  9430. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  9431. client->Message(0, "Proc Percent: %d%%", 0);
  9432. client->Message(0, "Procs Per Minute: %d", 0);
  9433. client->SimpleMessage(0, " ");
  9434. client->SimpleMessage(0, " ");
  9435. }
  9436. client->SimpleMessage(0, "Ranged:");
  9437. if (ranged) {
  9438. client->Message(0, "Name: %s", ranged->name.c_str());
  9439. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  9440. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  9441. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  9442. client->Message(0, "Proc Percent: %d%%", 0);
  9443. client->Message(0, "Procs Per Minute: %d", 0);
  9444. }
  9445. else
  9446. client->SimpleMessage(0, "None");
  9447. }
  9448. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  9449. const char *channel_name;
  9450. if (sep == NULL || !sep->IsSet(0)) {
  9451. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  9452. return;
  9453. }
  9454. channel_name = sep->arg[0];
  9455. if (!chat.ChannelExists(channel_name))
  9456. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  9457. else
  9458. chat.SendChannelUserList(client, channel_name);
  9459. }
  9460. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  9461. {
  9462. ZoneServer* zone = 0;
  9463. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  9464. if (zone_id > 0)
  9465. {
  9466. zone = zone_list.Get(zone_id, false);
  9467. if (zone)
  9468. {
  9469. zone->SetSafeX(client->GetPlayer()->GetX());
  9470. zone->SetSafeY(client->GetPlayer()->GetY());
  9471. zone->SetSafeZ(client->GetPlayer()->GetZ());
  9472. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  9473. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  9474. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  9475. else
  9476. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  9477. }
  9478. }
  9479. }
  9480. /*
  9481. Function:
  9482. Purpose :
  9483. Params :
  9484. Dev :
  9485. Example :
  9486. */
  9487. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  9488. {
  9489. ZoneInfo* zone_info = new ZoneInfo;
  9490. if (sep && sep->arg[0])
  9491. {
  9492. if (sep->IsNumber(0))
  9493. zone_info->id = atoi(sep->arg[0]);
  9494. else
  9495. zone_info->id = database.GetZoneID(sep->arg[0]);
  9496. if (zone_info->id > 0)
  9497. {
  9498. database.LoadZoneInfo(zone_info);
  9499. 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);
  9500. 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);
  9501. 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);
  9502. 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);
  9503. 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);
  9504. 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);
  9505. 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);
  9506. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  9507. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  9508. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  9509. }
  9510. else
  9511. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  9512. }
  9513. else
  9514. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  9515. safe_delete(zone_info);
  9516. }
  9517. /*
  9518. Function:
  9519. Purpose :
  9520. Params :
  9521. Dev :
  9522. Example :
  9523. */
  9524. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  9525. {
  9526. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  9527. {
  9528. ZoneServer* zone = 0;
  9529. int32 zone_id = 0;
  9530. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  9531. {
  9532. zone_id = atoi(sep->arg[0]);
  9533. zone = zone_list.Get(atoi(sep->arg[0]), false);
  9534. }
  9535. else
  9536. {
  9537. zone_id = database.GetZoneID(sep->arg[0]);
  9538. if (zone_id > 0)
  9539. zone = zone_list.Get(sep->arg[0], false);
  9540. }
  9541. if (zone_id > 0)
  9542. {
  9543. if (zone_set_values.count(string(sep->arg[1])) > 0)
  9544. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  9545. else
  9546. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  9547. }
  9548. else
  9549. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  9550. }
  9551. else
  9552. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  9553. }
  9554. void Commands::Command_Rain(Client* client, Seperator* sep) {
  9555. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  9556. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  9557. return;
  9558. }
  9559. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  9560. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  9561. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  9562. }
  9563. void Commands::Command_Wind(Client* client, Seperator* sep) {
  9564. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  9565. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  9566. return;
  9567. }
  9568. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  9569. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  9570. }
  9571. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  9572. Spawn* spawn = client->GetPlayer()->GetTarget();
  9573. if(spawn) {
  9574. client->SetMerchantTransaction(spawn);
  9575. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  9576. client->SendHailCommand(spawn);
  9577. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  9578. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  9579. client->SendBuyMerchantList(sell);
  9580. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  9581. client->SendSellMerchantList(sell);
  9582. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  9583. client->SendBuyBackList(sell);
  9584. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9585. if (packet) {
  9586. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  9587. packet->setDataByName("type", 16);
  9588. EQ2Packet* outapp = packet->serialize();
  9589. if (outapp)
  9590. client->QueuePacket(outapp);
  9591. safe_delete(packet);
  9592. }
  9593. }
  9594. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  9595. client->SendRepairList();
  9596. }
  9597. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  9598. }
  9599. void Commands::Command_Weather(Client* client, Seperator* sep)
  9600. {
  9601. //PrintSep(sep, "Weather");
  9602. if( sep && sep->arg[0] )
  9603. {
  9604. ZoneServer* zsZone = client->GetCurrentZone();
  9605. const char* value = sep->arg[0];
  9606. // process single-param commands first
  9607. if( strncasecmp(value, "details", strlen(value)) == 0 )
  9608. {
  9609. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  9610. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  9611. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  9612. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  9613. }
  9614. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  9615. {
  9616. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9617. zsZone->ProcessWeather();
  9618. }
  9619. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  9620. {
  9621. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  9622. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  9623. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  9624. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  9625. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  9626. zsZone->SetWeatherPattern(1);
  9627. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  9628. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  9629. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  9630. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9631. zsZone->ProcessWeather();
  9632. }
  9633. // process commands with params
  9634. if( sep->arg[1] )
  9635. {
  9636. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  9637. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  9638. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  9639. zsZone->SetWeatherType(atoi(sep->arg[1]));
  9640. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  9641. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  9642. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  9643. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  9644. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  9645. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  9646. }
  9647. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  9648. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  9649. zsZone->SetRain(zsZone->GetCurrentWeather());
  9650. }
  9651. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  9652. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  9653. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  9654. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  9655. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9656. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  9657. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9658. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  9659. }
  9660. }
  9661. else
  9662. {
  9663. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  9664. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  9665. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  9666. return;
  9667. }
  9668. }
  9669. void Commands::Command_Select(Client* client, Seperator* sep) {
  9670. if (sep && sep->arg[1]) {
  9671. Spawn* spawn = client->GetPlayer()->GetTarget();
  9672. if (spawn && strlen(sep->arg[1]) > 0)
  9673. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  9674. }
  9675. }
  9676. /*
  9677. Function: Command_ConsumeFood()
  9678. Purpose : Consume Food/Drink and apply mods
  9679. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  9680. Dev : Zcoretri
  9681. Example : /consume_food 22
  9682. */
  9683. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  9684. if (sep && sep->arg[0] && sep->IsNumber(0))
  9685. {
  9686. Player* player = client->GetPlayer();
  9687. int8 slot = atoi(sep->arg[0]);
  9688. Item* item = player->GetEquipmentList()->GetItem(slot);
  9689. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  9690. {
  9691. client->Message(CHANNEL_NARRATIVE, "If you ate anymore you would explode!");
  9692. return;
  9693. }
  9694. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  9695. {
  9696. client->Message(CHANNEL_NARRATIVE, "If you drank anymore you would explode!");
  9697. return;
  9698. }
  9699. client->ConsumeFoodDrink(item, slot);
  9700. }
  9701. }
  9702. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  9703. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9704. if (atoi(sep->arg[0]) == 1) {
  9705. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  9706. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  9707. client->GetPlayer()->SetCharSheetChanged(true);
  9708. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  9709. }
  9710. else {
  9711. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  9712. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  9713. client->GetPlayer()->SetCharSheetChanged(true);
  9714. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  9715. }
  9716. }
  9717. else
  9718. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  9719. }
  9720. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  9721. {
  9722. if(sep)
  9723. {
  9724. string data;
  9725. if(sep->arg[0]){
  9726. data = string(sep->arg[0]);
  9727. }
  9728. for(int i=1;i<sep->GetMaxArgNum();i++){
  9729. if(sep->arg[i])
  9730. data.append(" ").append(sep->arg[i]);
  9731. }
  9732. const char* target_name = 0;
  9733. int32 spawn_id = 0;
  9734. if(client->GetPlayer()->GetTarget())
  9735. {
  9736. target_name = client->GetPlayer()->GetTarget()->GetName();
  9737. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9738. }
  9739. else
  9740. target_name = "N/A";
  9741. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  9742. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  9743. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  9744. else
  9745. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  9746. }
  9747. }
  9748. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  9749. PrintSep(sep, "Command_Attune_Inv");
  9750. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9751. // Get the item index from the first parameter
  9752. int16 index = atoi(sep->arg[0]);
  9753. // Check to see if this is a valid item index for the player, if not exit out of the function
  9754. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  9755. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  9756. return;
  9757. }
  9758. // Get the item
  9759. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  9760. if(item) {
  9761. // Valid item lets check to make sure this item is attunable, if not return out
  9762. if (!item->CheckFlag(ATTUNEABLE)) {
  9763. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  9764. return;
  9765. }
  9766. // Remove the attunable flag
  9767. item->generic_info.item_flags -= ATTUNEABLE;
  9768. // Set the attuned flag
  9769. item->generic_info.item_flags += ATTUNED;
  9770. // Flag this item for saving
  9771. item->save_needed = true;
  9772. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  9773. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  9774. EQ2Packet* outapp = 0;
  9775. for (int32 i=0;i<packets.size();i++) {
  9776. outapp = packets[i];
  9777. if(outapp)
  9778. client->QueuePacket(outapp);
  9779. }
  9780. }
  9781. }
  9782. }
  9783. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  9784. PrintSep(sep, "Command_Reset_Zone_Timer");
  9785. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9786. int32 db_id = atoul(sep->arg[0]);
  9787. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  9788. if (data) {
  9789. // TODO: add a check to timers to ensure it can be reset
  9790. // Delete the character from the instance
  9791. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  9792. data->instance_id = 0;
  9793. // Update the success time and set to 0 so the player can enter it again
  9794. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  9795. data->last_success_timestamp = 0;
  9796. }
  9797. }*/
  9798. }
  9799. void Commands::Command_Player(Client* client, Seperator* sep) {
  9800. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  9801. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  9802. }
  9803. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  9804. // /player coins add 10
  9805. // /player coins add plat 10
  9806. Player* player = client->GetPlayer();
  9807. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  9808. player = (Player*)player->GetTarget();
  9809. if (sep && sep->arg[0] && sep->arg[1]) {
  9810. const char* action = sep->arg[0];
  9811. int64 value = 0;
  9812. if (strncasecmp(action, "add", strlen(action)) == 0) {
  9813. if (sep->IsNumber(1)) {
  9814. value = atoi64(sep->arg[1]);
  9815. player->AddCoins(value);
  9816. if (client->GetPlayer() == player)
  9817. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9818. else {
  9819. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9820. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9821. }
  9822. return;
  9823. }
  9824. else if (sep->arg[2] && sep->IsNumber(2)) {
  9825. const char* type = sep->arg[1];
  9826. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  9827. value = atoi64(sep->arg[2]);
  9828. }
  9829. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  9830. value = atoi64(sep->arg[2]) * 100;
  9831. }
  9832. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  9833. value = atoi64(sep->arg[2]) * 10000;
  9834. }
  9835. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  9836. value = atoi64(sep->arg[2]) * 1000000;
  9837. }
  9838. player->AddCoins(value);
  9839. if (client->GetPlayer() == player)
  9840. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9841. else {
  9842. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9843. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9844. }
  9845. return;
  9846. }
  9847. }
  9848. }
  9849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  9850. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  9851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  9852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  9853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  9854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  9855. }
  9856. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  9857. PrintSep(sep, "ACHIEVEMENT_ADD");
  9858. if (sep && sep->IsSet(0)) {
  9859. int32 spell_id = atoul(sep->arg[1]);
  9860. int8 spell_tier = 0;
  9861. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9862. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9863. // addspellbookentry here
  9864. if (spell_tier >= data->maxRank) {
  9865. return;
  9866. }
  9867. if (!spell_tier) {
  9868. spell_tier = 1;
  9869. }
  9870. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9871. {
  9872. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9873. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9874. client->GetPlayer()->UnlockSpell(spell);
  9875. client->SendSpellUpdate(spell);
  9876. }
  9877. else
  9878. {
  9879. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  9880. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9881. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9882. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9883. client->GetPlayer()->UnlockSpell(spell);
  9884. client->SendSpellUpdate(spell);
  9885. }
  9886. // cast spell here
  9887. if (!spell_tier)
  9888. spell_tier = 1;
  9889. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9890. if (spell) {
  9891. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9892. }
  9893. }
  9894. else {
  9895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9896. }
  9897. master_aa_list.DisplayAA(client, 0, 0);
  9898. }
  9899. void Commands::Command_Editor(Client* client, Seperator* sep) {
  9900. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  9901. if (packet) {
  9902. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  9903. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  9904. char command[255];
  9905. url = "browser " + url;
  9906. int32 spawn_id = 0;
  9907. int32 zone_id = 0;
  9908. string type;
  9909. if (client->GetCurrentZone())
  9910. zone_id = client->GetCurrentZone()->GetZoneID();
  9911. if (client->GetPlayer()->GetTarget()) {
  9912. Spawn* target = client->GetPlayer()->GetTarget();
  9913. if (target->IsWidget())
  9914. type = "widgets";
  9915. else if (target->IsSign())
  9916. type = "signs";
  9917. else if (target->IsObject())
  9918. type = "objects";
  9919. else if (target->IsNPC())
  9920. type = "npcs";
  9921. else if (target->IsGroundSpawn())
  9922. type = "ground";
  9923. else
  9924. type = "spawn";
  9925. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9926. }
  9927. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  9928. packet->setDataByName("accept_command", command);
  9929. }
  9930. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  9931. char command[255];
  9932. url = "browser " + url;
  9933. if (client->GetPlayer()->GetTarget())
  9934. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  9935. packet->setDataByName("accept_command", command);
  9936. }
  9937. else {
  9938. string command = "browser " + url;
  9939. packet->setDataByName("accept_command", command.c_str());
  9940. }
  9941. packet->setDataByName("text", "Open the web editor?");
  9942. packet->setDataByName("accept_text", "Open");
  9943. packet->setDataByName("cancel_text", "Cancel");
  9944. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  9945. packet->setDataByName("unknown2", 50);
  9946. packet->setDataByName("unknown4", 1);
  9947. client->QueuePacket(packet->serialize());
  9948. safe_delete(packet);
  9949. }
  9950. }
  9951. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  9952. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9953. return;
  9954. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9955. if(client->GetCurrentRez()->active)
  9956. client->AcceptResurrection();
  9957. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9958. }
  9959. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  9960. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9961. return;
  9962. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9963. if(client->GetCurrentRez()->active)
  9964. client->GetCurrentRez()->should_delete = true;
  9965. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9966. }
  9967. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  9968. PrintSep(sep, "Switch_AA_Profile");
  9969. if (sep && sep->IsSet(0)) {
  9970. string type = sep->arg[0];
  9971. int8 newtemplate = atoul(sep->arg[1]);
  9972. master_aa_list.DisplayAA(client, newtemplate, 1);
  9973. }
  9974. }
  9975. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  9976. PrintSep(sep, "Get_AA_Xml");
  9977. if (sep && sep->IsSet(0)) {
  9978. string tabnum = sep->arg[0];
  9979. string spellid = sep->arg[1];
  9980. }
  9981. }
  9982. void Commands::Add_AA(Client* client, Seperator* sep) {
  9983. PrintSep(sep, "Add_AA");
  9984. if (sep && sep->IsSet(0)) {
  9985. int32 spell_id = atoul(sep->arg[1]);
  9986. int8 spell_tier = 0;
  9987. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9988. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9989. // addspellbookentry here
  9990. if(!data) {
  9991. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  9992. return;
  9993. }
  9994. if (spell_tier >= data->maxRank) {
  9995. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  9996. return;
  9997. }
  9998. if (!spell_tier) {
  9999. spell_tier = 1;
  10000. }
  10001. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10002. {
  10003. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10004. if(spell)
  10005. {
  10006. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10007. client->GetPlayer()->UnlockSpell(spell);
  10008. client->SendSpellUpdate(spell);
  10009. }
  10010. }
  10011. else
  10012. {
  10013. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10014. if(spell)
  10015. {
  10016. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10017. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10018. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10019. client->GetPlayer()->UnlockSpell(spell);
  10020. client->SendSpellUpdate(spell);
  10021. }
  10022. }
  10023. // cast spell here
  10024. if (!spell_tier)
  10025. spell_tier = 1;
  10026. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10027. if (spell) {
  10028. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10029. }
  10030. }
  10031. else {
  10032. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10033. }
  10034. master_aa_list.DisplayAA(client, 0, 0);
  10035. }
  10036. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  10037. PrintSep(sep, "Commit_AA_Profile");
  10038. if (sep && sep->IsSet(0)) {
  10039. }
  10040. }
  10041. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  10042. PrintSep(sep, "Begin_AA_Profile");
  10043. if (sep && sep->IsSet(0)) {
  10044. master_aa_list.DisplayAA(client, 100, 2);
  10045. }
  10046. }
  10047. void Commands::Back_AA(Client* client, Seperator* sep) {
  10048. if (sep && sep->IsSet(0)) {
  10049. PrintSep(sep, "Back_AA");
  10050. }
  10051. }
  10052. void Commands::Remove_AA(Client* client, Seperator* sep) {
  10053. if (sep && sep->IsSet(0)) {
  10054. PrintSep(sep, "Remove_AA");
  10055. }
  10056. }
  10057. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  10058. MasterAAList master_aa_list;
  10059. PrintSep(sep, "Cancel_AA_Profile");
  10060. master_aa_list.DisplayAA(client, 0, 0);
  10061. }
  10062. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  10063. if (sep && sep->IsSet(0)) {
  10064. PrintSep(sep, "Save_AA_Profile");
  10065. }
  10066. }
  10067. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  10068. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  10069. if (!sep->IsNumber(0)) return;
  10070. int32 request_id = atoul(sep->arg[0]);
  10071. if (!sep->IsNumber(1)) return;
  10072. sint32 item_id = atoi(sep->arg[1]);
  10073. if (client->IsCurrentTransmuteID(request_id)) {
  10074. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  10075. }
  10076. else if (client->IsCurrentTransmuteID(item_id)) {
  10077. if (!sep->IsSet(2)) return;
  10078. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  10079. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  10080. }
  10081. }
  10082. }
  10083. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  10084. if(sep)
  10085. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  10086. }
  10087. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  10088. if(sep && sep->arg[0][0] && sep->arg[1][0])
  10089. {
  10090. char* name = sep->arg[0];
  10091. char* zoneName = sep->arg[1];
  10092. char query[256];
  10093. 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);
  10094. if (database.RunQuery(query, strnlen(query, 256)))
  10095. {
  10096. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  10097. }
  10098. else
  10099. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  10100. }
  10101. }