Commands.cpp 362 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121
  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. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  149. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  150. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  151. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  152. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  153. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  154. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  155. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  156. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  157. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  158. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  159. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  160. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  161. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  162. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  163. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  164. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  165. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  166. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  167. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  168. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  169. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  170. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  171. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  172. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  173. }
  174. Commands::~Commands() {
  175. safe_delete(remote_commands);
  176. }
  177. int32 Commands::GetSpawnSetType(string val){
  178. if(spawn_set_values.count(val) > 0)
  179. return spawn_set_values[val];
  180. return 0xFFFFFFFF;
  181. }
  182. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  183. if(!target)
  184. return false;
  185. int32 val = 0;
  186. try{
  187. if(type != SPAWN_SET_VALUE_NAME && !(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))
  188. val = atoul(value);
  189. }
  190. catch(...){
  191. if(client)
  192. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  193. return false;
  194. }
  195. if(temporary && temp_value){
  196. char tmp[128] = {0};
  197. switch(type){
  198. case SPAWN_SET_VALUE_NAME:{
  199. sprintf(tmp, "%s", target->GetName());
  200. target->SetName(value);
  201. client->GetCurrentZone()->SendUpdateTitles(target);
  202. break;
  203. }
  204. case SPAWN_SET_VALUE_X_OFFSET:
  205. {
  206. sprintf(tmp, "%f", target->GetXOffset());
  207. target->SetXOffset(float(val));
  208. break;
  209. }
  210. case SPAWN_SET_VALUE_Y_OFFSET:
  211. {
  212. sprintf(tmp, "%f", target->GetYOffset());
  213. target->SetYOffset(float(val));
  214. break;
  215. }
  216. case SPAWN_SET_VALUE_Z_OFFSET:
  217. {
  218. sprintf(tmp, "%f", target->GetZOffset());
  219. target->SetZOffset(float(val));
  220. break;
  221. }
  222. case SPAWN_SET_VALUE_EXPIRE: {
  223. sprintf(tmp, "%u", target->GetExpireTime());
  224. target->SetExpireTime(val);
  225. break;
  226. }
  227. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  228. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  229. target->SetExpireOffsetTime(val);
  230. break;
  231. }
  232. case SPAWN_SET_VALUE_SUB_TITLE: {
  233. sprintf(tmp, "%s", target->GetSubTitle());
  234. target->SetSubTitle(value);
  235. client->GetCurrentZone()->SendUpdateTitles(target);
  236. break;
  237. }
  238. case SPAWN_SET_VALUE_LEVEL:{
  239. sprintf(tmp, "%i", target->GetLevel());
  240. target->SetLevel(val, send_update);
  241. break;
  242. }
  243. case SPAWN_SET_VALUE_DIFFICULTY:{
  244. sprintf(tmp, "%i", target->GetEncounterLevel());
  245. target->SetEncounterLevel(val, send_update);
  246. break;
  247. }
  248. case SPAWN_SET_VALUE_MODEL_TYPE:{
  249. sprintf(tmp, "%i", target->GetModelType());
  250. target->SetModelType(val, send_update);
  251. break;
  252. }
  253. case SPAWN_SET_VALUE_CLASS:{
  254. sprintf(tmp, "%i", target->GetAdventureClass());
  255. target->SetAdventureClass(val, send_update);
  256. break;
  257. }
  258. case SPAWN_SET_VALUE_GENDER:{
  259. sprintf(tmp, "%i", target->GetGender());
  260. target->SetGender(val, send_update);
  261. break;
  262. }
  263. case SPAWN_SET_VALUE_SHOW_NAME:{
  264. sprintf(tmp, "%i", target->GetShowName());
  265. target->SetShowName(val, send_update);
  266. break;
  267. }
  268. case SPAWN_SET_VALUE_ATTACKABLE:{
  269. sprintf(tmp, "%i", target->GetAttackable());
  270. target->SetAttackable(val, send_update);
  271. break;
  272. }
  273. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  274. sprintf(tmp, "%i", target->GetShowLevel());
  275. target->SetShowLevel(val, send_update);
  276. break;
  277. }
  278. case SPAWN_SET_VALUE_TARGETABLE:{
  279. sprintf(tmp, "%i", target->GetTargetable());
  280. target->SetTargetable(val, send_update);
  281. break;
  282. }
  283. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  284. sprintf(tmp, "%i", target->GetShowCommandIcon());
  285. target->SetShowCommandIcon(val, send_update);
  286. break;
  287. }
  288. case SPAWN_SET_VALUE_HAND_ICON:{
  289. sprintf(tmp, "%i", target->GetShowHandIcon());
  290. target->SetShowHandIcon(val, send_update);
  291. break;
  292. }
  293. case SPAWN_SET_VALUE_HAIR_TYPE:{
  294. if(target->IsEntity()){
  295. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  296. ((Entity*)target)->SetHairType(val, send_update);
  297. }
  298. break;
  299. }
  300. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  301. if(target->IsEntity()){
  302. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  303. ((Entity*)target)->SetHairType(val, send_update);
  304. }
  305. break;
  306. }
  307. case SPAWN_SET_VALUE_WING_TYPE:{
  308. if(target->IsEntity()){
  309. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  310. ((Entity*)target)->SetWingType(val, send_update);
  311. }
  312. break;
  313. }
  314. case SPAWN_SET_VALUE_CHEST_TYPE:{
  315. if(target->IsEntity()){
  316. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  317. ((Entity*)target)->SetChestType(val, send_update);
  318. }
  319. break;
  320. }
  321. case SPAWN_SET_VALUE_LEGS_TYPE:{
  322. if(target->IsEntity()){
  323. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  324. ((Entity*)target)->SetLegsType(val, send_update);
  325. }
  326. break;
  327. }
  328. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  329. if(target->IsEntity()){
  330. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  331. ((Entity*)target)->SetSogaHairType(val, send_update);
  332. }
  333. break;
  334. }
  335. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  336. if(target->IsEntity()){
  337. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  338. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  339. }
  340. break;
  341. }
  342. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  343. sprintf(tmp, "%i", target->GetSogaModelType());
  344. target->SetSogaModelType(val, send_update);
  345. break;
  346. }
  347. case SPAWN_SET_VALUE_SIZE:{
  348. sprintf(tmp, "%i", target->GetSize());
  349. target->SetSize(val, send_update);
  350. break;
  351. }
  352. case SPAWN_SET_VALUE_HP:{
  353. sprintf(tmp, "%i", target->GetHP());
  354. target->SetHP(val, send_update);
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_POWER:{
  358. sprintf(tmp, "%i", target->GetPower());
  359. target->SetPower(val, send_update);
  360. break;
  361. }
  362. case SPAWN_SET_VALUE_HEROIC:{
  363. sprintf(tmp, "%i", target->GetHeroic());
  364. target->SetHeroic(val, send_update);
  365. break;
  366. }
  367. case SPAWN_SET_VALUE_RESPAWN:{
  368. sprintf(tmp, "%u", target->GetRespawnTime());
  369. target->SetRespawnTime(val);
  370. break;
  371. }
  372. case SPAWN_SET_VALUE_X:{
  373. sprintf(tmp, "%f", target->GetX());
  374. target->SetX(atof(value), send_update);
  375. break;
  376. }
  377. case SPAWN_SET_VALUE_Y:{
  378. sprintf(tmp, "%f", target->GetY());
  379. target->SetY(atof(value), send_update);
  380. break;
  381. }
  382. case SPAWN_SET_VALUE_Z:{
  383. sprintf(tmp, "%f", target->GetZ());
  384. target->SetZ(atof(value), send_update);
  385. break;
  386. }
  387. case SPAWN_SET_VALUE_HEADING:{
  388. sprintf(tmp, "%f", target->GetHeading());
  389. target->SetHeading(atof(value) + 360, send_update);
  390. break;
  391. }
  392. case SPAWN_SET_VALUE_VISUAL_STATE:{
  393. sprintf(tmp, "%i", target->GetVisualState());
  394. target->SetVisualState(val, send_update);
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_ACTION_STATE:{
  398. sprintf(tmp, "%i", target->GetActionState());
  399. target->SetActionState(val, send_update);
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_MOOD_STATE:{
  403. sprintf(tmp, "%i", target->GetMoodState());
  404. target->SetMoodState(val, send_update);
  405. break;
  406. }
  407. case SPAWN_SET_VALUE_INITIAL_STATE:{
  408. sprintf(tmp, "%i", target->GetInitialState());
  409. target->SetInitialState(val, send_update);
  410. break;
  411. }
  412. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  413. sprintf(tmp, "%i", target->GetActivityStatus());
  414. target->SetActivityStatus(val, send_update);
  415. break;
  416. }
  417. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  418. sprintf(tmp, "%i", target->GetCollisionRadius());
  419. target->SetCollisionRadius(val, send_update);
  420. break;
  421. }
  422. case SPAWN_SET_VALUE_DEVICE_ID: {
  423. if (target->IsObject()) {
  424. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  425. ((Object*)target)->SetDeviceID(val);
  426. }
  427. break;
  428. }
  429. case SPAWN_SET_VALUE_PITCH: {
  430. sprintf(tmp, "%f", target->GetPitch());
  431. target->SetPitch(atof(value), send_update);
  432. break;
  433. }
  434. case SPAWN_SET_VALUE_ROLL: {
  435. sprintf(tmp, "%f", target->GetRoll());
  436. target->SetRoll(atof(value), send_update);
  437. break;
  438. }
  439. case SPAWN_SET_VALUE_HIDE_HOOD: {
  440. sprintf(tmp, "%i", target->appearance.hide_hood);
  441. target->SetHideHood(val);
  442. break;
  443. }
  444. case SPAWN_SET_VALUE_EMOTE_STATE: {
  445. sprintf(tmp, "%i", target->appearance.emote_state);
  446. target->SetEmoteState(val);
  447. break;
  448. }
  449. case SPAWN_SET_VALUE_ICON: {
  450. sprintf(tmp, "%i", target->GetIconValue());
  451. target->SetIcon(val);
  452. break;
  453. }
  454. case SPAWN_SET_VALUE_PREFIX: {
  455. sprintf(tmp, "%s", target->GetPrefixTitle());
  456. target->SetPrefixTitle(value);
  457. client->GetCurrentZone()->SendUpdateTitles(target);
  458. break;
  459. }
  460. case SPAWN_SET_VALUE_SUFFIX: {
  461. sprintf(tmp, "%s", target->GetSuffixTitle());
  462. target->SetSuffixTitle(value);
  463. client->GetCurrentZone()->SendUpdateTitles(target);
  464. break;
  465. }
  466. case SPAWN_SET_VALUE_LASTNAME: {
  467. sprintf(tmp, "%s", target->GetLastName());
  468. target->SetLastName(value);
  469. client->GetCurrentZone()->SendUpdateTitles(target);
  470. break;
  471. }
  472. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  473. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  474. // nothing to do must reload spawns
  475. break;
  476. }
  477. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  478. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  479. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  480. break;
  481. }
  482. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  483. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  484. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  485. break;
  486. }
  487. *temp_value = string(tmp);
  488. }
  489. }
  490. else{
  491. switch(type){
  492. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  493. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  494. break;
  495. }
  496. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  497. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  498. break;
  499. }
  500. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  501. if (target->GetDatabaseID() > 0)
  502. {
  503. char query[256];
  504. snprintf(query, 256, "update spawn set expansion_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  505. if (database.RunQuery(query, strnlen(query, 256)))
  506. {
  507. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  508. }
  509. }
  510. break;
  511. }
  512. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  513. if (target->GetDatabaseID() > 0)
  514. {
  515. char query[256];
  516. snprintf(query, 256, "update spawn set holiday_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  517. if (database.RunQuery(query, strnlen(query, 256)))
  518. {
  519. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  520. }
  521. }
  522. break;
  523. }
  524. case SPAWN_SET_VALUE_NAME:{
  525. target->SetName(value);
  526. client->GetCurrentZone()->SendUpdateTitles(target);
  527. break;
  528. }
  529. case SPAWN_SET_VALUE_SUB_TITLE: {
  530. target->SetSubTitle(value);
  531. client->GetCurrentZone()->SendUpdateTitles(target);
  532. break;
  533. }
  534. case SPAWN_SET_VALUE_X_OFFSET:
  535. {
  536. target->SetXOffset(atof(value));
  537. break;
  538. }
  539. case SPAWN_SET_VALUE_Y_OFFSET:
  540. {
  541. target->SetYOffset(atof(value));
  542. break;
  543. }
  544. case SPAWN_SET_VALUE_Z_OFFSET:
  545. {
  546. target->SetZOffset(atof(value));
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_EXPIRE: {
  550. target->SetExpireTime(val);
  551. break;
  552. }
  553. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  554. target->SetExpireOffsetTime(val);
  555. break;
  556. }
  557. case SPAWN_SET_VALUE_LEVEL:{
  558. target->SetLevel(val, send_update);
  559. break;
  560. }
  561. case SPAWN_SET_VALUE_DIFFICULTY:{
  562. target->SetEncounterLevel(val, send_update);
  563. break;
  564. }
  565. case SPAWN_SET_VALUE_MODEL_TYPE:{
  566. target->SetModelType(val, send_update);
  567. break;
  568. }
  569. case SPAWN_SET_VALUE_CLASS:{
  570. target->SetAdventureClass(val, send_update);
  571. break;
  572. }
  573. case SPAWN_SET_VALUE_GENDER:{
  574. target->SetGender(val, send_update);
  575. break;
  576. }
  577. case SPAWN_SET_VALUE_SHOW_NAME:{
  578. target->SetShowName(val, send_update);
  579. break;
  580. }
  581. case SPAWN_SET_VALUE_ATTACKABLE:{
  582. target->SetAttackable(val, send_update);
  583. break;
  584. }
  585. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  586. target->SetShowLevel(val, send_update);
  587. break;
  588. }
  589. case SPAWN_SET_VALUE_TARGETABLE:{
  590. target->SetTargetable(val, send_update);
  591. break;
  592. }
  593. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  594. target->SetShowCommandIcon(val, send_update);
  595. break;
  596. }
  597. case SPAWN_SET_VALUE_HAND_ICON:{
  598. target->SetShowHandIcon(val, send_update);
  599. break;
  600. }
  601. case SPAWN_SET_VALUE_HAIR_TYPE:{
  602. if(target->IsEntity())
  603. ((Entity*)target)->SetHairType(val, send_update);
  604. break;
  605. }
  606. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  607. if(target->IsEntity())
  608. ((Entity*)target)->SetHairType(val, send_update);
  609. break;
  610. }
  611. case SPAWN_SET_VALUE_WING_TYPE:{
  612. if(target->IsEntity())
  613. ((Entity*)target)->SetWingType(val, send_update);
  614. break;
  615. }
  616. case SPAWN_SET_VALUE_CHEST_TYPE:{
  617. if(target->IsEntity())
  618. ((Entity*)target)->SetChestType(val, send_update);
  619. break;
  620. }
  621. case SPAWN_SET_VALUE_LEGS_TYPE:{
  622. if(target->IsEntity())
  623. ((Entity*)target)->SetLegsType(val, send_update);
  624. break;
  625. }
  626. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  627. if(target->IsEntity())
  628. ((Entity*)target)->SetSogaHairType(val, send_update);
  629. break;
  630. }
  631. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  632. if(target->IsEntity())
  633. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  634. break;
  635. }
  636. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  637. target->SetSogaModelType(val, send_update);
  638. break;
  639. }
  640. case SPAWN_SET_VALUE_SIZE:{
  641. target->SetSize(val, send_update);
  642. break;
  643. }
  644. case SPAWN_SET_VALUE_HP:{
  645. target->SetHP(val, send_update);
  646. break;
  647. }
  648. case SPAWN_SET_VALUE_POWER:{
  649. target->SetPower(val, send_update);
  650. break;
  651. }
  652. case SPAWN_SET_VALUE_HEROIC:{
  653. target->SetHeroic(val, send_update);
  654. break;
  655. }
  656. case SPAWN_SET_VALUE_RESPAWN:{
  657. target->SetRespawnTime(val);
  658. break;
  659. }
  660. case SPAWN_SET_VALUE_X:{
  661. target->SetX(atof(value), send_update);
  662. target->SetSpawnOrigX(target->GetX());
  663. break;
  664. }
  665. case SPAWN_SET_VALUE_Y:{
  666. target->SetY(atof(value), send_update);
  667. target->SetSpawnOrigY(target->GetY());
  668. break;
  669. }
  670. case SPAWN_SET_VALUE_Z:{
  671. target->SetZ(atof(value), send_update);
  672. target->SetSpawnOrigZ(target->GetZ());
  673. break;
  674. }
  675. case SPAWN_SET_VALUE_HEADING:{
  676. target->SetHeading(atof(value), send_update);
  677. target->SetSpawnOrigHeading(target->GetHeading());
  678. break;
  679. }
  680. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  681. ZoneServer* zone = target->GetZone();
  682. if (!zone)
  683. zone = client->GetCurrentZone();
  684. if(zone->GetEntityCommandList(val))
  685. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  686. target->primary_command_list_id = val;
  687. break;
  688. }
  689. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  690. ZoneServer* zone = target->GetZone();
  691. if (!zone)
  692. zone = client->GetCurrentZone();
  693. if (zone->GetEntityCommandList(val))
  694. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  695. target->secondary_command_list_id = val;
  696. break;
  697. }
  698. case SPAWN_SET_VALUE_VISUAL_STATE:{
  699. target->SetVisualState(val, send_update);
  700. break;
  701. }
  702. case SPAWN_SET_VALUE_ACTION_STATE:{
  703. target->SetActionState(val, send_update);
  704. break;
  705. }
  706. case SPAWN_SET_VALUE_MOOD_STATE:{
  707. target->SetMoodState(val, send_update);
  708. break;
  709. }
  710. case SPAWN_SET_VALUE_INITIAL_STATE:{
  711. target->SetInitialState(val, send_update);
  712. break;
  713. }
  714. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  715. target->SetActivityStatus(val, send_update);
  716. break;
  717. }
  718. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  719. target->SetCollisionRadius(val, send_update);
  720. break;
  721. }
  722. case SPAWN_SET_VALUE_FACTION:{
  723. ZoneServer* zone = target->GetZone();
  724. if (!zone)
  725. zone = client->GetCurrentZone();
  726. target->faction_id = val;
  727. zone->RemoveDeadEnemyList(target);
  728. if(target->IsNPC())
  729. zone->AddEnemyList((NPC*)target);
  730. break;
  731. }
  732. case SPAWN_SET_VALUE_DEVICE_ID:{
  733. if (target->IsObject())
  734. ((Object*)target)->SetDeviceID(val);
  735. break;
  736. }
  737. case SPAWN_SET_VALUE_PITCH: {
  738. target->SetPitch(atof(value), send_update);
  739. target->SetSpawnOrigPitch(atof(value));
  740. break;
  741. }
  742. case SPAWN_SET_VALUE_ROLL: {
  743. target->SetRoll(atof(value), send_update);
  744. target->SetSpawnOrigRoll(atof(value));
  745. break;
  746. }
  747. case SPAWN_SET_VALUE_HIDE_HOOD: {
  748. target->SetHideHood(val);
  749. break;
  750. }
  751. case SPAWN_SET_VALUE_EMOTE_STATE: {
  752. target->SetEmoteState(val);
  753. break;
  754. }
  755. case SPAWN_SET_VALUE_ICON: {
  756. target->SetIcon(val);
  757. break;
  758. }
  759. case SPAWN_SET_VALUE_PREFIX: {
  760. target->SetPrefixTitle(value);
  761. client->GetCurrentZone()->SendUpdateTitles(target);
  762. break;
  763. }
  764. case SPAWN_SET_VALUE_SUFFIX: {
  765. target->SetSuffixTitle(value);
  766. client->GetCurrentZone()->SendUpdateTitles(target);
  767. break;
  768. }
  769. case SPAWN_SET_VALUE_LASTNAME: {
  770. target->SetLastName(value);
  771. client->GetCurrentZone()->SendUpdateTitles(target);
  772. break;
  773. }
  774. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  775. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  776. if(client){
  777. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  778. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  779. }
  780. return false;
  781. }
  782. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  783. return false;
  784. else{
  785. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  786. target->SetSpawnScript(value);
  787. }
  788. break;
  789. }
  790. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  791. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  792. if(client){
  793. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  794. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  795. }
  796. return false;
  797. }
  798. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  799. return false;
  800. else{
  801. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  802. target->SetSpawnScript(value);
  803. }
  804. break;
  805. }
  806. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  807. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  808. if(client){
  809. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  810. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  811. }
  812. return false;
  813. }
  814. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  815. return false;
  816. else
  817. target->SetSpawnScript(value);
  818. break;
  819. }
  820. }
  821. }
  822. return true;
  823. }
  824. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  825. the database fields always and also update the zone in memory if it's running. */
  826. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  827. if (client && zone_id > 0 && type > 0 && value) {
  828. sint32 int_value = 0;
  829. float float_value = 0;
  830. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  831. try {
  832. float_value = atof(value);
  833. }
  834. catch (...) {
  835. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  836. return false;
  837. }
  838. }
  839. 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) {
  840. try {
  841. int_value = atoi(value);
  842. }
  843. catch (...) {
  844. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  845. return false;
  846. }
  847. }
  848. switch (type) {
  849. case ZONE_SET_VALUE_EXPANSION_ID: {
  850. break;
  851. }
  852. case ZONE_SET_VALUE_NAME: {
  853. if (zone)
  854. zone->SetZoneName(const_cast<char*>(value));
  855. database.SaveZoneInfo(zone_id, "name", value);
  856. break;
  857. }
  858. case ZONE_SET_VALUE_FILE: {
  859. if (zone)
  860. zone->SetZoneFile(const_cast<char*>(value));
  861. database.SaveZoneInfo(zone_id, "file", value);
  862. break;
  863. }
  864. case ZONE_SET_VALUE_DESCRIPTION: {
  865. if (zone)
  866. zone->SetZoneDescription(const_cast<char*>(value));
  867. database.SaveZoneInfo(zone_id, "description", value);
  868. break;
  869. }
  870. case ZONE_SET_VALUE_SAFE_X: {
  871. if (zone)
  872. zone->SetSafeX(float_value);
  873. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  874. break;
  875. }
  876. case ZONE_SET_VALUE_SAFE_Y: {
  877. if (zone)
  878. zone->SetSafeY(float_value);
  879. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  880. break;
  881. }
  882. case ZONE_SET_VALUE_SAFE_Z: {
  883. if (zone)
  884. zone->SetSafeZ(float_value);
  885. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  886. break;
  887. }
  888. case ZONE_SET_VALUE_UNDERWORLD: {
  889. if (zone)
  890. zone->SetUnderWorld(float_value);
  891. database.SaveZoneInfo(zone_id, "underworld", float_value);
  892. break;
  893. }
  894. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  895. break;
  896. }
  897. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  898. break;
  899. }
  900. case ZONE_SET_VALUE_ZONE_TYPE: {
  901. break;
  902. }
  903. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  904. if (zone)
  905. zone->SetAlwaysLoaded(int_value == 1);
  906. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  907. break;
  908. }
  909. case ZONE_SET_VALUE_CITY_ZONE: {
  910. if (zone)
  911. zone->SetCityZone(int_value == 1);
  912. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  913. break;
  914. }
  915. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  916. if (zone)
  917. zone->SetWeatherAllowed(int_value == 1);
  918. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  919. break;
  920. }
  921. case ZONE_SET_VALUE_MIN_STATUS: {
  922. if (zone)
  923. zone->SetMinimumStatus(int_value);
  924. database.SaveZoneInfo(zone_id, "min_status", int_value);
  925. break;
  926. }
  927. case ZONE_SET_VALUE_MIN_LEVEL: {
  928. if (zone)
  929. zone->SetMinimumLevel(int_value);
  930. database.SaveZoneInfo(zone_id, "min_level", int_value);
  931. break;
  932. }
  933. case ZONE_SET_VALUE_MAX_LEVEL: {
  934. if (zone)
  935. zone->SetMaximumLevel(int_value);
  936. database.SaveZoneInfo(zone_id, "max_level", int_value);
  937. break;
  938. }
  939. case ZONE_SET_VALUE_START_ZONE: {
  940. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  941. break;
  942. }
  943. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  944. if (zone)
  945. zone->SetInstanceType(int_value);
  946. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  947. break;
  948. }
  949. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  950. if (zone)
  951. zone->SetDefaultReenterTime(int_value);
  952. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  953. break;
  954. }
  955. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  956. if (zone)
  957. zone->SetDefaultResetTime(int_value);
  958. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  959. break;
  960. }
  961. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  962. if (zone)
  963. zone->SetDefaultLockoutTime(int_value);
  964. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  965. break;
  966. }
  967. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  968. if (zone)
  969. zone->SetForceGroupZoneOption(int_value);
  970. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  971. break;
  972. }
  973. case ZONE_SET_VALUE_LUA_SCRIPT: {
  974. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  975. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  976. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  977. return false;
  978. }
  979. else {
  980. world.AddZoneScript(zone_id, const_cast<char*>(value));
  981. database.SaveZoneInfo(zone_id, "lua_script", value);
  982. }
  983. break;
  984. }
  985. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  986. if (zone)
  987. zone->SetShutdownTimer(int_value);
  988. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  989. break;
  990. }
  991. case ZONE_SET_VALUE_ZONE_MOTD: {
  992. if (zone)
  993. zone->SetZoneMOTD(string(value));
  994. database.SaveZoneInfo(zone_id, "zone_motd", value);
  995. break;
  996. }
  997. default: {
  998. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  999. return false;
  1000. }
  1001. }
  1002. }
  1003. else {
  1004. if (client)
  1005. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1006. return false;
  1007. }
  1008. return true;
  1009. }
  1010. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1011. if (index >= remote_commands->commands.size()) {
  1012. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1013. return;
  1014. }
  1015. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1016. EQ2_RemoteCommandString* parent_command = 0;
  1017. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1018. Seperator* sep = 0;
  1019. if (command_parms->size > 0) {
  1020. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1021. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1022. parent_command = command;
  1023. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1024. safe_delete(sep);
  1025. if (command_parms->data.length() > (command->command.data.length() + 1))
  1026. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1027. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1028. }
  1029. else
  1030. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1031. }
  1032. int ndx = 0;
  1033. if (command->required_status > client->GetAdminStatus())
  1034. {
  1035. 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());
  1036. safe_delete(sep);
  1037. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1038. return;
  1039. }
  1040. Player* player = client->GetPlayer();
  1041. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1042. switch (command->handler) {
  1043. case COMMAND_RELOAD: {
  1044. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1045. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1047. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1048. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1049. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1051. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1053. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1054. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1057. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1058. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1060. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1061. break;
  1062. }
  1063. case COMMAND_RELOADSTRUCTS: {
  1064. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1065. configReader.ReloadStructs();
  1066. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1067. break;
  1068. }
  1069. case COMMAND_RELOAD_QUESTS: {
  1070. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1071. master_quest_list.Reload();
  1072. client_list.ReloadQuests();
  1073. zone_list.ReloadClientQuests();
  1074. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1075. break;
  1076. }
  1077. case COMMAND_RELOAD_SPAWNS: {
  1078. client->GetCurrentZone()->ReloadSpawns();
  1079. break;
  1080. }
  1081. case COMMAND_RELOAD_SPELLS: {
  1082. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1083. zone_list.DeleteSpellProcess();
  1084. master_spell_list.Reload();
  1085. if (lua_interface)
  1086. lua_interface->ReloadSpells();
  1087. zone_list.LoadSpellProcess();
  1088. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1089. break;
  1090. }
  1091. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1093. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1094. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1095. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1096. break;
  1097. }
  1098. case COMMAND_RELOAD_ZONESCRIPTS: {
  1099. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1100. world.ResetZoneScripts();
  1101. database.LoadZoneScriptData();
  1102. if (lua_interface)
  1103. lua_interface->DestroyZoneScripts();
  1104. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1105. break;
  1106. }
  1107. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1108. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1109. client->GetCurrentZone()->ClearEntityCommands();
  1110. database.LoadEntityCommands(client->GetCurrentZone());
  1111. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1112. break;
  1113. }
  1114. case COMMAND_RELOAD_FACTIONS: {
  1115. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1116. master_faction_list.Clear();
  1117. database.LoadFactionList();
  1118. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1119. break;
  1120. }
  1121. case COMMAND_RELOAD_MAIL: {
  1122. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1123. zone_list.ReloadMail();
  1124. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1125. break;
  1126. }
  1127. case COMMAND_RELOAD_GUILDS: {
  1128. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1129. world.ReloadGuilds();
  1130. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1131. break;
  1132. }
  1133. case COMMAND_RELOAD_LOCATIONS: {
  1134. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1135. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1136. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1137. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1138. break;
  1139. }
  1140. case COMMAND_RELOAD_RULES: {
  1141. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1142. database.LoadRuleSets(true);
  1143. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1144. break;
  1145. }
  1146. case COMMAND_RELOAD_TRANSPORTERS: {
  1147. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1148. database.LoadTransporters(client->GetCurrentZone());
  1149. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1150. break;
  1151. }
  1152. case COMMAND_READ: {
  1153. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1154. if (strcmp(sep->arg[0], "read") == 0) {
  1155. int32 item_index = atol(sep->arg[1]);
  1156. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1157. if (item) {
  1158. Spawn* spawn = cmdTarget;
  1159. int8 numpages = item->book_pages.size();
  1160. string page1 = string(item->book_pages[0]->page_text.data);
  1161. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  1162. string title = item->name;
  1163. if (packet) {
  1164. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  1165. packet->setDataByName("book_title", title.c_str());
  1166. packet->setDataByName("book_type", "simple");
  1167. packet->setDataByName("unknown2", 1);
  1168. packet->setDataByName("unknown5", 1, 4);
  1169. packet->setArrayLengthByName("num_pages", numpages);
  1170. for (int8 pages = 1; pages <= numpages; pages++) {
  1171. int8 pagenum = int8(item->book_pages[pages - 1]->page);
  1172. string page = string(item->book_pages[pages-1]->page_text.data);
  1173. int8 valign = int8(item->book_pages[pages - 1]->valign);
  1174. int8 halign = int8(item->book_pages[pages - 1]->halign);
  1175. packet->setArrayDataByName("page_text", page.c_str(), pagenum -1);
  1176. packet->setArrayDataByName("page_text_valign", valign , pagenum - 1);
  1177. packet->setArrayDataByName("page_text_halign", halign, pagenum - 1);
  1178. // Need to add support for images
  1179. }
  1180. client->QueuePacket(packet->serialize());
  1181. safe_delete(packet);
  1182. }
  1183. break;
  1184. }
  1185. }
  1186. }
  1187. }
  1188. case COMMAND_USEABILITY:{
  1189. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1190. if (client->GetPlayer()->GetHP() == 0) {
  1191. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1192. }
  1193. else {
  1194. int32 spell_id = atoul(sep->arg[0]);
  1195. int8 spell_tier = 0;
  1196. if (sep->arg[1][0] && sep->IsNumber(1))
  1197. spell_tier = atoi(sep->arg[1]);
  1198. else
  1199. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1200. if (!spell_tier)
  1201. spell_tier = 1;
  1202. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1203. if (spell) {
  1204. 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)
  1205. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1206. else
  1207. {
  1208. if (cmdTarget)
  1209. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1210. else
  1211. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1212. }
  1213. }
  1214. }
  1215. }
  1216. else if (cmdTarget && cmdTarget->IsWidget())
  1217. {
  1218. Widget* widget = (Widget*)cmdTarget;
  1219. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1220. }
  1221. else
  1222. {
  1223. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1224. }
  1225. break;
  1226. }
  1227. case COMMAND_INFO:{
  1228. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1229. if(strcmp(sep->arg[0], "inventory") == 0){
  1230. int32 item_index = atol(sep->arg[1]);
  1231. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1232. if(item){
  1233. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1234. break;
  1235. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1236. //DumpPacket(app);
  1237. client->QueuePacket(app);
  1238. if(item->GetItemScript() && lua_interface)
  1239. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1240. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1241. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id);
  1242. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1243. client->AddPendingQuest(quest);
  1244. }
  1245. }
  1246. else
  1247. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1248. }
  1249. else if(strcmp(sep->arg[0], "equipment") == 0){
  1250. int32 item_index = atol(sep->arg[1]);
  1251. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1252. if(item){
  1253. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1254. client->QueuePacket(app);
  1255. if(item->GetItemScript() && lua_interface)
  1256. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1257. }
  1258. else
  1259. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1260. }
  1261. 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){
  1262. int32 item_id = atoul(sep->arg[1]);
  1263. Item* item = master_item_list.GetItem(item_id);
  1264. if(item){
  1265. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1266. client->QueuePacket(app);
  1267. }
  1268. else
  1269. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1270. }
  1271. else if (strcmp(sep->arg[0], "spell") == 0) {
  1272. sint32 spell_id = atol(sep->arg[1]);
  1273. int8 tier = atoi(sep->arg[3]);
  1274. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1275. if (outapp)
  1276. client->QueuePacket(outapp);
  1277. else
  1278. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1279. }
  1280. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1281. sint32 spell_id = atol(sep->arg[2]);
  1282. int8 group = atoi(sep->arg[1]);
  1283. AltAdvanceData* data = 0;
  1284. SpellBookEntry* spellentry = 0;
  1285. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1286. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1287. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1288. if (outapp)
  1289. client->QueuePacket(outapp);
  1290. else
  1291. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1292. }
  1293. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1294. sint32 spell_id = atol(sep->arg[1]);
  1295. int8 tier = atoi(sep->arg[2]);
  1296. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1297. if (outapp)
  1298. client->QueuePacket(outapp);
  1299. else
  1300. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1301. }
  1302. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1303. sint32 recipe_id = atol(sep->arg[1]);
  1304. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1305. if(outapp)
  1306. client->QueuePacket(outapp);
  1307. else
  1308. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1309. }
  1310. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1311. int32 slot = atol(sep->arg[1]);
  1312. int32 spell_id = atol(sep->arg[2]);
  1313. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1314. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1315. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1316. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1317. if(outapp)
  1318. client->QueuePacket(outapp);
  1319. else
  1320. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1321. }
  1322. else if (strcmp(sep->arg[0], "effect") == 0) {
  1323. int32 spell_id = atol(sep->arg[1]);
  1324. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1325. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1326. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, 0x00);
  1327. if (outapp){
  1328. client->QueuePacket(outapp);
  1329. }
  1330. else
  1331. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1332. }
  1333. }
  1334. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1335. Item* item = player->item_list.GetOverflowItem();
  1336. if(item) {
  1337. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1338. client->QueuePacket(app);
  1339. }
  1340. else
  1341. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1342. }
  1343. else
  1344. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1345. break;
  1346. }
  1347. case COMMAND_USE_EQUIPPED_ITEM:{
  1348. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1349. int32 slot_id = atoul(sep->arg[0]);
  1350. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1351. if (item && item->generic_info.usable && item->GetItemScript())
  1352. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1353. }
  1354. break;
  1355. }
  1356. case COMMAND_USE_ITEM: {
  1357. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1358. int32 item_index = atoul(sep->arg[0]);
  1359. Item* item = player->item_list.GetItemFromIndex(item_index);
  1360. if (item && item->GetItemScript()) {
  1361. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1362. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1363. else {
  1364. if (item->generic_info.display_charges > 0) {
  1365. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1366. item->generic_info.display_charges -= 1;
  1367. item->save_needed = true;
  1368. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1369. }
  1370. }
  1371. }
  1372. }
  1373. break;
  1374. }
  1375. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1376. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1377. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1378. if (item) {
  1379. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1380. if(item->generic_info.item_type == 6) {
  1381. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1382. int8 old_slot = 0;
  1383. if (spell) {
  1384. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1385. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1386. player->RemoveSpellBookEntry(spell->GetSpellID());
  1387. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1388. player->UnlockSpell(spell);
  1389. client->SendSpellUpdate(spell);
  1390. database.DeleteItem(client->GetCharacterID(), item, 0);
  1391. player->item_list.RemoveItem(item, true);
  1392. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1393. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1394. }
  1395. }
  1396. else
  1397. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1398. }
  1399. else if(item->generic_info.item_type == 7){
  1400. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1401. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1402. // if valid recipe book and the player doesn't have it
  1403. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1404. client->Message(CHANNEL_COLOR_WHITE, "Your tradeskill level is not high enough to scribe this book.");
  1405. safe_delete(recipe_book);
  1406. }
  1407. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1408. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1409. // Add recipe book to the players list
  1410. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1411. // Get a list of all recipes this book contains
  1412. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1413. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1414. // Create the packet to send to update the players recipe list
  1415. PacketStruct* packet = 0;
  1416. if (client->GetRecipeListSent()) {
  1417. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1418. if (packet)
  1419. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1420. }
  1421. // loop through the list
  1422. vector<Recipe*>::iterator itr;
  1423. int16 i = 0;
  1424. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1425. // check to see if the player already has this recipe some how
  1426. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1427. // Player doesn't already have this recipe so lets add it
  1428. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1429. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1430. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1431. client->Message(CHANNEL_COLOR_WHITE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1432. if (packet && client->GetRecipeListSent()) {
  1433. packet->setArrayDataByName("id", recipe->GetID(), i);
  1434. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1435. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1436. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1437. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1438. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1439. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1440. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1441. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1442. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1443. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1444. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1445. i++;
  1446. }
  1447. }
  1448. }
  1449. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1450. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1451. database.DeleteItem(client->GetCharacterID(), item, 0);
  1452. client->GetPlayer()->item_list.RemoveItem(item, true);
  1453. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1454. if (packet && client->GetRecipeListSent())
  1455. client->QueuePacket(packet->serialize());
  1456. safe_delete(packet);
  1457. }
  1458. else {
  1459. if (recipe_book)
  1460. client->Message(CHANNEL_COLOR_WHITE, "You have already learned all you can from this item.");
  1461. safe_delete(recipe_book);
  1462. }
  1463. }
  1464. }
  1465. else
  1466. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1467. }
  1468. break;
  1469. }
  1470. case COMMAND_SUMMONITEM: {
  1471. if (sep && sep->IsNumber(0)) {
  1472. int32 item_id = atol(sep->arg[0]);
  1473. int32 quantity = 1;
  1474. if (sep->arg[1] && sep->IsNumber(1))
  1475. quantity = atoi(sep->arg[1]);
  1476. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1477. client->AddItemToBank(item_id,quantity);
  1478. }
  1479. else {
  1480. client->AddItem(item_id, quantity);
  1481. }
  1482. }
  1483. else {
  1484. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1485. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1486. }
  1487. break;
  1488. }
  1489. case COMMAND_COLLECTION_ADDITEM: {
  1490. // takes 2 params: collection_id, slot
  1491. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1492. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1493. if (item)
  1494. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1495. else
  1496. 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]));
  1497. }
  1498. else
  1499. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1500. break;
  1501. }
  1502. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1503. // takes 1 param: slot
  1504. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1505. int i = 0;
  1506. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1507. printf("\t%u: %s\n", i, sep->arg[i]);
  1508. i++;
  1509. }
  1510. break;
  1511. }
  1512. case COMMAND_WHO:{
  1513. const char* who = 0;
  1514. if(sep && sep->arg[0]){
  1515. //cout << "Who query: \n";
  1516. who = sep->argplus[0];
  1517. //cout << who << endl;
  1518. }
  1519. zone_list.ProcessWhoQuery(who, client);
  1520. break;
  1521. }
  1522. case COMMAND_SELECT_JUNCTION:{
  1523. 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__);
  1524. int32 choice = 0;
  1525. if(sep && sep->arg[0] && sep->IsNumber(0))
  1526. choice = atoul(sep->arg[0]);
  1527. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1528. client->HandlePlayerRevive(choice);
  1529. }
  1530. break;
  1531. }
  1532. case COMMAND_SPAWN_MOVE: {
  1533. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  1534. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1535. if (packet) {
  1536. float unknown2_3 = 0;
  1537. int8 placement_mode = 0;
  1538. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1539. if (sep && sep->arg[0][0]) {
  1540. if (strcmp(sep->arg[0], "wall") == 0) {
  1541. placement_mode = 2;
  1542. unknown2_3 = 150;
  1543. }
  1544. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1545. placement_mode = 1;
  1546. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1547. {
  1548. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1549. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1550. }
  1551. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1552. {
  1553. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1554. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1555. }
  1556. else if (strcmp(sep->arg[0], "myloc") == 0)
  1557. {
  1558. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1559. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1560. safe_delete(packet);
  1561. break;
  1562. }
  1563. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1564. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1565. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1566. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1567. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1568. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1569. safe_delete(packet);
  1570. break;
  1571. }
  1572. }
  1573. packet->setDataByName("placement_mode", placement_mode);
  1574. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1575. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1576. packet->setDataByName("unknown", 1); //size
  1577. packet->setDataByName("unknown2", 1); //size 2
  1578. packet->setDataByName("unknown2", .5, 1); //size 3
  1579. packet->setDataByName("unknown2", 3, 2);
  1580. packet->setDataByName("unknown2", unknown2_3, 3);
  1581. packet->setDataByName("max_distance", 500);
  1582. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1583. client->QueuePacket(packet->serialize());
  1584. safe_delete(packet);
  1585. }
  1586. }
  1587. else {
  1588. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1589. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1590. }
  1591. break;
  1592. }
  1593. case COMMAND_HAIL:{
  1594. Spawn* spawn = cmdTarget;
  1595. if(spawn && spawn->GetTargetable())
  1596. {
  1597. char tmp[75] = {0};
  1598. sprintf(tmp, "Hail, %s", spawn->GetName());
  1599. bool show_bubble = true;
  1600. if (spawn->IsNPC())
  1601. show_bubble = false;
  1602. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1603. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < 30){
  1604. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1605. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1606. else
  1607. spawn->ProcessMovement();
  1608. LogWrite(MISC__TODO, 0, "Check", "ProcessMovement has been called");
  1609. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer());
  1610. }
  1611. }
  1612. else {
  1613. string tmp = "Hail";
  1614. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1615. }
  1616. break;
  1617. }
  1618. case COMMAND_SAY:{
  1619. if (sep && sep->arg[0][0]) {
  1620. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1621. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1622. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1623. }
  1624. else
  1625. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1626. break;
  1627. }
  1628. case COMMAND_TELL:{
  1629. if(sep && sep->arg[0] && sep->argplus[1]){
  1630. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_TELL, sep->argplus[1]))
  1631. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1632. }else
  1633. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1634. break;
  1635. }
  1636. case COMMAND_SHOUT:{
  1637. if(sep && sep->arg[0][0])
  1638. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1639. else
  1640. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1641. break;
  1642. }
  1643. case COMMAND_AUCTION:{
  1644. if(sep && sep->arg[0][0])
  1645. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1646. else
  1647. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1648. break;
  1649. }
  1650. case COMMAND_OOC:{
  1651. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  1652. if(sep && sep->arg[0][0])
  1653. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OOC, sep->argplus[0]);
  1654. else
  1655. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  1656. break;
  1657. }
  1658. case COMMAND_EMOTE:{
  1659. if(sep && sep->arg[0][0])
  1660. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  1661. else
  1662. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  1663. break;
  1664. }
  1665. case COMMAND_RACE:{
  1666. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  1667. if(sep->arg[1][0] && sep->IsNumber(1)){
  1668. client->GetPlayer()->GetInfoStruct()->race = atoi(sep->arg[1]);
  1669. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  1670. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  1671. client->GetPlayer()->SetCharSheetChanged(true);
  1672. }
  1673. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  1674. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  1675. //client->QueuePacket(outapp);
  1676. }
  1677. else{
  1678. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  1679. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  1680. }
  1681. break;
  1682. }
  1683. case COMMAND_BANK_DEPOSIT:{
  1684. if(client->GetBanker() && sep && sep->arg[0]){
  1685. int64 amount = 0;
  1686. string deposit = string(sep->arg[0]);
  1687. amount = atoi64(deposit.c_str());
  1688. client->BankDeposit(amount);
  1689. }
  1690. break;
  1691. }
  1692. case COMMAND_BANK_WITHDRAWAL:{
  1693. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  1694. int64 amount = 0;
  1695. string deposit = string(sep->arg[0]);
  1696. amount = atoi64(deposit.c_str());
  1697. client->BankWithdrawal(amount);
  1698. }
  1699. break;
  1700. }
  1701. case COMMAND_BANK_CANCEL:{
  1702. Spawn* banker = cmdTarget;
  1703. client->Bank(banker, true);
  1704. break;
  1705. }
  1706. case COMMAND_BANK:{
  1707. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  1708. Spawn* banker = cmdTarget;
  1709. client->Bank(banker);
  1710. break;
  1711. }
  1712. case COMMAND_GUILD_BANK:{
  1713. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  1714. //Spawn* banker = client->GetPlayer()->GetTarget();
  1715. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  1716. break;
  1717. }
  1718. case COMMAND_START_MAIL: {
  1719. client->SetMailTransaction(cmdTarget);
  1720. client->SendMailList();
  1721. break;
  1722. }
  1723. case COMMAND_CANCEL_MAIL: {
  1724. client->SetMailTransaction(0);
  1725. break;
  1726. }
  1727. case COMMAND_GET_MAIL_MESSAGE: {
  1728. if (sep && sep->arg[0] && sep->IsNumber(0))
  1729. client->DisplayMailMessage(atoul(sep->arg[0]));
  1730. break;
  1731. }
  1732. case COMMAND_ADD_MAIL_PLAT: {
  1733. if (sep && sep->arg[0] && sep->IsNumber(0))
  1734. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1735. break;
  1736. }
  1737. case COMMAND_ADD_MAIL_GOLD: {
  1738. if (sep && sep->arg[0] && sep->IsNumber(0))
  1739. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  1740. break;
  1741. }
  1742. case COMMAND_ADD_MAIL_SILVER: {
  1743. if (sep && sep->arg[0] && sep->IsNumber(0))
  1744. client->AddMailCoin(0, atoul(sep->arg[0]));
  1745. break;
  1746. }
  1747. case COMMAND_ADD_MAIL_COPPER: {
  1748. if (sep && sep->arg[0] && sep->IsNumber(0))
  1749. client->AddMailCoin(atoul(sep->arg[0]));
  1750. break;
  1751. }
  1752. case COMMAND_SET_MAIL_ITEM: {
  1753. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1754. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1755. break;
  1756. }
  1757. case COMMAND_REMOVE_MAIL_PLAT: {
  1758. if (sep && sep->arg[0] && sep->IsNumber(0))
  1759. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1760. break;
  1761. }
  1762. case COMMAND_REMOVE_MAIL_GOLD: {
  1763. if (sep && sep->arg[0] && sep->IsNumber(0))
  1764. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  1765. break;
  1766. }
  1767. case COMMAND_REMOVE_MAIL_SILVER: {
  1768. if (sep && sep->arg[0] && sep->IsNumber(0))
  1769. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  1770. break;
  1771. }
  1772. case COMMAND_REMOVE_MAIL_COPPER: {
  1773. if (sep && sep->arg[0] && sep->IsNumber(0))
  1774. client->RemoveMailCoin(atoul(sep->arg[0]));
  1775. break;
  1776. }
  1777. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  1778. if (sep && sep->arg[0] && sep->IsNumber(0))
  1779. client->TakeMailAttachments(atoul(sep->arg[0]));
  1780. break;
  1781. }
  1782. case COMMAND_CANCEL_SEND_MAIL: {
  1783. client->CancelSendMail();
  1784. break;
  1785. }
  1786. case COMMAND_DELETE_MAIL_MESSAGE: {
  1787. if (sep && sep->arg[0] && sep->IsNumber(0))
  1788. client->DeleteMail(atoul(sep->arg[0]), true);
  1789. break;
  1790. }
  1791. case COMMAND_REPORT_SPAM: {
  1792. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1793. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1794. break;
  1795. }
  1796. case COMMAND_KILL:{
  1797. Spawn* dead = 0;
  1798. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  1799. dead=client->GetPlayer();
  1800. client->GetPlayer()->SetHP(0);
  1801. client->GetPlayer()->KillSpawn(dead);
  1802. }else{
  1803. dead= cmdTarget;
  1804. if(dead && dead->IsPlayer() == false){
  1805. dead->SetHP(0);
  1806. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  1807. client->GetCurrentZone()->RemoveSpawn(false, dead, true);
  1808. else
  1809. client->GetPlayer()->KillSpawn(dead);
  1810. }else{
  1811. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  1812. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  1813. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  1814. }
  1815. }
  1816. break;
  1817. }
  1818. case COMMAND_LEVEL:{
  1819. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  1820. int16 new_level = atoi(sep->arg[ndx]);
  1821. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  1822. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  1823. else {
  1824. if (new_level < 1)
  1825. new_level = 1;
  1826. if (new_level > 255)
  1827. new_level = 255;
  1828. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  1829. client->GetPlayer()->SetXP(1);
  1830. client->GetPlayer()->SetNeededXP();
  1831. }
  1832. }else
  1833. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  1834. break;
  1835. }
  1836. case COMMAND_SIT: {
  1837. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1838. if(client->GetPlayer()->GetHP() > 0){
  1839. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  1840. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  1841. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  1842. }
  1843. break;
  1844. }
  1845. case COMMAND_STAND: {
  1846. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1847. if(client->GetPlayer()->GetHP() > 0){
  1848. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  1849. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  1850. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  1851. }
  1852. break;
  1853. }
  1854. case COMMAND_CLASS:{
  1855. if(sep && sep->arg[ndx][0]){
  1856. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  1857. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  1858. }else
  1859. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  1860. break;
  1861. }
  1862. case COMMAND_GENDER:{
  1863. if(sep && sep->arg[ndx][0]){
  1864. client->GetPlayer()->GetInfoStruct()->gender = atoi(sep->arg[ndx]);
  1865. client->GetPlayer()->SetCharSheetChanged(true);
  1866. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  1867. }else{
  1868. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  1869. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  1870. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  1871. }
  1872. break;
  1873. }
  1874. case COMMAND_FLYMODE:{
  1875. if(sep && sep->arg[0] && sep->IsNumber(0)){
  1876. PrintSep(sep, "COMMAND_FLYMODE");
  1877. int8 val = atoi(sep->arg[0]);
  1878. ClientPacketFunctions::SendFlyMode(client, val);
  1879. }
  1880. else{
  1881. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  1882. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  1883. }
  1884. break;
  1885. }
  1886. case COMMAND_LOOT_LIST:{
  1887. Spawn* spawn = cmdTarget;
  1888. if(spawn && spawn->IsEntity()){
  1889. if (sep && sep->arg[0]) {
  1890. if (!spawn->GetDatabaseID())
  1891. {
  1892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  1893. break;
  1894. }
  1895. else if (!spawn->IsNPC())
  1896. {
  1897. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  1898. break;
  1899. }
  1900. bool reloadLoot = false;
  1901. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  1902. {
  1903. int32 loottable_id = atoul(sep->arg[1]);
  1904. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  1905. {
  1906. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  1907. reloadLoot = true;
  1908. }
  1909. else
  1910. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  1911. }
  1912. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  1913. {
  1914. int32 loottable_id = atoul(sep->arg[1]);
  1915. if (loottable_id > 0)
  1916. {
  1917. database.AddLootTableToSpawn(spawn, loottable_id);
  1918. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  1919. reloadLoot = true;
  1920. }
  1921. else
  1922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  1923. }
  1924. else if (!stricmp(sep->arg[0], "clearall"))
  1925. {
  1926. if (database.RemoveSpawnLootTable(spawn, 0))
  1927. {
  1928. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  1929. reloadLoot = true;
  1930. }
  1931. else
  1932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  1933. }
  1934. else
  1935. {
  1936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  1937. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  1938. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  1939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  1940. break;
  1941. }
  1942. if (reloadLoot)
  1943. {
  1944. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  1945. if (spawn->IsNPC())
  1946. {
  1947. Entity* ent = (Entity*)spawn;
  1948. ent->SetLootCoins(0);
  1949. ent->ClearLootList();
  1950. spawn->GetZone()->AddLoot((NPC*)spawn);
  1951. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  1952. }
  1953. }
  1954. break; // nothing further this is the end of these sub commands
  1955. }
  1956. else
  1957. {
  1958. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  1959. if (loot_list.size() > 0) {
  1960. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  1961. vector<int32>::iterator list_itr;
  1962. LootTable* table = 0;
  1963. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  1964. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  1965. if (table)
  1966. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  1967. }
  1968. }
  1969. Entity* target = (Entity*)spawn;
  1970. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", target->GetLootCoins());
  1971. vector<Item*>* items = target->GetLootItems();
  1972. if (items) {
  1973. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  1974. vector<Item*>::iterator itr;
  1975. Item* item = 0;
  1976. for (itr = items->begin(); itr != items->end(); itr++) {
  1977. item = *itr;
  1978. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  1979. }
  1980. }
  1981. else
  1982. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  1983. }
  1984. }
  1985. break;
  1986. }
  1987. case COMMAND_LOOT_SETCOIN:{
  1988. Spawn* spawn = cmdTarget;
  1989. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1990. Entity* target = (Entity*)spawn;
  1991. target->SetLootCoins(atoul(sep->arg[0]));
  1992. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  1993. }
  1994. else
  1995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  1996. break;
  1997. }
  1998. case COMMAND_LOOT_ADDITEM:{
  1999. Spawn* spawn = cmdTarget;
  2000. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2001. Entity* target = (Entity*)spawn;
  2002. int16 charges = 1;
  2003. if(sep->arg[1] && sep->IsNumber(1))
  2004. charges = atoi(sep->arg[1]);
  2005. target->AddLootItem(atoul(sep->arg[0]), charges);
  2006. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2007. }
  2008. else
  2009. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2010. break;
  2011. }
  2012. case COMMAND_LOOT_REMOVEITEM:{
  2013. Spawn* spawn = cmdTarget;
  2014. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2015. Entity* target = (Entity*)spawn;
  2016. target->LootItem(atoul(sep->arg[0]));
  2017. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2018. }
  2019. else
  2020. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2021. break;
  2022. }
  2023. case COMMAND_LOOT_CORPSE:
  2024. case COMMAND_DISARM:
  2025. case COMMAND_LOOT:{
  2026. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2027. {
  2028. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2029. break;
  2030. }
  2031. if(cmdTarget && cmdTarget->IsEntity()){
  2032. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2033. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2034. client->OpenChest((Entity*)cmdTarget, true);
  2035. else
  2036. client->Loot((Entity*)cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2037. if (!((Entity*)cmdTarget)->HasLoot()){
  2038. if (((Entity*)cmdTarget)->IsNPC())
  2039. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2040. }
  2041. }
  2042. else
  2043. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2044. }
  2045. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2047. break;
  2048. }
  2049. case COMMAND_RELOADSPAWNSCRIPTS:{
  2050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2051. if (lua_interface)
  2052. lua_interface->SetSpawnScriptsReloading(true);
  2053. world.ResetSpawnScripts();
  2054. database.LoadSpawnScriptData();
  2055. if(lua_interface) {
  2056. lua_interface->DestroySpawnScripts();
  2057. lua_interface->SetSpawnScriptsReloading(false);
  2058. }
  2059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2060. break;
  2061. }
  2062. case COMMAND_RELOADLUASYSTEM:{
  2063. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2064. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2065. safe_delete(lua_interface);
  2066. lua_interface = new LuaInterface();
  2067. if(lua_interface)
  2068. lua_interface->SetSpawnScriptsReloading(true);
  2069. if(lua_interface && debug_clients.size() > 0){
  2070. map<Client*, int32>::iterator itr;
  2071. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2072. if(lua_interface)
  2073. lua_interface->UpdateDebugClients(itr->first);
  2074. }
  2075. }
  2076. world.ResetSpawnScripts();
  2077. database.LoadSpawnScriptData();
  2078. world.ResetZoneScripts();
  2079. database.LoadZoneScriptData();
  2080. int32 quest_count = database.LoadQuests();
  2081. zone_list.DeleteSpellProcess();
  2082. master_spell_list.Reload();
  2083. int32 spell_count = 0;
  2084. if(lua_interface) {
  2085. lua_interface->DestroySpawnScripts();
  2086. lua_interface->DestroySpells();
  2087. spell_count = database.LoadSpellScriptData();
  2088. lua_interface->SetSpawnScriptsReloading(false);
  2089. }
  2090. zone_list.LoadSpellProcess();
  2091. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2092. break;
  2093. }
  2094. case COMMAND_DECLINE_QUEST:{
  2095. int32 quest_id = 0;
  2096. if(sep && sep->arg[0] && sep->IsNumber(0))
  2097. quest_id = atoul(sep->arg[0]);
  2098. if(quest_id > 0){
  2099. Quest* quest = client->GetPendingQuest(quest_id);
  2100. if(quest){
  2101. client->RemovePendingQuest(quest);
  2102. if(lua_interface)
  2103. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2104. safe_delete(quest);
  2105. client->GetCurrentZone()->SendQuestUpdates(client);
  2106. }
  2107. }
  2108. break;
  2109. }
  2110. case COMMAND_DELETE_QUEST:{
  2111. int32 quest_id = 0;
  2112. if(sep && sep->arg[0] && sep->IsNumber(0))
  2113. quest_id = atoul(sep->arg[0]);
  2114. if(quest_id > 0){
  2115. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2116. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2117. if (quest)
  2118. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2119. }
  2120. client->RemovePlayerQuest(quest_id);
  2121. client->GetCurrentZone()->SendQuestUpdates(client);
  2122. }
  2123. break;
  2124. }
  2125. case COMMAND_ACCEPT_QUEST:{
  2126. int32 quest_id = 0;
  2127. if(sep && sep->arg[0] && sep->IsNumber(0))
  2128. quest_id = atoul(sep->arg[0]);
  2129. if(quest_id > 0){
  2130. client->AcceptQuest(quest_id);
  2131. }
  2132. break;
  2133. }
  2134. case COMMAND_NAME:{
  2135. if(sep && sep->arg[ndx][0]){
  2136. memset(client->GetPlayer()->GetInfoStruct()->name, 0, 40);
  2137. strncpy(client->GetPlayer()->GetInfoStruct()->name, sep->arg[ndx], 39);
  2138. client->GetPlayer()->SetCharSheetChanged(true);
  2139. }else
  2140. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2141. break;
  2142. }
  2143. case COMMAND_GROUPSAY:{
  2144. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2145. if(sep && sep->arg[0] && gmi)
  2146. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2147. break;
  2148. }
  2149. case COMMAND_GROUPINVITE: {
  2150. Entity* target = 0;
  2151. Client* target_client = 0;
  2152. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2153. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2154. return;
  2155. }
  2156. // name provided with command so it has to be a player, npc not supported here
  2157. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2158. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2159. if (target_client) {
  2160. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2161. target = 0;
  2162. else
  2163. target = target_client->GetPlayer();
  2164. }
  2165. }
  2166. // if name was not provided use the players target, npc or player supported here
  2167. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2168. target = (Entity*)client->GetPlayer()->GetTarget();
  2169. if (target->IsPlayer()) {
  2170. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2171. }
  2172. }
  2173. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2174. if (result == 0) {
  2175. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2176. if (target_client) {
  2177. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2178. if (packet) {
  2179. packet->setDataByName("type", 1);
  2180. packet->setDataByName("name", client->GetPlayer()->GetName());
  2181. packet->setDataByName("unknown2", 1);
  2182. target_client->QueuePacket(packet->serialize());
  2183. safe_delete(packet);
  2184. }
  2185. }
  2186. }
  2187. else if (result == 1)
  2188. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2189. else if (result == 2)
  2190. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2191. else if (result == 3)
  2192. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2193. else if (result == 4)
  2194. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2195. else if (result == 5)
  2196. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2197. else if (result == 6)
  2198. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2199. else
  2200. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2201. break;
  2202. }
  2203. case COMMAND_GROUPDISBAND: {
  2204. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2205. if (gmi) { // TODO: Leader check
  2206. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2207. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2208. }
  2209. break;
  2210. }
  2211. case COMMAND_GROUP_LEAVE: {
  2212. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2213. if (gmi) {
  2214. int32 group_id = gmi->group_id;
  2215. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2216. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2217. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2218. }
  2219. else {
  2220. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2221. }
  2222. client->SimpleMessage(CHANNEL_COLOR_GROUP, "You have left the group");
  2223. }
  2224. break;
  2225. }
  2226. case COMMAND_FRIEND_ADD:{
  2227. string name = "";
  2228. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2229. name = database.GetPlayerName(sep->arg[0]);
  2230. else if(cmdTarget && cmdTarget->IsPlayer())
  2231. name = string(cmdTarget->GetName());
  2232. if(name.length() > 0){
  2233. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2234. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2235. client->GetPlayer()->RemoveIgnore(name.c_str());
  2236. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2237. client->SendChatRelationship(3, name.c_str());
  2238. }
  2239. client->GetPlayer()->AddFriend(name.c_str(), true);
  2240. client->SendChatRelationship(0, name.c_str());
  2241. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2242. if(zone_list.GetClientByCharName(name))
  2243. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2244. }
  2245. else
  2246. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2247. }
  2248. else
  2249. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2250. break;
  2251. }
  2252. case COMMAND_FRIEND_REMOVE:{
  2253. string name = "";
  2254. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2255. name = database.GetPlayerName(sep->arg[0]);
  2256. else if(cmdTarget && cmdTarget->IsPlayer())
  2257. name = string(cmdTarget->GetName());
  2258. if(name.length() > 0){
  2259. client->GetPlayer()->RemoveFriend(name.c_str());
  2260. client->SendChatRelationship(1, name.c_str());
  2261. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2262. }
  2263. else
  2264. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2265. break;
  2266. }
  2267. case COMMAND_FRIENDS:{
  2268. break;
  2269. }
  2270. case COMMAND_IGNORE_ADD:{
  2271. string name = "";
  2272. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2273. name = database.GetPlayerName(sep->arg[0]);
  2274. else if(cmdTarget && cmdTarget->IsPlayer())
  2275. name = string(cmdTarget->GetName());
  2276. if(name.length() > 0){
  2277. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2278. if(client->GetPlayer()->IsFriend(name.c_str())){
  2279. client->GetPlayer()->RemoveFriend(name.c_str());
  2280. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2281. client->SendChatRelationship(1, name.c_str());
  2282. }
  2283. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2284. client->SendChatRelationship(2, name.c_str());
  2285. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2286. }
  2287. else
  2288. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2289. }
  2290. else
  2291. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2292. break;
  2293. }
  2294. case COMMAND_IGNORE_REMOVE:{
  2295. string name = "";
  2296. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2297. name = database.GetPlayerName(sep->arg[0]);
  2298. else if(cmdTarget && cmdTarget->IsPlayer())
  2299. name = string(cmdTarget->GetName());
  2300. if(name.length() > 0){
  2301. client->GetPlayer()->RemoveIgnore(name.c_str());
  2302. client->SendChatRelationship(3, name.c_str());
  2303. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2304. }
  2305. break;
  2306. }
  2307. case COMMAND_IGNORES:{
  2308. break;
  2309. }
  2310. case COMMAND_GROUP_KICK:{
  2311. Entity* kicked = 0;
  2312. Client* kicked_client = 0;
  2313. int32 group_id = 0;
  2314. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2315. return;
  2316. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2317. if (sep && sep->arg[0]) {
  2318. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2319. if (kicked_client)
  2320. kicked = kicked_client->GetPlayer();
  2321. }
  2322. else if (cmdTarget && cmdTarget->IsEntity()) {
  2323. kicked = (Entity*)cmdTarget;
  2324. }
  2325. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2326. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2327. if (kicked)
  2328. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2329. if(send_kicked_message)
  2330. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2331. else
  2332. client->Message(CHANNEL_COLOR_GROUP, "You kicked %s from the group", kicked->GetName());
  2333. if (kicked_client)
  2334. kicked_client->SimpleMessage(CHANNEL_COLOR_GROUP, "You were kicked from the group");
  2335. break;
  2336. }
  2337. case COMMAND_GROUP_MAKE_LEADER:{
  2338. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2339. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2340. return;
  2341. }
  2342. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2343. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2344. if (new_leader) {
  2345. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2346. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2347. }
  2348. }
  2349. else
  2350. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2351. }
  2352. else if (cmdTarget && cmdTarget->IsPlayer())
  2353. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2354. else
  2355. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2356. break;
  2357. }
  2358. case COMMAND_GROUP_ACCEPT_INVITE: {
  2359. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2360. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2361. if (result == 0)
  2362. client->SimpleMessage(CHANNEL_GROUP, "You have joined the group.");
  2363. else if (result == 1)
  2364. client->SimpleMessage(CHANNEL_GROUP, "You do not have a pending invite.");
  2365. else if (result == 2)
  2366. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - could not find leader.");
  2367. else
  2368. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - unknown error.");
  2369. }
  2370. break;
  2371. }
  2372. case COMMAND_GROUP_DECLINE_INVITE: {
  2373. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2374. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2375. }
  2376. break;
  2377. }
  2378. case COMMAND_SUMMON:{
  2379. char* search_name = 0;
  2380. if(sep && sep->arg[0][0])
  2381. search_name = sep->arg[0];
  2382. if(!search_name && !cmdTarget){
  2383. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2384. 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.");
  2385. }
  2386. else{
  2387. if(!client->Summon(search_name))
  2388. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2389. }
  2390. break;
  2391. }
  2392. case COMMAND_GOTO:{
  2393. const char* search_name = 0;
  2394. if(sep && sep->arg[0][0])
  2395. search_name = sep->argplus[0];
  2396. if(!search_name && !cmdTarget){
  2397. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2398. 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.");
  2399. }
  2400. else{
  2401. if(!client->GotoSpawn(search_name))
  2402. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2403. }
  2404. break;
  2405. }
  2406. case COMMAND_MOVE:{
  2407. bool success = false;
  2408. try{
  2409. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2410. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2411. if(app){
  2412. client->QueuePacket(app);
  2413. success = true;
  2414. }
  2415. }
  2416. }
  2417. catch(...){}
  2418. if(!success){
  2419. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2420. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2421. }
  2422. break;
  2423. }
  2424. case COMMAND_SETTIME:{
  2425. if(sep && sep->arg[0]){
  2426. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2427. if(sep->arg[1] && sep->IsNumber(1))
  2428. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2429. if(sep->arg[2] && sep->IsNumber(2))
  2430. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2431. if(sep->arg[3] && sep->IsNumber(3))
  2432. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2433. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2434. }
  2435. else{
  2436. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2437. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2438. }
  2439. break;
  2440. }
  2441. case COMMAND_VERSION:{
  2442. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2443. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2444. break;
  2445. }
  2446. case COMMAND_ZONE:{
  2447. string* zonename = 0;
  2448. int32 instanceID = 0;
  2449. const char* zone = 0;
  2450. int32 zone_id = 0;
  2451. bool listSearch = false;
  2452. bool isInstance = false;
  2453. ZoneServer* zsZone = 0;
  2454. if(sep && sep->arg[0][0])
  2455. {
  2456. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2457. listSearch = true;
  2458. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2459. {
  2460. zone_list.SendZoneList(client);
  2461. break;
  2462. }
  2463. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2464. {
  2465. if(sep->IsNumber(1))
  2466. instanceID = atol(sep->arg[1]);
  2467. }
  2468. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2469. {
  2470. PrintSep(sep, "ZONE LOCK");
  2471. if(sep->IsNumber(1))
  2472. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2473. else
  2474. zsZone = zone_list.Get(sep->arg[1], false);
  2475. if( zsZone )
  2476. {
  2477. zsZone->SetZoneLockState(true);
  2478. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2479. }
  2480. else
  2481. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2482. break;
  2483. }
  2484. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2485. {
  2486. PrintSep(sep, "ZONE UNLOCK");
  2487. if(sep->IsNumber(1))
  2488. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2489. else
  2490. zsZone = zone_list.Get(sep->arg[1], false);
  2491. if( zsZone )
  2492. {
  2493. zsZone->SetZoneLockState(false);
  2494. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2495. }
  2496. else
  2497. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2498. break;
  2499. }
  2500. else
  2501. {
  2502. if(sep->IsNumber(0))
  2503. {
  2504. zone_id = atoul(sep->arg[0]);
  2505. zonename = database.GetZoneName(zone_id);
  2506. if(zonename)
  2507. zone = zonename->c_str();
  2508. }
  2509. else
  2510. zone = sep->arg[0];
  2511. }
  2512. if(instanceID > 0)
  2513. {
  2514. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2515. if(zsInstance != NULL)
  2516. {
  2517. instanceID = zsInstance->GetInstanceID();
  2518. zone = zsInstance->GetZoneName();
  2519. zone_id = zsInstance->GetZoneID();
  2520. isInstance = true;
  2521. }
  2522. }
  2523. }
  2524. if(!listSearch)
  2525. {
  2526. if(!zone)
  2527. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2528. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2529. zone_id != client->GetCurrentZone()->GetZoneID())
  2530. {
  2531. if(database.VerifyZone(zone))
  2532. {
  2533. if(client->CheckZoneAccess(zone))
  2534. {
  2535. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zone);
  2536. if(isInstance)
  2537. client->Zone(instanceID,true,true);
  2538. else
  2539. client->Zone(zone);
  2540. }
  2541. }
  2542. else
  2543. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zone);
  2544. }
  2545. else
  2546. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2547. }
  2548. else
  2549. {
  2550. const char* name = 0;
  2551. if(sep && sep->arg[1][0])
  2552. {
  2553. map<int32, string>* zone_names;
  2554. name = sep->argplus[1];
  2555. sint16 status = client->GetAdminStatus();
  2556. if( status > 0 )
  2557. {
  2558. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2559. zone_names = database.GetZoneList(name, true);
  2560. }
  2561. else
  2562. zone_names = database.GetZoneList(name);
  2563. if(!zone_names)
  2564. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2565. else
  2566. {
  2567. map<int32, string>::iterator itr;
  2568. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2569. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2570. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2571. safe_delete(zone_names);
  2572. }
  2573. }
  2574. else
  2575. {
  2576. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2577. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2578. }
  2579. }
  2580. safe_delete(zonename);
  2581. break;
  2582. }
  2583. case COMMAND_USE: {
  2584. Spawn* target = cmdTarget;
  2585. if (target->IsWidget())
  2586. ((Widget*)target)->HandleUse(client, "use");
  2587. break;
  2588. }
  2589. case COMMAND_OPEN: {
  2590. Spawn* target = cmdTarget;
  2591. if (target->IsWidget())
  2592. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2593. break;
  2594. }
  2595. case COMMAND_CASTSPELL: {
  2596. if (sep && sep->arg[0] && sep->IsNumber(0))
  2597. {
  2598. int8 tier = 1;
  2599. if (sep->arg[1] && sep->IsNumber(1))
  2600. tier = atoul(sep->arg[1]);
  2601. int32 spellid = atoul(sep->arg[0]);
  2602. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2603. if (spell)
  2604. {
  2605. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2606. SpellProcess* spellProcess = 0;
  2607. // Get the current zones spell process
  2608. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2609. spellProcess->CastInstant(spell, (Entity*)client->GetPlayer(), (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2610. }
  2611. else
  2612. {
  2613. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2614. }
  2615. }
  2616. else if (sep && sep->arg[0])
  2617. {
  2618. database.FindSpell(client, (char*)sep->argplus[0]);
  2619. }
  2620. else
  2621. {
  2622. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2623. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2624. }
  2625. break;
  2626. }
  2627. case COMMAND_KNOWLEDGEWINDOWSORT: {
  2628. if (client->GetVersion() <= 546)
  2629. break;
  2630. if (sep && sep->GetArgNumber() == 4)
  2631. {
  2632. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  2633. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  2634. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  2635. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  2636. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  2637. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  2638. ClientPacketFunctions::SendSkillSlotMappings(client);
  2639. }
  2640. else
  2641. {
  2642. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  2643. }
  2644. break;
  2645. }
  2646. case COMMAND_MOVE_ITEM:
  2647. {
  2648. int32 id = 0;
  2649. if (sep->IsNumber(0))
  2650. id = atoul(sep->arg[0]);
  2651. Spawn* spawn = 0;
  2652. if (id == 0)
  2653. {
  2654. spawn = cmdTarget;
  2655. }
  2656. else
  2657. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2658. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2659. break;
  2660. client->SendMoveObjectMode(spawn, 0);
  2661. break;
  2662. }
  2663. case COMMAND_PICKUP:
  2664. {
  2665. int32 id = 0;
  2666. if (sep->IsNumber(0))
  2667. id = atoul(sep->arg[0]);
  2668. Spawn* spawn = 0;
  2669. if (id == 0)
  2670. {
  2671. spawn = cmdTarget;
  2672. }
  2673. else
  2674. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2675. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2676. break;
  2677. client->AddItem(spawn->GetPickupItemID(), 1);
  2678. Query query;
  2679. 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());
  2680. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  2681. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, true);
  2682. }
  2683. // we had a UI Window displayed, update the house items
  2684. if ( id > 0 )
  2685. client->GetCurrentZone()->SendHouseItems(client);
  2686. break;
  2687. }
  2688. case COMMAND_HOUSE_DEPOSIT:
  2689. {
  2690. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  2691. // arg0 = ??? (set to 3)
  2692. // arg1 = coin (in copper)
  2693. // arg2 = status? (not implemented yet)
  2694. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2695. if (ph && sep && sep->IsNumber(1))
  2696. {
  2697. int64 outVal = strtoull(sep->arg[1], NULL, 0);
  2698. if (client->GetPlayer()->RemoveCoins(outVal))
  2699. {
  2700. char query[256];
  2701. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  2702. if (itr != ph->depositsMap.end())
  2703. {
  2704. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %I64u, last_amount = %I64u where house_id = %u and instance_id = %u and name='%s'", Timer::GetUnixTimeStamp(), outVal, outVal, ph->house_id, ph->instance_id, client->GetPlayer()->GetName());
  2705. }
  2706. else
  2707. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %I64u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outVal);
  2708. if (database.RunQuery(query, strnlen(query, 256)))
  2709. {
  2710. ph->escrow_coins += outVal;
  2711. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins);
  2712. database.LoadDeposits(ph);
  2713. client->PlaySound("coin_cha_ching");
  2714. HouseZone* hz = world.GetHouseZone(ph->house_id);
  2715. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2716. }
  2717. else
  2718. {
  2719. client->GetPlayer()->AddCoins(outVal);
  2720. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  2721. }
  2722. }
  2723. }
  2724. break;
  2725. }
  2726. case COMMAND_HOUSE:
  2727. {
  2728. if (sep && sep->IsNumber(0))
  2729. {
  2730. int32 unique_id = atoi(sep->arg[0]);
  2731. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2732. HouseZone* hz = 0;
  2733. if (ph)
  2734. hz = world.GetHouseZone(ph->house_id);
  2735. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2736. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2737. }
  2738. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  2739. {
  2740. // inside a house or something? Send the access window
  2741. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2742. HouseZone* hz = 0;
  2743. if ( ph )
  2744. hz = world.GetHouseZone(ph->house_id);
  2745. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2746. client->GetCurrentZone()->SendHouseItems(client);
  2747. }
  2748. break;
  2749. }
  2750. case COMMAND_HOUSE_UI:
  2751. {
  2752. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  2753. {
  2754. int32 unique_id = atoi(sep->arg[0]);
  2755. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2756. HouseZone* hz = 0;
  2757. if ( ph )
  2758. hz = world.GetHouseZone(ph->house_id);
  2759. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2760. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  2761. }
  2762. break;
  2763. }
  2764. case COMMAND_PLACE_HOUSE_ITEM: {
  2765. if (sep && sep->IsNumber(0))
  2766. {
  2767. int32 uniqueid = atoi(sep->arg[0]);
  2768. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  2769. //Item* item = player->GetEquipmentList()->GetItem(slot);
  2770. if (item && item->IsHouseItem())
  2771. {
  2772. if (!client->HasOwnerOrEditAccess())
  2773. {
  2774. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  2775. break;
  2776. }
  2777. else if (!item->generic_info.appearance_id)
  2778. {
  2779. 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);
  2780. break;
  2781. }
  2782. if (client->GetTempPlacementSpawn())
  2783. {
  2784. Spawn* tmp = client->GetTempPlacementSpawn();
  2785. client->GetCurrentZone()->RemoveSpawn(false, tmp);
  2786. delete tmp;
  2787. client->SetTempPlacementSpawn(nullptr);
  2788. }
  2789. Spawn* spawn = new Object();
  2790. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2791. spawn->SetID(Spawn::NextID());
  2792. spawn->SetX(client->GetPlayer()->GetX());
  2793. spawn->SetY(client->GetPlayer()->GetY());
  2794. spawn->SetZ(client->GetPlayer()->GetZ());
  2795. spawn->SetHeading(client->GetPlayer()->GetHeading());
  2796. spawn->SetSpawnOrigX(spawn->GetX());
  2797. spawn->SetSpawnOrigY(spawn->GetY());
  2798. spawn->SetSpawnOrigZ(spawn->GetZ());
  2799. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  2800. spawn->appearance.targetable = 1;
  2801. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  2802. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  2803. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  2804. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  2805. spawn->SetZone(client->GetCurrentZone());
  2806. client->GetCurrentZone()->SendSpawn(spawn, client);
  2807. client->SetTempPlacementSpawn(spawn);
  2808. client->SetPlacementUniqueItemID(uniqueid);
  2809. client->SendMoveObjectMode(spawn, 0);
  2810. }
  2811. }
  2812. break;
  2813. }
  2814. case COMMAND_GM:
  2815. {
  2816. if (sep->arg[0] && sep->arg[1])
  2817. {
  2818. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  2819. if (strcmp(sep->arg[0], "vision") == 0)
  2820. {
  2821. client->GetPlayer()->SetGMVision(onOff);
  2822. #if defined(__GNUC__)
  2823. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  2824. #else
  2825. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  2826. #endif
  2827. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  2828. if (onOff)
  2829. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  2830. else
  2831. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  2832. }
  2833. else if (strcmp(sep->arg[0], "luadebug") == 0)
  2834. {
  2835. client->SetLuaDebugClient(onOff);
  2836. #if defined(__GNUC__)
  2837. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  2838. #else
  2839. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  2840. #endif
  2841. if (onOff)
  2842. {
  2843. if (lua_interface)
  2844. lua_interface->UpdateDebugClients(client);
  2845. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  2846. }
  2847. else
  2848. {
  2849. if (lua_interface)
  2850. lua_interface->RemoveDebugClients(client);
  2851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  2852. }
  2853. }
  2854. }
  2855. break;
  2856. }
  2857. case COMMAND_ATTACK:
  2858. case COMMAND_AUTO_ATTACK:{
  2859. int8 type = 1;
  2860. Player* player = client->GetPlayer();
  2861. if(!player)
  2862. break;
  2863. bool incombat = player->EngagedInCombat();
  2864. if(sep && sep->arg[0] && sep->IsNumber(0))
  2865. type = atoi(sep->arg[0]);
  2866. if(client->GetPlayer()->GetHP() == 0){
  2867. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  2868. break;
  2869. }
  2870. if(type == 0){
  2871. if(incombat)
  2872. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2873. player->InCombat(false);
  2874. player->InCombat(false, true);
  2875. player->SetRangeAttack(false);
  2876. }
  2877. else {
  2878. if(type == 2){
  2879. player->InCombat(false);
  2880. if(incombat && player->GetRangeAttack()){
  2881. player->SetRangeAttack(false);
  2882. player->InCombat(false, true);
  2883. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2884. }
  2885. else{
  2886. player->SetRangeAttack(true);
  2887. player->InCombat(true, true);
  2888. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2889. }
  2890. }
  2891. else {
  2892. player->InCombat(false, true);
  2893. player->SetRangeAttack(false);
  2894. player->InCombat(true);
  2895. if(!incombat)
  2896. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2897. }
  2898. /*else
  2899. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  2900. }
  2901. player->SetCharSheetChanged(true);
  2902. break;
  2903. }
  2904. case COMMAND_DEPOP:{
  2905. bool allow_respawns = false;
  2906. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2907. if(atoi(sep->arg[0]) == 1)
  2908. allow_respawns = true;
  2909. }
  2910. client->GetCurrentZone()->Depop(allow_respawns);
  2911. break;
  2912. }
  2913. case COMMAND_REPOP:{
  2914. client->GetCurrentZone()->Depop(false, true);
  2915. break;
  2916. }
  2917. case COMMAND_BUYBACK:{
  2918. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2919. // 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
  2920. int64 id = atoi64(sep->arg[0]);
  2921. // get the first int32, the item id
  2922. //int32 item_id = (int32)id;
  2923. // get the second int32, the unique id
  2924. int32 unique_id = (int32)(id>>32);
  2925. int8 quantity = atoi(sep->arg[1]);
  2926. if(quantity == 255)
  2927. quantity = 1;
  2928. client->BuyBack(unique_id, quantity);
  2929. }
  2930. break;
  2931. }
  2932. case COMMAND_MERCHANT_BUY:{
  2933. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2934. int32 item_id = atoul(sep->arg[0]);
  2935. int8 quantity = atoi(sep->arg[1]);
  2936. client->BuyItem(item_id, quantity);
  2937. }
  2938. break;
  2939. }
  2940. case COMMAND_MERCHANT_SELL:{
  2941. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2942. // 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
  2943. int64 id = atoi64(sep->arg[0]);
  2944. // get the first int32, the item id
  2945. int32 item_id = (int32)id;
  2946. // get the second int32, the unique id
  2947. int32 unique_id = (int32)(id>>32);
  2948. int8 quantity = atoi(sep->arg[1]);
  2949. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  2950. client->SellItem(item_id, quantity, unique_id);
  2951. }
  2952. break;
  2953. }
  2954. case COMMAND_MENDER_REPAIR: {
  2955. if (sep && sep->arg[0] && sep->IsNumber(0))
  2956. client->RepairItem(atoul(sep->arg[0]));
  2957. break;
  2958. }
  2959. case COMMAND_MENDER_REPAIR_ALL: {
  2960. client->RepairAllItems();
  2961. break;
  2962. }
  2963. case COMMAND_CANCEL_MERCHANT:{
  2964. client->SetMerchantTransaction(0);
  2965. break;
  2966. }
  2967. case COMMAND_START_MERCHANT:{
  2968. break;
  2969. }
  2970. case COMMAND_INVULNERABLE:{
  2971. sint8 val = -1;
  2972. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2973. val = atoi(sep->arg[0]);
  2974. //devn00b: Fix for linux builds
  2975. #if defined(__GNUC__)
  2976. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  2977. #else
  2978. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2979. #endif
  2980. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2981. client->GetPlayer()->SetInvulnerable(val==1);
  2982. if(client->GetPlayer()->GetInvulnerable())
  2983. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  2984. else
  2985. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  2986. }
  2987. if(val == -1)
  2988. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  2989. break;
  2990. }
  2991. case COMMAND_REPAIR: {
  2992. Spawn* spawn = cmdTarget;
  2993. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  2994. client->SendHailCommand(spawn);
  2995. client->SetMerchantTransaction(spawn);
  2996. client->SendRepairList();
  2997. }
  2998. break;
  2999. }
  3000. case COMMAND_LOTTO: {
  3001. Spawn* spawn = cmdTarget;
  3002. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  3003. client->SetMerchantTransaction(spawn);
  3004. client->ShowLottoWindow();
  3005. }
  3006. break;
  3007. }
  3008. case COMMAND_ACCEPT_REWARD:{
  3009. int32 unknown = 0;
  3010. int32 selectable_item_id = 0;
  3011. //Quest *quest = 0;
  3012. Collection *collection = 0;
  3013. /* no idea what the first argument is for (faction maybe?)
  3014. if the reward has a selectable item reward, it's sent as the second argument
  3015. if neither of these are included in the reward, there is no sep
  3016. 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
  3017. only 1 quest or collection reward may be displayed at a time */
  3018. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3019. unknown = atoul(sep->arg[0]);
  3020. selectable_item_id = atoul(sep->arg[1]);
  3021. }
  3022. //if ((quest = player->GetPendingQuestReward()))
  3023. // client->AcceptQuestRewards(quest, selectable_item_id);
  3024. /* the below needs to go away eventually and be redone */
  3025. int32 item_id = 0;
  3026. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3027. item_id = atoul(sep->arg[0]);
  3028. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3029. if(quest){
  3030. client->AcceptQuestReward(quest, item_id);
  3031. break;
  3032. }
  3033. if (collection = player->GetPendingCollectionReward())
  3034. client->AcceptCollectionRewards(collection, selectable_item_id);
  3035. else
  3036. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  3037. break;
  3038. }
  3039. case COMMAND_BUY_FROM_BROKER:{
  3040. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3041. int32 item_id = atoul(sep->arg[0]);
  3042. int16 quantity = atoul(sep->arg[1]);
  3043. client->AddItem(item_id, quantity);
  3044. }
  3045. break;
  3046. }
  3047. case COMMAND_SEARCH_STORES_PAGE:{
  3048. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3049. int32 page = atoul(sep->arg[0]);
  3050. client->SearchStore(page);
  3051. }
  3052. break;
  3053. }
  3054. case COMMAND_SEARCH_STORES:{
  3055. if(sep && sep->arg[0][0]){
  3056. const char* values = sep->argplus[0];
  3057. if(values){
  3058. map<string, string> str_values = TranslateBrokerRequest(values);
  3059. vector<Item*>* items = master_item_list.GetItems(str_values);
  3060. if(items){
  3061. client->SetItemSearch(items);
  3062. client->SearchStore(0);
  3063. }
  3064. }
  3065. }
  3066. break;
  3067. }
  3068. case COMMAND_LUADEBUG:{
  3069. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  3070. client->SetLuaDebugClient(true);
  3071. if(lua_interface)
  3072. lua_interface->UpdateDebugClients(client);
  3073. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3074. }
  3075. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  3076. client->SetLuaDebugClient(false);
  3077. if(lua_interface)
  3078. lua_interface->RemoveDebugClients(client);
  3079. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3080. }
  3081. else{
  3082. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  3083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  3084. }
  3085. break;
  3086. }
  3087. case COMMAND_SPAWN_GROUP:
  3088. {
  3089. Spawn* target = cmdTarget;
  3090. if(target && target->IsPlayer() == false)
  3091. {
  3092. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  3093. {
  3094. if(target->GetSpawnLocationPlacementID() > 0)
  3095. {
  3096. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  3097. {
  3098. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  3099. if(id > 0)
  3100. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  3101. else
  3102. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  3103. target->SetSpawnGroupID(id);
  3104. target->AddSpawnToGroup(target);
  3105. }
  3106. else
  3107. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  3108. }
  3109. else
  3110. 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.");
  3111. }
  3112. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  3113. {
  3114. if(sep->arg[1] && sep->IsNumber(1))
  3115. {
  3116. int32 group_id = atoul(sep->arg[1]);
  3117. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  3118. if(leader)
  3119. {
  3120. leader->AddSpawnToGroup(target);
  3121. target->SetSpawnGroupID(group_id);
  3122. if(database.SpawnGroupAddSpawn(target, group_id))
  3123. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  3124. else
  3125. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  3126. }
  3127. else
  3128. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  3129. }
  3130. else
  3131. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  3132. }
  3133. else if(target->GetSpawnGroupID() == 0)
  3134. {
  3135. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  3136. }
  3137. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  3138. {
  3139. int32 group_id = target->GetSpawnGroupID();
  3140. target->RemoveSpawnFromGroup();
  3141. if(database.SpawnGroupRemoveSpawn(target, group_id))
  3142. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  3143. else
  3144. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  3145. }
  3146. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  3147. {
  3148. int32 group_id = target->GetSpawnGroupID();
  3149. if(sep->arg[1] && sep->IsNumber(1))
  3150. {
  3151. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  3152. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  3153. else
  3154. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  3155. }
  3156. else
  3157. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  3158. }
  3159. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  3160. {
  3161. int32 group_id = target->GetSpawnGroupID();
  3162. if(sep->arg[1] && sep->IsNumber(1))
  3163. {
  3164. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  3165. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  3166. else
  3167. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  3168. }
  3169. else
  3170. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  3171. }
  3172. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  3173. {
  3174. if(sep->arg[1] && sep->IsNumber(1))
  3175. {
  3176. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  3177. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  3178. else
  3179. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  3180. }
  3181. else
  3182. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  3183. }
  3184. else
  3185. {
  3186. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  3187. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  3188. }
  3189. }
  3190. else
  3191. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  3192. break;
  3193. }
  3194. case COMMAND_SPAWN_COMBINE:{
  3195. Spawn* spawn = cmdTarget;
  3196. float radius = 0;
  3197. bool failed = true;
  3198. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  3199. failed = false;
  3200. if(spawn->GetSpawnGroupID() > 0){
  3201. 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.");
  3202. }
  3203. else if(sep->IsNumber(0)){
  3204. radius = atof(sep->arg[0]);
  3205. client->CombineSpawns(radius, spawn);
  3206. }
  3207. else{
  3208. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  3209. client->AddCombineSpawn(spawn);
  3210. }
  3211. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  3212. client->RemoveCombineSpawn(spawn);
  3213. }
  3214. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  3215. const char* name = 0;
  3216. if(sep->arg[1] && sep->arg[1][0])
  3217. name = sep->argplus[1];
  3218. client->SaveCombineSpawns(name);
  3219. }
  3220. else
  3221. failed = true;
  3222. }
  3223. }
  3224. if(failed){
  3225. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  3226. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  3227. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  3228. }
  3229. break;
  3230. }
  3231. case COMMAND_SPAWN_CREATE:{
  3232. Spawn* spawn = 0;
  3233. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3234. spawn = new Object();
  3235. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3236. }
  3237. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3238. spawn = new GroundSpawn();
  3239. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3240. }
  3241. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3242. spawn = new Sign();
  3243. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3244. }
  3245. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3246. spawn = new NPC();
  3247. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3248. spawn->appearance.pos.collision_radius = 32;
  3249. spawn->secondary_command_list_id = 0;
  3250. spawn->primary_command_list_id = 0;
  3251. spawn->appearance.display_name = 1;
  3252. spawn->appearance.show_level = 1;
  3253. spawn->appearance.attackable = 1;
  3254. }
  3255. else{
  3256. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  3257. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  3258. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  3259. break;
  3260. }
  3261. spawn->SetID(Spawn::NextID());
  3262. spawn->SetX(client->GetPlayer()->GetX());
  3263. spawn->SetY(client->GetPlayer()->GetY());
  3264. spawn->SetZ(client->GetPlayer()->GetZ());
  3265. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3266. spawn->SetSpawnOrigX(spawn->GetX());
  3267. spawn->SetSpawnOrigY(spawn->GetY());
  3268. spawn->SetSpawnOrigZ(spawn->GetZ());
  3269. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3270. spawn->appearance.targetable = 1;
  3271. spawn->appearance.race = 255;
  3272. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3273. spawn->SetModelType(atoi(sep->arg[1]));
  3274. spawn->SetAdventureClass(atoi(sep->arg[2]));
  3275. spawn->SetLevel(atoi(sep->arg[3]));
  3276. spawn->SetName(sep->arg[4]);
  3277. if(sep->arg[5][0] && sep->IsNumber(5))
  3278. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  3279. if(sep->arg[6][0] && sep->IsNumber(6))
  3280. spawn->size = atoi(sep->arg[6]);
  3281. if(spawn->GetTotalHP() == 0){
  3282. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  3283. spawn->SetHP(25*spawn->GetLevel() + 1);
  3284. }
  3285. if(spawn->GetTotalPower() == 0){
  3286. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3287. spawn->SetPower(25*spawn->GetLevel() + 1);
  3288. }
  3289. client->GetCurrentZone()->AddSpawn(spawn);
  3290. break;
  3291. }
  3292. case COMMAND_SPAWN_EQUIPMENT:{
  3293. Spawn* spawn = cmdTarget;
  3294. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3295. int8 slot = atoi(sep->arg[0]);
  3296. int16 type = atoi(sep->arg[1]);
  3297. int8 red = 0;
  3298. int8 green = 0;
  3299. int8 blue = 0;
  3300. int8 h_red = 0;
  3301. int8 h_green = 0;
  3302. int8 h_blue = 0;
  3303. if(sep->arg[2])
  3304. red = atoi(sep->arg[2]);
  3305. if(sep->arg[3])
  3306. green = atoi(sep->arg[3]);
  3307. if(sep->arg[4])
  3308. blue = atoi(sep->arg[4]);
  3309. if(sep->arg[5])
  3310. h_red = atoi(sep->arg[5]);
  3311. if(sep->arg[6])
  3312. h_green = atoi(sep->arg[6]);
  3313. if(sep->arg[7])
  3314. h_blue = atoi(sep->arg[7]);
  3315. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3316. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3317. }
  3318. else{
  3319. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3320. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3321. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3322. }
  3323. break;
  3324. }
  3325. case COMMAND_SPAWN_DETAILS:{
  3326. Spawn* spawn = cmdTarget;
  3327. if (sep && sep->arg[0][0]) {
  3328. if (cmdTarget)
  3329. {
  3330. if (ToLower(string(sep->arg[0])) == "los")
  3331. {
  3332. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3333. if (hasLOS)
  3334. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3335. else
  3336. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3337. break;
  3338. }
  3339. else if (ToLower(string(sep->arg[0])) == "bestz")
  3340. {
  3341. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3342. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3343. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3344. break;
  3345. }
  3346. else if (ToLower(string(sep->arg[0])) == "pathto")
  3347. {
  3348. break;
  3349. }
  3350. else if (ToLower(string(sep->arg[0])) == "pathfrom")
  3351. {
  3352. break;
  3353. }
  3354. }
  3355. if (sep->IsNumber(0))
  3356. {
  3357. float radius = atof(sep->arg[0]);
  3358. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3359. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3360. break;
  3361. }
  3362. }
  3363. if(spawn){
  3364. const char* type = "NPC";
  3365. if(spawn->IsObject())
  3366. type = "Object";
  3367. else if(spawn->IsSign())
  3368. type = "Sign";
  3369. else if(spawn->IsWidget())
  3370. type = "Widget";
  3371. else if(spawn->IsGroundSpawn())
  3372. type = "GroundSpawn";
  3373. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3374. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3375. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3376. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3377. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3378. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3379. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3380. 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());
  3381. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3382. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3383. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3384. if(spawn->IsEntity()){
  3385. 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());
  3386. 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());
  3387. }
  3388. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3389. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3390. 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());
  3391. 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);
  3392. if (spawn->IsNPC())
  3393. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3394. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  3395. if (packet) {
  3396. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3397. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3398. packet->setDataByName("book_title", title.c_str());
  3399. packet->setDataByName("book_type", "simple");
  3400. packet->setDataByName("unknown2", 1);
  3401. packet->setDataByName("unknown5", 1, 4);
  3402. packet->setArrayLengthByName("num_pages", 4);
  3403. string details;
  3404. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3405. details += "Type: " + string(type) + "\n";
  3406. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3407. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3408. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3409. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3410. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3411. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3412. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3413. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3414. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3415. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3416. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3417. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3418. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3419. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3420. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3421. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3422. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3423. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3424. char x[16];
  3425. sprintf(x, "%.2f", spawn->GetX());
  3426. char y[16];
  3427. sprintf(y, "%.2f", spawn->GetY());
  3428. char z[16];
  3429. sprintf(z, "%.2f", spawn->GetZ());
  3430. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3431. string details2;
  3432. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3433. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3434. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3435. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3436. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3437. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3438. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3439. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3440. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3441. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3442. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3443. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3444. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3445. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3446. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3447. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3448. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3449. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3450. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3451. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3452. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3453. string details3;
  3454. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3455. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3456. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3457. string details4;
  3458. if (spawn->IsEntity()) {
  3459. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3460. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3461. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3462. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3463. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3464. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3465. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3466. if (spawn->IsNPC()) {
  3467. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3468. }
  3469. }
  3470. //details2 += "" + to_string() + "\n";
  3471. packet->setArrayDataByName("page_text", details.c_str());
  3472. packet->setArrayDataByName("page_text", details2.c_str(), 1);
  3473. packet->setArrayDataByName("page_text", details3.c_str(), 2);
  3474. packet->setArrayDataByName("page_text", details4.c_str(), 3);
  3475. client->QueuePacket(packet->serialize());
  3476. safe_delete(packet);
  3477. }
  3478. }
  3479. else {
  3480. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3481. 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.");
  3482. }
  3483. break;
  3484. }
  3485. case COMMAND_SPAWN_TARGET:{
  3486. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3487. int32 spawn_id = atoul(sep->arg[0]);
  3488. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3489. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3490. }
  3491. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3492. float distance = atof(sep->arg[1]);
  3493. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3494. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3495. }
  3496. else{
  3497. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3498. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3499. }
  3500. break;
  3501. }
  3502. case COMMAND_SPAWN_SET:
  3503. {
  3504. Spawn* spawn = cmdTarget;
  3505. sint16 set_type = -1;
  3506. string type_str;
  3507. if (spawn)
  3508. {
  3509. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3510. 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)
  3511. {
  3512. // set the type, which will be 0 if location or list or invalid
  3513. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3514. }
  3515. if(set_type > 0)
  3516. {
  3517. // check if spawn set is NOT a char update, or not location, or isn't a number
  3518. 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)
  3519. {
  3520. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3521. }
  3522. else
  3523. {
  3524. string name = string(spawn->GetName());
  3525. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1]))
  3526. {
  3527. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  3528. {
  3529. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  3530. }
  3531. else if(set_type == SPAWN_SET_VALUE_NAME)
  3532. {
  3533. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3534. }
  3535. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3536. {
  3537. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3538. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3539. }
  3540. else
  3541. {
  3542. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3543. }
  3544. switch (set_type)
  3545. {
  3546. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  3547. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  3548. case SPAWN_SET_VALUE_FACTION:
  3549. {
  3550. // not applicable
  3551. break;
  3552. }
  3553. default:
  3554. {
  3555. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->arg[1]);
  3556. break;
  3557. }
  3558. }
  3559. 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))
  3560. {
  3561. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3562. {
  3563. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3564. }
  3565. else if(spawn->GetSpawnLocationID() > 0)
  3566. {
  3567. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3568. }
  3569. }
  3570. else
  3571. {
  3572. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3573. {
  3574. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3575. }
  3576. else if(spawn->GetDatabaseID() > 0)
  3577. {
  3578. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3579. }
  3580. }
  3581. }
  3582. }
  3583. }
  3584. else if(set_type == 0)
  3585. {
  3586. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3587. map<string, int8>::iterator itr;
  3588. int i=0;
  3589. string list;
  3590. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3591. {
  3592. if(i==10)
  3593. {
  3594. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3595. i = 0;
  3596. }
  3597. if(i>0)
  3598. {
  3599. list.append(", ").append(itr->first);
  3600. }
  3601. else
  3602. {
  3603. list = itr->first;
  3604. }
  3605. }
  3606. if(list.length() > 0)
  3607. {
  3608. // if 1 or more, display in client.
  3609. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3610. }
  3611. }
  3612. else
  3613. {
  3614. // syntax fail
  3615. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3616. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3617. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3618. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3619. }
  3620. }
  3621. break;
  3622. }
  3623. case COMMAND_SPAWN_REMOVE:{
  3624. Spawn* spawn = cmdTarget;
  3625. if(spawn && !spawn->IsPlayer()){
  3626. if(spawn->GetSpawnLocationID() > 0){
  3627. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3628. bool delete_spawn = false;
  3629. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3630. if(atoi(sep->arg[0]) == 1)
  3631. delete_spawn = true;
  3632. }
  3633. if(delete_spawn)
  3634. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, false);
  3635. else
  3636. spawn->SetSpawnLocationID(0);
  3637. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3638. }
  3639. else
  3640. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3641. }
  3642. else
  3643. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3644. }
  3645. else{
  3646. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3647. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3648. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Optionally, you can supply a 1 after the command to despawn it as well. IE /spawn remove 1");
  3649. }
  3650. break;
  3651. }
  3652. case COMMAND_SPAWN_LIST:{
  3653. if(sep && sep->arg[0][0]){
  3654. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3655. vector<string>::iterator itr;
  3656. if(results){
  3657. for(itr=results->begin();itr!=results->end();itr++){
  3658. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3659. }
  3660. safe_delete(results);
  3661. }
  3662. else
  3663. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3664. }
  3665. else{
  3666. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3667. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3668. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3669. }
  3670. break;
  3671. }
  3672. case COMMAND_SPAWN_ADD:{
  3673. Spawn* spawn = cmdTarget;
  3674. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3675. if(spawn->GetSpawnLocationID() > 0){
  3676. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3677. break;
  3678. }
  3679. if(spawn->GetDatabaseID() == 0){
  3680. if(database.SaveSpawnInfo(spawn)) {
  3681. char spawn_type[32];
  3682. memset(spawn_type, 0, sizeof(spawn_type));
  3683. if (spawn->IsNPC())
  3684. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3685. else if (spawn->IsObject())
  3686. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3687. else if (spawn->IsSign())
  3688. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3689. else if (spawn->IsGroundSpawn())
  3690. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3691. else
  3692. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3693. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3694. }
  3695. else
  3696. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3697. }
  3698. int32 spawn_group_id = 0;
  3699. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3700. spawn_group_id = database.GetNextSpawnLocation();
  3701. else
  3702. spawn_group_id = atol(sep->arg[0]);
  3703. int8 percent = 100;
  3704. if(sep->arg[2] && sep->IsNumber(2))
  3705. percent = atoi(sep->arg[2]);
  3706. spawn->SetSpawnLocationID(spawn_group_id);
  3707. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3708. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3709. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3710. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3711. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3712. else
  3713. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3714. }
  3715. else{
  3716. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3717. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3718. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3719. }
  3720. break;
  3721. }
  3722. case COMMAND_SPAWN:{
  3723. int32 id = 0;
  3724. Spawn* spawn = 0;
  3725. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3726. id = atol(sep->arg[0]);
  3727. spawn = client->GetCurrentZone()->GetSpawn(id);
  3728. }
  3729. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3730. id = 0;
  3731. if(!id || !spawn){
  3732. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3733. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3734. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3735. safe_delete(sep);
  3736. return;
  3737. }
  3738. if(sep && sep->arg[1][0]){
  3739. float x = atof(sep->arg[1]);
  3740. spawn->appearance.pos.X = x;
  3741. }
  3742. else
  3743. spawn->SetX(client->GetPlayer()->GetX(), false);
  3744. if(sep && sep->arg[2][0]){
  3745. float y = atof(sep->arg[2]);
  3746. spawn->appearance.pos.Y = y;
  3747. }
  3748. else
  3749. spawn->SetY(client->GetPlayer()->GetY(), false);
  3750. if(sep && sep->arg[3][0]){
  3751. float z = atof(sep->arg[3]);
  3752. spawn->appearance.pos.Z = z;
  3753. }
  3754. else
  3755. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3756. if(sep && sep->arg[4][0]){
  3757. float heading = atof(sep->arg[4]);
  3758. spawn->SetHeading(heading);
  3759. }
  3760. else
  3761. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3762. spawn->SetSpawnOrigX(spawn->GetX());
  3763. spawn->SetSpawnOrigY(spawn->GetY());
  3764. spawn->SetSpawnOrigZ(spawn->GetZ());
  3765. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3766. if(sep && sep->arg[5][0])
  3767. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3768. else
  3769. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3770. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3771. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3772. spawn->SetHP(spawn->GetTotalHP());
  3773. }
  3774. if(spawn->GetTotalPower() == 0){
  3775. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3776. spawn->SetPower(spawn->GetTotalPower());
  3777. }
  3778. const char* script = world.GetSpawnScript(id);
  3779. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3780. spawn->SetSpawnScript(string(script));
  3781. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  3782. client->GetCurrentZone()->AddSpawn(spawn);
  3783. if(spawn->IsNPC())
  3784. spawn->GetZone()->AddLoot((NPC*)spawn);
  3785. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3786. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3787. break;
  3788. }
  3789. case COMMAND_ADMINFLAG:
  3790. {
  3791. if(sep && sep->arg[0]){
  3792. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3793. sint16 new_status = atoi(sep->arg[1]);
  3794. if(tmp_status == -10)
  3795. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3796. else if(tmp_status >= client->GetAdminStatus())
  3797. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3798. else if (new_status > client->GetAdminStatus())
  3799. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3800. else{
  3801. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3802. if (!client2)
  3803. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3804. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3805. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3806. if (client2) {
  3807. client2->SetAdminStatus(new_status);
  3808. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3809. }
  3810. }
  3811. else
  3812. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3813. }
  3814. }else{
  3815. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3816. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3817. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3818. }
  3819. break;
  3820. }
  3821. case COMMAND_CANNEDEMOTE:{
  3822. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3823. break;
  3824. }
  3825. case COMMAND_BROADCAST: {
  3826. if (sep && sep->arg[0])
  3827. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3828. else
  3829. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3830. break;
  3831. }
  3832. case COMMAND_ANNOUNCE: {
  3833. if (sep && sep->arg[0])
  3834. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3835. else
  3836. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3837. break;
  3838. }
  3839. case COMMAND_RELOAD_ITEMS:{
  3840. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3842. database.ReloadItemList();
  3843. database.LoadMerchantInformation();
  3844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3845. break;
  3846. }
  3847. case COMMAND_ENABLE_ABILITY_QUE:{
  3848. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3849. if(app)
  3850. client->QueuePacket(app);
  3851. break;
  3852. }
  3853. case COMMAND_ITEMSEARCH:{
  3854. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3855. if (packet) {
  3856. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3857. //packet->setDataByName("unknown", 1);
  3858. packet->setDataByName("unknown2", 5, 0);
  3859. packet->setDataByName("unknown2", 20, 1);
  3860. packet->setDataByName("unknown2", 58, 3);
  3861. packet->setDataByName("unknown2", 40, 4);
  3862. client->QueuePacket(packet->serialize());
  3863. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3864. if (packet2) {
  3865. packet2->setDataByName("char_id", client->GetCharacterID());
  3866. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3867. safe_delete(packet2);
  3868. }
  3869. safe_delete(packet);
  3870. }
  3871. break;
  3872. }
  3873. case COMMAND_ANIMTEST:{
  3874. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3875. if(command_packet){
  3876. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  3877. if (cmdTarget)
  3878. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  3879. command_packet->setDataByName ( "spawn_id" , id);
  3880. int animID = 1;
  3881. if(sep && sep->arg[0] && sep->IsNumber(0))
  3882. animID = atoi(sep->arg[0]);
  3883. VisualState* vs = NULL;
  3884. if(animID == 0)
  3885. {
  3886. vs = visual_states.FindVisualState(sep->arg[0]);
  3887. }
  3888. char msg[128];
  3889. sprintf(msg,"Animation Test ID: %i",animID);
  3890. command_packet->setMediumStringByName ( "emote_msg" , msg );
  3891. if(vs != NULL)
  3892. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  3893. else
  3894. command_packet->setDataByName ( "anim_type", animID );
  3895. command_packet->setDataByName ( "unknown0", 0 );
  3896. EQ2Packet* outapp = command_packet->serialize();
  3897. client->QueuePacket(outapp);
  3898. safe_delete(command_packet);
  3899. }
  3900. break;
  3901. }
  3902. case COMMAND_KICK:
  3903. {
  3904. if( sep == 0 || sep->arg[0] == 0)
  3905. {
  3906. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  3907. }
  3908. else
  3909. {
  3910. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  3911. if ( kickClient == client )
  3912. {
  3913. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  3914. break;
  3915. }
  3916. else if(kickClient != NULL)
  3917. {
  3918. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3919. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  3920. {
  3921. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3922. break;
  3923. }
  3924. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  3925. kickClient->Disconnect();
  3926. }
  3927. else
  3928. {
  3929. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3930. }
  3931. }
  3932. break;
  3933. }
  3934. case COMMAND_LOCK:
  3935. {
  3936. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  3937. int worldLocked = atoi(sep->arg[0]);
  3938. net.world_locked = worldLocked;
  3939. if ( worldLocked )
  3940. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  3941. else
  3942. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  3943. }
  3944. else
  3945. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  3946. break;
  3947. }
  3948. case COMMAND_BAN:{
  3949. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  3950. {
  3951. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  3952. }
  3953. else
  3954. {
  3955. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  3956. if ( kickClient == client )
  3957. {
  3958. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  3959. break;
  3960. }
  3961. else if(kickClient != NULL)
  3962. {
  3963. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3964. if ( maxStatus > client->GetAdminStatus( ) ||
  3965. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  3966. {
  3967. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3968. break;
  3969. }
  3970. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  3971. int perm = atol(sep->arg[1]);
  3972. if ( perm == 1 )
  3973. database.UpdateAdminStatus(sep->arg[0],-2);
  3974. else
  3975. database.UpdateAdminStatus(sep->arg[0],-1);
  3976. kickClient->Disconnect();
  3977. }
  3978. else
  3979. {
  3980. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3981. }
  3982. }
  3983. break;
  3984. }
  3985. case COMMAND_SET_COMBAT_VOICE:{
  3986. int32 value = 0;
  3987. if(sep && sep->arg[0] && sep->IsNumber(0))
  3988. value = atoi(sep->arg[0]);
  3989. client->GetPlayer()->SetCombatVoice(value);
  3990. break;
  3991. }
  3992. case COMMAND_SET_EMOTE_VOICE:{
  3993. int32 value = 0;
  3994. if(sep && sep->arg[0] && sep->IsNumber(0))
  3995. value = atoi(sep->arg[0]);
  3996. client->GetPlayer()->SetEmoteVoice(value);
  3997. break;
  3998. }
  3999. case COMMAND_GIVEITEM:{
  4000. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  4001. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  4002. if ( itemToClient == NULL )
  4003. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  4004. else
  4005. {
  4006. int32 item_id = atol(sep->arg[1]);
  4007. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  4008. itemToClient->AddItem(item_id);
  4009. }
  4010. }
  4011. else
  4012. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  4013. break;
  4014. }
  4015. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  4016. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  4017. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  4018. case COMMAND_SKILL :
  4019. case COMMAND_SKILL_ADD :
  4020. case COMMAND_SKILL_REMOVE :
  4021. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  4022. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  4023. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  4024. case COMMAND_ENTITYCOMMAND :
  4025. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  4026. case COMMAND_MERCHANT :
  4027. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  4028. case COMMAND_APPEARANCE :
  4029. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  4030. case COMMAND_TRACK : { Command_Track(client); break; }
  4031. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  4032. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  4033. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  4034. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  4035. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  4036. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  4037. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  4038. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  4039. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  4040. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  4041. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  4042. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  4043. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  4044. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  4045. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  4046. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  4047. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  4048. case COMMAND_LOCATION : { Command_Location(client); break; }
  4049. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  4050. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  4051. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  4052. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  4053. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  4054. case COMMAND_GRID : { Command_Grid(client); break; }
  4055. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  4056. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  4057. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  4058. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  4059. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  4060. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  4061. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  4062. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  4063. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  4064. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  4065. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  4066. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  4067. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  4068. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  4069. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  4070. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  4071. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  4072. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  4073. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  4074. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  4075. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  4076. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  4077. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  4078. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  4079. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  4080. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  4081. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  4082. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  4083. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  4084. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  4085. case COMMAND_MOTD : { Command_MOTD(client); break; }
  4086. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  4087. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  4088. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  4089. case COMMAND_TITLE : { Command_Title(client); break; }
  4090. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  4091. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  4092. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  4093. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  4094. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  4095. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  4096. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  4097. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  4098. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  4099. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  4100. case COMMAND_PET : { Command_Pet(client, sep); break; }
  4101. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  4102. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  4103. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  4104. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  4105. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  4106. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  4107. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  4108. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  4109. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  4110. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  4111. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  4112. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  4113. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  4114. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  4115. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  4116. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  4117. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  4118. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  4119. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  4120. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  4121. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  4122. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  4123. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  4124. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  4125. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  4126. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  4127. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  4128. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  4129. case COMMAND_MODIFY : { Command_Modify(client); break; }
  4130. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  4131. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  4132. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  4133. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  4134. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  4135. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  4136. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  4137. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  4138. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  4139. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  4140. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  4141. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  4142. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  4143. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  4144. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  4145. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  4146. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  4147. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  4148. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  4149. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  4150. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  4151. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  4152. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  4153. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  4154. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  4155. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  4156. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  4157. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  4158. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  4159. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  4160. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  4161. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  4162. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  4163. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  4164. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  4165. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  4166. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  4167. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  4168. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  4169. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  4170. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  4171. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  4172. case ADD_AA : { Add_AA(client, sep); break; }
  4173. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  4174. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  4175. case BACK_AA : { Back_AA(client, sep); break; }
  4176. case REMOVE_AA : { Remove_AA(client, sep); break; }
  4177. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  4178. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  4179. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  4180. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  4181. default:
  4182. {
  4183. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  4184. break;
  4185. }
  4186. }
  4187. safe_delete(sep);
  4188. }
  4189. /******************** New COMMAND Handler Functions ********************/
  4190. /*
  4191. Started breaking apart the huge switch() for commands into sepErate
  4192. functions so it is easier to locate the blocks of code by command
  4193. -- JA 2012.03.03
  4194. */
  4195. // sample function header
  4196. /*
  4197. Function:
  4198. Purpose :
  4199. Params :
  4200. Dev :
  4201. Example :
  4202. */
  4203. //void Commands::Command()
  4204. //{
  4205. //}
  4206. /*
  4207. Function: Command_AcceptAdvancement()
  4208. Purpose : Player accepts a new advancement option
  4209. Params : Spell ID
  4210. Dev : Jabantiz
  4211. */
  4212. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4213. {
  4214. Player *player = client->GetPlayer();
  4215. if (sep && sep->IsSet(0)) {
  4216. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4217. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4218. if (!player->HasSpell(trait->spellID, 0, true))
  4219. {
  4220. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4221. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4222. }
  4223. else
  4224. {
  4225. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4226. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4227. player->RemoveSpellBookEntry(spell->GetSpellID());
  4228. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4229. player->UnlockSpell(spell);
  4230. client->SendSpellUpdate(spell);
  4231. }
  4232. // Spell book update
  4233. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4234. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4235. }
  4236. }
  4237. /*
  4238. Function:
  4239. Purpose :
  4240. Params :
  4241. Dev :
  4242. Example :
  4243. */
  4244. void Commands::Command_AFK(Client* client, Seperator* sep)
  4245. {
  4246. Player* player = client->GetPlayer();
  4247. player->toggle_character_flag(CF_AFK);
  4248. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4249. if (player->get_character_flag(CF_AFK))
  4250. {
  4251. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4252. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  4253. if (sep && sep->argplus[0])
  4254. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4255. else
  4256. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4257. string message = string(player->GetName()) + " is going afk.";
  4258. Spawn* target = player->GetTarget();
  4259. if (target && target != player)
  4260. {
  4261. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4262. player->GetGender() == 1 ? message += "he" : message += "she";
  4263. message += " is going afk.";
  4264. }
  4265. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4266. }
  4267. /*else
  4268. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  4269. }
  4270. /*
  4271. Function: Command_Appearance()
  4272. Purpose : Handles /appearance commands
  4273. Params : list
  4274. Dev : Scatman
  4275. Example : /appearance list
  4276. */
  4277. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4278. {
  4279. if( handler == COMMAND_APPEARANCE )
  4280. {
  4281. // /appearance command by itself shows help (to be extended)
  4282. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4283. return;
  4284. }
  4285. else if( handler == COMMAND_APPEARANCE_LIST )
  4286. {
  4287. // /appearance list command expects "name" param
  4288. if (sep && sep->arg[0])
  4289. {
  4290. const char* appearance_name = sep->argplus[0];
  4291. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4292. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4293. if (appearances)
  4294. {
  4295. vector<int16>::iterator itr;
  4296. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4297. {
  4298. int16 id = *itr;
  4299. string name = database.GetAppearanceName(id);
  4300. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4301. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4302. }
  4303. safe_delete(appearances);
  4304. }
  4305. }
  4306. else // no param
  4307. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4308. }
  4309. }
  4310. /*
  4311. Function: Command_Claim()
  4312. Purpose :
  4313. Params :
  4314. Dev :
  4315. Example :
  4316. */
  4317. void Commands::Command_Claim(Client* client, Seperator* sep)
  4318. {
  4319. if (sep && sep->arg[0] && sep->IsNumber(0))
  4320. {
  4321. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4322. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4323. }
  4324. else
  4325. client->ShowClaimWindow();
  4326. }
  4327. /*
  4328. Function: Command_ClearAllQueued()
  4329. Purpose :
  4330. Params :
  4331. Dev :
  4332. Example :
  4333. */
  4334. void Commands::Command_ClearAllQueued(Client* client)
  4335. {
  4336. ZoneServer* zone = client->GetPlayer()->GetZone();
  4337. if (zone && zone->GetSpellProcess())
  4338. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4339. }
  4340. /*
  4341. Function: Command_CancelMaintained()
  4342. Purpose : Cancels maintained spells
  4343. Params : Maintained Spell Index
  4344. Dev : Zcoretri
  4345. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4346. */
  4347. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4348. {
  4349. if (sep && sep->arg[0] && sep->IsNumber(0))
  4350. {
  4351. int32 spell_index = atoul(sep->arg[0]);
  4352. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4353. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4354. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4355. // just not spelleffects/dets - Foof
  4356. //{
  4357. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell))
  4358. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4359. // }
  4360. //else
  4361. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4362. }
  4363. }
  4364. /*
  4365. Function: Command_Create()
  4366. Purpose : Handler for starting Tradeskilling table
  4367. Params :
  4368. Dev : Zcoretri
  4369. Example :
  4370. */
  4371. void Commands::Command_Create(Client* client, Seperator* sep)
  4372. {
  4373. PrintSep(sep, "COMMAND_CREATE");
  4374. client->SendRecipeList();
  4375. client->ShowRecipeBook();
  4376. }
  4377. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4378. {
  4379. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4380. if (sep && sep->arg[0] && sep->IsNumber(0))
  4381. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4382. }
  4383. /*
  4384. Function: Command_Distance()
  4385. Purpose : Displays distance from targeted spawn
  4386. Params :
  4387. Dev : Scatman
  4388. Example : /distance
  4389. */
  4390. void Commands::Command_Distance(Client* client)
  4391. {
  4392. Spawn* target = client->GetPlayer()->GetTarget();
  4393. if (target)
  4394. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4395. else
  4396. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4397. }
  4398. /*
  4399. Function: Command_Duel()
  4400. Purpose : Handle the /duel commands - not yet implemented
  4401. Params : unknown
  4402. Dev :
  4403. Example :
  4404. */
  4405. void Commands::Command_Duel(Client* client, Seperator* sep)
  4406. {
  4407. PrintSep(sep, "COMMAND_DUEL");
  4408. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4409. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4410. }
  4411. /*
  4412. Function: Command_DuelBet()
  4413. Purpose : Handle the /duel commands - not yet implemented
  4414. Params : unknown
  4415. Dev :
  4416. Example :
  4417. */
  4418. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4419. {
  4420. PrintSep(sep, "COMMAND_DUELBET");
  4421. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4422. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4423. }
  4424. /*
  4425. Function: Command_DuelAccept()
  4426. Purpose : Handle the /duel commands - not yet implemented
  4427. Params : unknown
  4428. Dev :
  4429. Example :
  4430. */
  4431. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4432. {
  4433. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4434. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4435. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4436. }
  4437. /*
  4438. Function: Command_DuelDecline()
  4439. Purpose : Handle the /duel commands - not yet implemented
  4440. Params : unknown
  4441. Dev :
  4442. Example :
  4443. */
  4444. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4445. {
  4446. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4447. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4448. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4449. }
  4450. /*
  4451. Function: Command_DuelSurrender()
  4452. Purpose : Handle the /duel commands - not yet implemented
  4453. Params : unknown
  4454. Dev :
  4455. Example :
  4456. */
  4457. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4458. {
  4459. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4460. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4461. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4462. // JA, just messin around ;)
  4463. char surrender[64];
  4464. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4465. zone_list.HandleGlobalAnnouncement(surrender);
  4466. }
  4467. /*
  4468. Function: Command_DuelToggle()
  4469. Purpose : Handle the /duel commands - not yet implemented
  4470. Params : unknown
  4471. Dev :
  4472. Example :
  4473. */
  4474. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4475. {
  4476. PrintSep(sep, "COMMAND_DUEL");
  4477. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4478. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4479. }
  4480. /*
  4481. Function:
  4482. Purpose :
  4483. Params :
  4484. Dev :
  4485. Example :
  4486. */
  4487. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4488. {
  4489. if( handler == COMMAND_ENTITYCOMMAND )
  4490. {
  4491. // /entitycommand command by itself shows help (to be extended)
  4492. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4493. return;
  4494. }
  4495. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4496. {
  4497. // /entitycommand list command expects "name" param
  4498. if (sep && sep->arg[0])
  4499. {
  4500. const char* entity_command_name = sep->argplus[0];
  4501. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4502. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4503. map<int32, vector<EntityCommand*>*>::iterator itr;
  4504. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4505. {
  4506. vector<EntityCommand*>* entity_command_list = itr->second;
  4507. vector<EntityCommand*>::iterator itr2;
  4508. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4509. {
  4510. EntityCommand* entity_command = *itr2;
  4511. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4512. 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);
  4513. }
  4514. }
  4515. }
  4516. else // no command name
  4517. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4518. }
  4519. }
  4520. /*
  4521. Function: Command_Follow()
  4522. Purpose : Handle the /follow command - not yet implemented
  4523. Params :
  4524. Dev :
  4525. Example :
  4526. */
  4527. void Commands::Command_Follow(Client* client, Seperator* sep)
  4528. {
  4529. PrintSep(sep, "COMMAND_FOLLOW");
  4530. // flag to toggle if the players target is in the players group
  4531. bool targetInGroup = false;
  4532. // get a pointer to the players group
  4533. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4534. // If the player has a group and has a target
  4535. if (gmi && client->GetPlayer()->GetTarget()) {
  4536. deque<GroupMemberInfo*>::iterator itr;
  4537. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4538. deque<GroupMemberInfo*>* members = world.GetGroupManager()->GetGroupMembers(gmi->group_id);
  4539. // Loop through the group members
  4540. for (itr = members->begin(); itr != members->end(); itr++) {
  4541. // If a group member matches a target
  4542. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4543. // toggle the flag and break the loop
  4544. targetInGroup = true;
  4545. break;
  4546. }
  4547. }
  4548. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4549. }
  4550. if (targetInGroup) {
  4551. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4552. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4553. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4554. client->GetPlayer()->info_changed = true;
  4555. client->GetPlayer()->changed = true;
  4556. }
  4557. else
  4558. client->Message(CHANNEL_COLOR_WHITE, "You must first select a group member to follow.");
  4559. }
  4560. /*
  4561. Function: Command_StopFollow()
  4562. Purpose : Handle the /stop_follow command - not yet implemented
  4563. Params :
  4564. Dev :
  4565. Example :
  4566. */
  4567. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4568. {
  4569. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4570. if (client->GetPlayer()->GetFollowTarget()) {
  4571. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4572. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4573. client->GetPlayer()->SetFollowTarget(0);
  4574. client->GetPlayer()->info_changed = true;
  4575. client->GetPlayer()->changed = true;
  4576. }
  4577. }
  4578. #include "../Zone/SPGrid.h"
  4579. /*
  4580. Function: Command_Grid()
  4581. Purpose : Show player's current Grid ID
  4582. Params :
  4583. Dev : Scatman
  4584. Example : /grid
  4585. */
  4586. void Commands::Command_Grid(Client* client)
  4587. {
  4588. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4589. if (client->GetCurrentZone()->Grid != nullptr) {
  4590. int32 grid = client->GetCurrentZone()->Grid->GetGridID(client->GetPlayer());
  4591. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4592. }
  4593. }
  4594. /*
  4595. Function: Command_Guild()
  4596. Purpose : Handler for all UI-related guild commands
  4597. Dev : Scatman
  4598. */
  4599. void Commands::Command_Guild(Client* client, Seperator* sep)
  4600. {
  4601. Guild* guild = client->GetPlayer()->GetGuild();
  4602. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  4603. {
  4604. const char* command = sep->arg[0];
  4605. int32 length = strlen(command);
  4606. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4607. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4608. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4609. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4610. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4611. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4612. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4613. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4614. guild->KickGuildMember(client, sep->arg[1]);
  4615. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4616. guild->DemoteGuildMember(client, sep->arg[1]);
  4617. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4618. guild->PromoteGuildMember(client, sep->arg[1]);
  4619. else if (strncmp(command, "points", length) == 0 && guild)
  4620. {
  4621. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4622. {
  4623. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4624. {
  4625. float points = atof(sep->arg[2]);
  4626. const char* option = sep->arg[3];
  4627. const char* comment = sep->argplus[4];
  4628. if (strncmp(option, "all", strlen(option)) == 0)
  4629. guild->AddPointsToAll(client, points, comment);
  4630. else if (strncmp(option, "online", strlen(option)) == 0)
  4631. guild->AddPointsToAllOnline(client, points, comment);
  4632. else if (strncmp(option, "group", strlen(option)) == 0)
  4633. guild->AddPointsToGroup(client, points, comment);
  4634. else if (strncmp(option, "raid", strlen(option)) == 0)
  4635. guild->AddPointsToRaid(client, points, comment);
  4636. else
  4637. guild->AddPointsToGuildMember(client, points, option, comment);
  4638. }
  4639. }
  4640. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4641. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4642. else
  4643. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4644. }
  4645. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4646. guild->SetMOTD(sep->argplus[1]);
  4647. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4648. {
  4649. if (sep->arg[1])
  4650. {
  4651. const char* option = sep->arg[1];
  4652. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4653. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4654. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4655. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4656. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4657. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4658. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4659. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4660. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4661. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4662. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4663. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4664. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4665. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4666. else
  4667. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4668. }
  4669. else
  4670. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4671. }
  4672. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4673. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4674. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4675. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4676. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4677. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4678. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4679. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4680. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4681. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4682. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4683. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4684. else if (strncmp(command, "invite", length) == 0 && guild)
  4685. {
  4686. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4687. guild->InvitePlayer(client, sep->arg[1]);
  4688. else
  4689. {
  4690. Spawn* target = client->GetPlayer()->GetTarget();
  4691. if (target)
  4692. {
  4693. if (target->IsPlayer())
  4694. guild->InvitePlayer(client, target->GetName());
  4695. else
  4696. client->Message(CHANNEL_COLOR_WHITE, "%s is not a player.", target->GetName());
  4697. }
  4698. }
  4699. }
  4700. else if (strncmp(command, "accept", length) == 0)
  4701. {
  4702. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4703. if (pgi && pgi->guild && pgi->invited_by)
  4704. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4705. client->SetPendingGuildInvite(0);
  4706. }
  4707. else if (strncmp(command, "decline", length) == 0)
  4708. {
  4709. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4710. if (pgi && pgi->guild && pgi->invited_by)
  4711. {
  4712. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4713. if (client_inviter)
  4714. client_inviter->Message(CHANNEL_COLOR_WHITE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4715. }
  4716. client->SetPendingGuildInvite(0);
  4717. }
  4718. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4719. {
  4720. const char* guild_name = sep->argplus[1];
  4721. if (!guild_list.GetGuild(guild_name))
  4722. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  4723. else
  4724. client->SimpleMessage(CHANNEL_COLOR_WHITE, "A guild with that name already exists.");
  4725. }
  4726. else if (strncmp(command, "search", length) == 0)
  4727. client->ShowGuildSearchWindow();
  4728. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4729. {
  4730. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4731. if (to_guild)
  4732. to_guild->SendGuildRecruitingDetails(client);
  4733. }
  4734. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4735. {
  4736. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4737. if (to_guild)
  4738. to_guild->SendGuildRecruitingImages(client);
  4739. }
  4740. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4741. {
  4742. if (sep->arg[1])
  4743. {
  4744. const char* option = sep->arg[1];
  4745. if (strncmp(option, "toggle", strlen(option)) == 0)
  4746. guild->ToggleGuildRecruiterAdventureClass(client);
  4747. }
  4748. else
  4749. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4750. }
  4751. else if (strncmp(command, "display_heraldry", length) == 0)
  4752. {
  4753. // JA: not sure this is right...
  4754. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4755. client->GetPlayer()->SetCharSheetChanged(true);
  4756. }
  4757. else
  4758. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4759. }
  4760. }
  4761. /*
  4762. Function: Command_GuildCreate()
  4763. Purpose : Display's in-game Guild Creation window
  4764. Dev : Scatman
  4765. */
  4766. void Commands::Command_CreateGuild(Client* client)
  4767. {
  4768. client->SendGuildCreateWindow();
  4769. }
  4770. /*
  4771. Function: Command_SetGuildOfficerNote()
  4772. Purpose :
  4773. Dev : Scatman
  4774. */
  4775. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4776. {
  4777. if (sep && sep->arg[0] && sep->arg[1])
  4778. {
  4779. Guild* guild = client->GetPlayer()->GetGuild();
  4780. if (guild)
  4781. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4782. }
  4783. }
  4784. /*
  4785. Function: Command_SetGuildMemberNote()
  4786. Purpose :
  4787. Dev : Scatman
  4788. */
  4789. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4790. {
  4791. if (sep && sep->arg[0] && sep->arg[1])
  4792. {
  4793. Guild* guild = client->GetPlayer()->GetGuild();
  4794. if (guild)
  4795. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4796. }
  4797. }
  4798. /*
  4799. Function: Command_GuildSay()
  4800. Purpose :
  4801. Dev : Scatman
  4802. */
  4803. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4804. {
  4805. Guild* guild = client->GetPlayer()->GetGuild();
  4806. if (guild)
  4807. {
  4808. if (sep && sep->arg[0])
  4809. guild->HandleGuildSay(client, sep->argplus[0]);
  4810. }
  4811. else
  4812. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4813. }
  4814. /*
  4815. Function: Command_OfficerSay()
  4816. Purpose :
  4817. Dev : Scatman
  4818. */
  4819. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4820. {
  4821. Guild* guild = client->GetPlayer()->GetGuild();
  4822. if (guild)
  4823. {
  4824. if (sep && sep->arg[0])
  4825. guild->HandleOfficerSay(client, sep->argplus[0]);
  4826. }
  4827. else
  4828. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4829. }
  4830. /*
  4831. Function: Command_Guilds()
  4832. Purpose : Shows help for /guild command
  4833. Params :
  4834. Dev : Scatman
  4835. Example :
  4836. */
  4837. void Commands::Command_Guilds(Client* client)
  4838. {
  4839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4840. }
  4841. /*
  4842. Function: Command_GuildsAdd()
  4843. Purpose : Add's players to a guild
  4844. Params : guild_name|guild_id, player name
  4845. Dev : Scatman
  4846. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4847. */
  4848. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4849. {
  4850. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4851. {
  4852. Guild* guild = 0;
  4853. bool found = true;
  4854. if (sep->IsNumber(0))
  4855. {
  4856. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4857. if (!guild)
  4858. {
  4859. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4860. found = false;
  4861. }
  4862. }
  4863. else
  4864. {
  4865. guild = guild_list.GetGuild(sep->arg[0]);
  4866. if (!guild)
  4867. {
  4868. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4869. found = false;
  4870. }
  4871. }
  4872. if (found)
  4873. {
  4874. Client* to_client = 0;
  4875. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4876. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4877. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4878. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4879. if (to_client)
  4880. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  4881. else
  4882. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4883. }
  4884. }
  4885. else
  4886. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  4887. }
  4888. /*
  4889. Function: Command_GuildsCreate()
  4890. Purpose : Creates a guild
  4891. Params : guild_name, player_name (optional)
  4892. Dev : Scatman
  4893. Example : /guilds create [guild name] (player name)
  4894. */
  4895. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  4896. {
  4897. if (sep && sep->arg[0])
  4898. {
  4899. const char* guild_name = sep->arg[0];
  4900. if (!guild_list.GetGuild(guild_name))
  4901. {
  4902. bool ret = false;
  4903. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4904. {
  4905. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4906. if (to_client)
  4907. {
  4908. world.CreateGuild(guild_name, to_client);
  4909. ret = true;
  4910. }
  4911. else
  4912. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  4913. }
  4914. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4915. {
  4916. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4917. if (to_client)
  4918. {
  4919. world.CreateGuild(guild_name, to_client);
  4920. ret = true;
  4921. }
  4922. }
  4923. else
  4924. {
  4925. world.CreateGuild(guild_name);
  4926. ret = true;
  4927. }
  4928. if (ret)
  4929. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  4930. else
  4931. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  4932. }
  4933. else
  4934. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  4935. }
  4936. else
  4937. 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.");
  4938. }
  4939. /*
  4940. Function: Command_GuildsDelete()
  4941. Purpose : Delete's a guild
  4942. Params : guild name
  4943. Dev : Scatman
  4944. Example : /guilds delete Test
  4945. */
  4946. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  4947. {
  4948. if (sep && sep->arg[0])
  4949. {
  4950. Guild* guild = 0;
  4951. bool found = true;
  4952. if (sep->IsNumber(0))
  4953. {
  4954. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4955. if (!guild)
  4956. {
  4957. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4958. found = false;
  4959. }
  4960. }
  4961. else
  4962. {
  4963. guild = guild_list.GetGuild(sep->arg[0]);
  4964. if (!guild)
  4965. {
  4966. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4967. found = false;
  4968. }
  4969. }
  4970. if (found)
  4971. {
  4972. guild->RemoveAllGuildMembers();
  4973. database.DeleteGuild(guild);
  4974. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  4975. guild_list.RemoveGuild(guild, true);
  4976. }
  4977. }
  4978. else
  4979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  4980. }
  4981. /*
  4982. Function: Command_GuildsList()
  4983. Purpose : Lists current guilds on server
  4984. Params :
  4985. Dev : Scatman
  4986. Example : /guilds list
  4987. */
  4988. void Commands::Command_GuildsList(Client* client)
  4989. {
  4990. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  4991. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  4992. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  4993. if (guilds->size() == 0)
  4994. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  4995. else {
  4996. while (itr.Next()) {
  4997. Guild* guild = itr.second;
  4998. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  4999. }
  5000. }
  5001. }
  5002. /*
  5003. Function: Command_GuildsRemove()
  5004. Purpose : Removes a player from a guild
  5005. Params : guild name|guild id, player name
  5006. Dev : Scatman
  5007. Example : /guilds remove 1 Admin = removes Admin from guild 1
  5008. */
  5009. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  5010. {
  5011. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5012. {
  5013. Guild* guild = 0;
  5014. bool found = true;
  5015. if (sep->IsNumber(0))
  5016. {
  5017. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5018. if (!guild)
  5019. {
  5020. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5021. found = false;
  5022. }
  5023. }
  5024. else
  5025. {
  5026. guild = guild_list.GetGuild(sep->arg[0]);
  5027. if (!guild)
  5028. {
  5029. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5030. found = false;
  5031. }
  5032. }
  5033. if (found)
  5034. {
  5035. Client* to_client = 0;
  5036. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5037. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5038. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5039. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5040. if (to_client)
  5041. {
  5042. Player* to_player = to_client->GetPlayer();
  5043. if (to_player->GetGuild())
  5044. {
  5045. if (to_player->GetGuild() == guild)
  5046. {
  5047. guild->KickGuildMember(client, to_player->GetName());
  5048. }
  5049. else
  5050. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  5051. }
  5052. else
  5053. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  5054. }
  5055. else
  5056. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5057. }
  5058. }
  5059. else
  5060. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  5061. }
  5062. /*
  5063. Function: Command_InspectPlayer()
  5064. Purpose : Handle the Inspect functions
  5065. Params : Client to inspect
  5066. Dev : Scatman
  5067. Example : /inspect Scatman
  5068. */
  5069. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  5070. {
  5071. if (sep && sep->arg[0])
  5072. {
  5073. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  5074. if (inspect_client)
  5075. client->InspectPlayer(inspect_client->GetPlayer());
  5076. }
  5077. else
  5078. {
  5079. Spawn* target = client->GetPlayer()->GetTarget();
  5080. if (target && target->IsPlayer())
  5081. client->InspectPlayer((Player*)target);
  5082. }
  5083. }
  5084. /*
  5085. Function: Command_Inventory()
  5086. Purpose : Handle changes in player inventory
  5087. Params : <TBD>
  5088. Dev : All
  5089. Example : /inventory delete item_id
  5090. */
  5091. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  5092. {
  5093. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  5094. Player* player = client->GetPlayer();
  5095. if(sep && sep->arg[0][0])
  5096. {
  5097. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  5098. if(client->GetPlayer()->GetHP() == 0)
  5099. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  5100. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5101. {
  5102. int16 index = atoi(sep->arg[1]);
  5103. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5104. if(item)
  5105. {
  5106. if(item->GetItemScript() && lua_interface)
  5107. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  5108. int32 bag_id = item->details.inv_slot_id;
  5109. database.DeleteItem(client->GetCharacterID(), item, 0);
  5110. client->GetPlayer()->item_list.DestroyItem(index);
  5111. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  5112. client->QueuePacket(outapp);
  5113. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  5114. if (outapp)
  5115. client->QueuePacket(outapp);
  5116. }
  5117. }
  5118. 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))
  5119. {
  5120. int16 from_index = atoi(sep->arg[1]);
  5121. sint16 to_slot = atoi(sep->arg[2]);
  5122. sint32 bag_id = atol(sep->arg[3]);
  5123. int8 charges = atoi(sep->arg[4]);
  5124. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  5125. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  5126. {
  5127. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  5128. return;
  5129. }
  5130. sint32 old_inventory_id = 0;
  5131. if(item)
  5132. old_inventory_id = item->details.inv_slot_id;
  5133. //autobank
  5134. if (bag_id == -3 && to_slot == -1)
  5135. {
  5136. if (player->HasFreeBankSlot())
  5137. to_slot = player->FindFreeBankSlot();
  5138. else
  5139. {
  5140. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  5141. return;
  5142. }
  5143. }
  5144. //auto inventory
  5145. if (bag_id == 0 && to_slot == -1)
  5146. {
  5147. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5148. {
  5149. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  5150. return;
  5151. }
  5152. }
  5153. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  5154. client->QueuePacket(outapp);
  5155. //removed from bag send update
  5156. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  5157. {
  5158. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  5159. if(outapp)
  5160. client->QueuePacket(outapp);
  5161. }
  5162. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  5163. {
  5164. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  5165. if(outapp)
  5166. client->QueuePacket(outapp);
  5167. }
  5168. }
  5169. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  5170. {
  5171. if(client->GetPlayer()->EngagedInCombat())
  5172. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  5173. else
  5174. {
  5175. int16 index = atoi(sep->arg[1]);
  5176. int8 slot_id = 255;
  5177. if(sep->arg[2][0] && sep->IsNumber(2))
  5178. slot_id = atoi(sep->arg[2]);
  5179. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  5180. EQ2Packet* outapp = 0;
  5181. for(int32 i=0;i<packets.size();i++)
  5182. {
  5183. outapp = packets[i];
  5184. if(outapp)
  5185. client->QueuePacket(outapp);
  5186. }
  5187. client->GetPlayer()->ChangePrimaryWeapon();
  5188. client->GetPlayer()->ChangeSecondaryWeapon();
  5189. client->GetPlayer()->ChangeRangedWeapon();
  5190. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5191. client->QueuePacket(characterSheetPackets);
  5192. }
  5193. }
  5194. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5195. {
  5196. if (client->GetPlayer()->EngagedInCombat())
  5197. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5198. else {
  5199. int16 index = atoi(sep->arg[1]);
  5200. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5201. if (item) {
  5202. // client->GetPlayer()->item_list.DestroyItem(index);
  5203. if (item->item_sets.size() > 0) {
  5204. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5205. ItemSet* set = item->item_sets[i];
  5206. if (set->item_stack_size == 0)
  5207. set->item_stack_size += 1;
  5208. client->AddItem(set->item_id, set->item_stack_size);
  5209. }
  5210. }
  5211. }
  5212. client->RemoveItem(item, 1);
  5213. }
  5214. }
  5215. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5216. {
  5217. if(client->GetPlayer()->EngagedInCombat())
  5218. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5219. else
  5220. {
  5221. int16 index = atoi(sep->arg[1]);
  5222. sint32 bag_id = -999;
  5223. int8 to_slot = 255;
  5224. if(sep->arg[3][0])
  5225. {
  5226. if(sep->IsNumber(2))
  5227. bag_id = atol(sep->arg[2]);
  5228. if(sep->IsNumber(3))
  5229. to_slot = atoi(sep->arg[3]);
  5230. }
  5231. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  5232. EQ2Packet* outapp = 0;
  5233. for(int32 i=0;i<packets.size();i++)
  5234. {
  5235. outapp = packets[i];
  5236. if(outapp)
  5237. client->QueuePacket(outapp);
  5238. }
  5239. client->GetPlayer()->ChangePrimaryWeapon();
  5240. client->GetPlayer()->ChangeSecondaryWeapon();
  5241. client->GetPlayer()->ChangeRangedWeapon();
  5242. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5243. client->QueuePacket(characterSheetPackets);
  5244. }
  5245. }
  5246. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5247. {
  5248. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5249. int16 index1 = atoi(sep->arg[1]);
  5250. int16 index2 = atoi(sep->arg[2]);
  5251. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  5252. if(outapp)
  5253. client->QueuePacket(outapp);
  5254. else
  5255. {
  5256. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5257. return;
  5258. }
  5259. }
  5260. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5261. {
  5262. sint16 to_slot = atoi(sep->arg[1]);
  5263. sint32 bag_id = atoi(sep->arg[2]);
  5264. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5265. if (item) {
  5266. //auto inventory
  5267. if (bag_id == 0 && to_slot == -1)
  5268. {
  5269. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5270. {
  5271. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5272. return;
  5273. }
  5274. // Set the slot for the item
  5275. item->details.inv_slot_id = bag_id;
  5276. item->details.slot_id = to_slot;
  5277. // Flag the item so it gets saved in its new location
  5278. item->save_needed = true;
  5279. // Add the item to its new location
  5280. player->item_list.AddItem(item);
  5281. // Remove the item from the overflow list
  5282. player->item_list.RemoveOverflowItem(item);
  5283. // Send the inventory update packet
  5284. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5285. return;
  5286. }
  5287. else if (bag_id == -3 && to_slot == -1) {
  5288. // Auto Bank
  5289. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5290. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5291. return;
  5292. }
  5293. item->details.inv_slot_id = bag_id;
  5294. item->details.slot_id = to_slot;
  5295. item->save_needed = true;
  5296. player->item_list.AddItem(item);
  5297. player->item_list.RemoveOverflowItem(item);
  5298. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5299. }
  5300. else if (bag_id == -4) {
  5301. // Shared Bank
  5302. if (!player->item_list.SharedBankAddAllowed(item)) {
  5303. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5304. return;
  5305. }
  5306. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5307. if (tmp_item) {
  5308. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5309. return;
  5310. }
  5311. else {
  5312. item->details.inv_slot_id = bag_id;
  5313. item->details.slot_id = to_slot;
  5314. item->save_needed = true;
  5315. player->item_list.AddItem(item);
  5316. player->item_list.RemoveOverflowItem(item);
  5317. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5318. return;
  5319. }
  5320. }
  5321. else {
  5322. // Try to get an item from the given bag id and slot id
  5323. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5324. // Check to see if we got an item, if we do send an error,
  5325. // if we don't put the overflow item into this slot
  5326. if (tmp_item) {
  5327. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5328. }
  5329. else {
  5330. item->details.inv_slot_id = bag_id;
  5331. item->details.slot_id = to_slot;
  5332. item->save_needed = true;
  5333. player->item_list.AddItem(item);
  5334. player->item_list.RemoveOverflowItem(item);
  5335. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5336. return;
  5337. }
  5338. }
  5339. }
  5340. }
  5341. }
  5342. else
  5343. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5344. }
  5345. /*
  5346. Function: Command_IRC()
  5347. Purpose : Handle the IRC functions
  5348. Params : IRC Commands
  5349. Dev : Scatman
  5350. Example : /irc say #Channel Hello World!
  5351. */
  5352. void Commands::Command_IRC(Client* client, Seperator* sep)
  5353. {
  5354. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5355. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5356. return;
  5357. }
  5358. if (sep && sep->arg[0][0]) {
  5359. if (strcasecmp(sep->arg[0], "say") == 0) {
  5360. if (sep->arg[1][0] && sep->arg[2][0]) {
  5361. if (sep->IsNumber(sep->arg[1]))
  5362. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5363. else
  5364. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5365. }
  5366. else
  5367. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5368. }
  5369. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5370. if (sep->arg[1][0])
  5371. irc.JoinChannel(client, sep->arg[1]);
  5372. else
  5373. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5374. }
  5375. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5376. if (sep->arg[1][0])
  5377. irc.LeaveChannel(client, sep->arg[1]);
  5378. else
  5379. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5380. }
  5381. else if (strcasecmp(sep->arg[0], "list") == 0)
  5382. irc.ListChannels(client);
  5383. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5384. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5385. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5386. else
  5387. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5388. }
  5389. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5390. irc.DisconnectFromServer(client);
  5391. else
  5392. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5393. }
  5394. else
  5395. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5396. }
  5397. /*
  5398. Function: Command_Languages()
  5399. Purpose : Show's languages the player knows
  5400. Params :
  5401. Dev : Zcoretri
  5402. Example :
  5403. */
  5404. void Commands::Command_Languages(Client* client, Seperator* sep)
  5405. {
  5406. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5407. list<Language*>::iterator itr;
  5408. Language* language;
  5409. client->Message(CHANNEL_COLOR_WHITE, "You know the following languages:");
  5410. for(itr = languages->begin(); itr != languages->end(); itr++)
  5411. {
  5412. language = *itr;
  5413. client->Message(CHANNEL_COLOR_WHITE, "%s", language->GetName());
  5414. }
  5415. }
  5416. /*
  5417. Function: Command_SetLanguage()
  5418. Purpose : Handles language commands
  5419. Params : Language ID
  5420. Dev : Zcoretri
  5421. Example :
  5422. */
  5423. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5424. {
  5425. Player* player = client->GetPlayer();
  5426. if (sep && sep->arg[0])
  5427. {
  5428. if(!sep->IsNumber(0))
  5429. {
  5430. //String passed in
  5431. const char* value = sep->arg[0];
  5432. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5433. {
  5434. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5435. client->SendLanguagesUpdate(0);
  5436. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", value);
  5437. }
  5438. else
  5439. {
  5440. if(player->HasLanguage(value))
  5441. {
  5442. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5443. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5444. client->SendLanguagesUpdate(language->GetID());
  5445. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5446. }
  5447. else
  5448. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", value);
  5449. }
  5450. }
  5451. else
  5452. {
  5453. //Number passed in
  5454. int32 id = atoul(sep->arg[0]);
  5455. if(player->HasLanguage(id))
  5456. {
  5457. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5458. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5459. client->SendLanguagesUpdate(id);
  5460. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5461. }
  5462. else
  5463. {
  5464. Language* language = master_languages_list.GetLanguage(id);
  5465. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", language->GetName());
  5466. }
  5467. }
  5468. }
  5469. else
  5470. {
  5471. //No value was passed in
  5472. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5473. if(id > 0)
  5474. {
  5475. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5476. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking %s ", language->GetName());
  5477. }
  5478. else
  5479. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking Common");
  5480. }
  5481. }
  5482. /*
  5483. Function: Command_LastName()
  5484. Purpose : Sets player surname
  5485. Params : Name text
  5486. Dev : theFoof
  5487. Example :
  5488. */
  5489. void Commands::Command_LastName(Client* client, Seperator* sep)
  5490. {
  5491. if (!client)
  5492. return;
  5493. if (sep && sep->arg[0])
  5494. {
  5495. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5496. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5497. return;
  5498. }
  5499. client->RemovePendingLastName();
  5500. uchar* checkname = (uchar*)sep->arg[0];
  5501. bool valid_name = true;
  5502. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5503. if (!alpha_check(checkname[i])) {
  5504. valid_name = false;
  5505. break;
  5506. }
  5507. }
  5508. if (!valid_name) {
  5509. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5510. return;
  5511. }
  5512. string last_name = (string)sep->arg[0];
  5513. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5514. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5515. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5516. client->SetPendingLastName(last_name);
  5517. client->SendLastNameConfirmation();
  5518. }
  5519. else
  5520. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5521. }
  5522. }
  5523. /*
  5524. Function: Command_ConfirmLastName()
  5525. Purpose : Confirms setting of player surname
  5526. Params : Name text
  5527. Dev : theFoof
  5528. Example :
  5529. */
  5530. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5531. {
  5532. if (!client)
  5533. return;
  5534. string* name = client->GetPendingLastName();
  5535. if (name){
  5536. Player* player = client->GetPlayer();
  5537. player->SetLastName(name->c_str(), false);
  5538. client->SendTitleUpdate();
  5539. player->SetCharSheetChanged(true);
  5540. client->RemovePendingLastName();
  5541. }
  5542. }
  5543. /*
  5544. Function: Command_Location()
  5545. Purpose : Display's Help for /location commands
  5546. Params :
  5547. Dev : Scatman
  5548. Example : /location = show's help for command
  5549. */
  5550. void Commands::Command_Location(Client* client)
  5551. {
  5552. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5553. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5554. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5555. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5556. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5557. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5558. }
  5559. /*
  5560. Function: Command_LocationAdd()
  5561. Purpose : Add's a location to an existing location config
  5562. Params : location_id
  5563. Dev : Scatman
  5564. Example : /location add {location_id}
  5565. */
  5566. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5567. {
  5568. if (sep && sep->arg[0] && sep->IsNumber(0))
  5569. {
  5570. int32 location_id = atoul(sep->arg[0]);
  5571. float x = client->GetPlayer()->GetX();
  5572. float y = client->GetPlayer()->GetY();
  5573. float z = client->GetPlayer()->GetZ();
  5574. if (database.AddLocationPoint(location_id, x, y, z))
  5575. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5576. else
  5577. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5578. }
  5579. else
  5580. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5581. }
  5582. /*
  5583. Function: Command_LocationCreate()
  5584. Purpose : Creates a new location config
  5585. Params : location name, 0/1 for include_y (optional)
  5586. Dev : Scatman
  5587. Example : /location create Test 1 = creates a new location named Test with include_y True
  5588. */
  5589. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5590. {
  5591. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5592. {
  5593. const char* name = sep->arg[0];
  5594. bool include_y = false;
  5595. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5596. include_y = true;
  5597. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5598. if (location_id > 0)
  5599. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5600. else
  5601. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5602. }
  5603. else
  5604. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5605. }
  5606. /*
  5607. Function: Command_LocationDelete()
  5608. Purpose : Delete's a location config and all it's location points
  5609. Params : location_id
  5610. Dev : Scatman
  5611. Example : /location delete {location_id}
  5612. */
  5613. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5614. {
  5615. if (sep && sep->arg[0] && sep->IsNumber(0))
  5616. {
  5617. int32 location_id = atoul(sep->arg[0]);
  5618. if (database.DeleteLocation(location_id))
  5619. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5620. else
  5621. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5622. }
  5623. else
  5624. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5625. }
  5626. /*
  5627. Function: Command_LocationList()
  5628. Purpose : Display's a list of location points
  5629. Params : location_id
  5630. Dev : Scatman
  5631. Example : /location list {location_id}
  5632. */
  5633. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5634. {
  5635. if (sep && sep->arg[0])
  5636. {
  5637. const char* option = sep->arg[0];
  5638. if (strncmp(option, "locations", strlen(option)) == 0)
  5639. database.ListLocations(client);
  5640. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5641. {
  5642. int32 location_id = atoul(sep->arg[1]);
  5643. database.ListLocationPoints(client, location_id);
  5644. }
  5645. else
  5646. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5647. }
  5648. else
  5649. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5650. }
  5651. /*
  5652. Function: Command_LocationRemove()
  5653. Purpose : Removes a single location point from a location config
  5654. Params : location_point_id (gotten from /location list {id})
  5655. Dev : Scatman
  5656. Example : /location remove 1 = will remove location_point_id 1
  5657. */
  5658. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5659. {
  5660. if (sep && sep->arg[0] && sep->IsNumber(0))
  5661. {
  5662. int32 location_point_id = atoul(sep->arg[0]);
  5663. if (database.DeleteLocationPoint(location_point_id))
  5664. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5665. else
  5666. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5667. }
  5668. else
  5669. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5670. }
  5671. /*
  5672. Function: Command_Merchant()
  5673. Purpose : Handles Merchant commands
  5674. Params : list
  5675. Dev : Scatman
  5676. Example : /merchant list
  5677. */
  5678. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5679. {
  5680. if( handler == COMMAND_MERCHANT )
  5681. {
  5682. // /merchant command by itself shows help (to be extended)
  5683. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5684. return;
  5685. }
  5686. else if( handler == COMMAND_MERCHANT_LIST )
  5687. {
  5688. // /merchant list command expects "description" param
  5689. if (sep && sep->arg[0])
  5690. {
  5691. const char* merchant_description = sep->argplus[0];
  5692. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5693. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5694. map<int32, MerchantInfo*>::iterator itr;
  5695. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5696. {
  5697. string description = database.GetMerchantDescription(itr->first);
  5698. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5699. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5700. }
  5701. }
  5702. else // no description
  5703. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5704. }
  5705. }
  5706. /*
  5707. Function: Command_Modify()
  5708. Purpose : to replace our other "set" commands
  5709. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5710. Dev : John Adams
  5711. Example : /modify spell set name "Aegolism III"
  5712. */
  5713. void Commands::Command_Modify(Client* client)
  5714. {
  5715. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5716. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5717. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5718. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5719. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5720. }
  5721. /*
  5722. Function: Command_ModifySpawn()
  5723. Purpose : replace "spawn set" commands
  5724. Params : Action : the action to perform (or special handler)
  5725. : Field : the DB field to change
  5726. : Value : what to set the value to
  5727. : Target : what object to change (my target, or spawn_id)
  5728. Dev : John Adams
  5729. Example : /modify spawn set name "Lady Vox"
  5730. :
  5731. Note : Special Handlers, like "zoneto" for Signs
  5732. : /modify spawn zoneto
  5733. : Will set a sign's zone x/y/z to my current coords
  5734. */
  5735. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5736. {
  5737. PrintSep(sep, "COMMAND_MODIFY");
  5738. // need at least 2 args for a valid command
  5739. if( sep && sep->arg[1] )
  5740. {
  5741. // JA: just a quick implementation because I need it :)
  5742. if (strcmp(sep->arg[0], "zoneto") == 0)
  5743. {
  5744. if( sep->IsNumber(1) )
  5745. {
  5746. int32 spawn_id = atoul(sep->arg[1]);
  5747. float x_coord = client->GetPlayer()->GetX();
  5748. float y_coord = client->GetPlayer()->GetY();
  5749. float z_coord = client->GetPlayer()->GetZ();
  5750. float h_coord = client->GetPlayer()->GetHeading();
  5751. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5752. }
  5753. else
  5754. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5755. }
  5756. }
  5757. else
  5758. Command_Modify(client);
  5759. }
  5760. /*
  5761. Function: Command_ModifyCharacter()
  5762. Purpose : to replace our other "set" commands
  5763. Params : Action : Add, Remove
  5764. : Field : copper, silver, gold, plat
  5765. : Value : min 1, max unlimited
  5766. : Target : Self, Player
  5767. Dev : Cynnar
  5768. Example : /modify character add gold 50
  5769. : /modify character remove silver 25
  5770. */
  5771. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5772. {
  5773. PrintSep(sep, "COMMAND_MODIFY");
  5774. int64 value = 0;
  5775. Player* player = client->GetPlayer();
  5776. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5777. player = (Player*)player->GetTarget();
  5778. // need at least 2 args for a valid command
  5779. if( sep && sep->arg[1] )
  5780. {
  5781. if (strcmp(sep->arg[0], "add") == 0)
  5782. {
  5783. if (strcmp(sep->arg[1], "copper") == 0)
  5784. {
  5785. value = atoi64(sep->arg[2]);
  5786. player->AddCoins(value);
  5787. if (client->GetPlayer() == player)
  5788. {
  5789. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5790. }
  5791. else {
  5792. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5793. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5794. }
  5795. }
  5796. else if (strcmp(sep->arg[1], "silver") == 0)
  5797. {
  5798. value = atoi64(sep->arg[2]) * 100;
  5799. player->AddCoins(value);
  5800. if (client->GetPlayer() == player)
  5801. {
  5802. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5803. }
  5804. else {
  5805. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5806. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5807. }
  5808. }
  5809. else if (strcmp(sep->arg[1], "gold") == 0)
  5810. {
  5811. value = atoi64(sep->arg[2]) * 10000;
  5812. player->AddCoins(value);
  5813. if (client->GetPlayer() == player)
  5814. {
  5815. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5816. }
  5817. else {
  5818. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5819. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5820. }
  5821. }
  5822. else if (strcmp(sep->arg[1], "plat") == 0)
  5823. {
  5824. value = atoi64(sep->arg[2]) * 1000000;
  5825. player->AddCoins(value);
  5826. if (client->GetPlayer() == player)
  5827. {
  5828. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5829. }
  5830. else {
  5831. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5832. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5833. }
  5834. }
  5835. else
  5836. {
  5837. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5838. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5839. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5840. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5841. }
  5842. }
  5843. else if (strcmp(sep->arg[0], "remove") == 0)
  5844. {
  5845. if (strcmp(sep->arg[1], "copper") == 0)
  5846. {
  5847. value = atoi64(sep->arg[2]);
  5848. player->RemoveCoins(value);
  5849. if (client->GetPlayer() == player)
  5850. {
  5851. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5852. }
  5853. else {
  5854. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5855. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5856. }
  5857. }
  5858. else if (strcmp(sep->arg[1], "silver") == 0)
  5859. {
  5860. value = atoi64(sep->arg[2]) * 100;
  5861. player->RemoveCoins(value);
  5862. if (client->GetPlayer() == player)
  5863. {
  5864. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5865. }
  5866. else {
  5867. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5868. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5869. }
  5870. }
  5871. else if (strcmp(sep->arg[1], "gold") == 0)
  5872. {
  5873. value = atoi64(sep->arg[2]) * 10000;
  5874. player->RemoveCoins(value);
  5875. if (client->GetPlayer() == player)
  5876. {
  5877. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  5878. }
  5879. else {
  5880. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  5881. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5882. }
  5883. }
  5884. else if (strcmp(sep->arg[1], "plat") == 0)
  5885. {
  5886. value = atoi64(sep->arg[2]) * 1000000;
  5887. player->RemoveCoins(value);
  5888. if (client->GetPlayer() == player)
  5889. {
  5890. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  5891. }
  5892. else {
  5893. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  5894. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5895. }
  5896. }
  5897. else
  5898. {
  5899. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5900. }
  5901. }
  5902. else if (strcmp(sep->arg[0], "set") == 0) {
  5903. if (strcmp(sep->arg[1], "tslevel") == 0) {
  5904. int8 level = atoi(sep->arg[2]);
  5905. if (level > 0 && level < 256) {
  5906. if (player) {
  5907. if (client->GetPlayer() == player)
  5908. client->ChangeTSLevel(player->GetTSLevel(), level);
  5909. else
  5910. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  5911. }
  5912. }
  5913. else
  5914. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  5915. }
  5916. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  5917. int8 tsclass = atoi(sep->arg[2]);
  5918. player->SetTradeskillClass(tsclass);
  5919. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  5920. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  5921. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  5922. player->SetCharSheetChanged(true);
  5923. }
  5924. }
  5925. }
  5926. else
  5927. {
  5928. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5929. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5930. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5931. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5932. }
  5933. }
  5934. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  5935. {
  5936. PrintSep(sep, "COMMAND_MODIFY");
  5937. // need at least 2 args for a valid command
  5938. if( sep && sep->arg[1] )
  5939. {
  5940. }
  5941. else
  5942. Command_Modify(client);
  5943. }
  5944. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  5945. {
  5946. PrintSep(sep, "COMMAND_MODIFY");
  5947. // need at least 2 args for a valid command
  5948. if( sep && sep->arg[1] )
  5949. {
  5950. }
  5951. else
  5952. Command_Modify(client);
  5953. }
  5954. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  5955. {
  5956. PrintSep(sep, "COMMAND_MODIFY");
  5957. // need at least 2 args for a valid command
  5958. if( sep && sep->arg[1] )
  5959. {
  5960. }
  5961. else
  5962. Command_Modify(client);
  5963. }
  5964. /*
  5965. Function: Command_ModifyQuest()
  5966. Purpose : to list players quest and completed quests
  5967. Params : Action : list, completed
  5968. : Target : Self, Player
  5969. Dev : Cynnar
  5970. Example : /modify quest list
  5971. : /modify quest completed
  5972. */
  5973. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  5974. {
  5975. PrintSep(sep, "COMMAND_MODIFY");
  5976. int64 value = 0;
  5977. Player* player = client->GetPlayer();
  5978. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5979. player = (Player*)player->GetTarget();
  5980. // need at least 2 args for a valid command
  5981. if (sep && sep->arg[1])
  5982. {
  5983. if (strcmp(sep->arg[0], "list") == 0)
  5984. {
  5985. map<int32, Quest*>* quests = player->GetPlayerQuests();
  5986. map<int32, Quest*>::iterator itr;
  5987. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  5988. if (quests->size() == 0)
  5989. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  5990. else
  5991. {
  5992. for (itr = quests->begin(); itr != quests->end(); itr++)
  5993. {
  5994. Quest* quest = itr->second;
  5995. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5996. }
  5997. }
  5998. }
  5999. else if (strcmp(sep->arg[0], "completed") == 0)
  6000. {
  6001. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  6002. map<int32, Quest*>::iterator itr;
  6003. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  6004. if (quests->size() == 0)
  6005. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  6006. else
  6007. {
  6008. for (itr = quests->begin(); itr != quests->end(); itr++)
  6009. {
  6010. Quest* quest = itr->second;
  6011. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6012. }
  6013. }
  6014. }
  6015. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  6016. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  6017. else if (strcmp(sep->arg[0], "remove") == 0)
  6018. {
  6019. int32 quest_id = 0;
  6020. if (sep && sep->arg[1] && sep->IsNumber(1))
  6021. quest_id = atoul(sep->arg[1]);
  6022. if (quest_id > 0)
  6023. {
  6024. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  6025. {
  6026. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6027. if (quest)
  6028. if (client->GetPlayer() == player)
  6029. {
  6030. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  6031. }
  6032. else
  6033. {
  6034. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  6035. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  6036. }
  6037. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  6038. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  6039. }
  6040. client->RemovePlayerQuest(quest_id);
  6041. client->GetCurrentZone()->SendQuestUpdates(client);
  6042. }
  6043. }
  6044. else if (strcmp(sep->arg[0], "advance") == 0)
  6045. {
  6046. int32 quest_id = 0;
  6047. int32 step = 0;
  6048. if (sep && sep->arg[1] && sep->IsNumber(1))
  6049. {
  6050. quest_id = atoul(sep->arg[1]);
  6051. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6052. if (sep && sep->arg[2] && sep->IsNumber(1))
  6053. {
  6054. step = atoul(sep->arg[2]);
  6055. if (quest_id > 0 && step > 0)
  6056. {
  6057. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  6058. {
  6059. if (client)
  6060. {
  6061. client->AddPendingQuestUpdate(quest_id, step);
  6062. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  6063. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  6064. }
  6065. }
  6066. }
  6067. else
  6068. {
  6069. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  6070. }
  6071. }
  6072. else
  6073. {
  6074. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  6075. }
  6076. }
  6077. else
  6078. {
  6079. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  6080. }
  6081. }
  6082. else
  6083. {
  6084. Command_Modify(client);
  6085. }
  6086. }
  6087. else
  6088. {
  6089. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  6090. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  6091. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  6092. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  6093. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  6094. }
  6095. }
  6096. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  6097. {
  6098. PrintSep(sep, "COMMAND_MODIFY");
  6099. // need at least 2 args for a valid command
  6100. if( sep && sep->arg[1] )
  6101. {
  6102. if (strcmp(sep->arg[0], "add") == 0) {
  6103. const char* skill_name = sep->argplus[1];
  6104. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6105. if (skill) {
  6106. Player* player = 0;
  6107. Client* to_client = 0;
  6108. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6109. player = (Player*)client->GetPlayer()->GetTarget();
  6110. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6111. }
  6112. else {
  6113. player = client->GetPlayer();
  6114. to_client = client;
  6115. }
  6116. if (player)
  6117. {
  6118. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6119. {
  6120. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6121. if (to_client == client) {
  6122. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  6123. }
  6124. else {
  6125. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6126. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6127. }
  6128. }
  6129. else
  6130. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  6131. }
  6132. }
  6133. else
  6134. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6135. }
  6136. else if (strcmp(sep->arg[0], "remove") == 0) {
  6137. const char* skill_name = sep->argplus[1];
  6138. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6139. if (skill) {
  6140. Player* player = 0;
  6141. Client* to_client = 0;
  6142. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6143. player = (Player*)client->GetPlayer()->GetTarget();
  6144. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6145. }
  6146. else {
  6147. player = client->GetPlayer();
  6148. to_client = client;
  6149. }
  6150. if (player)
  6151. {
  6152. if (player->GetSkills()->HasSkill(skill->skill_id))
  6153. {
  6154. player->RemoveSkillFromDB(skill, true);
  6155. if (client == to_client) {
  6156. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  6157. }
  6158. else {
  6159. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6160. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6161. }
  6162. }
  6163. else {
  6164. if (client == to_client)
  6165. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  6166. else
  6167. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6168. }
  6169. }
  6170. }
  6171. else
  6172. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6173. }
  6174. else if (strcmp(sep->arg[0], "set") == 0) {
  6175. if (!sep->IsNumber(2)) {
  6176. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  6177. return;
  6178. }
  6179. const char* skill_name = sep->arg[1];
  6180. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6181. if (skill) {
  6182. int16 val = atoi(sep->arg[2]);
  6183. Player* player = 0;
  6184. Client* to_client = 0;
  6185. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6186. player = (Player*)client->GetPlayer()->GetTarget();
  6187. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6188. }
  6189. else {
  6190. player = client->GetPlayer();
  6191. to_client = client;
  6192. }
  6193. if (player)
  6194. {
  6195. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6196. player->GetSkills()->SetSkill(skill->skill_id, val);
  6197. if (client != to_client)
  6198. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6199. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6200. }
  6201. else {
  6202. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6203. }
  6204. }
  6205. }
  6206. else {
  6207. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6208. }
  6209. }
  6210. else {
  6211. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6212. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6213. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6214. }
  6215. }
  6216. else {
  6217. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6218. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6219. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6220. }
  6221. }
  6222. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6223. {
  6224. PrintSep(sep, "COMMAND_MODIFY");
  6225. // need at least 2 args for a valid command
  6226. if( sep && sep->arg[1] )
  6227. {
  6228. }
  6229. else
  6230. Command_Modify(client);
  6231. }
  6232. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6233. {
  6234. PrintSep(sep, "COMMAND_MODIFY");
  6235. // need at least 2 args for a valid command
  6236. if( sep && sep->arg[1] )
  6237. {
  6238. }
  6239. else
  6240. Command_Modify(client);
  6241. }
  6242. /*
  6243. Function: Command_MOTD()
  6244. Purpose : Displays server MOTD
  6245. Params :
  6246. Dev : LethalEncounter
  6247. Example : /motd
  6248. */
  6249. void Commands::Command_MOTD(Client* client)
  6250. {
  6251. if (client)
  6252. ClientPacketFunctions::SendMOTD(client);
  6253. }
  6254. /*
  6255. Function: Command_Pet()
  6256. Purpose : Handle Pet {Command} commands
  6257. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6258. Dev :
  6259. Example : /pet preserve_master
  6260. */
  6261. void Commands::Command_Pet(Client* client, Seperator* sep)
  6262. {
  6263. PrintSep(sep, "COMMAND_PET");
  6264. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6265. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6266. if (strcmp(sep->arg[0], "hide") == 0) {
  6267. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6268. Entity* pet = client->GetPlayer()->GetDeityPet();
  6269. if (pet) {
  6270. if (pet->IsPrivateSpawn())
  6271. client->GetPlayer()->HideDeityPet(false);
  6272. else
  6273. client->GetPlayer()->HideDeityPet(true);
  6274. }
  6275. pet = client->GetPlayer()->GetCosmeticPet();
  6276. if (pet) {
  6277. if (pet->IsPrivateSpawn())
  6278. client->GetPlayer()->HideCosmeticPet(false);
  6279. else
  6280. client->GetPlayer()->HideCosmeticPet(true);
  6281. }
  6282. return;
  6283. }
  6284. // below is for all combat pets
  6285. if (!client->GetPlayer()->HasPet()) {
  6286. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6287. return;
  6288. }
  6289. if (strcmp(sep->arg[0], "stay") == 0) {
  6290. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6291. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  6292. client->GetPlayer()->SetCharSheetChanged(true);
  6293. if (client->GetPlayer()->GetPet())
  6294. client->GetPlayer()->GetPet()->following = false;
  6295. if (client->GetPlayer()->GetCharmedPet())
  6296. client->GetPlayer()->GetCharmedPet()->following = false;
  6297. }
  6298. else if (strcmp(sep->arg[0], "follow") == 0) {
  6299. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6300. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  6301. client->GetPlayer()->SetCharSheetChanged(true);
  6302. }
  6303. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6304. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  6305. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6306. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  6307. }
  6308. else {
  6309. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6310. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  6311. }
  6312. client->GetPlayer()->SetCharSheetChanged(true);
  6313. }
  6314. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6315. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  6316. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6317. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  6318. }
  6319. else {
  6320. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6321. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  6322. }
  6323. client->GetPlayer()->SetCharSheetChanged(true);
  6324. }
  6325. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6326. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6327. if (client->GetPlayer()->GetPet())
  6328. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6329. if (client->GetPlayer()->GetCharmedPet())
  6330. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6331. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  6332. client->GetPlayer()->SetCharSheetChanged(true);
  6333. }
  6334. else if (strcmp(sep->arg[0], "attack") == 0) {
  6335. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6336. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6337. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6338. if (client->GetPlayer()->GetPet())
  6339. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6340. if (client->GetPlayer()->GetCharmedPet())
  6341. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6342. }
  6343. else
  6344. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6345. }
  6346. else
  6347. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6348. }
  6349. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6350. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6351. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6352. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6353. }
  6354. else
  6355. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6356. }
  6357. /*
  6358. Function: Command_PetName()
  6359. Purpose : Pet your name (???)
  6360. Params :
  6361. Dev :
  6362. Example :
  6363. */
  6364. void Commands::Command_PetName(Client* client, Seperator* sep)
  6365. {
  6366. PrintSep(sep, "COMMAND_PETNAME");
  6367. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6368. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6369. }
  6370. /*
  6371. Function: Command_NamePet()
  6372. Purpose : Name your pet
  6373. Params :
  6374. Dev :
  6375. Example :
  6376. */
  6377. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6378. {
  6379. PrintSep(sep, "COMMAND_NAME_PET");
  6380. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6381. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6382. }
  6383. /*
  6384. Function: Command_Rename()
  6385. Purpose : Renames existing pet
  6386. Params :
  6387. Dev :
  6388. Example :
  6389. */
  6390. void Commands::Command_Rename(Client* client, Seperator* sep)
  6391. {
  6392. PrintSep(sep, "COMMAND_RENAME");
  6393. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6394. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6395. }
  6396. /*
  6397. Function: Command_ConfirmRename()
  6398. Purpose : Confirms renaming your pet
  6399. Params :
  6400. Dev :
  6401. Example :
  6402. */
  6403. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6404. {
  6405. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6406. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6407. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6408. }
  6409. /*
  6410. Function: Command_PetOptions()
  6411. Purpose : Sets various pet options
  6412. Params :
  6413. Dev :
  6414. Example :
  6415. */
  6416. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6417. {
  6418. PrintSep(sep, "COMMAND_PETOPTIONS");
  6419. Player* player = client->GetPlayer();
  6420. Spawn* target = player->GetTarget();
  6421. if (!target)
  6422. return;
  6423. if (target == player->GetPet())
  6424. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6425. else if (target == player->GetCharmedPet())
  6426. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6427. else if (target == player->GetCosmeticPet())
  6428. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6429. else if (target == player->GetDeityPet())
  6430. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6431. }
  6432. /*
  6433. Function: Command_Random()
  6434. Purpose : Handles /random dice roll in-game
  6435. Params : 1-100
  6436. Dev : Scatman
  6437. Example : /randon 1 100
  6438. */
  6439. void Commands::Command_Random(Client* client, Seperator* sep)
  6440. {
  6441. char message[256] = {0};
  6442. if (sep)
  6443. {
  6444. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6445. 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])));
  6446. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6447. 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])));
  6448. else
  6449. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6450. }
  6451. else
  6452. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6453. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6454. }
  6455. /*
  6456. Function: Command_Randomize()
  6457. Purpose : Sets randomize (appearance) values for NPCs
  6458. Params : Attrib Name
  6459. Dev : Scatman
  6460. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6461. */
  6462. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6463. {
  6464. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6465. if (target)
  6466. {
  6467. if (target->IsNPC())
  6468. {
  6469. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6470. {
  6471. const char* value = sep->arg[0];
  6472. if (strncasecmp(value, "show", strlen(value)) == 0)
  6473. {
  6474. client->DisplayRandomizeFeatures(target->GetRandomize());
  6475. }
  6476. else
  6477. {
  6478. if (sep->arg[1] && sep->IsNumber(1))
  6479. {
  6480. int8 option = atoi(sep->arg[1]);
  6481. if (option == 0 || option == 1)
  6482. {
  6483. int32 feature = 0;
  6484. char feature_text[32] = {0};
  6485. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6486. feature = RANDOMIZE_GENDER;
  6487. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6488. }
  6489. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6490. feature = RANDOMIZE_RACE;
  6491. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6492. }
  6493. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6494. feature = RANDOMIZE_MODEL_TYPE;
  6495. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6496. }
  6497. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6498. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6499. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6500. }
  6501. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6502. feature = RANDOMIZE_HAIR_TYPE;
  6503. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6504. }
  6505. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6506. feature = RANDOMIZE_WING_TYPE;
  6507. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6508. }
  6509. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6510. feature = RANDOMIZE_CHEEK_TYPE;
  6511. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6512. }
  6513. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6514. feature = RANDOMIZE_CHIN_TYPE;
  6515. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6516. }
  6517. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6518. feature = RANDOMIZE_EAR_TYPE;
  6519. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6520. }
  6521. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6522. feature = RANDOMIZE_EYE_BROW_TYPE;
  6523. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6524. }
  6525. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6526. feature = RANDOMIZE_EYE_TYPE;
  6527. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6528. }
  6529. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6530. feature = RANDOMIZE_LIP_TYPE;
  6531. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6532. }
  6533. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6534. feature = RANDOMIZE_NOSE_TYPE;
  6535. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6536. }
  6537. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6538. feature = RANDOMIZE_EYE_COLOR;
  6539. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6540. }
  6541. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6542. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6543. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6544. }
  6545. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6546. feature = RANDOMIZE_HAIR_COLOR1;
  6547. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6548. }
  6549. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6550. feature = RANDOMIZE_HAIR_COLOR2;
  6551. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6552. }
  6553. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6554. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6555. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6556. }
  6557. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6558. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6559. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6560. }
  6561. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6562. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6563. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6564. }
  6565. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6566. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6567. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6568. }
  6569. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6570. feature = RANDOMIZE_SKIN_COLOR;
  6571. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6572. }
  6573. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6574. feature = RANDOMIZE_WING_COLOR1;
  6575. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6576. }
  6577. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6578. feature = RANDOMIZE_WING_COLOR2;
  6579. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6580. }
  6581. else {
  6582. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6583. 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'.");
  6584. }
  6585. if (feature > 0) {
  6586. if (option == 1) {
  6587. if (target->GetRandomize() & feature)
  6588. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6589. else {
  6590. target->AddRandomize(feature);
  6591. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6592. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6593. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6594. }
  6595. }
  6596. else {
  6597. if (target->GetRandomize() & feature) {
  6598. target->AddRandomize(-feature);
  6599. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6600. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6601. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6602. }
  6603. else
  6604. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6605. }
  6606. }
  6607. }
  6608. else
  6609. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6610. }
  6611. else
  6612. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6613. }
  6614. }
  6615. else {
  6616. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6617. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6618. 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'.");
  6619. }
  6620. }
  6621. else
  6622. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6623. }
  6624. else
  6625. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6626. }
  6627. /*
  6628. Function: Command_ShowCloak()
  6629. Purpose : Character Settings combo box for Show Cloak
  6630. Params : true/false
  6631. Dev : John Adams
  6632. Example :
  6633. */
  6634. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6635. {
  6636. Player* player = client->GetPlayer();
  6637. if (sep && sep->arg[0])
  6638. {
  6639. const char* value = sep->arg[0];
  6640. if (strncasecmp(value, "true", strlen(value)) == 0)
  6641. {
  6642. player->set_character_flag(CF_SHOW_CLOAK);
  6643. player->reset_character_flag(CF2_SHOW_RANGED);
  6644. }
  6645. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6646. player->reset_character_flag(CF_SHOW_CLOAK);
  6647. else
  6648. {
  6649. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6650. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6651. }
  6652. }
  6653. }
  6654. /*
  6655. Function: Command_ShowHelm()
  6656. Purpose : Character Settings combo box for Show Helm
  6657. Params : true/false
  6658. Dev : John Adams
  6659. Example :
  6660. */
  6661. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6662. {
  6663. Player* player = client->GetPlayer();
  6664. if (sep && sep->arg[0])
  6665. {
  6666. const char* value = sep->arg[0];
  6667. if (strncasecmp(value, "true", strlen(value)) == 0)
  6668. {
  6669. player->reset_character_flag(CF_HIDE_HELM);
  6670. player->set_character_flag(CF_HIDE_HOOD);
  6671. }
  6672. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6673. player->set_character_flag(CF_HIDE_HELM);
  6674. else
  6675. {
  6676. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6677. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6678. }
  6679. }
  6680. }
  6681. /*
  6682. Function: Command_ShowHood()
  6683. Purpose : Character Settings combo box for Show Hood
  6684. Params : true/false
  6685. Dev : John Adams
  6686. Example :
  6687. */
  6688. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6689. {
  6690. Player* player = client->GetPlayer();
  6691. if (sep && sep->arg[0])
  6692. {
  6693. const char* value = sep->arg[0];
  6694. if (strncasecmp(value, "true", strlen(value)) == 0)
  6695. {
  6696. player->reset_character_flag(CF_HIDE_HOOD);
  6697. player->set_character_flag(CF_HIDE_HELM);
  6698. }
  6699. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6700. player->set_character_flag(CF_HIDE_HOOD);
  6701. else
  6702. {
  6703. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6704. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6705. }
  6706. }
  6707. }
  6708. /*
  6709. Function: Command_ShowHoodHelm()
  6710. Purpose : Character Settings combo box for Show Helm or Hood
  6711. Params : true/false
  6712. Dev : John Adams
  6713. Example :
  6714. */
  6715. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6716. {
  6717. Player* player = client->GetPlayer();
  6718. if (sep && sep->arg[0])
  6719. {
  6720. const char* value = sep->arg[0];
  6721. if (strncasecmp(value, "true", strlen(value)) == 0)
  6722. {
  6723. player->reset_character_flag(CF_HIDE_HOOD);
  6724. player->reset_character_flag(CF_HIDE_HELM);
  6725. }
  6726. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6727. {
  6728. // don't think we ever wind up in here...
  6729. player->set_character_flag(CF_HIDE_HOOD);
  6730. player->set_character_flag(CF_HIDE_HELM);
  6731. }
  6732. else
  6733. {
  6734. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6735. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6736. }
  6737. }
  6738. }
  6739. /*
  6740. Function: Command_ShowRanged()
  6741. Purpose : Character Settings combo box for Show Ranged weapon
  6742. Params : true/false
  6743. Dev : John Adams
  6744. Example :
  6745. */
  6746. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6747. {
  6748. Player* player = client->GetPlayer();
  6749. if (sep && sep->arg[0])
  6750. {
  6751. const char* value = sep->arg[0];
  6752. if (strncasecmp(value, "true", strlen(value)) == 0)
  6753. {
  6754. player->set_character_flag(CF2_SHOW_RANGED);
  6755. player->reset_character_flag(CF_SHOW_CLOAK);
  6756. }
  6757. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6758. player->reset_character_flag(CF2_SHOW_RANGED);
  6759. else
  6760. {
  6761. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6762. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6763. }
  6764. }
  6765. }
  6766. /*
  6767. Function:
  6768. Purpose :
  6769. Params :
  6770. Dev :
  6771. Example :
  6772. */
  6773. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6774. {
  6775. Player* player = 0;
  6776. Client* to_client = 0;
  6777. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6778. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6779. switch(handler)
  6780. {
  6781. case COMMAND_SKILL:
  6782. {
  6783. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6784. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6785. break;
  6786. }
  6787. case COMMAND_SKILL_ADD:
  6788. {
  6789. if (sep && sep->arg[0])
  6790. {
  6791. const char* skill_name = sep->argplus[0];
  6792. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6793. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6794. {
  6795. player = to_client->GetPlayer();
  6796. if (player)
  6797. {
  6798. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6799. {
  6800. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6801. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6802. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6803. }
  6804. else
  6805. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6806. }
  6807. }
  6808. else if (skill) // add skill to yourself
  6809. {
  6810. player = client->GetPlayer();
  6811. if (player)
  6812. {
  6813. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6814. {
  6815. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6816. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6817. }
  6818. else
  6819. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6820. }
  6821. }
  6822. else
  6823. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6824. }
  6825. else
  6826. {
  6827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6829. }
  6830. break;
  6831. }
  6832. case COMMAND_SKILL_REMOVE:
  6833. {
  6834. if (sep && sep->arg[0])
  6835. {
  6836. const char* skill_name = sep->argplus[0];
  6837. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6838. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6839. {
  6840. player = to_client->GetPlayer();
  6841. if (player)
  6842. {
  6843. if (player->GetSkills()->HasSkill(skill->skill_id))
  6844. {
  6845. player->RemoveSkillFromDB(skill, true);
  6846. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6847. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6848. }
  6849. else
  6850. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6851. }
  6852. }
  6853. else if(skill) // remove skill from yourself
  6854. {
  6855. Player* player = client->GetPlayer();
  6856. if (player)
  6857. {
  6858. if (player->GetSkills()->HasSkill(skill->skill_id))
  6859. {
  6860. player->RemoveSkillFromDB(skill, true);
  6861. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6862. }
  6863. else
  6864. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6865. }
  6866. }
  6867. else
  6868. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6869. }
  6870. else
  6871. {
  6872. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  6873. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6874. }
  6875. break;
  6876. }
  6877. case COMMAND_SKILL_LIST:
  6878. {
  6879. if (sep && sep->arg[0])
  6880. {
  6881. const char* skill_name = sep->argplus[0];
  6882. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  6883. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  6884. map<int32, Skill*>::iterator itr;
  6885. if (skills && skills->size() > 0)
  6886. {
  6887. for (itr = skills->begin(); itr != skills->end(); itr++)
  6888. {
  6889. Skill* skill = itr->second;
  6890. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  6891. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  6892. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  6893. }
  6894. }
  6895. }
  6896. else
  6897. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  6898. break;
  6899. }
  6900. }
  6901. }
  6902. /*
  6903. Function: Command_SpawnTemplate()
  6904. Purpose : Create or Use defined Spawn Templates
  6905. Params : create, save, rempve, list
  6906. Dev : John Adams
  6907. Example : /spawn template create "Test"
  6908. */
  6909. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  6910. {
  6911. if (sep == NULL || sep->arg[0] == NULL)
  6912. {
  6913. 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.");
  6914. return;
  6915. }
  6916. // got params, continue
  6917. const char * template_cmd = sep->arg[0];
  6918. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  6919. {
  6920. if (!sep->IsSet(1))
  6921. {
  6922. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  6923. 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.");
  6924. return;
  6925. }
  6926. map<int32, string>* template_names = 0;
  6927. if (sep->IsNumber(1))
  6928. {
  6929. int32 location_id = 0;
  6930. location_id = atoi(sep->arg[1]);
  6931. template_names = database.GetSpawnTemplateListByID(location_id);
  6932. }
  6933. else
  6934. {
  6935. const char* name = 0;
  6936. name = sep->argplus[1];
  6937. template_names = database.GetSpawnTemplateListByName(name);
  6938. }
  6939. if(!template_names)
  6940. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  6941. else
  6942. {
  6943. map<int32, string>::iterator itr;
  6944. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  6945. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  6946. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  6947. safe_delete(template_names);
  6948. }
  6949. }
  6950. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  6951. {
  6952. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6953. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  6954. {
  6955. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  6956. {
  6957. // first, lookup to see if template name already exists
  6958. const char* name = 0;
  6959. name = sep->argplus[1];
  6960. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  6961. if(!template_names)
  6962. {
  6963. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  6964. if( new_template_id > 0 )
  6965. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  6966. else
  6967. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  6968. }
  6969. else
  6970. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  6971. }
  6972. else
  6973. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  6974. }
  6975. else
  6976. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  6977. }
  6978. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  6979. {
  6980. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  6981. {
  6982. int32 template_id = 0;
  6983. template_id = atoi(sep->arg[1]);
  6984. if (database.RemoveSpawnTemplate(template_id))
  6985. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  6986. else
  6987. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  6988. }
  6989. else
  6990. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  6991. }
  6992. // Renamed create to spawn
  6993. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  6994. {
  6995. if (sep && sep->arg[1][0])
  6996. {
  6997. int32 new_location = 0;
  6998. if (sep->IsNumber(1))
  6999. {
  7000. int32 template_id = 0;
  7001. template_id = atoi(sep->arg[1]);
  7002. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  7003. if( new_location > 0 )
  7004. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  7005. else
  7006. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  7007. }
  7008. else
  7009. {
  7010. const char* name = 0;
  7011. name = sep->argplus[1];
  7012. new_location = database.CreateSpawnFromTemplateByName(client, name);
  7013. if( new_location > 0 )
  7014. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  7015. else
  7016. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  7017. }
  7018. }
  7019. else
  7020. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  7021. }
  7022. else
  7023. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  7024. }
  7025. void Commands::Command_Speed(Client* client, Seperator* sep) {
  7026. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  7027. float new_speed = atof(sep->arg[0]);
  7028. if (new_speed > 0.0f)
  7029. {
  7030. client->GetPlayer()->SetSpeed(new_speed, true);
  7031. client->GetPlayer()->SetCharSheetChanged(true);
  7032. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  7033. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  7034. }
  7035. else
  7036. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  7037. }
  7038. else{
  7039. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  7040. }
  7041. }
  7042. /*
  7043. Function: Command_StationMarketPlace()
  7044. Purpose : just trying to eat the console spam for now
  7045. Params :
  7046. Dev : John
  7047. */
  7048. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  7049. {
  7050. PrintSep(sep, "COMMAND_SMP");
  7051. // This will reduce the spam from once every 10 sec to once every 30 sec,
  7052. // can't seem to reduce it any more get rid of it completely...
  7053. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  7054. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  7055. if (packet) {
  7056. packet->setDataByName("account_id", client->GetAccountID());
  7057. packet->setDataByName("character_id", client->GetCharacterID());
  7058. packet->setDataByName("unknown1", 1, 5);
  7059. packet->setDataByName("unknown1", 26, 6);
  7060. packet->setDataByName("unknown2", 0xFFFFFFFF);
  7061. packet->setDataByName("unknown3", 248, 1);
  7062. client->QueuePacket(packet->serialize());
  7063. }
  7064. safe_delete(packet);
  7065. }
  7066. }
  7067. /*
  7068. Function: Command_StopDrinking()
  7069. Purpose : Stops player from auto-consuming drink
  7070. Params :
  7071. Dev : Zcoretri
  7072. Example : /stopdrinking
  7073. */
  7074. void Commands::Command_StopDrinking(Client* client)
  7075. {
  7076. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  7077. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  7078. }
  7079. /*
  7080. Function: Command_StopEating()
  7081. Purpose : Stops player from auto-consuming food
  7082. Params :
  7083. Dev : Zcoretri
  7084. Example : /stopeating
  7085. */
  7086. void Commands::Command_StopEating(Client* client)
  7087. {
  7088. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  7089. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  7090. }
  7091. /*
  7092. Function: Command_Title()
  7093. Purpose : Help for /title command
  7094. Params : n/a
  7095. Dev : Zcoretri
  7096. Example : /title
  7097. */
  7098. void Commands::Command_Title(Client* client)
  7099. {
  7100. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  7101. }
  7102. /*
  7103. Function: Command_TitleList()
  7104. Purpose : List available titles for player
  7105. Params : n/a
  7106. Dev : Zcoretri
  7107. Example : /title list
  7108. */
  7109. void Commands::Command_TitleList(Client* client)
  7110. {
  7111. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  7112. list<Title*>::iterator itr;
  7113. Title* title;
  7114. int16 i = 0;
  7115. client->Message(CHANNEL_COLOR_WHITE, "Listing available titles:");
  7116. for(itr = titles->begin(); itr != titles->end(); itr++)
  7117. {
  7118. title = *itr;
  7119. client->Message(CHANNEL_COLOR_WHITE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  7120. i++;
  7121. }
  7122. }
  7123. /*
  7124. Function: Command_TitleSetPrefix()
  7125. Purpose : Set Prefix title for player
  7126. Params : Title ID
  7127. Dev : Zcoretri
  7128. Example : /title setprefix 1
  7129. */
  7130. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  7131. {
  7132. if (sep && sep->arg[0] && sep->IsNumber(0))
  7133. {
  7134. int32 index = atoul(sep->arg[0]);
  7135. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  7136. client->SendTitleUpdate();
  7137. }
  7138. }
  7139. /*
  7140. Function: Command_TitleSetSuffix()
  7141. Purpose : Set Suffix title for player
  7142. Params : Title ID
  7143. Dev : Zcoretri
  7144. Example : /title setsuffix 1
  7145. */
  7146. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  7147. {
  7148. if (sep && sep->arg[0] && sep->IsNumber(0))
  7149. {
  7150. int32 index = atoul(sep->arg[0]);
  7151. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  7152. client->SendTitleUpdate();
  7153. }
  7154. }
  7155. /*
  7156. Function: Command_TitleFix()
  7157. Purpose : Fix title for player (???)
  7158. Params :
  7159. Dev : Zcoretri
  7160. Example :
  7161. */
  7162. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  7163. {
  7164. PrintSep(sep, "COMMAND_TITLE_FIX");
  7165. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  7166. }
  7167. /*
  7168. Function: Command_Toggle_Anonymous()
  7169. Purpose : Toggles player Anonymous
  7170. Params :
  7171. Dev : paulgh
  7172. Example : /anon
  7173. */
  7174. void Commands::Command_Toggle_Anonymous(Client* client)
  7175. {
  7176. Player* player = client->GetPlayer();
  7177. player->toggle_character_flag(CF_ANONYMOUS);
  7178. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  7179. if (player->get_character_flag(CF_ANONYMOUS))
  7180. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  7181. else
  7182. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  7183. }
  7184. /*
  7185. Function: Command_Toggle_AutoConsume()
  7186. Purpose : Toggles player food/drink auto consume
  7187. Params : unknown
  7188. Dev : paulgh
  7189. Example : /set_auto_consume
  7190. */
  7191. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7192. {
  7193. Player* player = client->GetPlayer();
  7194. if (sep && sep->arg[0])
  7195. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7196. if (sep && sep->arg[0] && sep->IsNumber(0))
  7197. {
  7198. int8 slot = atoi(sep->arg[0]);
  7199. int8 flag = atoi(sep->arg[1]);
  7200. if (slot == EQ2_FOOD_SLOT)
  7201. {
  7202. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7203. player->SetCharSheetChanged(true);
  7204. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7205. if (flag == 1)
  7206. client->Message(CHANNEL_COLOR_WHITE, "You decide to eat immediately whenever you become hungry.");
  7207. else
  7208. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the hunger.");
  7209. }
  7210. else
  7211. {
  7212. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7213. player->SetCharSheetChanged(true);
  7214. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7215. if (flag == 1)
  7216. client->Message(CHANNEL_COLOR_WHITE, "You decide to drink immediately whenever you become thirsty.");
  7217. else
  7218. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the thirst.");
  7219. }
  7220. }
  7221. }
  7222. /*
  7223. Function: Command_Toggle_BonusXP()
  7224. Purpose : Toggles player Bonus XP
  7225. Params :
  7226. Dev : John Adams
  7227. Example : /disable_char_bonus_exp
  7228. */
  7229. void Commands::Command_Toggle_BonusXP(Client* client)
  7230. {
  7231. Player* player = client->GetPlayer();
  7232. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7233. player->SetCharSheetChanged(true);
  7234. }
  7235. /*
  7236. Function: Command_Toggle_CombatXP()
  7237. Purpose : Toggles player Adventure XP
  7238. Params :
  7239. Dev : John Adams
  7240. Example : /disable_combat_exp
  7241. */
  7242. void Commands::Command_Toggle_CombatXP(Client* client)
  7243. {
  7244. Player* player = client->GetPlayer();
  7245. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7246. player->SetCharSheetChanged(true);
  7247. }
  7248. /*
  7249. Function: Command_Toggle_GMHide()
  7250. Purpose : Toggles hiding player GM status
  7251. Params :
  7252. Dev : Scatman
  7253. Example : /gm_hide
  7254. */
  7255. void Commands::Command_Toggle_GMHide(Client* client)
  7256. {
  7257. Player* player = client->GetPlayer();
  7258. player->toggle_character_flag(CF_HIDE_STATUS);
  7259. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7260. }
  7261. /*
  7262. Function: Command_Toggle_GMVanish()
  7263. Purpose : Toggles hiding GM players from /who searches
  7264. Params :
  7265. Dev : Scatman
  7266. Example : /gm_vanish
  7267. */
  7268. void Commands::Command_Toggle_GMVanish(Client* client)
  7269. {
  7270. Player* player = client->GetPlayer();
  7271. player->toggle_character_flag(CF_GM_HIDDEN);
  7272. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7273. }
  7274. /*
  7275. Function: Command_Toggle_Illusions()
  7276. Purpose : Toggles player illusion form
  7277. Params : not sure sep is needed, testing
  7278. Dev : paulgh
  7279. Example : /hide_illusions
  7280. */
  7281. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7282. {
  7283. if (sep && sep->arg[0])
  7284. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7285. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7286. }
  7287. /*
  7288. Function: Command_Toggle_LFG()
  7289. Purpose : Toggles player LFG Flag
  7290. Params :
  7291. Dev : paulgh
  7292. Example : /lfg
  7293. */
  7294. void Commands::Command_Toggle_LFG(Client* client)
  7295. {
  7296. Player* player = client->GetPlayer();
  7297. player->toggle_character_flag(CF_LFG);
  7298. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7299. if (player->get_character_flag(CF_LFG))
  7300. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7301. else
  7302. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7303. }
  7304. /*
  7305. Function: Command_Toggle_LFW()
  7306. Purpose : Toggles player LFW Flag
  7307. Params :
  7308. Dev : paulgh
  7309. Example : /lfw
  7310. */
  7311. void Commands::Command_Toggle_LFW(Client* client)
  7312. {
  7313. Player* player = client->GetPlayer();
  7314. player->toggle_character_flag(CF_LFW);
  7315. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7316. if (player->get_character_flag(CF_LFW))
  7317. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7318. else
  7319. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7320. }
  7321. /*
  7322. Function: Command_Toggle_QuestXP()
  7323. Purpose : Toggles player Quest XP
  7324. Params :
  7325. Dev : John Adams
  7326. Example : /disable_quest_exp
  7327. */
  7328. void Commands::Command_Toggle_QuestXP(Client* client)
  7329. {
  7330. Player* player = client->GetPlayer();
  7331. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7332. player->SetCharSheetChanged(true);
  7333. }
  7334. /*
  7335. Function: Command_Toggle_Roleplaying()
  7336. Purpose : Toggles player Roleplaying flag
  7337. Params :
  7338. Dev : paulgh
  7339. Example : /role
  7340. */
  7341. void Commands::Command_Toggle_Roleplaying(Client* client)
  7342. {
  7343. Player* player = client->GetPlayer();
  7344. player->toggle_character_flag(CF_ROLEPLAYING);
  7345. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  7346. if (player->get_character_flag(CF_ROLEPLAYING))
  7347. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  7348. else
  7349. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  7350. }
  7351. void Commands::Command_Toggle_Duels(Client* client)
  7352. {
  7353. Player* player = client->GetPlayer();
  7354. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7355. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7356. }
  7357. void Commands::Command_Toggle_Trades(Client* client)
  7358. {
  7359. Player* player = client->GetPlayer();
  7360. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7361. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7362. }
  7363. void Commands::Command_Toggle_Guilds(Client* client)
  7364. {
  7365. Player* player = client->GetPlayer();
  7366. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7367. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7368. }
  7369. void Commands::Command_Toggle_Groups(Client* client)
  7370. {
  7371. Player* player = client->GetPlayer();
  7372. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7373. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7374. }
  7375. void Commands::Command_Toggle_Raids(Client* client)
  7376. {
  7377. Player* player = client->GetPlayer();
  7378. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7379. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7380. }
  7381. void Commands::Command_Toggle_LON(Client* client)
  7382. {
  7383. Player* player = client->GetPlayer();
  7384. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7385. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7386. }
  7387. void Commands::Command_Toggle_VoiceChat(Client* client)
  7388. {
  7389. Player* player = client->GetPlayer();
  7390. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7391. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7392. }
  7393. /*
  7394. Function: Command_TradeStart()
  7395. Purpose : Starts item/coin trade between players
  7396. Params :
  7397. Dev :
  7398. Example :
  7399. */
  7400. #include "../Trade.h"
  7401. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7402. {
  7403. PrintSep(sep, "COMMAND_START_TRADE");
  7404. Entity* trader = client->GetPlayer();
  7405. Entity* trader2 = 0;
  7406. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7407. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7408. if (spawn) {
  7409. if (spawn->IsEntity())
  7410. trader2 = (Entity*)spawn;
  7411. }
  7412. }
  7413. else if (client->GetPlayer()->GetTarget()) {
  7414. if (client->GetPlayer()->GetTarget()->IsEntity())
  7415. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7416. }
  7417. // can only trade with player or bots
  7418. if (trader && trader2) {
  7419. if (trader == trader2) {
  7420. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7421. }
  7422. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7423. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7424. if (trader->trade)
  7425. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7426. else if (trader2->trade)
  7427. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7428. else {
  7429. Trade* trade = new Trade(trader, trader2);
  7430. trader->trade = trade;
  7431. trader2->trade = trade;
  7432. }
  7433. }
  7434. else {
  7435. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  7436. }
  7437. }
  7438. else
  7439. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  7440. }
  7441. /*
  7442. Function: Command_Track()
  7443. Purpose : Starts/Stops Tracking for a player
  7444. Params :
  7445. Dev : Scatman
  7446. Example : /track
  7447. */
  7448. void Commands::Command_Track(Client* client)
  7449. {
  7450. if (!client->GetPlayer()->GetIsTracking())
  7451. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7452. else
  7453. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7454. }
  7455. /*
  7456. Function: Command_TradeAccept()
  7457. Purpose : Accepts item/coin trade between players
  7458. Params :
  7459. Dev :
  7460. Example :
  7461. */
  7462. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7463. {
  7464. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7465. Trade* trade = client->GetPlayer()->trade;
  7466. if (trade) {
  7467. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7468. if (trade_complete)
  7469. safe_delete(trade);
  7470. }
  7471. else
  7472. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7473. }
  7474. /*
  7475. Function: Command_TradeReject()
  7476. Purpose : Rejects item/coin trade between players
  7477. Params :
  7478. Dev :
  7479. Example :
  7480. */
  7481. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7482. {
  7483. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7484. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7485. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7486. }
  7487. /*
  7488. Function: Command_TradeCancel()
  7489. Purpose : Cancels item/coin trade between players
  7490. Params :
  7491. Dev :
  7492. Example :
  7493. */
  7494. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7495. {
  7496. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7497. Trade* trade = client->GetPlayer()->trade;
  7498. if (trade) {
  7499. trade->CancelTrade(client->GetPlayer());
  7500. safe_delete(trade);
  7501. }
  7502. else
  7503. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7504. }
  7505. /*
  7506. Function: Command_TradeSetCoin()
  7507. Purpose : Sets coin trade between players
  7508. Params :
  7509. Dev :
  7510. Example :
  7511. */
  7512. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7513. {
  7514. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7515. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7516. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7517. }
  7518. /*
  7519. Function: Command_TradeAddCoin()
  7520. Purpose : Adds coin to trade between players
  7521. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7522. Dev :
  7523. Example :
  7524. */
  7525. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7526. {
  7527. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7528. Trade* trade = client->GetPlayer()->trade;
  7529. if (trade) {
  7530. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7531. int32 amount = atoi(sep->arg[0]);
  7532. int64 val = 0;
  7533. switch (handler) {
  7534. case COMMAND_ADD_TRADE_COPPER:
  7535. {
  7536. val = amount;
  7537. trade->AddCoinToTrade(client->GetPlayer(), val);
  7538. break;
  7539. }
  7540. case COMMAND_ADD_TRADE_SILVER:
  7541. {
  7542. val = amount * 100;
  7543. trade->AddCoinToTrade(client->GetPlayer(), val);
  7544. break;
  7545. }
  7546. case COMMAND_ADD_TRADE_GOLD:
  7547. {
  7548. val = amount * 10000;
  7549. trade->AddCoinToTrade(client->GetPlayer(), val);
  7550. break;
  7551. }
  7552. case COMMAND_ADD_TRADE_PLAT:
  7553. {
  7554. val = amount * 1000000;
  7555. trade->AddCoinToTrade(client->GetPlayer(), val);
  7556. break;
  7557. }
  7558. default:
  7559. {
  7560. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7561. break;
  7562. }
  7563. }
  7564. }
  7565. else
  7566. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7567. }
  7568. else
  7569. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7570. }
  7571. /*
  7572. Function: Command_TradeRemoveCoin()
  7573. Purpose : Removes coin from trade between players
  7574. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7575. Dev :
  7576. Example :
  7577. */
  7578. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7579. {
  7580. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7581. Trade* trade = client->GetPlayer()->trade;
  7582. if (trade) {
  7583. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7584. int32 amount = atoi(sep->arg[0]);
  7585. int64 val = 0;
  7586. switch (handler) {
  7587. case COMMAND_REMOVE_TRADE_COPPER:
  7588. {
  7589. val = amount;
  7590. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7591. break;
  7592. }
  7593. case COMMAND_REMOVE_TRADE_SILVER:
  7594. {
  7595. val = amount * 100;
  7596. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7597. break;
  7598. }
  7599. case COMMAND_REMOVE_TRADE_GOLD:
  7600. {
  7601. val = amount * 10000;
  7602. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7603. break;
  7604. }
  7605. case COMMAND_REMOVE_TRADE_PLAT:
  7606. {
  7607. val = amount * 1000000;
  7608. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7609. break;
  7610. }
  7611. default:
  7612. {
  7613. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7614. break;
  7615. }
  7616. }
  7617. }
  7618. else
  7619. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7620. }
  7621. else
  7622. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7623. }
  7624. /*
  7625. Function: Command_TradeAddItem()
  7626. Purpose : Adds item to trade between players
  7627. Params :
  7628. Dev :
  7629. Example :
  7630. */
  7631. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7632. {
  7633. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7634. /*
  7635. arg[0] = item index
  7636. arg[1] = slot
  7637. arg[2] = quantity
  7638. */
  7639. if (!client->GetPlayer()->trade) {
  7640. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7641. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7642. return;
  7643. }
  7644. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7645. Item* item = 0;
  7646. int32 index = atoi(sep->arg[0]);
  7647. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7648. if (item) {
  7649. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7650. if (result == 1)
  7651. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7652. else if (result == 2)
  7653. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7654. else if (result == 3)
  7655. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7656. else if (result == 255)
  7657. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7658. }
  7659. else {
  7660. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7661. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7662. }
  7663. }
  7664. else
  7665. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7666. }
  7667. /*
  7668. Function: Command_TradeRemoveItem()
  7669. Purpose : Removes item from trade between players
  7670. Params :
  7671. Dev :
  7672. Example :
  7673. */
  7674. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7675. {
  7676. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7677. /*
  7678. arg[0] = trade window slot
  7679. */
  7680. Trade* trade = client->GetPlayer()->trade;
  7681. if (trade) {
  7682. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7683. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7684. }
  7685. else
  7686. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7687. }
  7688. else
  7689. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7690. }
  7691. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7692. {
  7693. Item *item = 0;
  7694. sint32 crc;
  7695. if (sep) {
  7696. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7697. if (client->GetVersion() < 1096) {
  7698. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7699. {
  7700. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7701. crc = atol(sep->arg[2]);
  7702. }
  7703. }
  7704. else {
  7705. // From the broker and links in chat
  7706. if (strcmp(sep->arg[0], "crc") == 0) {
  7707. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7708. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7709. crc = atol(sep->arg[3]);
  7710. }
  7711. }
  7712. // From inventory
  7713. if (strcmp(sep->arg[0], "dbid") == 0) {
  7714. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7715. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7716. crc = atol(sep->arg[4]);
  7717. }
  7718. }
  7719. }
  7720. if (item)
  7721. client->ShowDressingRoom(item, crc);
  7722. }
  7723. }
  7724. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7725. const char *channel_name, *password = NULL;
  7726. if (sep == NULL || !sep->IsSet(0)) {
  7727. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7728. return;
  7729. }
  7730. channel_name = sep->arg[0];
  7731. if (sep->IsSet(1))
  7732. password = sep->arg[1];
  7733. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7734. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7735. return;
  7736. }
  7737. if (chat.IsInChannel(client, channel_name)) {
  7738. client->Message(CHANNEL_COLOR_WHITE, "You are already in '%s'.", channel_name);
  7739. return;
  7740. }
  7741. if (chat.HasPassword(channel_name)) {
  7742. if (password == NULL) {
  7743. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': That channel is password protected.", channel_name);
  7744. return;
  7745. }
  7746. if (!chat.PasswordMatches(channel_name, password)) {
  7747. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': The password is not correc.t", channel_name);
  7748. return;
  7749. }
  7750. }
  7751. if (!chat.JoinChannel(client, channel_name))
  7752. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7753. }
  7754. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7755. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7756. Command_JoinChannel(client, sep);
  7757. }
  7758. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7759. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7760. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7761. PrintSep(sep, "tellchannel");
  7762. return;
  7763. }
  7764. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7765. }
  7766. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7767. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7768. if (sep->IsSet(0)) {
  7769. if (atoi(sep->arg[0]) == 1) {
  7770. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  7771. if (packet2) {
  7772. packet2->setDataByName("spell_type", 2);
  7773. packet2->setDataByName("spell_id", 8308);
  7774. packet2->setDataByName("spell_name", "Sprint");
  7775. packet2->setDataByName("add_silently", 0);
  7776. packet2->setDataByName("tier", 1);
  7777. packet2->setDataByName("blah1", 1);
  7778. packet2->setDataByName("blah2", 1);
  7779. EQ2Packet* outapp = packet2->serialize();
  7780. DumpPacket(outapp);
  7781. client->QueuePacket(outapp);
  7782. safe_delete(packet2);
  7783. }
  7784. }
  7785. else if (atoi(sep->arg[0]) == 2) {
  7786. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  7787. if (packet2) {
  7788. packet2->setDataByName("guild_name", "Test");
  7789. packet2->setDataByName("guild_motd", "Test MOTD");
  7790. packet2->setDataByName("guild_id", 1234);
  7791. packet2->setDataByName("guild_level", 1);
  7792. packet2->setDataByName("unknown", 2);
  7793. packet2->setDataByName("unknown2", 3);
  7794. packet2->setDataByName("exp_current", 1);
  7795. packet2->setDataByName("exp_to_next_level", 4);
  7796. EQ2Packet* outapp = packet2->serialize();
  7797. DumpPacket(outapp);
  7798. client->QueuePacket(outapp);
  7799. safe_delete(packet2);
  7800. }
  7801. }
  7802. else if (atoi(sep->arg[0]) == 3) {
  7803. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  7804. if (packet2) {
  7805. packet2->setDataByName("guild_id", 1234);
  7806. packet2->setDataByName("character_id", 1);
  7807. packet2->setDataByName("account_id", 2);
  7808. packet2->setDataByName("guild_level", 1);
  7809. packet2->setDataByName("name", "Test");
  7810. packet2->setDataByName("unknown2", 0);
  7811. packet2->setDataByName("unknown3", 1);
  7812. packet2->setDataByName("adventure_class", 6);
  7813. packet2->setDataByName("adventure_level", 7);
  7814. packet2->setDataByName("tradeskill_class", 4);
  7815. packet2->setDataByName("tradeskill_level", 5);
  7816. packet2->setDataByName("rank", 0);
  7817. packet2->setDataByName("member_flags", 2);
  7818. packet2->setDataByName("join_date", 1591112273);
  7819. packet2->setDataByName("guild_status", 2);
  7820. packet2->setDataByName("last_login", 1591132273);
  7821. packet2->setDataByName("recruiter_id", 1);
  7822. packet2->setDataByName("points", 2345);
  7823. packet2->setDataByName("note", "note");
  7824. packet2->setMediumStringByName("officer_note", "O note");
  7825. packet2->setMediumStringByName("zone", "Blah");
  7826. EQ2Packet* outapp = packet2->serialize();
  7827. DumpPacket(outapp);
  7828. client->QueuePacket(outapp);
  7829. safe_delete(packet2);
  7830. }
  7831. }
  7832. else if (atoi(sep->arg[0]) == 5) {
  7833. client->GetPlayer()->GetTarget();
  7834. int16 offset = atoi(sep->arg[2]);
  7835. int32 value1 = atol(sep->arg[4]);
  7836. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  7837. client->QueuePacket(outapp);
  7838. }
  7839. else if (atoi(sep->arg[0]) == 6) {
  7840. Spawn* spawn = client->GetPlayer()->GetTarget();
  7841. if (!spawn)
  7842. spawn = client->GetPlayer();
  7843. else if (spawn->IsEntity())
  7844. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  7845. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  7846. }
  7847. else if (atoi(sep->arg[0]) == 7) {
  7848. int32 id = 0;
  7849. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  7850. if (spawn) {
  7851. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7852. spawn->SetY(client->GetPlayer()->GetY(), false);
  7853. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7854. float heading = client->GetPlayer()->GetHeading() + 180;
  7855. if (heading > 360)
  7856. heading -= 360;
  7857. spawn->SetLevel(5);
  7858. spawn->SetAdventureClass(4);
  7859. spawn->SetHeading(heading, false);
  7860. spawn->SetSpawnOrigX(spawn->GetX());
  7861. spawn->SetSpawnOrigY(spawn->GetY());
  7862. spawn->SetSpawnOrigZ(spawn->GetZ());
  7863. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  7864. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  7865. spawn->appearance.targetable = 1;
  7866. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  7867. spawn->SetTotalHP(spawn->GetLevel() * 15);
  7868. spawn->SetHP(spawn->GetTotalHP());
  7869. }
  7870. if (spawn->GetTotalPower() == 0) {
  7871. spawn->SetTotalPower(spawn->GetLevel() * 15);
  7872. spawn->SetPower(spawn->GetTotalPower());
  7873. }
  7874. int16 offset = atoi(sep->arg[1]);
  7875. int32 value1 = atol(sep->arg[2]);
  7876. sprintf(spawn->appearance.name, "Offset %i", offset);
  7877. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  7878. DumpPacket(ret);
  7879. client->QueuePacket(ret);
  7880. }
  7881. }
  7882. else if (atoi(sep->arg[0]) == 8) {
  7883. int32 id = atoi(sep->arg[1]);
  7884. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  7885. if (spawn) {
  7886. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7887. spawn->SetY(client->GetPlayer()->GetY(), false);
  7888. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7889. float heading = client->GetPlayer()->GetHeading() + 180;
  7890. if (heading > 360)
  7891. heading -= 360;
  7892. spawn->SetLevel(5);
  7893. spawn->SetAdventureClass(4);
  7894. spawn->SetHeading(heading, false);
  7895. spawn->SetSpawnOrigX(spawn->GetX());
  7896. spawn->SetSpawnOrigY(spawn->GetY());
  7897. spawn->SetSpawnOrigZ(spawn->GetZ());
  7898. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  7899. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  7900. spawn->appearance.targetable = 1;
  7901. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  7902. spawn->SetTotalHP(spawn->GetLevel() * 15);
  7903. spawn->SetHP(spawn->GetTotalHP());
  7904. }
  7905. if (spawn->GetTotalPower() == 0) {
  7906. spawn->SetTotalPower(spawn->GetLevel() * 15);
  7907. spawn->SetPower(spawn->GetTotalPower());
  7908. }
  7909. int16 offset = atoi(sep->arg[2]);
  7910. int16 offset2 = atoi(sep->arg[3]);
  7911. int32 value1 = atol(sep->arg[4]);
  7912. int16 offset3 = 0;
  7913. int16 offset4 = 0;
  7914. int32 value2 = 0;
  7915. if (sep->IsSet(7)) {
  7916. offset3 = atoi(sep->arg[5]);
  7917. offset4 = atoi(sep->arg[6]);
  7918. value2 = atol(sep->arg[7]);
  7919. }
  7920. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  7921. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  7922. DumpPacket(ret);
  7923. client->QueuePacket(ret);
  7924. }
  7925. }
  7926. else if (atoi(sep->arg[0]) == 9) {
  7927. Item* item = master_item_list.GetItem(70007);
  7928. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  7929. if (sep->IsSet(2)) {
  7930. int8 offset = atoi(sep->arg[1]);
  7931. uchar* ptr2 = app->pBuffer;
  7932. ptr2 += offset;
  7933. if (sep->IsNumber(2)) {
  7934. int32 value1 = atol(sep->arg[2]);
  7935. if (value1 > 0xFFFF)
  7936. memcpy(ptr2, (uchar*)&value1, 4);
  7937. else if (value1 > 0xFF)
  7938. memcpy(ptr2, (uchar*)&value1, 2);
  7939. else
  7940. memcpy(ptr2, (uchar*)&value1, 1);
  7941. }
  7942. else {
  7943. int8 len = strlen(sep->arg[2]);
  7944. memcpy(ptr2, (uchar*)&len, 1);
  7945. ptr2 += 1;
  7946. memcpy(ptr2, sep->arg[2], len);
  7947. }
  7948. }
  7949. if (sep->IsSet(4)) {
  7950. int8 offset = atoi(sep->arg[3]);
  7951. uchar* ptr2 = app->pBuffer;
  7952. ptr2 += offset;
  7953. if (sep->IsNumber(4)) {
  7954. int32 value1 = atol(sep->arg[4]);
  7955. if (value1 > 0xFFFF)
  7956. memcpy(ptr2, (uchar*)&value1, 4);
  7957. else if (value1 > 0xFF)
  7958. memcpy(ptr2, (uchar*)&value1, 2);
  7959. else
  7960. memcpy(ptr2, (uchar*)&value1, 1);
  7961. }
  7962. else {
  7963. int8 len = strlen(sep->arg[4]);
  7964. memcpy(ptr2, (uchar*)&len, 1);
  7965. ptr2 += 1;
  7966. memcpy(ptr2, sep->arg[4], len);
  7967. }
  7968. }
  7969. DumpPacket(app);
  7970. client->QueuePacket(app);
  7971. }
  7972. else if (atoi(sep->arg[0]) == 10) {
  7973. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  7974. if (packet2) {
  7975. packet2->setArrayLengthByName("num_quests", 1);
  7976. packet2->setArrayDataByName("active", 1);
  7977. packet2->setArrayDataByName("name", "Archetype Selection");
  7978. packet2->setArrayDataByName("quest_type", "Hallmark");
  7979. packet2->setArrayDataByName("quest_zone", "Hallmark");
  7980. packet2->setArrayDataByName("journal_updated", 1);
  7981. packet2->setArrayDataByName("quest_id", 5);
  7982. packet2->setArrayDataByName("day", 19);
  7983. packet2->setArrayDataByName("month", 6);
  7984. packet2->setArrayDataByName("year", 20);
  7985. packet2->setArrayDataByName("level", 2);
  7986. packet2->setArrayDataByName("encounter_level", 4);
  7987. packet2->setArrayDataByName("difficulty", 3);
  7988. packet2->setArrayDataByName("visible", 1);
  7989. packet2->setDataByName("visible_quest_id", 5);
  7990. packet2->setDataByName("player_crc", 2900677088);
  7991. packet2->setDataByName("player_name", "LethalEncounter");
  7992. EQ2Packet* app = packet2->serialize();
  7993. if (sep->IsSet(2)) {
  7994. int8 offset = atoi(sep->arg[1]);
  7995. uchar* ptr2 = app->pBuffer;
  7996. ptr2 += offset;
  7997. if (sep->IsNumber(2)) {
  7998. int32 value1 = atol(sep->arg[2]);
  7999. if (value1 > 0xFFFF)
  8000. memcpy(ptr2, (uchar*)&value1, 4);
  8001. else if (value1 > 0xFF)
  8002. memcpy(ptr2, (uchar*)&value1, 2);
  8003. else
  8004. memcpy(ptr2, (uchar*)&value1, 1);
  8005. }
  8006. else {
  8007. int8 len = strlen(sep->arg[2]);
  8008. memcpy(ptr2, (uchar*)&len, 1);
  8009. ptr2 += 1;
  8010. memcpy(ptr2, sep->arg[2], len);
  8011. }
  8012. }
  8013. DumpPacket(app);
  8014. client->QueuePacket(app);
  8015. safe_delete(packet2);
  8016. }
  8017. }
  8018. else if (atoi(sep->arg[0]) == 11) {
  8019. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8020. if (packet2) {
  8021. packet2->setDataByName("quest_id", 5);
  8022. packet2->setDataByName("player_crc", 2900677088);
  8023. packet2->setDataByName("name", "Archetype Selection");
  8024. packet2->setDataByName("description", "I have reported my profession to Garven Tralk");
  8025. packet2->setDataByName("type", "Hallmark");
  8026. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8027. packet2->setDataByName("day", 19);
  8028. packet2->setDataByName("month", 6);
  8029. packet2->setDataByName("year", 20);
  8030. packet2->setDataByName("level", 2);
  8031. packet2->setDataByName("encounter_level", 4);
  8032. packet2->setDataByName("difficulty", 3);
  8033. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8034. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8035. packet2->setDataByName("timer_duration", 300);
  8036. packet2->setDataByName("timer_running", 1);
  8037. packet2->setArrayLengthByName("task_groups_completed", 0);
  8038. packet2->setArrayLengthByName("num_task_groups", 1);
  8039. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8040. packet2->setSubArrayLengthByName("num_tasks", 1);
  8041. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8042. packet2->setSubArrayLengthByName("num_updates", 1);
  8043. packet2->setSubArrayDataByName("update_currentval", 0);
  8044. packet2->setSubArrayDataByName("update_maxval", 1);
  8045. packet2->setSubArrayDataByName("icon", 11);
  8046. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8047. packet2->setDataByName("journal_updated", 1);
  8048. EQ2Packet* app = packet2->serialize();
  8049. if (sep->IsSet(2)) {
  8050. int16 offset = atoi(sep->arg[1]);
  8051. uchar* ptr2 = app->pBuffer;
  8052. ptr2 += offset;
  8053. if (sep->IsNumber(2)) {
  8054. int32 value1 = atol(sep->arg[2]);
  8055. if (value1 > 0xFFFF)
  8056. memcpy(ptr2, (uchar*)&value1, 4);
  8057. else if (value1 > 0xFF)
  8058. memcpy(ptr2, (uchar*)&value1, 2);
  8059. else
  8060. memcpy(ptr2, (uchar*)&value1, 1);
  8061. }
  8062. else {
  8063. int16 len = strlen(sep->arg[2]);
  8064. memcpy(ptr2, (uchar*)&len, 2);
  8065. ptr2 += 2;
  8066. memcpy(ptr2, sep->arg[2], len);
  8067. }
  8068. }
  8069. DumpPacket(app);
  8070. client->QueuePacket(app);
  8071. safe_delete(packet2);
  8072. }
  8073. }
  8074. else if (atoi(sep->arg[0]) == 12) {
  8075. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8076. if (packet2) {
  8077. packet2->setDataByName("quest_id", 5);
  8078. packet2->setDataByName("player_crc", 2900677088);
  8079. packet2->setDataByName("name", "Archetype Selection");
  8080. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  8081. packet2->setDataByName("type", "Hallmark");
  8082. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8083. packet2->setDataByName("day", 19);
  8084. packet2->setDataByName("month", 6);
  8085. packet2->setDataByName("year", 20);
  8086. packet2->setDataByName("level", 2);
  8087. packet2->setDataByName("encounter_level", 4);
  8088. packet2->setDataByName("difficulty", 3);
  8089. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8090. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8091. packet2->setDataByName("timer_duration", 300);
  8092. packet2->setDataByName("timer_running", 1);
  8093. packet2->setArrayLengthByName("task_groups_completed", 0);
  8094. packet2->setArrayLengthByName("num_task_groups", 1);
  8095. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8096. packet2->setSubArrayLengthByName("num_tasks", 1);
  8097. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8098. packet2->setSubArrayLengthByName("num_updates", 1);
  8099. packet2->setSubArrayDataByName("update_currentval", 0);
  8100. packet2->setSubArrayDataByName("update_maxval", 1);
  8101. packet2->setSubArrayDataByName("icon", 11);
  8102. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8103. packet2->setDataByName("journal_updated", 1);
  8104. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8105. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8106. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  8107. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8108. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8109. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8110. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  8111. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  8112. Item* item = master_item_list.GetItem(152755);
  8113. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8114. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8115. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  8116. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  8117. packet2->setSubstructDataByName("item", "icon", 0xe7);
  8118. packet2->setSubstructDataByName("item", "tier", 4);
  8119. packet2->setSubstructDataByName("item", "flags", 0x60);
  8120. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  8121. packet2->setSubstructDataByName("item", "stat_type", 1);
  8122. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  8123. packet2->setSubstructDataByName("item", "value", 3);
  8124. packet2->setSubstructDataByName("item", "condition", 100);
  8125. packet2->setSubstructDataByName("item", "weight", 1);
  8126. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  8127. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  8128. packet2->setSubstructDataByName("item", "skill_min", 1);
  8129. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  8130. packet2->setSubstructDataByName("item", "adventure_class", 1);
  8131. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  8132. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  8133. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  8134. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  8135. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  8136. packet2->setSubstructDataByName("item", "level", 0x1e);
  8137. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  8138. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  8139. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  8140. //packet2->PrintPacket();
  8141. EQ2Packet* app = packet2->serialize();
  8142. if (sep->IsSet(2)) {
  8143. int16 offset = atoi(sep->arg[1]);
  8144. uchar* ptr2 = app->pBuffer;
  8145. ptr2 += offset;
  8146. if (sep->IsNumber(2)) {
  8147. int32 value1 = atol(sep->arg[2]);
  8148. if (value1 > 0xFFFF)
  8149. memcpy(ptr2, (uchar*)&value1, 4);
  8150. else if (value1 > 0xFF)
  8151. memcpy(ptr2, (uchar*)&value1, 2);
  8152. else
  8153. memcpy(ptr2, (uchar*)&value1, 1);
  8154. }
  8155. else {
  8156. int16 len = strlen(sep->arg[2]);
  8157. memcpy(ptr2, (uchar*)&len, 2);
  8158. ptr2 += 2;
  8159. memcpy(ptr2, sep->arg[2], len);
  8160. }
  8161. }
  8162. DumpPacket(app);
  8163. client->QueuePacket(app);
  8164. safe_delete(packet2);
  8165. }
  8166. }
  8167. else if (atoi(sep->arg[0]) == 13) {
  8168. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  8169. if (packet2 && sep->IsSet(7)) {
  8170. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  8171. char blah[128];
  8172. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  8173. packet2->setDataByName("text", blah);
  8174. packet2->setDataByName("message_type", sep->arg[3]);
  8175. packet2->setDataByName("size", atof(sep->arg[4]));
  8176. packet2->setDataByName("red", atoi(sep->arg[5]));
  8177. packet2->setDataByName("green", atoi(sep->arg[6]));
  8178. packet2->setDataByName("blue", atoi(sep->arg[7]));
  8179. EQ2Packet* app = packet2->serialize();
  8180. DumpPacket(app);
  8181. client->QueuePacket(app);
  8182. safe_delete(packet2);
  8183. }
  8184. }
  8185. else if (atoi(sep->arg[0]) == 14) {
  8186. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  8187. if (packet2 && sep->IsSet(3)) {
  8188. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  8189. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  8190. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  8191. 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.");
  8192. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  8193. packet2->setArrayLengthByName("num_goals", 1);
  8194. //packet2->setArrayDataByName("goal_text", )
  8195. packet2->setSubArrayLengthByName("num_tasks", 1);
  8196. packet2->setSubArrayDataByName("task_text", "continue");
  8197. packet2->setDataByName("complete_sound", "click");
  8198. packet2->setDataByName("signal", "introduction");
  8199. packet2->setDataByName("voice_key1", 0xcda65173);
  8200. packet2->setDataByName("voice_key2", 0x984bfc6d);
  8201. EQ2Packet* app = packet2->serialize();
  8202. DumpPacket(app);
  8203. client->QueuePacket(app);
  8204. safe_delete(packet2);
  8205. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  8206. packet2->setDataByName("window", "MainHUD.StartMenu");
  8207. packet2->setDataByName("show", 1);
  8208. app = packet2->serialize();
  8209. DumpPacket(app);
  8210. client->QueuePacket(app);
  8211. safe_delete(packet2);
  8212. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  8213. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  8214. packet2->setDataByName("flash_seconds", 10);
  8215. app = packet2->serialize();
  8216. DumpPacket(app);
  8217. client->QueuePacket(app);
  8218. safe_delete(packet2);
  8219. }
  8220. }
  8221. else if (atoi(sep->arg[0]) == 15) {
  8222. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8223. if (packet2) {
  8224. packet2->setArrayLengthByName("loot_count", 1);
  8225. packet2->setArrayDataByName("name", "Test");
  8226. packet2->setArrayDataByName("item_id", 1234);
  8227. packet2->setArrayDataByName("count", 1);
  8228. packet2->setArrayDataByName("icon", 258);
  8229. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  8230. Spawn* spawn = client->GetPlayer()->GetTarget();
  8231. if (spawn)
  8232. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8233. packet2->setDataByName("unknown3", 1);
  8234. packet2->setDataByName("unknown4", 1);
  8235. packet2->setDataByName("unknown5", 60);
  8236. EQ2Packet* app = packet2->serialize();
  8237. DumpPacket(app);
  8238. client->QueuePacket(app);
  8239. safe_delete(packet2);
  8240. }
  8241. }
  8242. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  8243. char blah[32];
  8244. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  8245. client->SimpleMessage(atoi(sep->arg[1]), blah);
  8246. }
  8247. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  8248. if (sep->IsSet(2)) {
  8249. int16 offset = atoi(sep->arg[1]);
  8250. if (sep->IsNumber(2)) {
  8251. int32 value1 = atol(sep->arg[2]);
  8252. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  8253. cout << "Sent" << endl;
  8254. }
  8255. }
  8256. }
  8257. else if (atoi(sep->arg[0]) == 18) {
  8258. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  8259. if (packet2) {
  8260. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8261. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8262. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8263. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8264. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8265. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  8266. Item* item = new Item(master_item_list.GetItem(36212));
  8267. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8268. item->stack_count = 20;
  8269. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8270. safe_delete(item);
  8271. item = new Item(master_item_list.GetItem(36685));
  8272. item->stack_count = 20;
  8273. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8274. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  8275. safe_delete(item);
  8276. item = master_item_list.GetItem(1414);
  8277. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8278. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  8279. item = master_item_list.GetItem(75057);
  8280. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8281. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  8282. EQ2Packet* app = packet2->serialize();
  8283. if (sep->IsSet(2)) {
  8284. int16 offset = atoi(sep->arg[1]);
  8285. uchar* ptr2 = app->pBuffer;
  8286. ptr2 += offset;
  8287. if (sep->IsNumber(2)) {
  8288. int32 value1 = atol(sep->arg[2]);
  8289. if (value1 > 0xFFFF)
  8290. memcpy(ptr2, (uchar*)&value1, 4);
  8291. else if (value1 > 0xFF)
  8292. memcpy(ptr2, (uchar*)&value1, 2);
  8293. else
  8294. memcpy(ptr2, (uchar*)&value1, 1);
  8295. }
  8296. else {
  8297. int16 len = strlen(sep->arg[2]);
  8298. memcpy(ptr2, (uchar*)&len, 2);
  8299. ptr2 += 2;
  8300. memcpy(ptr2, sep->arg[2], len);
  8301. }
  8302. }
  8303. DumpPacket(app);
  8304. client->QueuePacket(app);
  8305. safe_delete(packet2);
  8306. }
  8307. }
  8308. else if (atoi(sep->arg[0]) == 19) {
  8309. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8310. Spawn* spawn = client->GetPlayer()->GetTarget();
  8311. if (packet2 && spawn) {
  8312. Item* item = master_item_list.GetItem(130053);
  8313. packet2->setArrayLengthByName("loot_count", 1);
  8314. packet2->setArrayDataByName("loot_id", item->details.item_id);
  8315. packet2->setArrayDataByName("unknown2", 1);
  8316. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  8317. packet2->setDataByName("display", 1);
  8318. packet2->setDataByName("unknown2b", 1);
  8319. packet2->setDataByName("unknown3", 0x3c);
  8320. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8321. packet2->PrintPacket();
  8322. EQ2Packet* app = packet2->serialize();
  8323. if (sep->IsSet(2)) {
  8324. int16 offset = atoi(sep->arg[1]);
  8325. int16 offset2 = 0;
  8326. int32 value1 = 0;
  8327. if (sep->IsSet(3)) {
  8328. offset2 = atoi(sep->arg[2]);
  8329. value1 = atol(sep->arg[3]);
  8330. }
  8331. else
  8332. value1 = atol(sep->arg[2]);
  8333. int16 offset3 = 0;
  8334. int16 offset4 = 0;
  8335. int32 value2 = 0;
  8336. if (sep->IsSet(6)) {
  8337. offset3 = atoi(sep->arg[4]);
  8338. offset4 = atoi(sep->arg[5]);
  8339. value2 = atol(sep->arg[6]);
  8340. }
  8341. offset--;
  8342. if (offset2 > 0 && offset2 >= offset) {
  8343. offset2--;
  8344. uchar* ptr2 = app->pBuffer;
  8345. ptr2 += offset;
  8346. for (int i = offset; i <= offset2; i++) {
  8347. if (value1 > 0xFFFF) {
  8348. memcpy(ptr2, (uchar*)&value1, 4);
  8349. i += 3;
  8350. ptr2 += 3;
  8351. }
  8352. else if (value1 > 0xFF) {
  8353. memcpy(ptr2, (uchar*)&value1, 2);
  8354. i++;
  8355. ptr2++;
  8356. }
  8357. else
  8358. memcpy(ptr2, (uchar*)&value1, 1);
  8359. ptr2++;
  8360. }
  8361. }
  8362. if (offset4 > 0 && offset4 >= offset3) {
  8363. offset3--;
  8364. offset4--;
  8365. uchar* ptr2 = app->pBuffer;
  8366. ptr2 += offset3;
  8367. for (int i = offset3; i <= offset4; i++) {
  8368. if (value2 > 0xFFFF) {
  8369. memcpy(ptr2, (uchar*)&value2, 4);
  8370. i += 3;
  8371. ptr2 += 3;
  8372. }
  8373. else if (value2 > 0xFF) {
  8374. memcpy(ptr2, (uchar*)&value2, 2);
  8375. i++;
  8376. ptr2++;
  8377. }
  8378. else
  8379. memcpy(ptr2, (uchar*)&value2, 1);
  8380. ptr2++;
  8381. }
  8382. }
  8383. }
  8384. DumpPacket(app);
  8385. client->QueuePacket(app);
  8386. safe_delete(packet2);
  8387. }
  8388. }
  8389. else if (atoi(sep->arg[0]) == 20) {
  8390. uchar blah[] = { 0x09,0x01,0x00,0x00,0xff,0xc9,0x01,0x03,0x00,0x4d,0xf0,0x00,0x00,0x01
  8391. ,0x00,0x00,0x00,0x4d,0xf0,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd7
  8392. ,0x05,0x01,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
  8393. ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x0a,0x8c,0x5a,0xf1,0xd2,0x8c,0x5a,0xf1
  8394. ,0xd2,0x01,0x01,0x00,0xff,0x1e,0x00,0x01,0x03,0x03,0x00,0x00,0x00,0x03,0x07
  8395. ,0x07,0x00,0x10,0x74,0x68,0x72,0x65,0x61,0x64,0x62,0x61,0x72,0x65,0x20,0x74,0x75
  8396. ,0x6e,0x69,0x63,0x00,0x00,0x4e,0xf0,0x00,0x00,0x01,0x00,0x04,0x00,0x4e,0xf0,0x00
  8397. ,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0a,0x00,0x01,0x60,0x00,0x00,0x00
  8398. ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
  8399. ,0x00,0x64,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x03
  8400. ,0x00,0x00,0x00,0x05,0x04,0x04,0x00,0x00,0x00,0x00,0x09,0x73,0x6d,0x61,0x6c,0x6c
  8401. ,0x20,0x62,0x61,0x67,0x00,0x00,0x4f,0xf0,0x00,0x00,0x01,0x00,0x04,0x00,0x4f,0xf0
  8402. ,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x02,0x01,0x01,0x60,0x01,0x00
  8403. ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
  8404. ,0x00,0x00,0x64,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00
  8405. ,0x03,0x00,0x00,0x00,0x00,0x00,0x0c,0x57,0x61,0x75,0x6c,0x6f,0x6e,0x27,0x73,0x20
  8406. ,0x48,0x61,0x74,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x0d,0x00
  8407. ,0x00,0x00 };
  8408. EQ2Packet* app = new EQ2Packet(OP_ClientCmdMsg, blah, sizeof(blah));
  8409. if (sep->IsSet(2)) {
  8410. int16 offset = atoi(sep->arg[1]);
  8411. uchar* ptr2 = app->pBuffer;
  8412. ptr2 += offset;
  8413. if (sep->IsNumber(2)) {
  8414. int32 value1 = atol(sep->arg[2]);
  8415. if (value1 > 0xFFFF)
  8416. memcpy(ptr2, (uchar*)&value1, 4);
  8417. else if (value1 > 0xFF)
  8418. memcpy(ptr2, (uchar*)&value1, 2);
  8419. else
  8420. memcpy(ptr2, (uchar*)&value1, 1);
  8421. }
  8422. else {
  8423. int16 len = strlen(sep->arg[2]);
  8424. memcpy(ptr2, (uchar*)&len, 2);
  8425. ptr2 += 2;
  8426. memcpy(ptr2, sep->arg[2], len);
  8427. }
  8428. }
  8429. DumpPacket(app);
  8430. client->QueuePacket(app);
  8431. }
  8432. }
  8433. else if (atoi(sep->arg[0]) == 21) {
  8434. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8435. if (packet2) {
  8436. packet2->setDataByName("unknown0", 255);
  8437. packet2->setDataByName("reward", "New Quest");
  8438. packet2->setDataByName("title", "Title");
  8439. packet2->setDataByName("description", "description");
  8440. packet2->setDataByName("quest_difficulty", 3);
  8441. packet2->setDataByName("unknown1", 5);
  8442. packet2->setDataByName("level", 3);
  8443. packet2->setDataByName("coin", 150);
  8444. packet2->setDataByName("status_points", 5);
  8445. packet2->setDataByName("exp_bonus", 10);
  8446. packet2->setArrayLengthByName("num_rewards", 1);
  8447. Item* item = new Item(master_item_list.GetItem(36212));
  8448. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8449. item->stack_count = 20;
  8450. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8451. safe_delete(item);
  8452. char accept[35] = { 0 };
  8453. char decline[35] = { 0 };
  8454. sprintf(accept, "q_accept_pending_quest %u", 0);
  8455. sprintf(decline, "q_deny_pending_quest %u", 0);
  8456. packet2->setDataByName("accept_command", accept);
  8457. packet2->setDataByName("decline_command", decline);
  8458. EQ2Packet* app = packet2->serialize();
  8459. if (sep->IsSet(2)) {
  8460. int16 offset = atoi(sep->arg[1]);
  8461. uchar* ptr2 = app->pBuffer;
  8462. ptr2 += offset;
  8463. if (sep->IsNumber(2)) {
  8464. int32 value1 = atol(sep->arg[2]);
  8465. if (value1 > 0xFFFF)
  8466. memcpy(ptr2, (uchar*)&value1, 4);
  8467. else if (value1 > 0xFF)
  8468. memcpy(ptr2, (uchar*)&value1, 2);
  8469. else
  8470. memcpy(ptr2, (uchar*)&value1, 1);
  8471. }
  8472. else {
  8473. int16 len = strlen(sep->arg[2]);
  8474. memcpy(ptr2, (uchar*)&len, 2);
  8475. ptr2 += 2;
  8476. memcpy(ptr2, sep->arg[2], len);
  8477. }
  8478. }
  8479. DumpPacket(app);
  8480. client->QueuePacket(app);
  8481. safe_delete(packet2);
  8482. }
  8483. }
  8484. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  8485. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8486. if (packet2) {
  8487. packet2->setDataByName("unknown0", 255);
  8488. packet2->setDataByName("reward", "New Quest");
  8489. packet2->setDataByName("title", "Title");
  8490. packet2->setDataByName("description", "description");
  8491. packet2->setDataByName("quest_difficulty", 3);
  8492. packet2->setDataByName("unknown1", 5);
  8493. packet2->setDataByName("level", 3);
  8494. packet2->setDataByName("coin", 150);
  8495. packet2->setDataByName("status_points", 5);
  8496. packet2->setDataByName("exp_bonus", 10);
  8497. packet2->setArrayLengthByName("num_rewards", 1);
  8498. Item* item = new Item(master_item_list.GetItem(36212));
  8499. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8500. item->stack_count = 20;
  8501. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8502. safe_delete(item);
  8503. char accept[35] = { 0 };
  8504. char decline[35] = { 0 };
  8505. sprintf(accept, "q_accept_pending_quest %u", 0);
  8506. sprintf(decline, "q_deny_pending_quest %u", 0);
  8507. packet2->setDataByName("accept_command", accept);
  8508. packet2->setDataByName("decline_command", decline);
  8509. EQ2Packet* app = packet2->serialize();
  8510. if (sep->IsSet(2)) {
  8511. int16 offset = atoi(sep->arg[1]);
  8512. uchar* ptr2 = app->pBuffer;
  8513. ptr2 += offset;
  8514. if (sep->IsNumber(2)) {
  8515. int32 value1 = atol(sep->arg[2]);
  8516. if (value1 > 0xFFFF)
  8517. memcpy(ptr2, (uchar*)&value1, 4);
  8518. else if (value1 > 0xFF)
  8519. memcpy(ptr2, (uchar*)&value1, 2);
  8520. else
  8521. memcpy(ptr2, (uchar*)&value1, 1);
  8522. }
  8523. else {
  8524. int8 len = strlen(sep->arg[2]);
  8525. memcpy(ptr2, (uchar*)&len, 1);
  8526. ptr2 += 1;
  8527. memcpy(ptr2, sep->arg[2], len);
  8528. }
  8529. }
  8530. DumpPacket(app);
  8531. client->QueuePacket(app);
  8532. safe_delete(packet2);
  8533. }
  8534. }
  8535. else {
  8536. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  8537. if (packet2) {
  8538. packet2->setSubstructDataByName("info_header", "show_name", 1);
  8539. packet2->setSubstructDataByName("info_header", "unknown", 7);
  8540. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  8541. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  8542. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  8543. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  8544. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  8545. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  8546. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  8547. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  8548. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  8549. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  8550. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  8551. packet2->setSubstructDataByName("info_header", "packettype", 3);
  8552. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  8553. packet2->setSubstructDataByName("spell_info", "level", 19);
  8554. packet2->setSubstructDataByName("spell_info", "tier", 1);
  8555. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  8556. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  8557. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  8558. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  8559. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  8560. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  8561. packet2->setSubstructDataByName("spell_info", "recast", 280);
  8562. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  8563. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  8564. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  8565. packet2->setSubstructDataByName("spell_info", "quality", 3);
  8566. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  8567. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  8568. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  8569. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  8570. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  8571. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  8572. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  8573. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  8574. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  8575. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  8576. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  8577. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  8578. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  8579. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  8580. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  8581. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  8582. packet2->setArrayDataByName("reagent", "Alcohol");
  8583. packet2->setArrayDataByName("consumed", "123");
  8584. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  8585. packet2->setSubstructDataByName("spell_info", "id", 8308);
  8586. packet2->setSubstructDataByName("spell_info", "icon", 303);
  8587. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  8588. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  8589. packet2->setSubstructDataByName("spell_info", "type", 2);
  8590. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  8591. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  8592. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  8593. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  8594. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  8595. EQ2Packet* outapp = packet2->serialize();
  8596. DumpPacket(outapp);
  8597. client->QueuePacket(outapp);
  8598. safe_delete(packet2);
  8599. }
  8600. }
  8601. return;
  8602. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  8603. if (!p) return;
  8604. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8605. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  8606. //}
  8607. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8608. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  8609. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  8610. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  8611. if (packet) {
  8612. client->QueuePacket(packet->serialize());
  8613. safe_delete(packet);
  8614. }
  8615. }*/
  8616. /*if (client->GetCurrentZone()->Grid != nullptr) {
  8617. int32 numFaces = 0;
  8618. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  8619. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  8620. map<int32, vector<Face*> >::iterator itr;
  8621. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  8622. numFaces += (*itr).second.size();
  8623. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  8624. }*/
  8625. //uchar blah[] = {
  8626. // 1208 - OP_EQUpdateStoreCmd
  8627. // /*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
  8628. // /*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
  8629. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  8630. // /*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
  8631. /*};
  8632. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8633. int8 val = 0;
  8634. int16 pos = 0;
  8635. int idx = 0;
  8636. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  8637. pos = atoi(sep2->arg[idx]);
  8638. val = atoi(sep2->arg[idx+1]);
  8639. memset(blah+pos, val, 1);
  8640. idx+=2;
  8641. }
  8642. DumpPacket(blah, sizeof(blah));
  8643. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  8644. if (client->GetPlayer()->GetTarget()) {
  8645. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  8646. if (packet) {
  8647. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8648. packet->setDataByName("size", 0);
  8649. packet->setDataByName("unknown2", 0);
  8650. EQ2Packet* app = packet->serialize();
  8651. client->QueuePacket(app);
  8652. safe_delete(packet);
  8653. }
  8654. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  8655. if (set_pov) {
  8656. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8657. EQ2Packet* app_pov = set_pov->serialize();
  8658. client->QueuePacket(app_pov);
  8659. safe_delete(set_pov);
  8660. }
  8661. }
  8662. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8663. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  8664. if (packet) {
  8665. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  8666. packet->setDataByName("Type", atoi(sep2->arg[0]));
  8667. else
  8668. packet->setDataByName("Type", 2);
  8669. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  8670. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  8671. else
  8672. packet->setDataByName("race_id", 0);
  8673. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  8674. packet->setDataByName("gender", atoi(sep2->arg[2]));
  8675. else
  8676. packet->setDataByName("gender", 2);
  8677. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  8678. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  8679. else
  8680. packet->setDataByName("unknown", 0, 0);
  8681. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  8682. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  8683. else
  8684. packet->setDataByName("unknown", 0, 1);
  8685. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  8686. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  8687. else
  8688. packet->setDataByName("unknown", 0, 2);
  8689. client->QueuePacket(packet->serialize());
  8690. }
  8691. safe_delete(packet);
  8692. safe_delete(sep2);
  8693. }
  8694. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  8695. const char *channel_name;
  8696. if (sep == NULL || !sep->IsSet(0)) {
  8697. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  8698. PrintSep(sep);
  8699. return;
  8700. }
  8701. channel_name = sep->arg[0];
  8702. if (!chat.IsInChannel(client, channel_name))
  8703. client->Message(CHANNEL_COLOR_WHITE, "Unable to leave '%s': You are not in the channel.", channel_name);
  8704. else if (!chat.LeaveChannel(client, channel_name))
  8705. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  8706. }
  8707. /*
  8708. Function:
  8709. Purpose :
  8710. Params :
  8711. Dev :
  8712. Example :
  8713. */
  8714. void Commands::Command_WeaponStats(Client* client)
  8715. {
  8716. Player* player = client->GetPlayer();
  8717. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  8718. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  8719. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  8720. client->SimpleMessage(0, "Primary:");
  8721. if (primary) {
  8722. client->Message(0, "Name: %s", primary->name.c_str());
  8723. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  8724. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8725. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  8726. client->Message(0, "Proc Percent: %d%%", 0);
  8727. client->Message(0, "Procs Per Minute: %d", 0);
  8728. }
  8729. else {
  8730. client->SimpleMessage(0, "Name: fist");
  8731. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8732. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8733. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  8734. client->Message(0, "Proc Percent: %d%%", 0);
  8735. client->Message(0, "Procs Per Minute: %d", 0);
  8736. }
  8737. client->SimpleMessage(0, " ");
  8738. client->SimpleMessage(0, " ");
  8739. if (secondary) {
  8740. client->SimpleMessage(0, "Secondary:");
  8741. client->Message(0, "Name: %s", secondary->name.c_str());
  8742. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  8743. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  8744. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  8745. client->Message(0, "Proc Percent: %d%%", 0);
  8746. client->Message(0, "Procs Per Minute: %d", 0);
  8747. client->SimpleMessage(0, " ");
  8748. client->SimpleMessage(0, " ");
  8749. }
  8750. client->SimpleMessage(0, "Ranged:");
  8751. if (ranged) {
  8752. client->Message(0, "Name: %s", ranged->name.c_str());
  8753. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  8754. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  8755. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  8756. client->Message(0, "Proc Percent: %d%%", 0);
  8757. client->Message(0, "Procs Per Minute: %d", 0);
  8758. }
  8759. else
  8760. client->SimpleMessage(0, "None");
  8761. }
  8762. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  8763. const char *channel_name;
  8764. if (sep == NULL || !sep->IsSet(0)) {
  8765. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  8766. return;
  8767. }
  8768. channel_name = sep->arg[0];
  8769. if (!chat.ChannelExists(channel_name))
  8770. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  8771. else
  8772. chat.SendChannelUserList(client, channel_name);
  8773. }
  8774. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  8775. {
  8776. ZoneServer* zone = 0;
  8777. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  8778. if (zone_id > 0)
  8779. {
  8780. zone = zone_list.Get(zone_id, false);
  8781. if (zone)
  8782. {
  8783. zone->SetSafeX(client->GetPlayer()->GetX());
  8784. zone->SetSafeY(client->GetPlayer()->GetY());
  8785. zone->SetSafeZ(client->GetPlayer()->GetZ());
  8786. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  8787. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  8788. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  8789. else
  8790. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  8791. }
  8792. }
  8793. }
  8794. /*
  8795. Function:
  8796. Purpose :
  8797. Params :
  8798. Dev :
  8799. Example :
  8800. */
  8801. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  8802. {
  8803. ZoneInfo* zone_info = new ZoneInfo;
  8804. if (sep && sep->arg[0])
  8805. {
  8806. if (sep->IsNumber(0))
  8807. zone_info->id = atoi(sep->arg[0]);
  8808. else
  8809. zone_info->id = database.GetZoneID(sep->arg[0]);
  8810. if (zone_info->id > 0)
  8811. {
  8812. database.LoadZoneInfo(zone_info);
  8813. 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);
  8814. 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);
  8815. 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);
  8816. 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);
  8817. 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);
  8818. 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);
  8819. 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);
  8820. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  8821. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  8822. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  8823. }
  8824. else
  8825. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  8826. }
  8827. else
  8828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  8829. safe_delete(zone_info);
  8830. }
  8831. /*
  8832. Function:
  8833. Purpose :
  8834. Params :
  8835. Dev :
  8836. Example :
  8837. */
  8838. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  8839. {
  8840. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  8841. {
  8842. ZoneServer* zone = 0;
  8843. int32 zone_id = 0;
  8844. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  8845. {
  8846. zone_id = atoi(sep->arg[0]);
  8847. zone = zone_list.Get(atoi(sep->arg[0]), false);
  8848. }
  8849. else
  8850. {
  8851. zone_id = database.GetZoneID(sep->arg[0]);
  8852. if (zone_id > 0)
  8853. zone = zone_list.Get(sep->arg[0], false);
  8854. }
  8855. if (zone_id > 0)
  8856. {
  8857. if (zone_set_values.count(string(sep->arg[1])) > 0)
  8858. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  8859. else
  8860. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  8861. }
  8862. else
  8863. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  8864. }
  8865. else
  8866. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  8867. }
  8868. void Commands::Command_Rain(Client* client, Seperator* sep) {
  8869. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  8871. return;
  8872. }
  8873. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  8874. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  8875. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  8876. }
  8877. void Commands::Command_Wind(Client* client, Seperator* sep) {
  8878. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8879. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  8880. return;
  8881. }
  8882. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  8883. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  8884. }
  8885. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  8886. Spawn* spawn = client->GetPlayer()->GetTarget();
  8887. if(spawn) {
  8888. client->SetMerchantTransaction(spawn);
  8889. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  8890. client->SendHailCommand(spawn);
  8891. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  8892. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  8893. client->SendBuyMerchantList(sell);
  8894. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  8895. client->SendSellMerchantList(sell);
  8896. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  8897. client->SendBuyBackList(sell);
  8898. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  8899. if (packet) {
  8900. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  8901. packet->setDataByName("type", 16);
  8902. EQ2Packet* outapp = packet->serialize();
  8903. if (outapp)
  8904. client->QueuePacket(outapp);
  8905. safe_delete(packet);
  8906. }
  8907. }
  8908. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  8909. client->SendRepairList();
  8910. }
  8911. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  8912. }
  8913. void Commands::Command_Weather(Client* client, Seperator* sep)
  8914. {
  8915. //PrintSep(sep, "Weather");
  8916. if( sep && sep->arg[0] )
  8917. {
  8918. ZoneServer* zsZone = client->GetCurrentZone();
  8919. const char* value = sep->arg[0];
  8920. // process single-param commands first
  8921. if( strncasecmp(value, "details", strlen(value)) == 0 )
  8922. {
  8923. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  8924. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  8925. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  8926. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  8927. }
  8928. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  8929. {
  8930. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  8931. zsZone->ProcessWeather();
  8932. }
  8933. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  8934. {
  8935. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  8936. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  8937. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  8938. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  8939. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  8940. zsZone->SetWeatherPattern(1);
  8941. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  8942. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  8943. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  8944. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  8945. zsZone->ProcessWeather();
  8946. }
  8947. // process commands with params
  8948. if( sep->arg[1] )
  8949. {
  8950. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  8951. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  8952. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  8953. zsZone->SetWeatherType(atoi(sep->arg[1]));
  8954. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  8955. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  8956. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  8957. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  8958. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  8959. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  8960. }
  8961. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  8962. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  8963. zsZone->SetRain(zsZone->GetCurrentWeather());
  8964. }
  8965. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  8966. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  8967. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  8968. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  8969. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  8970. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  8971. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  8972. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  8973. }
  8974. }
  8975. else
  8976. {
  8977. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  8978. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  8979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  8980. return;
  8981. }
  8982. }
  8983. void Commands::Command_Select(Client* client, Seperator* sep) {
  8984. if (sep && sep->arg[1]) {
  8985. Spawn* spawn = client->GetPlayer()->GetTarget();
  8986. if (spawn && strlen(sep->arg[1]) > 0)
  8987. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  8988. }
  8989. }
  8990. /*
  8991. Function: Command_ConsumeFood()
  8992. Purpose : Consume Food/Drink and apply mods
  8993. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  8994. Dev : Zcoretri
  8995. Example : /consume_food 22
  8996. */
  8997. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  8998. if (sep && sep->arg[0] && sep->IsNumber(0))
  8999. {
  9000. Player* player = client->GetPlayer();
  9001. int8 slot = atoi(sep->arg[0]);
  9002. Item* item = player->GetEquipmentList()->GetItem(slot);
  9003. if(item) {
  9004. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  9005. if(item->GetItemScript() && lua_interface){
  9006. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  9007. if (slot == 22)
  9008. client->Message(CHANNEL_COLOR_WHITE, "You eat a %s.", item->name.c_str());
  9009. else
  9010. client->Message(CHANNEL_COLOR_WHITE, "You drink a %s.", item->name.c_str());
  9011. }
  9012. }
  9013. if (item->details.count > 1) {
  9014. item->details.count -= 1;
  9015. item->save_needed = true;
  9016. }
  9017. else {
  9018. player->GetEquipmentList()->RemoveItem(slot, true);
  9019. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  9020. }
  9021. client->GetPlayer()->SetCharSheetChanged(true);
  9022. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  9023. }
  9024. }
  9025. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  9026. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9027. if (atoi(sep->arg[0]) == 1) {
  9028. client->GetPlayer()->GetInfoStruct()->vision = 4;
  9029. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  9030. client->GetPlayer()->SetCharSheetChanged(true);
  9031. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  9032. }
  9033. else {
  9034. client->GetPlayer()->GetInfoStruct()->vision = 0;
  9035. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  9036. client->GetPlayer()->SetCharSheetChanged(true);
  9037. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  9038. }
  9039. }
  9040. else
  9041. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  9042. }
  9043. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  9044. {
  9045. if(sep)
  9046. {
  9047. string data;
  9048. if(sep->arg[0]){
  9049. data = string(sep->arg[0]);
  9050. }
  9051. for(int i=1;i<sep->GetMaxArgNum();i++){
  9052. if(sep->arg[i])
  9053. data.append(" ").append(sep->arg[i]);
  9054. }
  9055. const char* target_name = 0;
  9056. int32 spawn_id = 0;
  9057. if(client->GetPlayer()->GetTarget())
  9058. {
  9059. target_name = client->GetPlayer()->GetTarget()->GetName();
  9060. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9061. }
  9062. else
  9063. target_name = "N/A";
  9064. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  9065. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  9066. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  9067. else
  9068. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  9069. }
  9070. }
  9071. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  9072. PrintSep(sep, "Command_Attune_Inv");
  9073. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9074. // Get the item index from the first parameter
  9075. int16 index = atoi(sep->arg[0]);
  9076. // Check to see if this is a valid item index for the player, if not exit out of the function
  9077. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  9078. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  9079. return;
  9080. }
  9081. // Get the item
  9082. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  9083. if(item) {
  9084. // Valid item lets check to make sure this item is attunable, if not return out
  9085. if (!item->CheckFlag(ATTUNEABLE)) {
  9086. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  9087. return;
  9088. }
  9089. // Remove the attunable flag
  9090. item->generic_info.item_flags -= ATTUNEABLE;
  9091. // Set the attuned flag
  9092. item->generic_info.item_flags += ATTUNED;
  9093. // Flag this item for saving
  9094. item->save_needed = true;
  9095. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  9096. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  9097. EQ2Packet* outapp = 0;
  9098. for (int32 i=0;i<packets.size();i++) {
  9099. outapp = packets[i];
  9100. if(outapp)
  9101. client->QueuePacket(outapp);
  9102. }
  9103. }
  9104. }
  9105. }
  9106. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  9107. PrintSep(sep, "Command_Reset_Zone_Timer");
  9108. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9109. int32 db_id = atoul(sep->arg[0]);
  9110. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  9111. if (data) {
  9112. // TODO: add a check to timers to ensure it can be reset
  9113. // Delete the character from the instance
  9114. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  9115. data->instance_id = 0;
  9116. // Update the success time and set to 0 so the player can enter it again
  9117. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  9118. data->last_success_timestamp = 0;
  9119. }
  9120. }*/
  9121. }
  9122. void Commands::Command_Player(Client* client, Seperator* sep) {
  9123. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  9124. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  9125. }
  9126. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  9127. // /player coins add 10
  9128. // /player coins add plat 10
  9129. Player* player = client->GetPlayer();
  9130. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  9131. player = (Player*)player->GetTarget();
  9132. if (sep && sep->arg[0] && sep->arg[1]) {
  9133. const char* action = sep->arg[0];
  9134. int64 value = 0;
  9135. if (strncasecmp(action, "add", strlen(action)) == 0) {
  9136. if (sep->IsNumber(1)) {
  9137. value = atoi64(sep->arg[1]);
  9138. player->AddCoins(value);
  9139. if (client->GetPlayer() == player)
  9140. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9141. else {
  9142. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9143. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9144. }
  9145. return;
  9146. }
  9147. else if (sep->arg[2] && sep->IsNumber(2)) {
  9148. const char* type = sep->arg[1];
  9149. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  9150. value = atoi64(sep->arg[2]);
  9151. }
  9152. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  9153. value = atoi64(sep->arg[2]) * 100;
  9154. }
  9155. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  9156. value = atoi64(sep->arg[2]) * 10000;
  9157. }
  9158. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  9159. value = atoi64(sep->arg[2]) * 1000000;
  9160. }
  9161. player->AddCoins(value);
  9162. if (client->GetPlayer() == player)
  9163. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9164. else {
  9165. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9166. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9167. }
  9168. return;
  9169. }
  9170. }
  9171. }
  9172. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  9173. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  9174. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  9175. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  9176. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  9177. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  9178. }
  9179. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  9180. PrintSep(sep, "ACHIEVEMENT_ADD");
  9181. if (sep && sep->IsSet(0)) {
  9182. int32 spell_id = atoul(sep->arg[1]);
  9183. int8 spell_tier = 0;
  9184. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9185. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9186. // addspellbookentry here
  9187. if (spell_tier >= data->maxRank) {
  9188. return;
  9189. }
  9190. if (!spell_tier) {
  9191. spell_tier = 1;
  9192. }
  9193. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9194. {
  9195. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9196. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9197. client->GetPlayer()->UnlockSpell(spell);
  9198. client->SendSpellUpdate(spell);
  9199. }
  9200. else
  9201. {
  9202. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  9203. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9204. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9205. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9206. client->GetPlayer()->UnlockSpell(spell);
  9207. client->SendSpellUpdate(spell);
  9208. }
  9209. // cast spell here
  9210. if (!spell_tier)
  9211. spell_tier = 1;
  9212. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9213. if (spell) {
  9214. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9215. }
  9216. }
  9217. else {
  9218. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9219. }
  9220. master_aa_list.DisplayAA(client, 0, 0);
  9221. }
  9222. void Commands::Command_Editor(Client* client, Seperator* sep) {
  9223. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  9224. if (packet) {
  9225. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  9226. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  9227. char command[255];
  9228. url = "browser " + url;
  9229. int32 spawn_id = 0;
  9230. int32 zone_id = 0;
  9231. string type;
  9232. if (client->GetCurrentZone())
  9233. zone_id = client->GetCurrentZone()->GetZoneID();
  9234. if (client->GetPlayer()->GetTarget()) {
  9235. Spawn* target = client->GetPlayer()->GetTarget();
  9236. if (target->IsWidget())
  9237. type = "widgets";
  9238. else if (target->IsSign())
  9239. type = "signs";
  9240. else if (target->IsObject())
  9241. type = "objects";
  9242. else if (target->IsNPC())
  9243. type = "npcs";
  9244. else if (target->IsGroundSpawn())
  9245. type = "ground";
  9246. else
  9247. type = "spawn";
  9248. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9249. }
  9250. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  9251. packet->setDataByName("accept_command", command);
  9252. }
  9253. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  9254. char command[255];
  9255. url = "browser " + url;
  9256. if (client->GetPlayer()->GetTarget())
  9257. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  9258. packet->setDataByName("accept_command", command);
  9259. }
  9260. else {
  9261. string command = "browser " + url;
  9262. packet->setDataByName("accept_command", command.c_str());
  9263. }
  9264. packet->setDataByName("text", "Open the web editor?");
  9265. packet->setDataByName("accept_text", "Open");
  9266. packet->setDataByName("cancel_text", "Cancel");
  9267. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  9268. packet->setDataByName("unknown2", 50);
  9269. packet->setDataByName("unknown4", 1);
  9270. client->QueuePacket(packet->serialize());
  9271. safe_delete(packet);
  9272. }
  9273. }
  9274. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  9275. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9276. return;
  9277. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9278. if(client->GetCurrentRez()->active)
  9279. client->AcceptResurrection();
  9280. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9281. }
  9282. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  9283. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9284. return;
  9285. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9286. if(client->GetCurrentRez()->active)
  9287. client->GetCurrentRez()->should_delete = true;
  9288. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9289. }
  9290. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  9291. PrintSep(sep, "Switch_AA_Profile");
  9292. if (sep && sep->IsSet(0)) {
  9293. string type = sep->arg[0];
  9294. int8 newtemplate = atoul(sep->arg[1]);
  9295. master_aa_list.DisplayAA(client, newtemplate, 1);
  9296. }
  9297. }
  9298. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  9299. PrintSep(sep, "Get_AA_Xml");
  9300. if (sep && sep->IsSet(0)) {
  9301. string tabnum = sep->arg[0];
  9302. string spellid = sep->arg[1];
  9303. }
  9304. }
  9305. void Commands::Add_AA(Client* client, Seperator* sep) {
  9306. PrintSep(sep, "Add_AA");
  9307. if (sep && sep->IsSet(0)) {
  9308. int32 spell_id = atoul(sep->arg[1]);
  9309. int8 spell_tier = 0;
  9310. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9311. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9312. // addspellbookentry here
  9313. if (spell_tier >= data->maxRank) {
  9314. return;
  9315. }
  9316. if (!spell_tier) {
  9317. spell_tier = 1;
  9318. }
  9319. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9320. {
  9321. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9322. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9323. client->GetPlayer()->UnlockSpell(spell);
  9324. client->SendSpellUpdate(spell);
  9325. }
  9326. else
  9327. {
  9328. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  9329. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9330. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9331. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9332. client->GetPlayer()->UnlockSpell(spell);
  9333. client->SendSpellUpdate(spell);
  9334. }
  9335. // cast spell here
  9336. if (!spell_tier)
  9337. spell_tier = 1;
  9338. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9339. if (spell) {
  9340. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9341. }
  9342. }
  9343. else {
  9344. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9345. }
  9346. master_aa_list.DisplayAA(client, 0, 0);
  9347. }
  9348. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  9349. PrintSep(sep, "Commit_AA_Profile");
  9350. if (sep && sep->IsSet(0)) {
  9351. }
  9352. }
  9353. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  9354. PrintSep(sep, "Begin_AA_Profile");
  9355. if (sep && sep->IsSet(0)) {
  9356. master_aa_list.DisplayAA(client, 100, 2);
  9357. }
  9358. }
  9359. void Commands::Back_AA(Client* client, Seperator* sep) {
  9360. if (sep && sep->IsSet(0)) {
  9361. PrintSep(sep, "Back_AA");
  9362. }
  9363. }
  9364. void Commands::Remove_AA(Client* client, Seperator* sep) {
  9365. if (sep && sep->IsSet(0)) {
  9366. PrintSep(sep, "Remove_AA");
  9367. }
  9368. }
  9369. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  9370. MasterAAList master_aa_list;
  9371. PrintSep(sep, "Cancel_AA_Profile");
  9372. master_aa_list.DisplayAA(client, 0, 0);
  9373. }
  9374. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  9375. if (sep && sep->IsSet(0)) {
  9376. PrintSep(sep, "Save_AA_Profile");
  9377. }
  9378. }
  9379. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  9380. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  9381. if (!sep->IsNumber(0)) return;
  9382. int32 request_id = atoul(sep->arg[0]);
  9383. if (!sep->IsNumber(1)) return;
  9384. sint32 item_id = atoi(sep->arg[1]);
  9385. if (client->IsCurrentTransmuteID(request_id)) {
  9386. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  9387. }
  9388. else if (client->IsCurrentTransmuteID(item_id)) {
  9389. if (!sep->IsSet(2)) return;
  9390. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  9391. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  9392. }
  9393. }
  9394. }