Commands.cpp 311 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797
  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. extern WorldDatabase database;
  46. extern MasterSpellList master_spell_list;
  47. extern MasterTraitList master_trait_list;
  48. extern MasterRecipeList master_recipe_list;
  49. extern MasterRecipeBookList master_recipebook_list;
  50. extern World world;
  51. extern ClientList client_list;
  52. extern ConfigReader configReader;
  53. extern VisualStates visual_states;
  54. extern ZoneList zone_list;
  55. extern LuaInterface* lua_interface;
  56. extern MasterQuestList master_quest_list;
  57. extern MasterCollectionList master_collection_list;
  58. extern MasterSkillList master_skill_list;
  59. extern MasterFactionList master_faction_list;
  60. extern GuildList guild_list;
  61. extern MasterLanguagesList master_languages_list;
  62. extern IRC irc;
  63. extern Chat chat;
  64. extern RuleManager rule_manager;
  65. extern MasterAAList master_aa_list;
  66. extern MasterRaceTypeList race_types_list;
  67. extern Classes classes;
  68. EQ2Packet* RemoteCommands::serialize(){
  69. buffer.clear();
  70. vector<EQ2_RemoteCommandString>::iterator command_list;
  71. buffer.append((char*)&num_commands, sizeof(int16));
  72. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  73. AddDataCommand(&(*command_list));
  74. }
  75. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  76. return app;
  77. }
  78. Commands::Commands(){
  79. remote_commands = new RemoteCommands();
  80. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  81. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  82. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  83. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  84. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  85. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  86. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  87. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  88. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  89. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  90. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  91. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  92. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  93. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  94. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  95. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  96. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  97. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  98. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  99. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  100. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  101. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  102. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  103. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  104. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  105. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  106. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  107. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  108. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  109. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  110. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  111. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  112. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  113. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  114. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  115. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  116. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  117. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  118. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  119. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  120. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  121. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  122. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  123. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  124. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  125. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  126. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  127. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  128. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  129. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  130. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  131. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  132. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  133. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  134. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  135. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  136. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  137. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  138. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  139. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  140. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  141. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  142. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  143. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  144. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  145. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  146. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  147. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  148. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  149. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  150. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  151. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  152. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  153. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  154. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  155. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  156. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  157. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  158. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  159. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  160. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  161. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  162. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  163. }
  164. Commands::~Commands() {
  165. safe_delete(remote_commands);
  166. }
  167. int32 Commands::GetSpawnSetType(string val){
  168. if(spawn_set_values.count(val) > 0)
  169. return spawn_set_values[val];
  170. return 0xFFFFFFFF;
  171. }
  172. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  173. if(!target)
  174. return false;
  175. int32 val = 0;
  176. try{
  177. 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_LASTNAME))
  178. val = atoul(value);
  179. }
  180. catch(...){
  181. if(client)
  182. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  183. return false;
  184. }
  185. if(temporary && temp_value){
  186. char tmp[128] = {0};
  187. switch(type){
  188. case SPAWN_SET_VALUE_NAME:{
  189. sprintf(tmp, "%s", target->GetName());
  190. target->SetName(value);
  191. client->GetCurrentZone()->SendUpdateTitles(target);
  192. break;
  193. }
  194. case SPAWN_SET_VALUE_X_OFFSET:
  195. {
  196. sprintf(tmp, "%f", target->GetXOffset());
  197. target->SetXOffset(float(val));
  198. break;
  199. }
  200. case SPAWN_SET_VALUE_Y_OFFSET:
  201. {
  202. sprintf(tmp, "%f", target->GetYOffset());
  203. target->SetYOffset(float(val));
  204. break;
  205. }
  206. case SPAWN_SET_VALUE_Z_OFFSET:
  207. {
  208. sprintf(tmp, "%f", target->GetZOffset());
  209. target->SetZOffset(float(val));
  210. break;
  211. }
  212. case SPAWN_SET_VALUE_EXPIRE: {
  213. sprintf(tmp, "%u", target->GetExpireTime());
  214. target->SetExpireTime(val);
  215. break;
  216. }
  217. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  218. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  219. target->SetExpireOffsetTime(val);
  220. break;
  221. }
  222. case SPAWN_SET_VALUE_SUB_TITLE: {
  223. sprintf(tmp, "%s", target->GetSubTitle());
  224. target->SetSubTitle(value);
  225. client->GetCurrentZone()->SendUpdateTitles(target);
  226. break;
  227. }
  228. case SPAWN_SET_VALUE_LEVEL:{
  229. sprintf(tmp, "%i", target->GetLevel());
  230. target->SetLevel(val, send_update);
  231. break;
  232. }
  233. case SPAWN_SET_VALUE_DIFFICULTY:{
  234. sprintf(tmp, "%i", target->GetEncounterLevel());
  235. target->SetEncounterLevel(val, send_update);
  236. break;
  237. }
  238. case SPAWN_SET_VALUE_MODEL_TYPE:{
  239. sprintf(tmp, "%i", target->GetModelType());
  240. target->SetModelType(val, send_update);
  241. break;
  242. }
  243. case SPAWN_SET_VALUE_CLASS:{
  244. sprintf(tmp, "%i", target->GetAdventureClass());
  245. target->SetAdventureClass(val, send_update);
  246. break;
  247. }
  248. case SPAWN_SET_VALUE_GENDER:{
  249. sprintf(tmp, "%i", target->GetGender());
  250. target->SetGender(val, send_update);
  251. break;
  252. }
  253. case SPAWN_SET_VALUE_SHOW_NAME:{
  254. sprintf(tmp, "%i", target->GetShowName());
  255. target->SetShowName(val, send_update);
  256. break;
  257. }
  258. case SPAWN_SET_VALUE_ATTACKABLE:{
  259. sprintf(tmp, "%i", target->GetAttackable());
  260. target->SetAttackable(val, send_update);
  261. break;
  262. }
  263. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  264. sprintf(tmp, "%i", target->GetShowLevel());
  265. target->SetShowLevel(val, send_update);
  266. break;
  267. }
  268. case SPAWN_SET_VALUE_TARGETABLE:{
  269. sprintf(tmp, "%i", target->GetTargetable());
  270. target->SetTargetable(val, send_update);
  271. break;
  272. }
  273. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  274. sprintf(tmp, "%i", target->GetShowCommandIcon());
  275. target->SetShowCommandIcon(val, send_update);
  276. break;
  277. }
  278. case SPAWN_SET_VALUE_HAND_ICON:{
  279. sprintf(tmp, "%i", target->GetShowHandIcon());
  280. target->SetShowHandIcon(val, send_update);
  281. break;
  282. }
  283. case SPAWN_SET_VALUE_HAIR_TYPE:{
  284. if(target->IsEntity()){
  285. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  286. ((Entity*)target)->SetHairType(val, send_update);
  287. }
  288. break;
  289. }
  290. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  291. if(target->IsEntity()){
  292. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  293. ((Entity*)target)->SetHairType(val, send_update);
  294. }
  295. break;
  296. }
  297. case SPAWN_SET_VALUE_WING_TYPE:{
  298. if(target->IsEntity()){
  299. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  300. ((Entity*)target)->SetWingType(val, send_update);
  301. }
  302. break;
  303. }
  304. case SPAWN_SET_VALUE_CHEST_TYPE:{
  305. if(target->IsEntity()){
  306. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  307. ((Entity*)target)->SetChestType(val, send_update);
  308. }
  309. break;
  310. }
  311. case SPAWN_SET_VALUE_LEGS_TYPE:{
  312. if(target->IsEntity()){
  313. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  314. ((Entity*)target)->SetLegsType(val, send_update);
  315. }
  316. break;
  317. }
  318. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  319. if(target->IsEntity()){
  320. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  321. ((Entity*)target)->SetSogaHairType(val, send_update);
  322. }
  323. break;
  324. }
  325. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  326. if(target->IsEntity()){
  327. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  328. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  329. }
  330. break;
  331. }
  332. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  333. sprintf(tmp, "%i", target->GetSogaModelType());
  334. target->SetSogaModelType(val, send_update);
  335. break;
  336. }
  337. case SPAWN_SET_VALUE_SIZE:{
  338. sprintf(tmp, "%i", target->GetSize());
  339. target->SetSize(val, send_update);
  340. break;
  341. }
  342. case SPAWN_SET_VALUE_HP:{
  343. sprintf(tmp, "%i", target->GetHP());
  344. target->SetHP(val, send_update);
  345. break;
  346. }
  347. case SPAWN_SET_VALUE_POWER:{
  348. sprintf(tmp, "%i", target->GetPower());
  349. target->SetPower(val, send_update);
  350. break;
  351. }
  352. case SPAWN_SET_VALUE_HEROIC:{
  353. sprintf(tmp, "%i", target->GetHeroic());
  354. target->SetHeroic(val, send_update);
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_RESPAWN:{
  358. sprintf(tmp, "%u", target->GetRespawnTime());
  359. target->SetRespawnTime(val);
  360. break;
  361. }
  362. case SPAWN_SET_VALUE_X:{
  363. sprintf(tmp, "%f", target->GetX());
  364. target->SetX(atof(value), send_update);
  365. break;
  366. }
  367. case SPAWN_SET_VALUE_Y:{
  368. sprintf(tmp, "%f", target->GetY());
  369. target->SetY(atof(value), send_update);
  370. break;
  371. }
  372. case SPAWN_SET_VALUE_Z:{
  373. sprintf(tmp, "%f", target->GetZ());
  374. target->SetZ(atof(value), send_update);
  375. break;
  376. }
  377. case SPAWN_SET_VALUE_HEADING:{
  378. sprintf(tmp, "%f", target->GetHeading());
  379. target->SetHeading(atof(value) + 360, send_update);
  380. break;
  381. }
  382. case SPAWN_SET_VALUE_VISUAL_STATE:{
  383. sprintf(tmp, "%i", target->GetVisualState());
  384. target->SetVisualState(val, send_update);
  385. break;
  386. }
  387. case SPAWN_SET_VALUE_ACTION_STATE:{
  388. sprintf(tmp, "%i", target->GetActionState());
  389. target->SetActionState(val, send_update);
  390. break;
  391. }
  392. case SPAWN_SET_VALUE_MOOD_STATE:{
  393. sprintf(tmp, "%i", target->GetMoodState());
  394. target->SetMoodState(val, send_update);
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_INITIAL_STATE:{
  398. sprintf(tmp, "%i", target->GetInitialState());
  399. target->SetInitialState(val, send_update);
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  403. sprintf(tmp, "%i", target->GetActivityStatus());
  404. target->SetActivityStatus(val, send_update);
  405. break;
  406. }
  407. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  408. sprintf(tmp, "%i", target->GetCollisionRadius());
  409. target->SetCollisionRadius(val, send_update);
  410. break;
  411. }
  412. case SPAWN_SET_VALUE_DEVICE_ID: {
  413. if (target->IsObject()) {
  414. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  415. ((Object*)target)->SetDeviceID(val);
  416. }
  417. break;
  418. }
  419. case SPAWN_SET_VALUE_PITCH: {
  420. sprintf(tmp, "%f", target->GetPitch());
  421. target->SetPitch(atof(value), send_update);
  422. break;
  423. }
  424. case SPAWN_SET_VALUE_ROLL: {
  425. sprintf(tmp, "%f", target->GetRoll());
  426. target->SetRoll(atof(value), send_update);
  427. break;
  428. }
  429. case SPAWN_SET_VALUE_HIDE_HOOD: {
  430. sprintf(tmp, "%i", target->appearance.hide_hood);
  431. target->SetHideHood(val);
  432. break;
  433. }
  434. case SPAWN_SET_VALUE_EMOTE_STATE: {
  435. sprintf(tmp, "%i", target->appearance.emote_state);
  436. target->SetEmoteState(val);
  437. break;
  438. }
  439. case SPAWN_SET_VALUE_ICON: {
  440. sprintf(tmp, "%i", target->GetIconValue());
  441. target->SetIcon(val);
  442. break;
  443. }
  444. case SPAWN_SET_VALUE_PREFIX: {
  445. sprintf(tmp, "%s", target->GetPrefixTitle());
  446. target->SetPrefixTitle(value);
  447. client->GetCurrentZone()->SendUpdateTitles(target);
  448. break;
  449. }
  450. case SPAWN_SET_VALUE_SUFFIX: {
  451. sprintf(tmp, "%s", target->GetSuffixTitle());
  452. target->SetSuffixTitle(value);
  453. client->GetCurrentZone()->SendUpdateTitles(target);
  454. break;
  455. }
  456. case SPAWN_SET_VALUE_LASTNAME: {
  457. sprintf(tmp, "%s", target->GetLastName());
  458. target->SetLastName(value);
  459. client->GetCurrentZone()->SendUpdateTitles(target);
  460. break;
  461. }
  462. *temp_value = string(tmp);
  463. }
  464. }
  465. else{
  466. switch(type){
  467. case SPAWN_SET_VALUE_NAME:{
  468. target->SetName(value);
  469. client->GetCurrentZone()->SendUpdateTitles(target);
  470. break;
  471. }
  472. case SPAWN_SET_VALUE_SUB_TITLE: {
  473. target->SetSubTitle(value);
  474. client->GetCurrentZone()->SendUpdateTitles(target);
  475. break;
  476. }
  477. case SPAWN_SET_VALUE_X_OFFSET:
  478. {
  479. target->SetXOffset(atof(value));
  480. break;
  481. }
  482. case SPAWN_SET_VALUE_Y_OFFSET:
  483. {
  484. target->SetYOffset(atof(value));
  485. break;
  486. }
  487. case SPAWN_SET_VALUE_Z_OFFSET:
  488. {
  489. target->SetZOffset(atof(value));
  490. break;
  491. }
  492. case SPAWN_SET_VALUE_EXPIRE: {
  493. target->SetExpireTime(val);
  494. break;
  495. }
  496. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  497. target->SetExpireOffsetTime(val);
  498. break;
  499. }
  500. case SPAWN_SET_VALUE_LEVEL:{
  501. target->SetLevel(val, send_update);
  502. break;
  503. }
  504. case SPAWN_SET_VALUE_DIFFICULTY:{
  505. target->SetEncounterLevel(val, send_update);
  506. break;
  507. }
  508. case SPAWN_SET_VALUE_MODEL_TYPE:{
  509. target->SetModelType(val, send_update);
  510. break;
  511. }
  512. case SPAWN_SET_VALUE_CLASS:{
  513. target->SetAdventureClass(val, send_update);
  514. break;
  515. }
  516. case SPAWN_SET_VALUE_GENDER:{
  517. target->SetGender(val, send_update);
  518. break;
  519. }
  520. case SPAWN_SET_VALUE_SHOW_NAME:{
  521. target->SetShowName(val, send_update);
  522. break;
  523. }
  524. case SPAWN_SET_VALUE_ATTACKABLE:{
  525. target->SetAttackable(val, send_update);
  526. break;
  527. }
  528. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  529. target->SetShowLevel(val, send_update);
  530. break;
  531. }
  532. case SPAWN_SET_VALUE_TARGETABLE:{
  533. target->SetTargetable(val, send_update);
  534. break;
  535. }
  536. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  537. target->SetShowCommandIcon(val, send_update);
  538. break;
  539. }
  540. case SPAWN_SET_VALUE_HAND_ICON:{
  541. target->SetShowHandIcon(val, send_update);
  542. break;
  543. }
  544. case SPAWN_SET_VALUE_HAIR_TYPE:{
  545. if(target->IsEntity())
  546. ((Entity*)target)->SetHairType(val, send_update);
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  550. if(target->IsEntity())
  551. ((Entity*)target)->SetHairType(val, send_update);
  552. break;
  553. }
  554. case SPAWN_SET_VALUE_WING_TYPE:{
  555. if(target->IsEntity())
  556. ((Entity*)target)->SetWingType(val, send_update);
  557. break;
  558. }
  559. case SPAWN_SET_VALUE_CHEST_TYPE:{
  560. if(target->IsEntity())
  561. ((Entity*)target)->SetChestType(val, send_update);
  562. break;
  563. }
  564. case SPAWN_SET_VALUE_LEGS_TYPE:{
  565. if(target->IsEntity())
  566. ((Entity*)target)->SetLegsType(val, send_update);
  567. break;
  568. }
  569. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  570. if(target->IsEntity())
  571. ((Entity*)target)->SetSogaHairType(val, send_update);
  572. break;
  573. }
  574. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  575. if(target->IsEntity())
  576. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  577. break;
  578. }
  579. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  580. target->SetSogaModelType(val, send_update);
  581. break;
  582. }
  583. case SPAWN_SET_VALUE_SIZE:{
  584. target->SetSize(val, send_update);
  585. break;
  586. }
  587. case SPAWN_SET_VALUE_HP:{
  588. target->SetHP(val, send_update);
  589. break;
  590. }
  591. case SPAWN_SET_VALUE_POWER:{
  592. target->SetPower(val, send_update);
  593. break;
  594. }
  595. case SPAWN_SET_VALUE_HEROIC:{
  596. target->SetHeroic(val, send_update);
  597. break;
  598. }
  599. case SPAWN_SET_VALUE_RESPAWN:{
  600. target->SetRespawnTime(val);
  601. break;
  602. }
  603. case SPAWN_SET_VALUE_X:{
  604. target->SetX(atof(value), send_update);
  605. target->SetSpawnOrigX(target->GetX());
  606. break;
  607. }
  608. case SPAWN_SET_VALUE_Y:{
  609. target->SetY(atof(value), send_update);
  610. target->SetSpawnOrigY(target->GetY());
  611. break;
  612. }
  613. case SPAWN_SET_VALUE_Z:{
  614. target->SetZ(atof(value), send_update);
  615. target->SetSpawnOrigZ(target->GetZ());
  616. break;
  617. }
  618. case SPAWN_SET_VALUE_HEADING:{
  619. target->SetHeading(atof(value), send_update);
  620. target->SetSpawnOrigHeading(target->GetHeading());
  621. break;
  622. }
  623. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  624. ZoneServer* zone = target->GetZone();
  625. if (!zone)
  626. zone = client->GetCurrentZone();
  627. if(zone->GetEntityCommandList(val))
  628. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  629. target->primary_command_list_id = val;
  630. break;
  631. }
  632. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  633. ZoneServer* zone = target->GetZone();
  634. if (!zone)
  635. zone = client->GetCurrentZone();
  636. if (zone->GetEntityCommandList(val))
  637. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  638. target->secondary_command_list_id = val;
  639. break;
  640. }
  641. case SPAWN_SET_VALUE_VISUAL_STATE:{
  642. target->SetVisualState(val, send_update);
  643. break;
  644. }
  645. case SPAWN_SET_VALUE_ACTION_STATE:{
  646. target->SetActionState(val, send_update);
  647. break;
  648. }
  649. case SPAWN_SET_VALUE_MOOD_STATE:{
  650. target->SetMoodState(val, send_update);
  651. break;
  652. }
  653. case SPAWN_SET_VALUE_INITIAL_STATE:{
  654. target->SetInitialState(val, send_update);
  655. break;
  656. }
  657. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  658. target->SetActivityStatus(val, send_update);
  659. break;
  660. }
  661. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  662. target->SetCollisionRadius(val, send_update);
  663. break;
  664. }
  665. case SPAWN_SET_VALUE_FACTION:{
  666. ZoneServer* zone = target->GetZone();
  667. if (!zone)
  668. zone = client->GetCurrentZone();
  669. target->faction_id = val;
  670. zone->RemoveDeadEnemyList(target);
  671. if(target->IsNPC())
  672. zone->AddEnemyList((NPC*)target);
  673. break;
  674. }
  675. case SPAWN_SET_VALUE_DEVICE_ID:{
  676. if (target->IsObject())
  677. ((Object*)target)->SetDeviceID(val);
  678. break;
  679. }
  680. case SPAWN_SET_VALUE_PITCH: {
  681. target->SetPitch(atof(value), send_update);
  682. target->SetSpawnOrigPitch(atof(value));
  683. break;
  684. }
  685. case SPAWN_SET_VALUE_ROLL: {
  686. target->SetRoll(atof(value), send_update);
  687. target->SetSpawnOrigRoll(atof(value));
  688. break;
  689. }
  690. case SPAWN_SET_VALUE_HIDE_HOOD: {
  691. target->SetHideHood(val);
  692. break;
  693. }
  694. case SPAWN_SET_VALUE_EMOTE_STATE: {
  695. target->SetEmoteState(val);
  696. break;
  697. }
  698. case SPAWN_SET_VALUE_ICON: {
  699. target->SetIcon(val);
  700. break;
  701. }
  702. case SPAWN_SET_VALUE_PREFIX: {
  703. target->SetPrefixTitle(value);
  704. client->GetCurrentZone()->SendUpdateTitles(target);
  705. break;
  706. }
  707. case SPAWN_SET_VALUE_SUFFIX: {
  708. target->SetSuffixTitle(value);
  709. client->GetCurrentZone()->SendUpdateTitles(target);
  710. break;
  711. }
  712. case SPAWN_SET_VALUE_LASTNAME: {
  713. target->SetLastName(value);
  714. client->GetCurrentZone()->SendUpdateTitles(target);
  715. break;
  716. }
  717. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  718. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  719. if(client){
  720. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  721. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  722. }
  723. return false;
  724. }
  725. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  726. return false;
  727. else{
  728. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  729. target->SetSpawnScript(value);
  730. }
  731. break;
  732. }
  733. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  734. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  735. if(client){
  736. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  737. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  738. }
  739. return false;
  740. }
  741. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  742. return false;
  743. else{
  744. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  745. target->SetSpawnScript(value);
  746. }
  747. break;
  748. }
  749. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  750. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  751. if(client){
  752. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  753. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  754. }
  755. return false;
  756. }
  757. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  758. return false;
  759. else
  760. target->SetSpawnScript(value);
  761. break;
  762. }
  763. }
  764. }
  765. return true;
  766. }
  767. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  768. the database fields always and also update the zone in memory if it's running. */
  769. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  770. if (client && zone_id > 0 && type > 0 && value) {
  771. sint32 int_value = 0;
  772. float float_value = 0;
  773. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  774. try {
  775. float_value = atof(value);
  776. }
  777. catch (...) {
  778. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  779. return false;
  780. }
  781. }
  782. 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) {
  783. try {
  784. int_value = atoi(value);
  785. }
  786. catch (...) {
  787. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  788. return false;
  789. }
  790. }
  791. switch (type) {
  792. case ZONE_SET_VALUE_EXPANSION_ID: {
  793. break;
  794. }
  795. case ZONE_SET_VALUE_NAME: {
  796. if (zone)
  797. zone->SetZoneName(const_cast<char*>(value));
  798. database.SaveZoneInfo(zone_id, "name", value);
  799. break;
  800. }
  801. case ZONE_SET_VALUE_FILE: {
  802. if (zone)
  803. zone->SetZoneFile(const_cast<char*>(value));
  804. database.SaveZoneInfo(zone_id, "file", value);
  805. break;
  806. }
  807. case ZONE_SET_VALUE_DESCRIPTION: {
  808. if (zone)
  809. zone->SetZoneDescription(const_cast<char*>(value));
  810. database.SaveZoneInfo(zone_id, "description", value);
  811. break;
  812. }
  813. case ZONE_SET_VALUE_SAFE_X: {
  814. if (zone)
  815. zone->SetSafeX(float_value);
  816. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  817. break;
  818. }
  819. case ZONE_SET_VALUE_SAFE_Y: {
  820. if (zone)
  821. zone->SetSafeY(float_value);
  822. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  823. break;
  824. }
  825. case ZONE_SET_VALUE_SAFE_Z: {
  826. if (zone)
  827. zone->SetSafeZ(float_value);
  828. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  829. break;
  830. }
  831. case ZONE_SET_VALUE_UNDERWORLD: {
  832. if (zone)
  833. zone->SetUnderWorld(float_value);
  834. database.SaveZoneInfo(zone_id, "underworld", float_value);
  835. break;
  836. }
  837. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  838. break;
  839. }
  840. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  841. break;
  842. }
  843. case ZONE_SET_VALUE_ZONE_TYPE: {
  844. break;
  845. }
  846. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  847. if (zone)
  848. zone->SetAlwaysLoaded(int_value == 1);
  849. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  850. break;
  851. }
  852. case ZONE_SET_VALUE_CITY_ZONE: {
  853. if (zone)
  854. zone->SetCityZone(int_value == 1);
  855. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  856. break;
  857. }
  858. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  859. if (zone)
  860. zone->SetWeatherAllowed(int_value == 1);
  861. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  862. break;
  863. }
  864. case ZONE_SET_VALUE_MIN_STATUS: {
  865. if (zone)
  866. zone->SetMinimumStatus(int_value);
  867. database.SaveZoneInfo(zone_id, "min_status", int_value);
  868. break;
  869. }
  870. case ZONE_SET_VALUE_MIN_LEVEL: {
  871. if (zone)
  872. zone->SetMinimumLevel(int_value);
  873. database.SaveZoneInfo(zone_id, "min_level", int_value);
  874. break;
  875. }
  876. case ZONE_SET_VALUE_MAX_LEVEL: {
  877. if (zone)
  878. zone->SetMaximumLevel(int_value);
  879. database.SaveZoneInfo(zone_id, "max_level", int_value);
  880. break;
  881. }
  882. case ZONE_SET_VALUE_START_ZONE: {
  883. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  884. break;
  885. }
  886. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  887. if (zone)
  888. zone->SetInstanceType(int_value);
  889. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  890. break;
  891. }
  892. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  893. if (zone)
  894. zone->SetDefaultReenterTime(int_value);
  895. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  896. break;
  897. }
  898. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  899. if (zone)
  900. zone->SetDefaultResetTime(int_value);
  901. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  902. break;
  903. }
  904. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  905. if (zone)
  906. zone->SetDefaultLockoutTime(int_value);
  907. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  908. break;
  909. }
  910. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  911. if (zone)
  912. zone->SetForceGroupZoneOption(int_value);
  913. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  914. break;
  915. }
  916. case ZONE_SET_VALUE_LUA_SCRIPT: {
  917. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  918. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  919. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  920. return false;
  921. }
  922. else {
  923. world.AddZoneScript(zone_id, const_cast<char*>(value));
  924. database.SaveZoneInfo(zone_id, "lua_script", value);
  925. }
  926. break;
  927. }
  928. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  929. if (zone)
  930. zone->SetShutdownTimer(int_value);
  931. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  932. break;
  933. }
  934. case ZONE_SET_VALUE_ZONE_MOTD: {
  935. if (zone)
  936. zone->SetZoneMOTD(string(value));
  937. database.SaveZoneInfo(zone_id, "zone_motd", value);
  938. break;
  939. }
  940. default: {
  941. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  942. return false;
  943. }
  944. }
  945. }
  946. else {
  947. if (client)
  948. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  949. return false;
  950. }
  951. return true;
  952. }
  953. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  954. if (index >= remote_commands->commands.size()) {
  955. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  956. return;
  957. }
  958. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  959. EQ2_RemoteCommandString* parent_command = 0;
  960. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  961. Seperator* sep = 0;
  962. if (command_parms->size > 0) {
  963. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  964. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  965. parent_command = command;
  966. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  967. safe_delete(sep);
  968. if (command_parms->data.length() > (command->command.data.length() + 1))
  969. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  970. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  971. }
  972. else
  973. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  974. }
  975. int ndx = 0;
  976. if (command->required_status > client->GetAdminStatus())
  977. {
  978. 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());
  979. safe_delete(sep);
  980. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  981. return;
  982. }
  983. Player* player = client->GetPlayer();
  984. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  985. switch (command->handler) {
  986. case COMMAND_RELOAD: {
  987. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  988. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  989. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  990. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  991. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  992. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  994. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  996. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  997. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  998. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  999. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1000. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1001. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1002. break;
  1003. }
  1004. case COMMAND_RELOADSTRUCTS: {
  1005. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1006. configReader.ReloadStructs();
  1007. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1008. break;
  1009. }
  1010. case COMMAND_RELOAD_QUESTS: {
  1011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1012. master_quest_list.Reload();
  1013. client_list.ReloadQuests();
  1014. zone_list.ReloadClientQuests();
  1015. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1016. break;
  1017. }
  1018. case COMMAND_RELOAD_SPAWNS: {
  1019. client->GetCurrentZone()->ReloadSpawns();
  1020. break;
  1021. }
  1022. case COMMAND_RELOAD_SPELLS: {
  1023. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1024. zone_list.DeleteSpellProcess();
  1025. master_spell_list.Reload();
  1026. if (lua_interface)
  1027. lua_interface->ReloadSpells();
  1028. zone_list.LoadSpellProcess();
  1029. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1030. break;
  1031. }
  1032. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1033. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1034. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1035. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1036. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1037. break;
  1038. }
  1039. case COMMAND_RELOAD_ZONESCRIPTS: {
  1040. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1041. world.ResetZoneScripts();
  1042. database.LoadZoneScriptData();
  1043. if (lua_interface)
  1044. lua_interface->DestroyZoneScripts();
  1045. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1046. break;
  1047. }
  1048. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1049. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1050. client->GetCurrentZone()->ClearEntityCommands();
  1051. database.LoadEntityCommands(client->GetCurrentZone());
  1052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1053. break;
  1054. }
  1055. case COMMAND_RELOAD_FACTIONS: {
  1056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1057. master_faction_list.Clear();
  1058. database.LoadFactionList();
  1059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1060. break;
  1061. }
  1062. case COMMAND_RELOAD_MAIL: {
  1063. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1064. zone_list.ReloadMail();
  1065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1066. break;
  1067. }
  1068. case COMMAND_RELOAD_GUILDS: {
  1069. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1070. world.ReloadGuilds();
  1071. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1072. break;
  1073. }
  1074. case COMMAND_RELOAD_LOCATIONS: {
  1075. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1076. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1077. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1078. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1079. break;
  1080. }
  1081. case COMMAND_READ: {
  1082. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1083. if (strcmp(sep->arg[0], "read") == 0) {
  1084. int32 item_index = atol(sep->arg[1]);
  1085. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1086. if (item) {
  1087. Spawn* spawn = cmdTarget;
  1088. int8 numpages = item->book_pages.size();
  1089. string page1 = string(item->book_pages[0]->page_text.data);
  1090. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  1091. string title = item->name;
  1092. if (packet) {
  1093. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  1094. packet->setDataByName("book_title", title.c_str());
  1095. packet->setDataByName("book_type", "simple");
  1096. packet->setDataByName("unknown2", 1);
  1097. packet->setDataByName("unknown5", 1, 4);
  1098. packet->setArrayLengthByName("num_pages", numpages);
  1099. for (int8 pages = 1; pages <= numpages; pages++) {
  1100. int8 pagenum = int8(item->book_pages[pages - 1]->page);
  1101. string page = string(item->book_pages[pages-1]->page_text.data);
  1102. int8 valign = int8(item->book_pages[pages - 1]->valign);
  1103. int8 halign = int8(item->book_pages[pages - 1]->halign);
  1104. packet->setArrayDataByName("page_text", page.c_str(), pagenum -1);
  1105. packet->setArrayDataByName("page_text_valign", valign , pagenum - 1);
  1106. packet->setArrayDataByName("page_text_halign", halign, pagenum - 1);
  1107. // Need to add support for images
  1108. }
  1109. client->QueuePacket(packet->serialize());
  1110. safe_delete(packet);
  1111. }
  1112. break;
  1113. }
  1114. }
  1115. }
  1116. }
  1117. case COMMAND_USEABILITY:{
  1118. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1119. if (client->GetPlayer()->GetHP() == 0) {
  1120. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1121. }
  1122. else {
  1123. int32 spell_id = atoul(sep->arg[0]);
  1124. int8 spell_tier = 0;
  1125. if (sep->arg[1][0] && sep->IsNumber(1))
  1126. spell_tier = atoi(sep->arg[1]);
  1127. else
  1128. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1129. if (!spell_tier)
  1130. spell_tier = 1;
  1131. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1132. if (spell) {
  1133. 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)
  1134. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1135. else
  1136. {
  1137. if (cmdTarget)
  1138. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1139. else
  1140. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1141. }
  1142. }
  1143. }
  1144. }
  1145. else if (cmdTarget && cmdTarget->IsWidget())
  1146. {
  1147. Widget* widget = (Widget*)cmdTarget;
  1148. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1149. }
  1150. else
  1151. {
  1152. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1153. }
  1154. break;
  1155. }
  1156. case COMMAND_INFO:{
  1157. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1158. if(strcmp(sep->arg[0], "inventory") == 0){
  1159. int32 item_index = atol(sep->arg[1]);
  1160. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1161. if(item){
  1162. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1163. break;
  1164. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1165. //DumpPacket(app);
  1166. client->QueuePacket(app);
  1167. if(item->GetItemScript() && lua_interface)
  1168. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1169. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1170. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id);
  1171. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1172. client->AddPendingQuest(quest);
  1173. }
  1174. }
  1175. else
  1176. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1177. }
  1178. else if(strcmp(sep->arg[0], "equipment") == 0){
  1179. int32 item_index = atol(sep->arg[1]);
  1180. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1181. if(item){
  1182. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1183. client->QueuePacket(app);
  1184. if(item->GetItemScript() && lua_interface)
  1185. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1186. }
  1187. else
  1188. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1189. }
  1190. 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){
  1191. int32 item_id = atoul(sep->arg[1]);
  1192. Item* item = master_item_list.GetItem(item_id);
  1193. if(item){
  1194. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1195. client->QueuePacket(app);
  1196. }
  1197. else
  1198. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1199. }
  1200. else if (strcmp(sep->arg[0], "spell") == 0) {
  1201. sint32 spell_id = atol(sep->arg[1]);
  1202. int8 tier = atoi(sep->arg[3]);
  1203. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1204. if (outapp)
  1205. client->QueuePacket(outapp);
  1206. else
  1207. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1208. }
  1209. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1210. sint32 spell_id = atol(sep->arg[2]);
  1211. int8 group = atoi(sep->arg[1]);
  1212. AltAdvanceData* data = 0;
  1213. SpellBookEntry* spellentry = 0;
  1214. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1215. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1216. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1217. if (outapp)
  1218. client->QueuePacket(outapp);
  1219. else
  1220. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1221. }
  1222. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1223. sint32 spell_id = atol(sep->arg[1]);
  1224. int8 tier = atoi(sep->arg[2]);
  1225. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1226. if (outapp)
  1227. client->QueuePacket(outapp);
  1228. else
  1229. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1230. }
  1231. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1232. sint32 recipe_id = atol(sep->arg[1]);
  1233. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1234. if(outapp)
  1235. client->QueuePacket(outapp);
  1236. else
  1237. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1238. }
  1239. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1240. int32 slot = atol(sep->arg[1]);
  1241. int32 spell_id = atol(sep->arg[2]);
  1242. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1243. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1244. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1245. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1246. if(outapp)
  1247. client->QueuePacket(outapp);
  1248. else
  1249. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1250. }
  1251. else if (strcmp(sep->arg[0], "effect") == 0) {
  1252. int32 spell_id = atol(sep->arg[1]);
  1253. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1254. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1255. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, 0x00);
  1256. if (outapp){
  1257. client->QueuePacket(outapp);
  1258. }
  1259. else
  1260. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1261. }
  1262. }
  1263. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1264. Item* item = player->item_list.GetOverflowItem();
  1265. if(item) {
  1266. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1267. client->QueuePacket(app);
  1268. }
  1269. else
  1270. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1271. }
  1272. else
  1273. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1274. break;
  1275. }
  1276. case COMMAND_USE_EQUIPPED_ITEM:{
  1277. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1278. int32 slot_id = atoul(sep->arg[0]);
  1279. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1280. if (item && item->generic_info.usable && item->GetItemScript())
  1281. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1282. }
  1283. break;
  1284. }
  1285. case COMMAND_USE_ITEM: {
  1286. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1287. int32 item_index = atoul(sep->arg[0]);
  1288. Item* item = player->item_list.GetItemFromIndex(item_index);
  1289. if (item && item->GetItemScript()) {
  1290. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1291. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1292. else {
  1293. if (item->generic_info.display_charges > 0) {
  1294. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1295. item->generic_info.display_charges -= 1;
  1296. item->save_needed = true;
  1297. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1298. }
  1299. }
  1300. }
  1301. }
  1302. break;
  1303. }
  1304. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1305. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1306. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1307. if (item) {
  1308. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1309. if(item->generic_info.item_type == 6) {
  1310. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1311. int8 old_slot = 0;
  1312. if (spell) {
  1313. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1314. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1315. player->RemoveSpellBookEntry(spell->GetSpellID());
  1316. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1317. player->UnlockSpell(spell);
  1318. client->SendSpellUpdate(spell);
  1319. database.DeleteItem(client->GetCharacterID(), item, 0);
  1320. player->item_list.RemoveItem(item, true);
  1321. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1322. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1323. }
  1324. }
  1325. else
  1326. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1327. }
  1328. else if(item->generic_info.item_type == 7){
  1329. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1330. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1331. // if valid recipe book and the player doesn't have it
  1332. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1333. client->Message(CHANNEL_COLOR_WHITE, "Your tradeskill level is not high enough to scribe this book.");
  1334. safe_delete(recipe_book);
  1335. }
  1336. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1337. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1338. // Add recipe book to the players list
  1339. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1340. // Get a list of all recipes this book contains
  1341. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1342. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1343. // Create the packet to send to update the players recipe list
  1344. PacketStruct* packet = 0;
  1345. if (client->GetRecipeListSent()) {
  1346. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1347. if (packet)
  1348. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1349. }
  1350. // loop through the list
  1351. vector<Recipe*>::iterator itr;
  1352. int16 i = 0;
  1353. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1354. // check to see if the player already has this recipe some how
  1355. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1356. // Player doesn't already have this recipe so lets add it
  1357. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1358. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1359. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1360. client->Message(CHANNEL_COLOR_WHITE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1361. if (packet && client->GetRecipeListSent()) {
  1362. packet->setArrayDataByName("id", recipe->GetID(), i);
  1363. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1364. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1365. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1366. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1367. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1368. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1369. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1370. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1371. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1372. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1373. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1374. i++;
  1375. }
  1376. }
  1377. }
  1378. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1379. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1380. database.DeleteItem(client->GetCharacterID(), item, 0);
  1381. client->GetPlayer()->item_list.RemoveItem(item, true);
  1382. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1383. if (packet && client->GetRecipeListSent())
  1384. client->QueuePacket(packet->serialize());
  1385. safe_delete(packet);
  1386. }
  1387. else {
  1388. if (recipe_book)
  1389. client->Message(CHANNEL_COLOR_WHITE, "You have already learned all you can from this item.");
  1390. safe_delete(recipe_book);
  1391. }
  1392. }
  1393. }
  1394. else
  1395. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1396. }
  1397. break;
  1398. }
  1399. case COMMAND_SUMMONITEM: {
  1400. if (sep && sep->IsNumber(0)) {
  1401. int32 item_id = atol(sep->arg[0]);
  1402. int32 quantity = 1;
  1403. if (sep->arg[1] && sep->IsNumber(1))
  1404. quantity = atoi(sep->arg[1]);
  1405. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1406. client->AddItemToBank(item_id,quantity);
  1407. }
  1408. else {
  1409. client->AddItem(item_id, quantity);
  1410. }
  1411. }
  1412. else {
  1413. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1414. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1415. }
  1416. break;
  1417. }
  1418. case COMMAND_COLLECTION_ADDITEM: {
  1419. // takes 2 params: collection_id, slot
  1420. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1421. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1422. if (item)
  1423. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1424. else
  1425. 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]));
  1426. }
  1427. else
  1428. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1429. break;
  1430. }
  1431. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1432. // takes 1 param: slot
  1433. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1434. int i = 0;
  1435. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1436. printf("\t%u: %s\n", i, sep->arg[i]);
  1437. i++;
  1438. }
  1439. break;
  1440. }
  1441. case COMMAND_WHO:{
  1442. const char* who = 0;
  1443. if(sep && sep->arg[0]){
  1444. //cout << "Who query: \n";
  1445. who = sep->argplus[0];
  1446. //cout << who << endl;
  1447. }
  1448. zone_list.ProcessWhoQuery(who, client);
  1449. break;
  1450. }
  1451. case COMMAND_SELECT_JUNCTION:{
  1452. 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__);
  1453. int32 choice = 0;
  1454. if(sep && sep->arg[0] && sep->IsNumber(0))
  1455. choice = atoul(sep->arg[0]);
  1456. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1457. client->HandlePlayerRevive(choice);
  1458. }
  1459. break;
  1460. }
  1461. case COMMAND_SPAWN_MOVE:{
  1462. if(cmdTarget && cmdTarget->IsPlayer() == false){
  1463. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1464. if(packet){
  1465. float unknown2_3 = 0;
  1466. int8 placement_mode = 0;
  1467. if(sep && sep->arg[0][0]){
  1468. if(strcmp(sep->arg[0], "wall") == 0){
  1469. placement_mode = 2;
  1470. unknown2_3 = 150;
  1471. }
  1472. else if(strcmp(sep->arg[0], "ceiling") == 0)
  1473. placement_mode = 1;
  1474. }
  1475. packet->setDataByName("placement_mode", placement_mode);
  1476. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1477. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1478. packet->setDataByName("unknown", 1); //size
  1479. packet->setDataByName("unknown2", 1); //size 2
  1480. packet->setDataByName("unknown2", .5, 1); //size 3
  1481. packet->setDataByName("unknown2", 3, 2);
  1482. packet->setDataByName("unknown2", unknown2_3, 3);
  1483. packet->setDataByName("max_distance", 500);
  1484. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1485. client->QueuePacket(packet->serialize());
  1486. safe_delete(packet);
  1487. }
  1488. }
  1489. else{
  1490. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1491. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1492. }
  1493. break;
  1494. }
  1495. case COMMAND_HAIL:{
  1496. Spawn* spawn = cmdTarget;
  1497. if(spawn && spawn->GetTargetable())
  1498. {
  1499. char tmp[75] = {0};
  1500. sprintf(tmp, "Hail, %s", spawn->GetName());
  1501. bool show_bubble = true;
  1502. if (spawn->IsNPC())
  1503. show_bubble = false;
  1504. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1505. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < 30){
  1506. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1507. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1508. else
  1509. spawn->ProcessMovement();
  1510. LogWrite(MISC__TODO, 0, "Check", "ProcessMovement has been called");
  1511. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer());
  1512. }
  1513. }
  1514. else {
  1515. string tmp = "Hail";
  1516. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1517. }
  1518. break;
  1519. }
  1520. case COMMAND_SAY:{
  1521. if (sep && sep->arg[0][0]) {
  1522. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1523. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1524. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1525. }
  1526. else
  1527. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1528. break;
  1529. }
  1530. case COMMAND_TELL:{
  1531. if(sep && sep->arg[0] && sep->argplus[1]){
  1532. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_TELL, sep->argplus[1]))
  1533. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1534. }else
  1535. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1536. break;
  1537. }
  1538. case COMMAND_SHOUT:{
  1539. if(sep && sep->arg[0][0])
  1540. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1541. else
  1542. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1543. break;
  1544. }
  1545. case COMMAND_AUCTION:{
  1546. if(sep && sep->arg[0][0])
  1547. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1548. else
  1549. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1550. break;
  1551. }
  1552. case COMMAND_OOC:{
  1553. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  1554. if(sep && sep->arg[0][0])
  1555. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OOC, sep->argplus[0]);
  1556. else
  1557. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  1558. break;
  1559. }
  1560. case COMMAND_EMOTE:{
  1561. if(sep && sep->arg[0][0])
  1562. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  1563. else
  1564. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  1565. break;
  1566. }
  1567. case COMMAND_RACE:{
  1568. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  1569. if(sep->arg[1][0] && sep->IsNumber(1)){
  1570. client->GetPlayer()->GetInfoStruct()->race = atoi(sep->arg[1]);
  1571. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  1572. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  1573. client->GetPlayer()->SetCharSheetChanged(true);
  1574. }
  1575. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  1576. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  1577. //client->QueuePacket(outapp);
  1578. }
  1579. else{
  1580. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  1581. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  1582. }
  1583. break;
  1584. }
  1585. case COMMAND_BANK_DEPOSIT:{
  1586. if(client->GetBanker() && sep && sep->arg[0]){
  1587. int64 amount = 0;
  1588. string deposit = string(sep->arg[0]);
  1589. amount = atoi64(deposit.c_str());
  1590. client->BankDeposit(amount);
  1591. }
  1592. break;
  1593. }
  1594. case COMMAND_BANK_WITHDRAWAL:{
  1595. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  1596. int64 amount = 0;
  1597. string deposit = string(sep->arg[0]);
  1598. amount = atoi64(deposit.c_str());
  1599. client->BankWithdrawal(amount);
  1600. }
  1601. break;
  1602. }
  1603. case COMMAND_BANK_CANCEL:{
  1604. Spawn* banker = cmdTarget;
  1605. client->Bank(banker, true);
  1606. break;
  1607. }
  1608. case COMMAND_BANK:{
  1609. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  1610. Spawn* banker = cmdTarget;
  1611. client->Bank(banker);
  1612. break;
  1613. }
  1614. case COMMAND_GUILD_BANK:{
  1615. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  1616. //Spawn* banker = client->GetPlayer()->GetTarget();
  1617. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  1618. break;
  1619. }
  1620. case COMMAND_START_MAIL: {
  1621. client->SetMailTransaction(cmdTarget);
  1622. client->SendMailList();
  1623. break;
  1624. }
  1625. case COMMAND_CANCEL_MAIL: {
  1626. client->SetMailTransaction(0);
  1627. break;
  1628. }
  1629. case COMMAND_GET_MAIL_MESSAGE: {
  1630. if (sep && sep->arg[0] && sep->IsNumber(0))
  1631. client->DisplayMailMessage(atoul(sep->arg[0]));
  1632. break;
  1633. }
  1634. case COMMAND_ADD_MAIL_PLAT: {
  1635. if (sep && sep->arg[0] && sep->IsNumber(0))
  1636. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1637. break;
  1638. }
  1639. case COMMAND_ADD_MAIL_GOLD: {
  1640. if (sep && sep->arg[0] && sep->IsNumber(0))
  1641. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  1642. break;
  1643. }
  1644. case COMMAND_ADD_MAIL_SILVER: {
  1645. if (sep && sep->arg[0] && sep->IsNumber(0))
  1646. client->AddMailCoin(0, atoul(sep->arg[0]));
  1647. break;
  1648. }
  1649. case COMMAND_ADD_MAIL_COPPER: {
  1650. if (sep && sep->arg[0] && sep->IsNumber(0))
  1651. client->AddMailCoin(atoul(sep->arg[0]));
  1652. break;
  1653. }
  1654. case COMMAND_SET_MAIL_ITEM: {
  1655. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1656. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1657. break;
  1658. }
  1659. case COMMAND_REMOVE_MAIL_PLAT: {
  1660. if (sep && sep->arg[0] && sep->IsNumber(0))
  1661. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1662. break;
  1663. }
  1664. case COMMAND_REMOVE_MAIL_GOLD: {
  1665. if (sep && sep->arg[0] && sep->IsNumber(0))
  1666. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  1667. break;
  1668. }
  1669. case COMMAND_REMOVE_MAIL_SILVER: {
  1670. if (sep && sep->arg[0] && sep->IsNumber(0))
  1671. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  1672. break;
  1673. }
  1674. case COMMAND_REMOVE_MAIL_COPPER: {
  1675. if (sep && sep->arg[0] && sep->IsNumber(0))
  1676. client->RemoveMailCoin(atoul(sep->arg[0]));
  1677. break;
  1678. }
  1679. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  1680. if (sep && sep->arg[0] && sep->IsNumber(0))
  1681. client->TakeMailAttachments(atoul(sep->arg[0]));
  1682. break;
  1683. }
  1684. case COMMAND_CANCEL_SEND_MAIL: {
  1685. client->CancelSendMail();
  1686. break;
  1687. }
  1688. case COMMAND_DELETE_MAIL_MESSAGE: {
  1689. if (sep && sep->arg[0] && sep->IsNumber(0))
  1690. client->DeleteMail(atoul(sep->arg[0]), true);
  1691. break;
  1692. }
  1693. case COMMAND_REPORT_SPAM: {
  1694. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1695. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1696. break;
  1697. }
  1698. case COMMAND_KILL:{
  1699. Spawn* dead = 0;
  1700. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  1701. dead=client->GetPlayer();
  1702. client->GetPlayer()->SetHP(0);
  1703. client->GetPlayer()->KillSpawn(dead);
  1704. }else{
  1705. dead= cmdTarget;
  1706. if(dead && dead->IsPlayer() == false){
  1707. dead->SetHP(0);
  1708. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  1709. client->GetCurrentZone()->RemoveSpawn(dead, true);
  1710. else
  1711. client->GetPlayer()->KillSpawn(dead);
  1712. }else{
  1713. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  1714. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  1715. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  1716. }
  1717. }
  1718. break;
  1719. }
  1720. case COMMAND_LEVEL:{
  1721. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  1722. int16 new_level = atoi(sep->arg[ndx]);
  1723. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  1724. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  1725. else {
  1726. if (new_level < 1)
  1727. new_level = 1;
  1728. if (new_level > 255)
  1729. new_level = 255;
  1730. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  1731. client->GetPlayer()->SetXP(1);
  1732. client->GetPlayer()->SetNeededXP();
  1733. }
  1734. }else
  1735. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  1736. break;
  1737. }
  1738. case COMMAND_SIT: {
  1739. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1740. if(client->GetPlayer()->GetHP() > 0){
  1741. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  1742. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  1743. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  1744. }
  1745. break;
  1746. }
  1747. case COMMAND_STAND: {
  1748. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1749. if(client->GetPlayer()->GetHP() > 0){
  1750. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  1751. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  1752. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  1753. }
  1754. break;
  1755. }
  1756. case COMMAND_CLASS:{
  1757. if(sep && sep->arg[ndx][0]){
  1758. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  1759. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  1760. }else
  1761. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  1762. break;
  1763. }
  1764. case COMMAND_GENDER:{
  1765. if(sep && sep->arg[ndx][0]){
  1766. client->GetPlayer()->GetInfoStruct()->gender = atoi(sep->arg[ndx]);
  1767. client->GetPlayer()->SetCharSheetChanged(true);
  1768. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  1769. }else{
  1770. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  1771. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  1772. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  1773. }
  1774. break;
  1775. }
  1776. case COMMAND_FLYMODE:{
  1777. if(sep && sep->arg[0] && sep->IsNumber(0)){
  1778. PrintSep(sep, "COMMAND_FLYMODE");
  1779. int8 val = atoi(sep->arg[0]);
  1780. ClientPacketFunctions::SendFlyMode(client, val);
  1781. }
  1782. else{
  1783. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  1784. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  1785. }
  1786. break;
  1787. }
  1788. case COMMAND_LOOT_LIST:{
  1789. Spawn* spawn = cmdTarget;
  1790. if(spawn && spawn->IsEntity()){
  1791. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  1792. if(loot_list.size() > 0){
  1793. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  1794. vector<int32>::iterator list_itr;
  1795. LootTable* table = 0;
  1796. for(list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++){
  1797. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  1798. if(table)
  1799. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  1800. }
  1801. }
  1802. Entity* target = (Entity*)spawn;
  1803. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", target->GetLootCoins());
  1804. vector<Item*>* items = target->GetLootItems();
  1805. if(items){
  1806. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  1807. vector<Item*>::iterator itr;
  1808. Item* item = 0;
  1809. for(itr = items->begin(); itr != items->end(); itr++){
  1810. item = *itr;
  1811. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  1812. }
  1813. }
  1814. else
  1815. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  1816. }
  1817. break;
  1818. }
  1819. case COMMAND_LOOT_SETCOIN:{
  1820. Spawn* spawn = cmdTarget;
  1821. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1822. Entity* target = (Entity*)spawn;
  1823. target->SetLootCoins(atoul(sep->arg[0]));
  1824. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  1825. }
  1826. else
  1827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  1828. break;
  1829. }
  1830. case COMMAND_LOOT_ADDITEM:{
  1831. Spawn* spawn = cmdTarget;
  1832. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1833. Entity* target = (Entity*)spawn;
  1834. int16 charges = 1;
  1835. if(sep->arg[1] && sep->IsNumber(1))
  1836. charges = atoi(sep->arg[1]);
  1837. target->AddLootItem(atoul(sep->arg[0]), charges);
  1838. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  1839. }
  1840. else
  1841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  1842. break;
  1843. }
  1844. case COMMAND_LOOT_REMOVEITEM:{
  1845. Spawn* spawn = cmdTarget;
  1846. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1847. Entity* target = (Entity*)spawn;
  1848. target->LootItem(atoul(sep->arg[0]));
  1849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  1850. }
  1851. else
  1852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  1853. break;
  1854. }
  1855. case COMMAND_LOOT_CORPSE:
  1856. case COMMAND_LOOT:{
  1857. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  1858. {
  1859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  1860. break;
  1861. }
  1862. if(cmdTarget && cmdTarget->IsEntity()){
  1863. if (cmdTarget->GetDistance(client->GetPlayer()) <= 10){
  1864. client->Loot((Entity*)cmdTarget);
  1865. if (!((Entity*)cmdTarget)->HasLoot()){
  1866. if (((Entity*)cmdTarget)->IsNPC())
  1867. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  1868. }
  1869. }
  1870. else
  1871. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  1872. }
  1873. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  1874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  1875. break;
  1876. }
  1877. case COMMAND_RELOADSPAWNSCRIPTS:{
  1878. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  1879. if (lua_interface)
  1880. lua_interface->SetSpawnScriptsReloading(true);
  1881. world.ResetSpawnScripts();
  1882. database.LoadSpawnScriptData();
  1883. if(lua_interface) {
  1884. lua_interface->DestroySpawnScripts();
  1885. lua_interface->SetSpawnScriptsReloading(false);
  1886. }
  1887. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  1888. break;
  1889. }
  1890. case COMMAND_RELOADLUASYSTEM:{
  1891. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  1892. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  1893. safe_delete(lua_interface);
  1894. lua_interface = new LuaInterface();
  1895. if(lua_interface)
  1896. lua_interface->SetSpawnScriptsReloading(true);
  1897. if(lua_interface && debug_clients.size() > 0){
  1898. map<Client*, int32>::iterator itr;
  1899. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  1900. if(lua_interface)
  1901. lua_interface->UpdateDebugClients(itr->first);
  1902. }
  1903. }
  1904. world.ResetSpawnScripts();
  1905. database.LoadSpawnScriptData();
  1906. world.ResetZoneScripts();
  1907. database.LoadZoneScriptData();
  1908. int32 quest_count = database.LoadQuests();
  1909. zone_list.DeleteSpellProcess();
  1910. master_spell_list.Reload();
  1911. int32 spell_count = 0;
  1912. if(lua_interface) {
  1913. lua_interface->DestroySpawnScripts();
  1914. lua_interface->DestroySpells();
  1915. spell_count = database.LoadSpellScriptData();
  1916. lua_interface->SetSpawnScriptsReloading(false);
  1917. }
  1918. zone_list.LoadSpellProcess();
  1919. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  1920. break;
  1921. }
  1922. case COMMAND_DECLINE_QUEST:{
  1923. int32 quest_id = 0;
  1924. if(sep && sep->arg[0] && sep->IsNumber(0))
  1925. quest_id = atoul(sep->arg[0]);
  1926. if(quest_id > 0){
  1927. Quest* quest = client->GetPendingQuest(quest_id);
  1928. if(quest){
  1929. client->RemovePendingQuest(quest);
  1930. if(lua_interface)
  1931. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  1932. safe_delete(quest);
  1933. client->GetCurrentZone()->SendQuestUpdates(client);
  1934. }
  1935. }
  1936. break;
  1937. }
  1938. case COMMAND_DELETE_QUEST:{
  1939. int32 quest_id = 0;
  1940. if(sep && sep->arg[0] && sep->IsNumber(0))
  1941. quest_id = atoul(sep->arg[0]);
  1942. if(quest_id > 0){
  1943. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  1944. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  1945. if (quest)
  1946. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  1947. }
  1948. client->RemovePlayerQuest(quest_id);
  1949. client->GetCurrentZone()->SendQuestUpdates(client);
  1950. }
  1951. break;
  1952. }
  1953. case COMMAND_ACCEPT_QUEST:{
  1954. int32 quest_id = 0;
  1955. if(sep && sep->arg[0] && sep->IsNumber(0))
  1956. quest_id = atoul(sep->arg[0]);
  1957. if(quest_id > 0){
  1958. Quest* quest = client->GetPendingQuest(quest_id);
  1959. if(quest){
  1960. client->RemovePendingQuest(quest);
  1961. client->AddPlayerQuest(quest);
  1962. client->GetCurrentZone()->SendQuestUpdates(client);
  1963. // If character has already completed this quest once update the given date in the database
  1964. if (client->GetPlayer()->GetCompletedPlayerQuests()->count(quest_id) > 0) {
  1965. Quest* quest2 = client->GetPlayer()->GetCompletedQuest(quest_id);
  1966. if (quest2)
  1967. quest->SetCompleteCount(quest2->GetCompleteCount());
  1968. database.SaveCharRepeatableQuest(client, quest_id, quest->GetCompleteCount());
  1969. }
  1970. }
  1971. }
  1972. break;
  1973. }
  1974. case COMMAND_NAME:{
  1975. if(sep && sep->arg[ndx][0]){
  1976. memset(client->GetPlayer()->GetInfoStruct()->name, 0, 40);
  1977. strncpy(client->GetPlayer()->GetInfoStruct()->name, sep->arg[ndx], 39);
  1978. client->GetPlayer()->SetCharSheetChanged(true);
  1979. }else
  1980. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  1981. break;
  1982. }
  1983. case COMMAND_GROUPSAY:{
  1984. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  1985. if(sep && sep->arg[0] && gmi)
  1986. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  1987. break;
  1988. }
  1989. case COMMAND_GROUPINVITE: {
  1990. Entity* target = 0;
  1991. Client* target_client = 0;
  1992. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  1993. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  1994. return;
  1995. }
  1996. // name provided with command so it has to be a player, npc not supported here
  1997. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  1998. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  1999. if (target_client) {
  2000. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2001. target = 0;
  2002. else
  2003. target = target_client->GetPlayer();
  2004. }
  2005. }
  2006. // if name was not provided use the players target, npc or player supported here
  2007. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2008. target = (Entity*)client->GetPlayer()->GetTarget();
  2009. if (target->IsPlayer()) {
  2010. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2011. }
  2012. }
  2013. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2014. if (result == 0) {
  2015. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2016. if (target_client) {
  2017. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2018. if (packet) {
  2019. packet->setDataByName("type", 1);
  2020. packet->setDataByName("name", client->GetPlayer()->GetName());
  2021. packet->setDataByName("unknown2", 1);
  2022. target_client->QueuePacket(packet->serialize());
  2023. safe_delete(packet);
  2024. }
  2025. }
  2026. }
  2027. else if (result == 1)
  2028. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2029. else if (result == 2)
  2030. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2031. else if (result == 3)
  2032. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2033. else if (result == 4)
  2034. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2035. else if (result == 5)
  2036. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2037. else if (result == 6)
  2038. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2039. else
  2040. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2041. break;
  2042. }
  2043. case COMMAND_GROUPDISBAND: {
  2044. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2045. if (gmi) { // TODO: Leader check
  2046. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2047. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2048. }
  2049. break;
  2050. }
  2051. case COMMAND_GROUP_LEAVE: {
  2052. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2053. if (gmi) {
  2054. int32 group_id = gmi->group_id;
  2055. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2056. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2057. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2058. }
  2059. else {
  2060. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2061. }
  2062. client->SimpleMessage(CHANNEL_COLOR_GROUP, "You have left the group");
  2063. }
  2064. break;
  2065. }
  2066. case COMMAND_FRIEND_ADD:{
  2067. string name = "";
  2068. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2069. name = database.GetPlayerName(sep->arg[0]);
  2070. else if(cmdTarget && cmdTarget->IsPlayer())
  2071. name = string(cmdTarget->GetName());
  2072. if(name.length() > 0){
  2073. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2074. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2075. client->GetPlayer()->RemoveIgnore(name.c_str());
  2076. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2077. client->SendChatRelationship(3, name.c_str());
  2078. }
  2079. client->GetPlayer()->AddFriend(name.c_str(), true);
  2080. client->SendChatRelationship(0, name.c_str());
  2081. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2082. if(zone_list.GetClientByCharName(name))
  2083. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2084. }
  2085. else
  2086. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2087. }
  2088. else
  2089. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2090. break;
  2091. }
  2092. case COMMAND_FRIEND_REMOVE:{
  2093. string name = "";
  2094. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2095. name = database.GetPlayerName(sep->arg[0]);
  2096. else if(cmdTarget && cmdTarget->IsPlayer())
  2097. name = string(cmdTarget->GetName());
  2098. if(name.length() > 0){
  2099. client->GetPlayer()->RemoveFriend(name.c_str());
  2100. client->SendChatRelationship(1, name.c_str());
  2101. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2102. }
  2103. else
  2104. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2105. break;
  2106. }
  2107. case COMMAND_FRIENDS:{
  2108. break;
  2109. }
  2110. case COMMAND_IGNORE_ADD:{
  2111. string name = "";
  2112. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2113. name = database.GetPlayerName(sep->arg[0]);
  2114. else if(cmdTarget && cmdTarget->IsPlayer())
  2115. name = string(cmdTarget->GetName());
  2116. if(name.length() > 0){
  2117. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2118. if(client->GetPlayer()->IsFriend(name.c_str())){
  2119. client->GetPlayer()->RemoveFriend(name.c_str());
  2120. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2121. client->SendChatRelationship(1, name.c_str());
  2122. }
  2123. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2124. client->SendChatRelationship(2, name.c_str());
  2125. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2126. }
  2127. else
  2128. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2129. }
  2130. else
  2131. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2132. break;
  2133. }
  2134. case COMMAND_IGNORE_REMOVE:{
  2135. string name = "";
  2136. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2137. name = database.GetPlayerName(sep->arg[0]);
  2138. else if(cmdTarget && cmdTarget->IsPlayer())
  2139. name = string(cmdTarget->GetName());
  2140. if(name.length() > 0){
  2141. client->GetPlayer()->RemoveIgnore(name.c_str());
  2142. client->SendChatRelationship(3, name.c_str());
  2143. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2144. }
  2145. break;
  2146. }
  2147. case COMMAND_IGNORES:{
  2148. break;
  2149. }
  2150. case COMMAND_GROUP_KICK:{
  2151. Entity* kicked = 0;
  2152. Client* kicked_client = 0;
  2153. int32 group_id = 0;
  2154. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2155. return;
  2156. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2157. if (sep && sep->arg[0]) {
  2158. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2159. if (kicked_client)
  2160. kicked = kicked_client->GetPlayer();
  2161. }
  2162. else if (cmdTarget && cmdTarget->IsEntity()) {
  2163. kicked = (Entity*)cmdTarget;
  2164. }
  2165. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2166. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2167. if (kicked)
  2168. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2169. if(send_kicked_message)
  2170. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2171. else
  2172. client->Message(CHANNEL_COLOR_GROUP, "You kicked %s from the group", kicked->GetName());
  2173. if (kicked_client)
  2174. kicked_client->SimpleMessage(CHANNEL_COLOR_GROUP, "You were kicked from the group");
  2175. break;
  2176. }
  2177. case COMMAND_GROUP_MAKE_LEADER:{
  2178. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2179. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2180. return;
  2181. }
  2182. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2183. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2184. if (new_leader) {
  2185. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2186. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2187. }
  2188. }
  2189. else
  2190. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2191. }
  2192. else if (cmdTarget && cmdTarget->IsPlayer())
  2193. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2194. else
  2195. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2196. break;
  2197. }
  2198. case COMMAND_GROUP_ACCEPT_INVITE: {
  2199. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2200. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2201. if (result == 0)
  2202. client->SimpleMessage(CHANNEL_GROUP, "You have joined the group.");
  2203. else if (result == 1)
  2204. client->SimpleMessage(CHANNEL_GROUP, "You do not have a pending invite.");
  2205. else if (result == 2)
  2206. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - could not find leader.");
  2207. else
  2208. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - unknown error.");
  2209. }
  2210. break;
  2211. }
  2212. case COMMAND_GROUP_DECLINE_INVITE: {
  2213. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2214. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2215. }
  2216. break;
  2217. }
  2218. case COMMAND_SUMMON:{
  2219. char* search_name = 0;
  2220. if(sep && sep->arg[0][0])
  2221. search_name = sep->arg[0];
  2222. if(!search_name && !cmdTarget){
  2223. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2224. 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.");
  2225. }
  2226. else{
  2227. if(!client->Summon(search_name))
  2228. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2229. }
  2230. break;
  2231. }
  2232. case COMMAND_GOTO:{
  2233. const char* search_name = 0;
  2234. if(sep && sep->arg[0][0])
  2235. search_name = sep->argplus[0];
  2236. if(!search_name && !cmdTarget){
  2237. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2238. 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.");
  2239. }
  2240. else{
  2241. if(!client->GotoSpawn(search_name))
  2242. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2243. }
  2244. break;
  2245. }
  2246. case COMMAND_MOVE:{
  2247. bool success = false;
  2248. try{
  2249. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2250. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2251. if(app){
  2252. client->QueuePacket(app);
  2253. success = true;
  2254. }
  2255. }
  2256. }
  2257. catch(...){}
  2258. if(!success){
  2259. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2260. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2261. }
  2262. break;
  2263. }
  2264. case COMMAND_SETTIME:{
  2265. if(sep && sep->arg[0]){
  2266. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2267. if(sep->arg[1] && sep->IsNumber(1))
  2268. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2269. if(sep->arg[2] && sep->IsNumber(2))
  2270. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2271. if(sep->arg[3] && sep->IsNumber(3))
  2272. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2273. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2274. }
  2275. else{
  2276. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2277. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2278. }
  2279. break;
  2280. }
  2281. case COMMAND_VERSION:{
  2282. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2283. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2284. break;
  2285. }
  2286. case COMMAND_ZONE:{
  2287. string* zonename = 0;
  2288. int32 instanceID = 0;
  2289. const char* zone = 0;
  2290. int32 zone_id = 0;
  2291. bool listSearch = false;
  2292. bool isInstance = false;
  2293. ZoneServer* zsZone = 0;
  2294. if(sep && sep->arg[0][0])
  2295. {
  2296. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2297. listSearch = true;
  2298. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2299. {
  2300. zone_list.SendZoneList(client);
  2301. break;
  2302. }
  2303. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2304. {
  2305. if(sep->IsNumber(1))
  2306. instanceID = atol(sep->arg[1]);
  2307. }
  2308. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2309. {
  2310. PrintSep(sep, "ZONE LOCK");
  2311. if(sep->IsNumber(1))
  2312. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2313. else
  2314. zsZone = zone_list.Get(sep->arg[1], false);
  2315. if( zsZone )
  2316. {
  2317. zsZone->SetZoneLockState(true);
  2318. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2319. }
  2320. else
  2321. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2322. break;
  2323. }
  2324. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2325. {
  2326. PrintSep(sep, "ZONE UNLOCK");
  2327. if(sep->IsNumber(1))
  2328. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2329. else
  2330. zsZone = zone_list.Get(sep->arg[1], false);
  2331. if( zsZone )
  2332. {
  2333. zsZone->SetZoneLockState(false);
  2334. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2335. }
  2336. else
  2337. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2338. break;
  2339. }
  2340. else
  2341. {
  2342. if(sep->IsNumber(0))
  2343. {
  2344. zone_id = atoul(sep->arg[0]);
  2345. zonename = database.GetZoneName(zone_id);
  2346. if(zonename)
  2347. zone = zonename->c_str();
  2348. }
  2349. else
  2350. zone = sep->arg[0];
  2351. }
  2352. if(instanceID > 0)
  2353. {
  2354. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2355. if(zsInstance != NULL)
  2356. {
  2357. instanceID = zsInstance->GetInstanceID();
  2358. zone = zsInstance->GetZoneName();
  2359. zone_id = zsInstance->GetZoneID();
  2360. isInstance = true;
  2361. }
  2362. }
  2363. }
  2364. if(!listSearch)
  2365. {
  2366. if(!zone)
  2367. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2368. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2369. zone_id != client->GetCurrentZone()->GetZoneID())
  2370. {
  2371. if(database.VerifyZone(zone))
  2372. {
  2373. if(client->CheckZoneAccess(zone))
  2374. {
  2375. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zone);
  2376. if(isInstance)
  2377. client->Zone(instanceID,true,true);
  2378. else
  2379. client->Zone(zone);
  2380. }
  2381. }
  2382. else
  2383. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zone);
  2384. }
  2385. else
  2386. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2387. }
  2388. else
  2389. {
  2390. const char* name = 0;
  2391. if(sep && sep->arg[1][0])
  2392. {
  2393. map<int32, string>* zone_names;
  2394. name = sep->argplus[1];
  2395. sint16 status = client->GetAdminStatus();
  2396. if( status > 0 )
  2397. {
  2398. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2399. zone_names = database.GetZoneList(name, true);
  2400. }
  2401. else
  2402. zone_names = database.GetZoneList(name);
  2403. if(!zone_names)
  2404. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2405. else
  2406. {
  2407. map<int32, string>::iterator itr;
  2408. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2409. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2410. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2411. safe_delete(zone_names);
  2412. }
  2413. }
  2414. else
  2415. {
  2416. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2417. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2418. }
  2419. }
  2420. safe_delete(zonename);
  2421. break;
  2422. }
  2423. case COMMAND_USE: {
  2424. Spawn* target = cmdTarget;
  2425. if (target->IsWidget())
  2426. ((Widget*)target)->HandleUse(client, "use");
  2427. break;
  2428. }
  2429. case COMMAND_OPEN: {
  2430. Spawn* target = cmdTarget;
  2431. if (target->IsWidget())
  2432. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2433. break;
  2434. }
  2435. case COMMAND_CASTSPELL: {
  2436. if (sep && sep->arg[0] && sep->IsNumber(0))
  2437. {
  2438. int8 tier = 1;
  2439. if (sep->arg[1] && sep->IsNumber(1))
  2440. tier = atoul(sep->arg[1]);
  2441. int32 spellid = atoul(sep->arg[0]);
  2442. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2443. if (spell)
  2444. {
  2445. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2446. SpellProcess* spellProcess = 0;
  2447. // Get the current zones spell process
  2448. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2449. spellProcess->CastInstant(spell, (Entity*)client->GetPlayer(), (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2450. }
  2451. else
  2452. {
  2453. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2454. }
  2455. }
  2456. else if (sep && sep->arg[0])
  2457. {
  2458. database.FindSpell(client, (char*)sep->argplus[0]);
  2459. }
  2460. else
  2461. {
  2462. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2463. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2464. }
  2465. }
  2466. case COMMAND_ATTACK:
  2467. case COMMAND_AUTO_ATTACK:{
  2468. int8 type = 1;
  2469. Player* player = client->GetPlayer();
  2470. if(!player)
  2471. break;
  2472. bool incombat = player->EngagedInCombat();
  2473. if(sep && sep->arg[0] && sep->IsNumber(0))
  2474. type = atoi(sep->arg[0]);
  2475. if(client->GetPlayer()->GetHP() == 0){
  2476. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  2477. break;
  2478. }
  2479. if(type == 0){
  2480. if(incombat)
  2481. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2482. player->InCombat(false);
  2483. player->InCombat(false, true);
  2484. player->SetRangeAttack(false);
  2485. }
  2486. else {
  2487. if(type == 2){
  2488. player->InCombat(false);
  2489. if(incombat && player->GetRangeAttack()){
  2490. player->SetRangeAttack(false);
  2491. player->InCombat(false, true);
  2492. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2493. }
  2494. else{
  2495. player->SetRangeAttack(true);
  2496. player->InCombat(true, true);
  2497. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2498. }
  2499. }
  2500. else {
  2501. player->InCombat(false, true);
  2502. player->SetRangeAttack(false);
  2503. player->InCombat(true);
  2504. if(!incombat)
  2505. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2506. }
  2507. /*else
  2508. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  2509. }
  2510. player->SetCharSheetChanged(true);
  2511. break;
  2512. }
  2513. case COMMAND_DEPOP:{
  2514. bool allow_respawns = false;
  2515. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2516. if(atoi(sep->arg[0]) == 1)
  2517. allow_respawns = true;
  2518. }
  2519. client->GetCurrentZone()->Depop(allow_respawns);
  2520. break;
  2521. }
  2522. case COMMAND_REPOP:{
  2523. client->GetCurrentZone()->Depop(false, true);
  2524. break;
  2525. }
  2526. case COMMAND_BUYBACK:{
  2527. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2528. // 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
  2529. int64 id = atoi64(sep->arg[0]);
  2530. // get the first int32, the item id
  2531. //int32 item_id = (int32)id;
  2532. // get the second int32, the unique id
  2533. int32 unique_id = (int32)(id>>32);
  2534. int8 quantity = atoi(sep->arg[1]);
  2535. if(quantity == 255)
  2536. quantity = 1;
  2537. client->BuyBack(unique_id, quantity);
  2538. }
  2539. break;
  2540. }
  2541. case COMMAND_MERCHANT_BUY:{
  2542. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2543. int32 item_id = atoul(sep->arg[0]);
  2544. int8 quantity = atoi(sep->arg[1]);
  2545. client->BuyItem(item_id, quantity);
  2546. }
  2547. break;
  2548. }
  2549. case COMMAND_MERCHANT_SELL:{
  2550. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2551. // 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
  2552. int64 id = atoi64(sep->arg[0]);
  2553. // get the first int32, the item id
  2554. int32 item_id = (int32)id;
  2555. // get the second int32, the unique id
  2556. int32 unique_id = (int32)(id>>32);
  2557. int8 quantity = atoi(sep->arg[1]);
  2558. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  2559. client->SellItem(item_id, quantity, unique_id);
  2560. }
  2561. break;
  2562. }
  2563. case COMMAND_MENDER_REPAIR: {
  2564. if (sep && sep->arg[0] && sep->IsNumber(0))
  2565. client->RepairItem(atoul(sep->arg[0]));
  2566. break;
  2567. }
  2568. case COMMAND_MENDER_REPAIR_ALL: {
  2569. client->RepairAllItems();
  2570. break;
  2571. }
  2572. case COMMAND_CANCEL_MERCHANT:{
  2573. client->SetMerchantTransaction(0);
  2574. break;
  2575. }
  2576. case COMMAND_START_MERCHANT:{
  2577. break;
  2578. }
  2579. case COMMAND_INVULNERABLE:{
  2580. sint8 val = -1;
  2581. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2582. val = atoi(sep->arg[0]);
  2583. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2584. client->GetPlayer()->SetInvulnerable(val==1);
  2585. if(client->GetPlayer()->GetInvulnerable())
  2586. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  2587. else
  2588. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  2589. }
  2590. if(val == -1)
  2591. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  2592. break;
  2593. }
  2594. case COMMAND_REPAIR: {
  2595. Spawn* spawn = cmdTarget;
  2596. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  2597. client->SetMerchantTransaction(spawn);
  2598. client->SendRepairList();
  2599. }
  2600. break;
  2601. }
  2602. case COMMAND_LOTTO: {
  2603. Spawn* spawn = cmdTarget;
  2604. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  2605. client->SetMerchantTransaction(spawn);
  2606. client->ShowLottoWindow();
  2607. }
  2608. break;
  2609. }
  2610. case COMMAND_ACCEPT_REWARD:{
  2611. int32 unknown = 0;
  2612. int32 selectable_item_id = 0;
  2613. //Quest *quest = 0;
  2614. Collection *collection = 0;
  2615. /* no idea what the first argument is for (faction maybe?)
  2616. if the reward has a selectable item reward, it's sent as the second argument
  2617. if neither of these are included in the reward, there is no sep
  2618. 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
  2619. only 1 quest or collection reward may be displayed at a time */
  2620. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2621. unknown = atoul(sep->arg[0]);
  2622. selectable_item_id = atoul(sep->arg[1]);
  2623. }
  2624. //if ((quest = player->GetPendingQuestReward()))
  2625. // client->AcceptQuestRewards(quest, selectable_item_id);
  2626. /* the below needs to go away eventually and be redone */
  2627. int32 item_id = 0;
  2628. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  2629. item_id = atoul(sep->arg[0]);
  2630. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  2631. if(quest){
  2632. client->AcceptQuestReward(quest, item_id);
  2633. break;
  2634. }
  2635. if (collection = player->GetPendingCollectionReward())
  2636. client->AcceptCollectionRewards(collection, selectable_item_id);
  2637. else
  2638. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  2639. break;
  2640. }
  2641. case COMMAND_BUY_FROM_BROKER:{
  2642. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2643. int32 item_id = atoul(sep->arg[0]);
  2644. int16 quantity = atoul(sep->arg[1]);
  2645. client->AddItem(item_id, quantity);
  2646. }
  2647. break;
  2648. }
  2649. case COMMAND_SEARCH_STORES_PAGE:{
  2650. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2651. int32 page = atoul(sep->arg[0]);
  2652. client->SearchStore(page);
  2653. }
  2654. break;
  2655. }
  2656. case COMMAND_SEARCH_STORES:{
  2657. if(sep && sep->arg[0][0]){
  2658. const char* values = sep->argplus[0];
  2659. if(values){
  2660. map<string, string> str_values = TranslateBrokerRequest(values);
  2661. vector<Item*>* items = master_item_list.GetItems(str_values);
  2662. if(items){
  2663. client->SetItemSearch(items);
  2664. client->SearchStore(0);
  2665. }
  2666. }
  2667. }
  2668. break;
  2669. }
  2670. case COMMAND_LUADEBUG:{
  2671. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  2672. client->SetLuaDebugClient(true);
  2673. if(lua_interface)
  2674. lua_interface->UpdateDebugClients(client);
  2675. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  2676. }
  2677. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  2678. client->SetLuaDebugClient(false);
  2679. if(lua_interface)
  2680. lua_interface->RemoveDebugClients(client);
  2681. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  2682. }
  2683. else{
  2684. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  2685. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  2686. }
  2687. break;
  2688. }
  2689. case COMMAND_SPAWN_GROUP:
  2690. {
  2691. Spawn* target = cmdTarget;
  2692. if(target && target->IsPlayer() == false)
  2693. {
  2694. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  2695. {
  2696. if(target->GetSpawnLocationPlacementID() > 0)
  2697. {
  2698. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  2699. {
  2700. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  2701. if(id > 0)
  2702. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  2703. else
  2704. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  2705. target->SetSpawnGroupID(id);
  2706. target->AddSpawnToGroup(target);
  2707. }
  2708. else
  2709. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  2710. }
  2711. else
  2712. 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.");
  2713. }
  2714. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  2715. {
  2716. if(sep->arg[1] && sep->IsNumber(1))
  2717. {
  2718. int32 group_id = atoul(sep->arg[1]);
  2719. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  2720. if(leader)
  2721. {
  2722. leader->AddSpawnToGroup(target);
  2723. target->SetSpawnGroupID(group_id);
  2724. if(database.SpawnGroupAddSpawn(target, group_id))
  2725. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  2726. else
  2727. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  2728. }
  2729. else
  2730. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  2731. }
  2732. else
  2733. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  2734. }
  2735. else if(target->GetSpawnGroupID() == 0)
  2736. {
  2737. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  2738. }
  2739. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  2740. {
  2741. int32 group_id = target->GetSpawnGroupID();
  2742. target->RemoveSpawnFromGroup();
  2743. if(database.SpawnGroupRemoveSpawn(target, group_id))
  2744. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  2745. else
  2746. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  2747. }
  2748. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  2749. {
  2750. int32 group_id = target->GetSpawnGroupID();
  2751. if(sep->arg[1] && sep->IsNumber(1))
  2752. {
  2753. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  2754. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  2755. else
  2756. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  2757. }
  2758. else
  2759. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  2760. }
  2761. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  2762. {
  2763. int32 group_id = target->GetSpawnGroupID();
  2764. if(sep->arg[1] && sep->IsNumber(1))
  2765. {
  2766. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  2767. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  2768. else
  2769. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  2770. }
  2771. else
  2772. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  2773. }
  2774. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  2775. {
  2776. if(sep->arg[1] && sep->IsNumber(1))
  2777. {
  2778. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  2779. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  2780. else
  2781. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  2782. }
  2783. else
  2784. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  2785. }
  2786. else
  2787. {
  2788. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  2789. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  2790. }
  2791. }
  2792. else
  2793. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  2794. break;
  2795. }
  2796. case COMMAND_SPAWN_COMBINE:{
  2797. Spawn* spawn = cmdTarget;
  2798. float radius = 0;
  2799. bool failed = true;
  2800. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  2801. failed = false;
  2802. if(spawn->GetSpawnGroupID() > 0){
  2803. 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.");
  2804. }
  2805. else if(sep->IsNumber(0)){
  2806. radius = atof(sep->arg[0]);
  2807. client->CombineSpawns(radius, spawn);
  2808. }
  2809. else{
  2810. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  2811. client->AddCombineSpawn(spawn);
  2812. }
  2813. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  2814. client->RemoveCombineSpawn(spawn);
  2815. }
  2816. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  2817. const char* name = 0;
  2818. if(sep->arg[1] && sep->arg[1][0])
  2819. name = sep->argplus[1];
  2820. client->SaveCombineSpawns(name);
  2821. }
  2822. else
  2823. failed = true;
  2824. }
  2825. }
  2826. if(failed){
  2827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  2828. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  2829. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  2830. }
  2831. break;
  2832. }
  2833. case COMMAND_SPAWN_CREATE:{
  2834. Spawn* spawn = 0;
  2835. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  2836. spawn = new Object();
  2837. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2838. }
  2839. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  2840. spawn = new GroundSpawn();
  2841. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2842. }
  2843. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  2844. spawn = new Sign();
  2845. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2846. }
  2847. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  2848. spawn = new NPC();
  2849. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2850. spawn->appearance.pos.collision_radius = 32;
  2851. spawn->secondary_command_list_id = 0;
  2852. spawn->primary_command_list_id = 0;
  2853. spawn->appearance.display_name = 1;
  2854. spawn->appearance.show_level = 1;
  2855. spawn->appearance.attackable = 1;
  2856. }
  2857. else{
  2858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  2859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  2860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  2861. break;
  2862. }
  2863. spawn->SetID(Spawn::NextID());
  2864. spawn->SetX(client->GetPlayer()->GetX());
  2865. spawn->SetY(client->GetPlayer()->GetY());
  2866. spawn->SetZ(client->GetPlayer()->GetZ());
  2867. spawn->SetHeading(client->GetPlayer()->GetHeading());
  2868. spawn->SetSpawnOrigX(spawn->GetX());
  2869. spawn->SetSpawnOrigY(spawn->GetY());
  2870. spawn->SetSpawnOrigZ(spawn->GetZ());
  2871. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  2872. spawn->appearance.targetable = 1;
  2873. spawn->appearance.race = 255;
  2874. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  2875. spawn->SetModelType(atoi(sep->arg[1]));
  2876. spawn->SetAdventureClass(atoi(sep->arg[2]));
  2877. spawn->SetLevel(atoi(sep->arg[3]));
  2878. spawn->SetName(sep->arg[4]);
  2879. if(sep->arg[5][0] && sep->IsNumber(5))
  2880. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  2881. if(sep->arg[6][0] && sep->IsNumber(6))
  2882. spawn->size = atoi(sep->arg[6]);
  2883. if(spawn->GetTotalHP() == 0){
  2884. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  2885. spawn->SetHP(25*spawn->GetLevel() + 1);
  2886. }
  2887. if(spawn->GetTotalPower() == 0){
  2888. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  2889. spawn->SetPower(25*spawn->GetLevel() + 1);
  2890. }
  2891. client->GetCurrentZone()->AddSpawn(spawn);
  2892. break;
  2893. }
  2894. case COMMAND_SPAWN_EQUIPMENT:{
  2895. Spawn* spawn = cmdTarget;
  2896. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  2897. int8 slot = atoi(sep->arg[0]);
  2898. int16 type = atoi(sep->arg[1]);
  2899. int8 red = 0;
  2900. int8 green = 0;
  2901. int8 blue = 0;
  2902. int8 h_red = 0;
  2903. int8 h_green = 0;
  2904. int8 h_blue = 0;
  2905. if(sep->arg[2])
  2906. red = atoi(sep->arg[2]);
  2907. if(sep->arg[3])
  2908. green = atoi(sep->arg[3]);
  2909. if(sep->arg[4])
  2910. blue = atoi(sep->arg[4]);
  2911. if(sep->arg[5])
  2912. h_red = atoi(sep->arg[5]);
  2913. if(sep->arg[6])
  2914. h_green = atoi(sep->arg[6]);
  2915. if(sep->arg[7])
  2916. h_blue = atoi(sep->arg[7]);
  2917. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  2918. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  2919. }
  2920. else{
  2921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  2922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  2923. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  2924. }
  2925. break;
  2926. }
  2927. case COMMAND_SPAWN_DETAILS:{
  2928. Spawn* spawn = cmdTarget;
  2929. if(spawn){
  2930. const char* type = "NPC";
  2931. if(spawn->IsObject())
  2932. type = "Object";
  2933. else if(spawn->IsSign())
  2934. type = "Sign";
  2935. else if(spawn->IsWidget())
  2936. type = "Widget";
  2937. else if(spawn->IsGroundSpawn())
  2938. type = "GroundSpawn";
  2939. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  2940. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  2941. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  2942. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  2943. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  2944. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  2945. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  2946. 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());
  2947. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  2948. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  2949. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  2950. if(spawn->IsEntity()){
  2951. 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());
  2952. 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());
  2953. }
  2954. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  2955. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  2956. 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());
  2957. 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);
  2958. if (spawn->IsNPC())
  2959. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  2960. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  2961. if (packet) {
  2962. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  2963. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  2964. packet->setDataByName("book_title", title.c_str());
  2965. packet->setDataByName("book_type", "simple");
  2966. packet->setDataByName("unknown2", 1);
  2967. packet->setDataByName("unknown5", 1, 4);
  2968. packet->setArrayLengthByName("num_pages", 4);
  2969. string details;
  2970. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  2971. details += "Type: " + string(type) + "\n";
  2972. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  2973. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  2974. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  2975. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  2976. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  2977. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  2978. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  2979. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  2980. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  2981. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  2982. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  2983. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  2984. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  2985. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  2986. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  2987. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  2988. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  2989. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  2990. char x[16];
  2991. sprintf(x, "%.2f", spawn->GetX());
  2992. char y[16];
  2993. sprintf(y, "%.2f", spawn->GetY());
  2994. char z[16];
  2995. sprintf(z, "%.2f", spawn->GetZ());
  2996. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  2997. string details2;
  2998. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  2999. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3000. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3001. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3002. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3003. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3004. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3005. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3006. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3007. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3008. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3009. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3010. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3011. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3012. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3013. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3014. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3015. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3016. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3017. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3018. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3019. string details3;
  3020. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3021. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3022. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3023. string details4;
  3024. if (spawn->IsEntity()) {
  3025. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3026. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3027. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3028. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3029. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3030. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3031. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3032. if (spawn->IsNPC()) {
  3033. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3034. }
  3035. }
  3036. //details2 += "" + to_string() + "\n";
  3037. packet->setArrayDataByName("page_text", details.c_str());
  3038. packet->setArrayDataByName("page_text", details2.c_str(), 1);
  3039. packet->setArrayDataByName("page_text", details3.c_str(), 2);
  3040. packet->setArrayDataByName("page_text", details4.c_str(), 3);
  3041. client->QueuePacket(packet->serialize());
  3042. safe_delete(packet);
  3043. }
  3044. }
  3045. else if (sep && sep->arg[0][0] && sep->IsNumber(0))
  3046. {
  3047. float radius = atof(sep->arg[0]);
  3048. if ( !client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius) )
  3049. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3050. }
  3051. else {
  3052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3053. 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.");
  3054. }
  3055. break;
  3056. }
  3057. case COMMAND_SPAWN_TARGET:{
  3058. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3059. int32 spawn_id = atoul(sep->arg[0]);
  3060. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3061. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3062. }
  3063. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3064. float distance = atof(sep->arg[1]);
  3065. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3066. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3067. }
  3068. else{
  3069. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3070. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3071. }
  3072. break;
  3073. }
  3074. case COMMAND_SPAWN_SET:
  3075. {
  3076. Spawn* spawn = cmdTarget;
  3077. sint16 set_type = -1;
  3078. string type_str;
  3079. if (spawn)
  3080. {
  3081. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3082. 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)
  3083. {
  3084. // set the type, which will be 0 if location or list or invalid
  3085. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3086. }
  3087. if(set_type > 0)
  3088. {
  3089. // check if spawn set is NOT a char update, or not location, or isn't a number
  3090. if(!(set_type >= SPAWN_SET_VALUE_PREFIX) && !(set_type <= SPAWN_SET_VALUE_LASTNAME) && 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)
  3091. {
  3092. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3093. }
  3094. else
  3095. {
  3096. string name = string(spawn->GetName());
  3097. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1]))
  3098. {
  3099. if(set_type == SPAWN_SET_VALUE_NAME)
  3100. {
  3101. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3102. }
  3103. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3104. {
  3105. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3106. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3107. }
  3108. else
  3109. {
  3110. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3111. }
  3112. if(set_type != SPAWN_SET_VALUE_FACTION)
  3113. {
  3114. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->arg[1]);
  3115. }
  3116. 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))
  3117. {
  3118. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3119. {
  3120. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3121. }
  3122. else if(spawn->GetSpawnLocationID() > 0)
  3123. {
  3124. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3125. }
  3126. }
  3127. else
  3128. {
  3129. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3130. {
  3131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3132. }
  3133. else if(spawn->GetDatabaseID() > 0)
  3134. {
  3135. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3136. }
  3137. }
  3138. }
  3139. }
  3140. }
  3141. else if(set_type == 0)
  3142. {
  3143. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3144. map<string, int8>::iterator itr;
  3145. int i=0;
  3146. string list;
  3147. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3148. {
  3149. if(i==10)
  3150. {
  3151. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3152. i = 0;
  3153. }
  3154. if(i>0)
  3155. {
  3156. list.append(", ").append(itr->first);
  3157. }
  3158. else
  3159. {
  3160. list = itr->first;
  3161. }
  3162. }
  3163. if(list.length() > 0)
  3164. {
  3165. // if 1 or more, display in client.
  3166. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3167. }
  3168. }
  3169. else
  3170. {
  3171. // syntax fail
  3172. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3173. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3174. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3175. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3176. }
  3177. }
  3178. break;
  3179. }
  3180. case COMMAND_SPAWN_REMOVE:{
  3181. Spawn* spawn = cmdTarget;
  3182. if(spawn && !spawn->IsPlayer()){
  3183. if(spawn->GetSpawnLocationID() > 0){
  3184. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3185. bool delete_spawn = false;
  3186. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3187. if(atoi(sep->arg[0]) == 1)
  3188. delete_spawn = true;
  3189. }
  3190. if(delete_spawn)
  3191. client->GetCurrentZone()->RemoveSpawn(spawn, true, false);
  3192. else
  3193. spawn->SetSpawnLocationID(0);
  3194. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3195. }
  3196. else
  3197. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3198. }
  3199. else
  3200. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3201. }
  3202. else{
  3203. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3204. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3205. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Optionally, you can supply a 1 after the command to despawn it as well. IE /spawn remove 1");
  3206. }
  3207. break;
  3208. }
  3209. case COMMAND_SPAWN_LIST:{
  3210. if(sep && sep->arg[0][0]){
  3211. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3212. vector<string>::iterator itr;
  3213. if(results){
  3214. for(itr=results->begin();itr!=results->end();itr++){
  3215. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3216. }
  3217. safe_delete(results);
  3218. }
  3219. else
  3220. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3221. }
  3222. else{
  3223. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3224. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3225. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3226. }
  3227. break;
  3228. }
  3229. case COMMAND_SPAWN_ADD:{
  3230. Spawn* spawn = cmdTarget;
  3231. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3232. if(spawn->GetSpawnLocationID() > 0){
  3233. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3234. break;
  3235. }
  3236. if(spawn->GetDatabaseID() == 0){
  3237. if(database.SaveSpawnInfo(spawn)) {
  3238. char spawn_type[32];
  3239. memset(spawn_type, 0, sizeof(spawn_type));
  3240. if (spawn->IsNPC())
  3241. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3242. else if (spawn->IsObject())
  3243. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3244. else if (spawn->IsSign())
  3245. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3246. else if (spawn->IsGroundSpawn())
  3247. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3248. else
  3249. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3250. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3251. }
  3252. else
  3253. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3254. }
  3255. int32 spawn_group_id = 0;
  3256. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3257. spawn_group_id = database.GetNextSpawnLocation();
  3258. else
  3259. spawn_group_id = atol(sep->arg[0]);
  3260. int8 percent = 100;
  3261. if(sep->arg[2] && sep->IsNumber(2))
  3262. percent = atoi(sep->arg[2]);
  3263. spawn->SetSpawnLocationID(spawn_group_id);
  3264. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3265. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3266. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3267. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3268. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3269. else
  3270. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3271. }
  3272. else{
  3273. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3274. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3275. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3276. }
  3277. break;
  3278. }
  3279. case COMMAND_SPAWN:{
  3280. int32 id = 0;
  3281. Spawn* spawn = 0;
  3282. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3283. id = atol(sep->arg[0]);
  3284. spawn = client->GetCurrentZone()->GetSpawn(id);
  3285. }
  3286. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3287. id = 0;
  3288. if(!id || !spawn){
  3289. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3290. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3291. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3292. safe_delete(sep);
  3293. return;
  3294. }
  3295. if(sep && sep->arg[1][0]){
  3296. float x = atof(sep->arg[1]);
  3297. spawn->appearance.pos.X = x;
  3298. }
  3299. else
  3300. spawn->SetX(client->GetPlayer()->GetX(), false);
  3301. if(sep && sep->arg[2][0]){
  3302. float y = atof(sep->arg[2]);
  3303. spawn->appearance.pos.Y = y;
  3304. }
  3305. else
  3306. spawn->SetY(client->GetPlayer()->GetY(), false);
  3307. if(sep && sep->arg[3][0]){
  3308. float z = atof(sep->arg[3]);
  3309. spawn->appearance.pos.Z = z;
  3310. }
  3311. else
  3312. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3313. if(sep && sep->arg[4][0]){
  3314. float heading = atof(sep->arg[4]);
  3315. spawn->SetHeading(heading);
  3316. }
  3317. else
  3318. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3319. spawn->SetSpawnOrigX(spawn->GetX());
  3320. spawn->SetSpawnOrigY(spawn->GetY());
  3321. spawn->SetSpawnOrigZ(spawn->GetZ());
  3322. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3323. if(sep && sep->arg[5][0])
  3324. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3325. else
  3326. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3327. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3328. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3329. spawn->SetHP(spawn->GetTotalHP());
  3330. }
  3331. if(spawn->GetTotalPower() == 0){
  3332. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3333. spawn->SetPower(spawn->GetTotalPower());
  3334. }
  3335. const char* script = world.GetSpawnScript(id);
  3336. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3337. spawn->SetSpawnScript(string(script));
  3338. client->GetCurrentZone()->AddSpawn(spawn);
  3339. if(spawn->IsNPC())
  3340. spawn->GetZone()->AddLoot((NPC*)spawn);
  3341. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3342. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3343. break;
  3344. }
  3345. case COMMAND_ADMINFLAG:
  3346. {
  3347. if(sep && sep->arg[0]){
  3348. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3349. sint16 new_status = atoi(sep->arg[1]);
  3350. if(tmp_status == -10)
  3351. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3352. else if(tmp_status >= client->GetAdminStatus())
  3353. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3354. else if (new_status > client->GetAdminStatus())
  3355. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3356. else{
  3357. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3358. if (!client2)
  3359. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3360. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3361. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3362. if (client2) {
  3363. client2->SetAdminStatus(new_status);
  3364. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3365. }
  3366. }
  3367. else
  3368. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3369. }
  3370. }else{
  3371. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3372. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3373. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3374. }
  3375. break;
  3376. }
  3377. case COMMAND_CANNEDEMOTE:{
  3378. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3379. break;
  3380. }
  3381. case COMMAND_BROADCAST: {
  3382. if (sep && sep->arg[0])
  3383. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3384. else
  3385. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3386. break;
  3387. }
  3388. case COMMAND_ANNOUNCE: {
  3389. if (sep && sep->arg[0])
  3390. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3391. else
  3392. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3393. break;
  3394. }
  3395. case COMMAND_RELOAD_ITEMS:{
  3396. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3397. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3398. database.ReloadItemList();
  3399. database.LoadMerchantInformation();
  3400. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3401. break;
  3402. }
  3403. case COMMAND_ENABLE_ABILITY_QUE:{
  3404. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3405. if(app)
  3406. client->QueuePacket(app);
  3407. break;
  3408. }
  3409. case COMMAND_ITEMSEARCH:{
  3410. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3411. if(packet){
  3412. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3413. //packet->setDataByName("unknown", 1);
  3414. packet->setDataByName("unknown2", 5, 0);
  3415. packet->setDataByName("unknown2", 20, 1);
  3416. packet->setDataByName("unknown2", 58, 3);
  3417. packet->setDataByName("unknown2", 40, 4);
  3418. client->QueuePacket(packet->serialize());
  3419. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3420. if(packet2){
  3421. packet2->setDataByName("char_id", client->GetCharacterID());
  3422. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3423. safe_delete(packet2);
  3424. }
  3425. safe_delete(packet);
  3426. }
  3427. break;
  3428. }
  3429. case COMMAND_ANIMTEST:{
  3430. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3431. if(command_packet){
  3432. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  3433. if (cmdTarget)
  3434. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  3435. command_packet->setDataByName ( "spawn_id" , id);
  3436. int animID = 1;
  3437. if(sep && sep->arg[0] && sep->IsNumber(0))
  3438. animID = atoi(sep->arg[0]);
  3439. VisualState* vs = NULL;
  3440. if(animID == 0)
  3441. {
  3442. vs = visual_states.FindVisualState(sep->arg[0]);
  3443. }
  3444. char msg[128];
  3445. sprintf(msg,"Animation Test ID: %i",animID);
  3446. command_packet->setMediumStringByName ( "emote_msg" , msg );
  3447. if(vs != NULL)
  3448. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  3449. else
  3450. command_packet->setDataByName ( "anim_type", animID );
  3451. command_packet->setDataByName ( "unknown0", 0 );
  3452. EQ2Packet* outapp = command_packet->serialize();
  3453. client->QueuePacket(outapp);
  3454. safe_delete(command_packet);
  3455. }
  3456. break;
  3457. }
  3458. case COMMAND_KICK:
  3459. {
  3460. if( sep == 0 || sep->arg[0] == 0)
  3461. {
  3462. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  3463. }
  3464. else
  3465. {
  3466. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  3467. if ( kickClient == client )
  3468. {
  3469. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  3470. break;
  3471. }
  3472. else if(kickClient != NULL)
  3473. {
  3474. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3475. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  3476. {
  3477. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3478. break;
  3479. }
  3480. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  3481. kickClient->Disconnect();
  3482. }
  3483. else
  3484. {
  3485. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3486. }
  3487. }
  3488. break;
  3489. }
  3490. case COMMAND_LOCK:
  3491. {
  3492. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  3493. int worldLocked = atoi(sep->arg[0]);
  3494. net.world_locked = worldLocked;
  3495. if ( worldLocked )
  3496. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  3497. else
  3498. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  3499. }
  3500. else
  3501. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  3502. break;
  3503. }
  3504. case COMMAND_BAN:{
  3505. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  3506. {
  3507. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  3508. }
  3509. else
  3510. {
  3511. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  3512. if ( kickClient == client )
  3513. {
  3514. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  3515. break;
  3516. }
  3517. else if(kickClient != NULL)
  3518. {
  3519. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3520. if ( maxStatus > client->GetAdminStatus( ) ||
  3521. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  3522. {
  3523. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3524. break;
  3525. }
  3526. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  3527. int perm = atol(sep->arg[1]);
  3528. if ( perm == 1 )
  3529. database.UpdateAdminStatus(sep->arg[0],-2);
  3530. else
  3531. database.UpdateAdminStatus(sep->arg[0],-1);
  3532. kickClient->Disconnect();
  3533. }
  3534. else
  3535. {
  3536. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3537. }
  3538. }
  3539. break;
  3540. }
  3541. case COMMAND_SET_COMBAT_VOICE:{
  3542. int32 value = 0;
  3543. if(sep && sep->arg[0] && sep->IsNumber(0))
  3544. value = atoi(sep->arg[0]);
  3545. client->GetPlayer()->SetCombatVoice(value);
  3546. break;
  3547. }
  3548. case COMMAND_SET_EMOTE_VOICE:{
  3549. int32 value = 0;
  3550. if(sep && sep->arg[0] && sep->IsNumber(0))
  3551. value = atoi(sep->arg[0]);
  3552. client->GetPlayer()->SetEmoteVoice(value);
  3553. break;
  3554. }
  3555. case COMMAND_GIVEITEM:{
  3556. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  3557. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  3558. if ( itemToClient == NULL )
  3559. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  3560. else
  3561. {
  3562. int32 item_id = atol(sep->arg[1]);
  3563. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  3564. itemToClient->AddItem(item_id);
  3565. }
  3566. }
  3567. else
  3568. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  3569. break;
  3570. }
  3571. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  3572. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  3573. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  3574. case COMMAND_SKILL :
  3575. case COMMAND_SKILL_ADD :
  3576. case COMMAND_SKILL_REMOVE :
  3577. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  3578. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  3579. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  3580. case COMMAND_ENTITYCOMMAND :
  3581. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  3582. case COMMAND_MERCHANT :
  3583. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  3584. case COMMAND_APPEARANCE :
  3585. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  3586. case COMMAND_TRACK : { Command_Track(client); break; }
  3587. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  3588. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  3589. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  3590. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  3591. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  3592. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  3593. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  3594. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  3595. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  3596. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  3597. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  3598. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  3599. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  3600. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  3601. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  3602. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  3603. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  3604. case COMMAND_LOCATION : { Command_Location(client); break; }
  3605. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  3606. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  3607. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  3608. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  3609. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  3610. case COMMAND_GRID : { Command_Grid(client); break; }
  3611. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  3612. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  3613. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  3614. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  3615. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  3616. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  3617. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  3618. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  3619. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  3620. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  3621. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  3622. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  3623. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  3624. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  3625. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  3626. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  3627. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  3628. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  3629. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  3630. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  3631. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  3632. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  3633. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  3634. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  3635. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  3636. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  3637. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  3638. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  3639. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  3640. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  3641. case COMMAND_MOTD : { Command_MOTD(client); break; }
  3642. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  3643. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  3644. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  3645. case COMMAND_TITLE : { Command_Title(client); break; }
  3646. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  3647. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  3648. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  3649. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  3650. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  3651. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  3652. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  3653. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  3654. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  3655. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  3656. case COMMAND_PET : { Command_Pet(client, sep); break; }
  3657. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  3658. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  3659. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  3660. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  3661. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  3662. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  3663. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  3664. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  3665. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  3666. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  3667. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  3668. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  3669. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  3670. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  3671. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  3672. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  3673. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  3674. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  3675. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  3676. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  3677. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  3678. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  3679. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  3680. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  3681. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  3682. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  3683. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  3684. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  3685. case COMMAND_MODIFY : { Command_Modify(client); break; }
  3686. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  3687. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  3688. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  3689. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  3690. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  3691. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  3692. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  3693. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  3694. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  3695. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  3696. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  3697. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  3698. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  3699. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  3700. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  3701. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  3702. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  3703. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  3704. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  3705. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  3706. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  3707. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  3708. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  3709. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  3710. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  3711. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  3712. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  3713. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  3714. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  3715. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  3716. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  3717. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  3718. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  3719. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  3720. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  3721. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  3722. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  3723. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  3724. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  3725. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  3726. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  3727. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  3728. case ADD_AA : { Add_AA(client, sep); break; }
  3729. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  3730. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  3731. case BACK_AA : { Back_AA(client, sep); break; }
  3732. case REMOVE_AA : { Remove_AA(client, sep); break; }
  3733. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  3734. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  3735. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  3736. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  3737. default:
  3738. {
  3739. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  3740. break;
  3741. }
  3742. }
  3743. safe_delete(sep);
  3744. }
  3745. /******************** New COMMAND Handler Functions ********************/
  3746. /*
  3747. Started breaking apart the huge switch() for commands into sepErate
  3748. functions so it is easier to locate the blocks of code by command
  3749. -- JA 2012.03.03
  3750. */
  3751. // sample function header
  3752. /*
  3753. Function:
  3754. Purpose :
  3755. Params :
  3756. Dev :
  3757. Example :
  3758. */
  3759. //void Commands::Command()
  3760. //{
  3761. //}
  3762. /*
  3763. Function: Command_AcceptAdvancement()
  3764. Purpose : Player accepts a new advancement option
  3765. Params : Spell ID
  3766. Dev : Jabantiz
  3767. */
  3768. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  3769. {
  3770. Player *player = client->GetPlayer();
  3771. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  3772. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  3773. if (!player->HasSpell(trait->spellID, 0, true))
  3774. {
  3775. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  3776. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  3777. }
  3778. else
  3779. {
  3780. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  3781. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  3782. player->RemoveSpellBookEntry(spell->GetSpellID());
  3783. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  3784. player->UnlockSpell(spell);
  3785. client->SendSpellUpdate(spell);
  3786. }
  3787. // Spell book update
  3788. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  3789. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  3790. }
  3791. /*
  3792. Function:
  3793. Purpose :
  3794. Params :
  3795. Dev :
  3796. Example :
  3797. */
  3798. void Commands::Command_AFK(Client* client, Seperator* sep)
  3799. {
  3800. Player* player = client->GetPlayer();
  3801. player->toggle_character_flag(CF_AFK);
  3802. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  3803. if (player->get_character_flag(CF_AFK))
  3804. {
  3805. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  3806. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  3807. if (sep && sep->argplus[0])
  3808. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  3809. else
  3810. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  3811. string message = string(player->GetName()) + " is going afk.";
  3812. Spawn* target = player->GetTarget();
  3813. if (target && target != player)
  3814. {
  3815. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  3816. player->GetGender() == 1 ? message += "he" : message += "she";
  3817. message += " is going afk.";
  3818. }
  3819. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  3820. }
  3821. /*else
  3822. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  3823. }
  3824. /*
  3825. Function: Command_Appearance()
  3826. Purpose : Handles /appearance commands
  3827. Params : list
  3828. Dev : Scatman
  3829. Example : /appearance list
  3830. */
  3831. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  3832. {
  3833. if( handler == COMMAND_APPEARANCE )
  3834. {
  3835. // /appearance command by itself shows help (to be extended)
  3836. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  3837. return;
  3838. }
  3839. else if( handler == COMMAND_APPEARANCE_LIST )
  3840. {
  3841. // /appearance list command expects "name" param
  3842. if (sep && sep->arg[0])
  3843. {
  3844. const char* appearance_name = sep->argplus[0];
  3845. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  3846. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  3847. if (appearances)
  3848. {
  3849. vector<int16>::iterator itr;
  3850. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  3851. {
  3852. int16 id = *itr;
  3853. string name = database.GetAppearanceName(id);
  3854. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  3855. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  3856. }
  3857. safe_delete(appearances);
  3858. }
  3859. }
  3860. else // no param
  3861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  3862. }
  3863. }
  3864. /*
  3865. Function: Command_Claim()
  3866. Purpose :
  3867. Params :
  3868. Dev :
  3869. Example :
  3870. */
  3871. void Commands::Command_Claim(Client* client, Seperator* sep)
  3872. {
  3873. if (sep && sep->arg[0] && sep->IsNumber(0))
  3874. {
  3875. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  3876. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  3877. }
  3878. else
  3879. client->ShowClaimWindow();
  3880. }
  3881. /*
  3882. Function: Command_ClearAllQueued()
  3883. Purpose :
  3884. Params :
  3885. Dev :
  3886. Example :
  3887. */
  3888. void Commands::Command_ClearAllQueued(Client* client)
  3889. {
  3890. ZoneServer* zone = client->GetPlayer()->GetZone();
  3891. if (zone && zone->GetSpellProcess())
  3892. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  3893. }
  3894. /*
  3895. Function: Command_CancelMaintained()
  3896. Purpose : Cancels maintained spells
  3897. Params : Maintained Spell Index
  3898. Dev : Zcoretri
  3899. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  3900. */
  3901. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  3902. {
  3903. if (sep && sep->arg[0] && sep->IsNumber(0))
  3904. {
  3905. int32 spell_index = atoul(sep->arg[0]);
  3906. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  3907. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  3908. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  3909. // just not spelleffects/dets - Foof
  3910. //{
  3911. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell))
  3912. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  3913. // }
  3914. //else
  3915. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  3916. }
  3917. }
  3918. /*
  3919. Function: Command_Create()
  3920. Purpose : Handler for starting Tradeskilling table
  3921. Params :
  3922. Dev : Zcoretri
  3923. Example :
  3924. */
  3925. void Commands::Command_Create(Client* client, Seperator* sep)
  3926. {
  3927. PrintSep(sep, "COMMAND_CREATE");
  3928. client->SendRecipeList();
  3929. client->ShowRecipeBook();
  3930. }
  3931. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  3932. {
  3933. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  3934. if (sep && sep->arg[0] && sep->IsNumber(0))
  3935. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  3936. }
  3937. /*
  3938. Function: Command_Distance()
  3939. Purpose : Displays distance from targeted spawn
  3940. Params :
  3941. Dev : Scatman
  3942. Example : /distance
  3943. */
  3944. void Commands::Command_Distance(Client* client)
  3945. {
  3946. Spawn* target = client->GetPlayer()->GetTarget();
  3947. if (target)
  3948. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  3949. else
  3950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  3951. }
  3952. /*
  3953. Function: Command_Duel()
  3954. Purpose : Handle the /duel commands - not yet implemented
  3955. Params : unknown
  3956. Dev :
  3957. Example :
  3958. */
  3959. void Commands::Command_Duel(Client* client, Seperator* sep)
  3960. {
  3961. PrintSep(sep, "COMMAND_DUEL");
  3962. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  3963. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  3964. }
  3965. /*
  3966. Function: Command_DuelBet()
  3967. Purpose : Handle the /duel commands - not yet implemented
  3968. Params : unknown
  3969. Dev :
  3970. Example :
  3971. */
  3972. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  3973. {
  3974. PrintSep(sep, "COMMAND_DUELBET");
  3975. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  3976. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  3977. }
  3978. /*
  3979. Function: Command_DuelAccept()
  3980. Purpose : Handle the /duel commands - not yet implemented
  3981. Params : unknown
  3982. Dev :
  3983. Example :
  3984. */
  3985. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  3986. {
  3987. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  3988. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  3989. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  3990. }
  3991. /*
  3992. Function: Command_DuelDecline()
  3993. Purpose : Handle the /duel commands - not yet implemented
  3994. Params : unknown
  3995. Dev :
  3996. Example :
  3997. */
  3998. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  3999. {
  4000. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4001. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4002. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4003. }
  4004. /*
  4005. Function: Command_DuelSurrender()
  4006. Purpose : Handle the /duel commands - not yet implemented
  4007. Params : unknown
  4008. Dev :
  4009. Example :
  4010. */
  4011. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4012. {
  4013. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4014. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4015. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4016. // JA, just messin around ;)
  4017. char surrender[64];
  4018. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4019. zone_list.HandleGlobalAnnouncement(surrender);
  4020. }
  4021. /*
  4022. Function: Command_DuelToggle()
  4023. Purpose : Handle the /duel commands - not yet implemented
  4024. Params : unknown
  4025. Dev :
  4026. Example :
  4027. */
  4028. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4029. {
  4030. PrintSep(sep, "COMMAND_DUEL");
  4031. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4032. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4033. }
  4034. /*
  4035. Function:
  4036. Purpose :
  4037. Params :
  4038. Dev :
  4039. Example :
  4040. */
  4041. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4042. {
  4043. if( handler == COMMAND_ENTITYCOMMAND )
  4044. {
  4045. // /entitycommand command by itself shows help (to be extended)
  4046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4047. return;
  4048. }
  4049. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4050. {
  4051. // /entitycommand list command expects "name" param
  4052. if (sep && sep->arg[0])
  4053. {
  4054. const char* entity_command_name = sep->argplus[0];
  4055. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4056. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4057. map<int32, vector<EntityCommand*>*>::iterator itr;
  4058. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4059. {
  4060. vector<EntityCommand*>* entity_command_list = itr->second;
  4061. vector<EntityCommand*>::iterator itr2;
  4062. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4063. {
  4064. EntityCommand* entity_command = *itr2;
  4065. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4066. 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);
  4067. }
  4068. }
  4069. }
  4070. else // no command name
  4071. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4072. }
  4073. }
  4074. /*
  4075. Function: Command_Follow()
  4076. Purpose : Handle the /follow command - not yet implemented
  4077. Params :
  4078. Dev :
  4079. Example :
  4080. */
  4081. void Commands::Command_Follow(Client* client, Seperator* sep)
  4082. {
  4083. PrintSep(sep, "COMMAND_FOLLOW");
  4084. // flag to toggle if the players target is in the players group
  4085. bool targetInGroup = false;
  4086. // get a pointer to the players group
  4087. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4088. // If the player has a group and has a target
  4089. if (gmi && client->GetPlayer()->GetTarget()) {
  4090. deque<GroupMemberInfo*>::iterator itr;
  4091. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4092. deque<GroupMemberInfo*>* members = world.GetGroupManager()->GetGroupMembers(gmi->group_id);
  4093. // Loop through the group members
  4094. for (itr = members->begin(); itr != members->end(); itr++) {
  4095. // If a group member matches a target
  4096. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4097. // toggle the flag and break the loop
  4098. targetInGroup = true;
  4099. break;
  4100. }
  4101. }
  4102. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4103. }
  4104. if (targetInGroup) {
  4105. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4106. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4107. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4108. client->GetPlayer()->info_changed = true;
  4109. client->GetPlayer()->changed = true;
  4110. }
  4111. else
  4112. client->Message(CHANNEL_COLOR_WHITE, "You must first select a group member to follow.");
  4113. }
  4114. /*
  4115. Function: Command_StopFollow()
  4116. Purpose : Handle the /stop_follow command - not yet implemented
  4117. Params :
  4118. Dev :
  4119. Example :
  4120. */
  4121. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4122. {
  4123. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4124. if (client->GetPlayer()->GetFollowTarget()) {
  4125. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4126. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4127. client->GetPlayer()->SetFollowTarget(0);
  4128. client->GetPlayer()->info_changed = true;
  4129. client->GetPlayer()->changed = true;
  4130. }
  4131. }
  4132. #include "../Zone/SPGrid.h"
  4133. /*
  4134. Function: Command_Grid()
  4135. Purpose : Show player's current Grid ID
  4136. Params :
  4137. Dev : Scatman
  4138. Example : /grid
  4139. */
  4140. void Commands::Command_Grid(Client* client)
  4141. {
  4142. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4143. if (client->GetCurrentZone()->Grid != nullptr) {
  4144. int32 grid = client->GetCurrentZone()->Grid->GetGridID(client->GetPlayer());
  4145. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4146. }
  4147. }
  4148. /*
  4149. Function: Command_Guild()
  4150. Purpose : Handler for all UI-related guild commands
  4151. Dev : Scatman
  4152. */
  4153. void Commands::Command_Guild(Client* client, Seperator* sep)
  4154. {
  4155. Guild* guild = client->GetPlayer()->GetGuild();
  4156. if (sep && sep->arg[0])
  4157. {
  4158. const char* command = sep->arg[0];
  4159. int32 length = strlen(command);
  4160. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4161. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4162. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4163. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4164. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4165. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4166. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4167. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4168. guild->KickGuildMember(client, sep->arg[1]);
  4169. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4170. guild->DemoteGuildMember(client, sep->arg[1]);
  4171. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4172. guild->PromoteGuildMember(client, sep->arg[1]);
  4173. else if (strncmp(command, "points", length) == 0 && guild)
  4174. {
  4175. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4176. {
  4177. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4178. {
  4179. float points = atof(sep->arg[2]);
  4180. const char* option = sep->arg[3];
  4181. const char* comment = sep->argplus[4];
  4182. if (strncmp(option, "all", strlen(option)) == 0)
  4183. guild->AddPointsToAll(client, points, comment);
  4184. else if (strncmp(option, "online", strlen(option)) == 0)
  4185. guild->AddPointsToAllOnline(client, points, comment);
  4186. else if (strncmp(option, "group", strlen(option)) == 0)
  4187. guild->AddPointsToGroup(client, points, comment);
  4188. else if (strncmp(option, "raid", strlen(option)) == 0)
  4189. guild->AddPointsToRaid(client, points, comment);
  4190. else
  4191. guild->AddPointsToGuildMember(client, points, option, comment);
  4192. }
  4193. }
  4194. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4195. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4196. else
  4197. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4198. }
  4199. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4200. guild->SetMOTD(sep->argplus[1]);
  4201. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4202. {
  4203. if (sep->arg[1])
  4204. {
  4205. const char* option = sep->arg[1];
  4206. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4207. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4208. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4209. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4210. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4211. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4212. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4213. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4214. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4215. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4216. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4217. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4218. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4219. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4220. else
  4221. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4222. }
  4223. else
  4224. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4225. }
  4226. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4227. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4228. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4229. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4230. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4231. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4232. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4233. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4234. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4235. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4236. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4237. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4238. else if (strncmp(command, "invite", length) == 0 && guild)
  4239. {
  4240. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4241. guild->InvitePlayer(client, sep->arg[1]);
  4242. else
  4243. {
  4244. Spawn* target = client->GetPlayer()->GetTarget();
  4245. if (target)
  4246. {
  4247. if (target->IsPlayer())
  4248. guild->InvitePlayer(client, target->GetName());
  4249. else
  4250. client->Message(CHANNEL_COLOR_WHITE, "%s is not a player.", target->GetName());
  4251. }
  4252. }
  4253. }
  4254. else if (strncmp(command, "accept", length) == 0)
  4255. {
  4256. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4257. if (pgi && pgi->guild && pgi->invited_by)
  4258. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4259. client->SetPendingGuildInvite(0);
  4260. }
  4261. else if (strncmp(command, "decline", length) == 0)
  4262. {
  4263. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4264. if (pgi && pgi->guild && pgi->invited_by)
  4265. {
  4266. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4267. if (client_inviter)
  4268. client_inviter->Message(CHANNEL_COLOR_WHITE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4269. }
  4270. client->SetPendingGuildInvite(0);
  4271. }
  4272. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4273. {
  4274. const char* guild_name = sep->argplus[0];
  4275. if (!guild_list.GetGuild(guild_name))
  4276. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo()->group_id);
  4277. else
  4278. client->SimpleMessage(CHANNEL_COLOR_WHITE, "A guild with that name already exists.");
  4279. }
  4280. else if (strncmp(command, "search", length) == 0)
  4281. client->ShowGuildSearchWindow();
  4282. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4283. {
  4284. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4285. if (to_guild)
  4286. to_guild->SendGuildRecruitingDetails(client);
  4287. }
  4288. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4289. {
  4290. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4291. if (to_guild)
  4292. to_guild->SendGuildRecruitingImages(client);
  4293. }
  4294. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4295. {
  4296. if (sep->arg[1])
  4297. {
  4298. const char* option = sep->arg[1];
  4299. if (strncmp(option, "toggle", strlen(option)) == 0)
  4300. guild->ToggleGuildRecruiterAdventureClass(client);
  4301. }
  4302. else
  4303. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4304. }
  4305. else if (strncmp(command, "display_heraldry", length) == 0)
  4306. {
  4307. // JA: not sure this is right...
  4308. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4309. client->GetPlayer()->SetCharSheetChanged(true);
  4310. }
  4311. else
  4312. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4313. }
  4314. }
  4315. /*
  4316. Function: Command_GuildCreate()
  4317. Purpose : Display's in-game Guild Creation window
  4318. Dev : Scatman
  4319. */
  4320. void Commands::Command_CreateGuild(Client* client)
  4321. {
  4322. client->SendGuildCreateWindow();
  4323. }
  4324. /*
  4325. Function: Command_SetGuildOfficerNote()
  4326. Purpose :
  4327. Dev : Scatman
  4328. */
  4329. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4330. {
  4331. if (sep && sep->arg[0] && sep->arg[1])
  4332. {
  4333. Guild* guild = client->GetPlayer()->GetGuild();
  4334. if (guild)
  4335. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4336. }
  4337. }
  4338. /*
  4339. Function: Command_SetGuildMemberNote()
  4340. Purpose :
  4341. Dev : Scatman
  4342. */
  4343. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4344. {
  4345. if (sep && sep->arg[0] && sep->arg[1])
  4346. {
  4347. Guild* guild = client->GetPlayer()->GetGuild();
  4348. if (guild)
  4349. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4350. }
  4351. }
  4352. /*
  4353. Function: Command_GuildSay()
  4354. Purpose :
  4355. Dev : Scatman
  4356. */
  4357. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4358. {
  4359. Guild* guild = client->GetPlayer()->GetGuild();
  4360. if (guild)
  4361. {
  4362. if (sep && sep->arg[0])
  4363. guild->HandleGuildSay(client, sep->argplus[0]);
  4364. }
  4365. else
  4366. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4367. }
  4368. /*
  4369. Function: Command_OfficerSay()
  4370. Purpose :
  4371. Dev : Scatman
  4372. */
  4373. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4374. {
  4375. Guild* guild = client->GetPlayer()->GetGuild();
  4376. if (guild)
  4377. {
  4378. if (sep && sep->arg[0])
  4379. guild->HandleOfficerSay(client, sep->argplus[0]);
  4380. }
  4381. else
  4382. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4383. }
  4384. /*
  4385. Function: Command_Guilds()
  4386. Purpose : Shows help for /guild command
  4387. Params :
  4388. Dev : Scatman
  4389. Example :
  4390. */
  4391. void Commands::Command_Guilds(Client* client)
  4392. {
  4393. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4394. }
  4395. /*
  4396. Function: Command_GuildsAdd()
  4397. Purpose : Add's players to a guild
  4398. Params : guild_name|guild_id, player name
  4399. Dev : Scatman
  4400. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4401. */
  4402. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4403. {
  4404. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4405. {
  4406. Guild* guild = 0;
  4407. bool found = true;
  4408. if (sep->IsNumber(0))
  4409. {
  4410. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4411. if (!guild)
  4412. {
  4413. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4414. found = false;
  4415. }
  4416. }
  4417. else
  4418. {
  4419. guild = guild_list.GetGuild(sep->arg[0]);
  4420. if (!guild)
  4421. {
  4422. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4423. found = false;
  4424. }
  4425. }
  4426. if (found)
  4427. {
  4428. Client* to_client = 0;
  4429. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4430. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4431. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4432. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4433. if (to_client)
  4434. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  4435. else
  4436. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4437. }
  4438. }
  4439. else
  4440. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  4441. }
  4442. /*
  4443. Function: Command_GuildsCreate()
  4444. Purpose : Creates a guild
  4445. Params : guild_name, player_name (optional)
  4446. Dev : Scatman
  4447. Example : /guilds create [guild name] (player name)
  4448. */
  4449. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  4450. {
  4451. if (sep && sep->arg[0])
  4452. {
  4453. const char* guild_name = sep->arg[0];
  4454. if (!guild_list.GetGuild(guild_name))
  4455. {
  4456. bool ret = false;
  4457. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4458. {
  4459. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4460. if (to_client)
  4461. {
  4462. world.CreateGuild(guild_name, to_client);
  4463. ret = true;
  4464. }
  4465. else
  4466. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  4467. }
  4468. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4469. {
  4470. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4471. if (to_client)
  4472. {
  4473. world.CreateGuild(guild_name, to_client);
  4474. ret = true;
  4475. }
  4476. }
  4477. else
  4478. {
  4479. world.CreateGuild(guild_name);
  4480. ret = true;
  4481. }
  4482. if (ret)
  4483. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  4484. else
  4485. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  4486. }
  4487. else
  4488. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  4489. }
  4490. else
  4491. 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.");
  4492. }
  4493. /*
  4494. Function: Command_GuildsDelete()
  4495. Purpose : Delete's a guild
  4496. Params : guild name
  4497. Dev : Scatman
  4498. Example : /guilds delete Test
  4499. */
  4500. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  4501. {
  4502. if (sep && sep->arg[0])
  4503. {
  4504. Guild* guild = 0;
  4505. bool found = true;
  4506. if (sep->IsNumber(0))
  4507. {
  4508. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4509. if (!guild)
  4510. {
  4511. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4512. found = false;
  4513. }
  4514. }
  4515. else
  4516. {
  4517. guild = guild_list.GetGuild(sep->arg[0]);
  4518. if (!guild)
  4519. {
  4520. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4521. found = false;
  4522. }
  4523. }
  4524. if (found)
  4525. {
  4526. guild->RemoveAllGuildMembers();
  4527. database.DeleteGuild(guild);
  4528. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  4529. guild_list.RemoveGuild(guild, true);
  4530. }
  4531. }
  4532. else
  4533. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  4534. }
  4535. /*
  4536. Function: Command_GuildsList()
  4537. Purpose : Lists current guilds on server
  4538. Params :
  4539. Dev : Scatman
  4540. Example : /guilds list
  4541. */
  4542. void Commands::Command_GuildsList(Client* client)
  4543. {
  4544. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  4545. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  4546. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  4547. if (guilds->size() == 0)
  4548. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  4549. else {
  4550. while (itr.Next()) {
  4551. Guild* guild = itr.second;
  4552. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  4553. }
  4554. }
  4555. }
  4556. /*
  4557. Function: Command_GuildsRemove()
  4558. Purpose : Removes a player from a guild
  4559. Params : guild name|guild id, player name
  4560. Dev : Scatman
  4561. Example : /guilds remove 1 Admin = removes Admin from guild 1
  4562. */
  4563. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  4564. {
  4565. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4566. {
  4567. Guild* guild = 0;
  4568. bool found = true;
  4569. if (sep->IsNumber(0))
  4570. {
  4571. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4572. if (!guild)
  4573. {
  4574. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4575. found = false;
  4576. }
  4577. }
  4578. else
  4579. {
  4580. guild = guild_list.GetGuild(sep->arg[0]);
  4581. if (!guild)
  4582. {
  4583. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4584. found = false;
  4585. }
  4586. }
  4587. if (found)
  4588. {
  4589. Client* to_client = 0;
  4590. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4591. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4592. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4593. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4594. if (to_client)
  4595. {
  4596. Player* to_player = to_client->GetPlayer();
  4597. if (to_player->GetGuild())
  4598. {
  4599. if (to_player->GetGuild() == guild)
  4600. {
  4601. guild->KickGuildMember(client, to_player->GetName());
  4602. }
  4603. else
  4604. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  4605. }
  4606. else
  4607. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  4608. }
  4609. else
  4610. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4611. }
  4612. }
  4613. else
  4614. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  4615. }
  4616. /*
  4617. Function: Command_InspectPlayer()
  4618. Purpose : Handle the Inspect functions
  4619. Params : Client to inspect
  4620. Dev : Scatman
  4621. Example : /inspect Scatman
  4622. */
  4623. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  4624. {
  4625. if (sep && sep->arg[0])
  4626. {
  4627. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  4628. if (inspect_client)
  4629. client->InspectPlayer(inspect_client->GetPlayer());
  4630. }
  4631. else
  4632. {
  4633. Spawn* target = client->GetPlayer()->GetTarget();
  4634. if (target && target->IsPlayer())
  4635. client->InspectPlayer((Player*)target);
  4636. }
  4637. }
  4638. /*
  4639. Function: Command_Inventory()
  4640. Purpose : Handle changes in player inventory
  4641. Params : <TBD>
  4642. Dev : All
  4643. Example : /inventory delete item_id
  4644. */
  4645. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  4646. {
  4647. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  4648. Player* player = client->GetPlayer();
  4649. if(sep && sep->arg[0][0])
  4650. {
  4651. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  4652. if(client->GetPlayer()->GetHP() == 0)
  4653. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  4654. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  4655. {
  4656. int16 index = atoi(sep->arg[1]);
  4657. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  4658. if(item)
  4659. {
  4660. if(item->GetItemScript() && lua_interface)
  4661. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  4662. int32 bag_id = item->details.inv_slot_id;
  4663. database.DeleteItem(client->GetCharacterID(), item, 0);
  4664. client->GetPlayer()->item_list.DestroyItem(index);
  4665. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4666. client->QueuePacket(outapp);
  4667. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  4668. if (outapp)
  4669. client->QueuePacket(outapp);
  4670. }
  4671. }
  4672. 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))
  4673. {
  4674. int16 from_index = atoi(sep->arg[1]);
  4675. sint16 to_slot = atoi(sep->arg[2]);
  4676. sint32 bag_id = atol(sep->arg[3]);
  4677. int8 charges = atoi(sep->arg[4]);
  4678. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  4679. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  4680. {
  4681. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  4682. return;
  4683. }
  4684. sint32 old_inventory_id = 0;
  4685. if(item)
  4686. old_inventory_id = item->details.inv_slot_id;
  4687. //autobank
  4688. if (bag_id == -3 && to_slot == -1)
  4689. {
  4690. if (player->HasFreeBankSlot())
  4691. to_slot = player->FindFreeBankSlot();
  4692. else
  4693. {
  4694. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  4695. return;
  4696. }
  4697. }
  4698. //auto inventory
  4699. if (bag_id == 0 && to_slot == -1)
  4700. {
  4701. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  4702. {
  4703. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  4704. return;
  4705. }
  4706. }
  4707. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  4708. client->QueuePacket(outapp);
  4709. //removed from bag send update
  4710. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  4711. {
  4712. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  4713. if(outapp)
  4714. client->QueuePacket(outapp);
  4715. }
  4716. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  4717. {
  4718. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  4719. if(outapp)
  4720. client->QueuePacket(outapp);
  4721. }
  4722. }
  4723. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  4724. {
  4725. if(client->GetPlayer()->EngagedInCombat())
  4726. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  4727. else
  4728. {
  4729. int16 index = atoi(sep->arg[1]);
  4730. int8 slot_id = 255;
  4731. if(sep->arg[2][0] && sep->IsNumber(2))
  4732. slot_id = atoi(sep->arg[2]);
  4733. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  4734. EQ2Packet* outapp = 0;
  4735. for(int32 i=0;i<packets.size();i++)
  4736. {
  4737. outapp = packets[i];
  4738. if(outapp)
  4739. client->QueuePacket(outapp);
  4740. }
  4741. client->GetPlayer()->ChangePrimaryWeapon();
  4742. client->GetPlayer()->ChangeSecondaryWeapon();
  4743. client->GetPlayer()->ChangeRangedWeapon();
  4744. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  4745. client->QueuePacket(characterSheetPackets);
  4746. }
  4747. }
  4748. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  4749. {
  4750. if (client->GetPlayer()->EngagedInCombat())
  4751. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  4752. else {
  4753. int16 index = atoi(sep->arg[1]);
  4754. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  4755. if (item) {
  4756. // client->GetPlayer()->item_list.DestroyItem(index);
  4757. if (item->item_sets.size() > 0) {
  4758. for (int32 i = 0; i < item->item_sets.size(); i++) {
  4759. ItemSet* set = item->item_sets[i];
  4760. if (set->item_stack_size == 0)
  4761. set->item_stack_size += 1;
  4762. client->AddItem(set->item_id, set->item_stack_size);
  4763. }
  4764. }
  4765. }
  4766. client->RemoveItem(item, 1);
  4767. }
  4768. }
  4769. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  4770. {
  4771. if(client->GetPlayer()->EngagedInCombat())
  4772. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  4773. else
  4774. {
  4775. int16 index = atoi(sep->arg[1]);
  4776. sint32 bag_id = -999;
  4777. int8 to_slot = 255;
  4778. if(sep->arg[3][0])
  4779. {
  4780. if(sep->IsNumber(2))
  4781. bag_id = atol(sep->arg[2]);
  4782. if(sep->IsNumber(3))
  4783. to_slot = atoi(sep->arg[3]);
  4784. }
  4785. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  4786. EQ2Packet* outapp = 0;
  4787. for(int32 i=0;i<packets.size();i++)
  4788. {
  4789. outapp = packets[i];
  4790. if(outapp)
  4791. client->QueuePacket(outapp);
  4792. }
  4793. client->GetPlayer()->ChangePrimaryWeapon();
  4794. client->GetPlayer()->ChangeSecondaryWeapon();
  4795. client->GetPlayer()->ChangeRangedWeapon();
  4796. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  4797. client->QueuePacket(characterSheetPackets);
  4798. }
  4799. }
  4800. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  4801. {
  4802. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4803. int16 index1 = atoi(sep->arg[1]);
  4804. int16 index2 = atoi(sep->arg[2]);
  4805. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  4806. if(outapp)
  4807. client->QueuePacket(outapp);
  4808. else
  4809. {
  4810. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  4811. return;
  4812. }
  4813. }
  4814. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  4815. {
  4816. sint16 to_slot = atoi(sep->arg[1]);
  4817. sint32 bag_id = atoi(sep->arg[2]);
  4818. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  4819. if (item) {
  4820. //auto inventory
  4821. if (bag_id == 0 && to_slot == -1)
  4822. {
  4823. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  4824. {
  4825. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  4826. return;
  4827. }
  4828. // Set the slot for the item
  4829. item->details.inv_slot_id = bag_id;
  4830. item->details.slot_id = to_slot;
  4831. // Flag the item so it gets saved in its new location
  4832. item->save_needed = true;
  4833. // Add the item to its new location
  4834. player->item_list.AddItem(item);
  4835. // Remove the item from the overflow list
  4836. player->item_list.RemoveOverflowItem(item);
  4837. // Send the inventory update packet
  4838. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4839. return;
  4840. }
  4841. else if (bag_id == -3 && to_slot == -1) {
  4842. // Auto Bank
  4843. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  4844. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  4845. return;
  4846. }
  4847. item->details.inv_slot_id = bag_id;
  4848. item->details.slot_id = to_slot;
  4849. item->save_needed = true;
  4850. player->item_list.AddItem(item);
  4851. player->item_list.RemoveOverflowItem(item);
  4852. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4853. }
  4854. else if (bag_id == -4) {
  4855. // Shared Bank
  4856. if (!player->item_list.SharedBankAddAllowed(item)) {
  4857. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  4858. return;
  4859. }
  4860. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  4861. if (tmp_item) {
  4862. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  4863. return;
  4864. }
  4865. else {
  4866. item->details.inv_slot_id = bag_id;
  4867. item->details.slot_id = to_slot;
  4868. item->save_needed = true;
  4869. player->item_list.AddItem(item);
  4870. player->item_list.RemoveOverflowItem(item);
  4871. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4872. return;
  4873. }
  4874. }
  4875. else {
  4876. // Try to get an item from the given bag id and slot id
  4877. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  4878. // Check to see if we got an item, if we do send an error,
  4879. // if we don't put the overflow item into this slot
  4880. if (tmp_item) {
  4881. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  4882. }
  4883. else {
  4884. item->details.inv_slot_id = bag_id;
  4885. item->details.slot_id = to_slot;
  4886. item->save_needed = true;
  4887. player->item_list.AddItem(item);
  4888. player->item_list.RemoveOverflowItem(item);
  4889. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4890. return;
  4891. }
  4892. }
  4893. }
  4894. }
  4895. }
  4896. else
  4897. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  4898. }
  4899. /*
  4900. Function: Command_IRC()
  4901. Purpose : Handle the IRC functions
  4902. Params : IRC Commands
  4903. Dev : Scatman
  4904. Example : /irc say #Channel Hello World!
  4905. */
  4906. void Commands::Command_IRC(Client* client, Seperator* sep)
  4907. {
  4908. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  4909. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  4910. return;
  4911. }
  4912. if (sep && sep->arg[0][0]) {
  4913. if (strcasecmp(sep->arg[0], "say") == 0) {
  4914. if (sep->arg[1][0] && sep->arg[2][0]) {
  4915. if (sep->IsNumber(sep->arg[1]))
  4916. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  4917. else
  4918. irc.Say(client, sep->arg[1], sep->argplus[2]);
  4919. }
  4920. else
  4921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  4922. }
  4923. else if (strcasecmp(sep->arg[0], "join") == 0) {
  4924. if (sep->arg[1][0])
  4925. irc.JoinChannel(client, sep->arg[1]);
  4926. else
  4927. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  4928. }
  4929. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  4930. if (sep->arg[1][0])
  4931. irc.LeaveChannel(client, sep->arg[1]);
  4932. else
  4933. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  4934. }
  4935. else if (strcasecmp(sep->arg[0], "list") == 0)
  4936. irc.ListChannels(client);
  4937. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  4938. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  4939. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  4940. else
  4941. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  4942. }
  4943. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  4944. irc.DisconnectFromServer(client);
  4945. else
  4946. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  4947. }
  4948. else
  4949. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  4950. }
  4951. /*
  4952. Function: Command_Languages()
  4953. Purpose : Show's languages the player knows
  4954. Params :
  4955. Dev : Zcoretri
  4956. Example :
  4957. */
  4958. void Commands::Command_Languages(Client* client, Seperator* sep)
  4959. {
  4960. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  4961. list<Language*>::iterator itr;
  4962. Language* language;
  4963. client->Message(CHANNEL_COLOR_WHITE, "You know the following languages:");
  4964. for(itr = languages->begin(); itr != languages->end(); itr++)
  4965. {
  4966. language = *itr;
  4967. client->Message(CHANNEL_COLOR_WHITE, "%s", language->GetName());
  4968. }
  4969. }
  4970. /*
  4971. Function: Command_SetLanguage()
  4972. Purpose : Handles language commands
  4973. Params : Language ID
  4974. Dev : Zcoretri
  4975. Example :
  4976. */
  4977. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  4978. {
  4979. Player* player = client->GetPlayer();
  4980. if (sep && sep->arg[0])
  4981. {
  4982. if(!sep->IsNumber(0))
  4983. {
  4984. //String passed in
  4985. const char* value = sep->arg[0];
  4986. if(strncasecmp(value, "Common", strlen(value)) == 0)
  4987. {
  4988. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  4989. client->SendLanguagesUpdate(0);
  4990. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", value);
  4991. }
  4992. else
  4993. {
  4994. if(player->HasLanguage(value))
  4995. {
  4996. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  4997. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  4998. client->SendLanguagesUpdate(language->GetID());
  4999. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5000. }
  5001. else
  5002. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", value);
  5003. }
  5004. }
  5005. else
  5006. {
  5007. //Number passed in
  5008. int32 id = atoul(sep->arg[0]);
  5009. if(player->HasLanguage(id))
  5010. {
  5011. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5012. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5013. client->SendLanguagesUpdate(id);
  5014. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5015. }
  5016. else
  5017. {
  5018. Language* language = master_languages_list.GetLanguage(id);
  5019. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", language->GetName());
  5020. }
  5021. }
  5022. }
  5023. else
  5024. {
  5025. //No value was passed in
  5026. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5027. if(id > 0)
  5028. {
  5029. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5030. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking %s ", language->GetName());
  5031. }
  5032. else
  5033. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking Common");
  5034. }
  5035. }
  5036. /*
  5037. Function: Command_LastName()
  5038. Purpose : Sets player surname
  5039. Params : Name text
  5040. Dev : theFoof
  5041. Example :
  5042. */
  5043. void Commands::Command_LastName(Client* client, Seperator* sep)
  5044. {
  5045. if (!client)
  5046. return;
  5047. if (sep && sep->arg[0])
  5048. {
  5049. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5050. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5051. return;
  5052. }
  5053. client->RemovePendingLastName();
  5054. uchar* checkname = (uchar*)sep->arg[0];
  5055. bool valid_name = true;
  5056. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5057. if (!alpha_check(checkname[i])) {
  5058. valid_name = false;
  5059. break;
  5060. }
  5061. }
  5062. if (!valid_name) {
  5063. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5064. return;
  5065. }
  5066. string last_name = (string)sep->arg[0];
  5067. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5068. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5069. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5070. client->SetPendingLastName(last_name);
  5071. client->SendLastNameConfirmation();
  5072. }
  5073. else
  5074. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5075. }
  5076. }
  5077. /*
  5078. Function: Command_ConfirmLastName()
  5079. Purpose : Confirms setting of player surname
  5080. Params : Name text
  5081. Dev : theFoof
  5082. Example :
  5083. */
  5084. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5085. {
  5086. if (!client)
  5087. return;
  5088. string* name = client->GetPendingLastName();
  5089. if (name){
  5090. Player* player = client->GetPlayer();
  5091. player->SetLastName(name->c_str(), false);
  5092. client->SendTitleUpdate();
  5093. player->SetCharSheetChanged(true);
  5094. client->RemovePendingLastName();
  5095. }
  5096. }
  5097. /*
  5098. Function: Command_Location()
  5099. Purpose : Display's Help for /location commands
  5100. Params :
  5101. Dev : Scatman
  5102. Example : /location = show's help for command
  5103. */
  5104. void Commands::Command_Location(Client* client)
  5105. {
  5106. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5107. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5108. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5109. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5110. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5111. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5112. }
  5113. /*
  5114. Function: Command_LocationAdd()
  5115. Purpose : Add's a location to an existing location config
  5116. Params : location_id
  5117. Dev : Scatman
  5118. Example : /location add {location_id}
  5119. */
  5120. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5121. {
  5122. if (sep && sep->arg[0] && sep->IsNumber(0))
  5123. {
  5124. int32 location_id = atoul(sep->arg[0]);
  5125. float x = client->GetPlayer()->GetX();
  5126. float y = client->GetPlayer()->GetY();
  5127. float z = client->GetPlayer()->GetZ();
  5128. if (database.AddLocationPoint(location_id, x, y, z))
  5129. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5130. else
  5131. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5132. }
  5133. else
  5134. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5135. }
  5136. /*
  5137. Function: Command_LocationCreate()
  5138. Purpose : Creates a new location config
  5139. Params : location name, 0/1 for include_y (optional)
  5140. Dev : Scatman
  5141. Example : /location create Test 1 = creates a new location named Test with include_y True
  5142. */
  5143. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5144. {
  5145. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5146. {
  5147. const char* name = sep->arg[0];
  5148. bool include_y = false;
  5149. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5150. include_y = true;
  5151. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5152. if (location_id > 0)
  5153. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5154. else
  5155. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5156. }
  5157. else
  5158. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5159. }
  5160. /*
  5161. Function: Command_LocationDelete()
  5162. Purpose : Delete's a location config and all it's location points
  5163. Params : location_id
  5164. Dev : Scatman
  5165. Example : /location delete {location_id}
  5166. */
  5167. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5168. {
  5169. if (sep && sep->arg[0] && sep->IsNumber(0))
  5170. {
  5171. int32 location_id = atoul(sep->arg[0]);
  5172. if (database.DeleteLocation(location_id))
  5173. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5174. else
  5175. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5176. }
  5177. else
  5178. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5179. }
  5180. /*
  5181. Function: Command_LocationList()
  5182. Purpose : Display's a list of location points
  5183. Params : location_id
  5184. Dev : Scatman
  5185. Example : /location list {location_id}
  5186. */
  5187. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5188. {
  5189. if (sep && sep->arg[0])
  5190. {
  5191. const char* option = sep->arg[0];
  5192. if (strncmp(option, "locations", strlen(option)) == 0)
  5193. database.ListLocations(client);
  5194. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5195. {
  5196. int32 location_id = atoul(sep->arg[1]);
  5197. database.ListLocationPoints(client, location_id);
  5198. }
  5199. else
  5200. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5201. }
  5202. else
  5203. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5204. }
  5205. /*
  5206. Function: Command_LocationRemove()
  5207. Purpose : Removes a single location point from a location config
  5208. Params : location_point_id (gotten from /location list {id})
  5209. Dev : Scatman
  5210. Example : /location remove 1 = will remove location_point_id 1
  5211. */
  5212. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5213. {
  5214. if (sep && sep->arg[0] && sep->IsNumber(0))
  5215. {
  5216. int32 location_point_id = atoul(sep->arg[0]);
  5217. if (database.DeleteLocationPoint(location_point_id))
  5218. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5219. else
  5220. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5221. }
  5222. else
  5223. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5224. }
  5225. /*
  5226. Function: Command_Merchant()
  5227. Purpose : Handles Merchant commands
  5228. Params : list
  5229. Dev : Scatman
  5230. Example : /merchant list
  5231. */
  5232. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5233. {
  5234. if( handler == COMMAND_MERCHANT )
  5235. {
  5236. // /merchant command by itself shows help (to be extended)
  5237. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5238. return;
  5239. }
  5240. else if( handler == COMMAND_MERCHANT_LIST )
  5241. {
  5242. // /merchant list command expects "description" param
  5243. if (sep && sep->arg[0])
  5244. {
  5245. const char* merchant_description = sep->argplus[0];
  5246. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5247. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5248. map<int32, MerchantInfo*>::iterator itr;
  5249. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5250. {
  5251. string description = database.GetMerchantDescription(itr->first);
  5252. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5253. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5254. }
  5255. }
  5256. else // no description
  5257. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5258. }
  5259. }
  5260. /*
  5261. Function: Command_Modify()
  5262. Purpose : to replace our other "set" commands
  5263. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5264. Dev : John Adams
  5265. Example : /modify spell set name "Aegolism III"
  5266. */
  5267. void Commands::Command_Modify(Client* client)
  5268. {
  5269. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5270. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5271. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5272. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5273. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5274. }
  5275. /*
  5276. Function: Command_ModifySpawn()
  5277. Purpose : replace "spawn set" commands
  5278. Params : Action : the action to perform (or special handler)
  5279. : Field : the DB field to change
  5280. : Value : what to set the value to
  5281. : Target : what object to change (my target, or spawn_id)
  5282. Dev : John Adams
  5283. Example : /modify spawn set name "Lady Vox"
  5284. :
  5285. Note : Special Handlers, like "zoneto" for Signs
  5286. : /modify spawn zoneto
  5287. : Will set a sign's zone x/y/z to my current coords
  5288. */
  5289. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5290. {
  5291. PrintSep(sep, "COMMAND_MODIFY");
  5292. // need at least 2 args for a valid command
  5293. if( sep && sep->arg[1] )
  5294. {
  5295. // JA: just a quick implementation because I need it :)
  5296. if (strcmp(sep->arg[0], "zoneto") == 0)
  5297. {
  5298. if( sep->IsNumber(1) )
  5299. {
  5300. int32 spawn_id = atoul(sep->arg[1]);
  5301. float x_coord = client->GetPlayer()->GetX();
  5302. float y_coord = client->GetPlayer()->GetY();
  5303. float z_coord = client->GetPlayer()->GetZ();
  5304. float h_coord = client->GetPlayer()->GetHeading();
  5305. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5306. }
  5307. else
  5308. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5309. }
  5310. }
  5311. else
  5312. Command_Modify(client);
  5313. }
  5314. /*
  5315. Function: Command_ModifyCharacter()
  5316. Purpose : to replace our other "set" commands
  5317. Params : Action : Add, Remove
  5318. : Field : copper, silver, gold, plat
  5319. : Value : min 1, max unlimited
  5320. : Target : Self, Player
  5321. Dev : Cynnar
  5322. Example : /modify character add gold 50
  5323. : /modify character remove silver 25
  5324. */
  5325. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5326. {
  5327. PrintSep(sep, "COMMAND_MODIFY");
  5328. int64 value = 0;
  5329. Player* player = client->GetPlayer();
  5330. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5331. player = (Player*)player->GetTarget();
  5332. // need at least 2 args for a valid command
  5333. if( sep && sep->arg[1] )
  5334. {
  5335. if (strcmp(sep->arg[0], "add") == 0)
  5336. {
  5337. if (strcmp(sep->arg[1], "copper") == 0)
  5338. {
  5339. value = atoi64(sep->arg[2]);
  5340. player->AddCoins(value);
  5341. if (client->GetPlayer() == player)
  5342. {
  5343. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5344. }
  5345. else {
  5346. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5347. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5348. }
  5349. }
  5350. else if (strcmp(sep->arg[1], "silver") == 0)
  5351. {
  5352. value = atoi64(sep->arg[2]) * 100;
  5353. player->AddCoins(value);
  5354. if (client->GetPlayer() == player)
  5355. {
  5356. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5357. }
  5358. else {
  5359. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5360. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5361. }
  5362. }
  5363. else if (strcmp(sep->arg[1], "gold") == 0)
  5364. {
  5365. value = atoi64(sep->arg[2]) * 10000;
  5366. player->AddCoins(value);
  5367. if (client->GetPlayer() == player)
  5368. {
  5369. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5370. }
  5371. else {
  5372. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5373. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5374. }
  5375. }
  5376. else if (strcmp(sep->arg[1], "plat") == 0)
  5377. {
  5378. value = atoi64(sep->arg[2]) * 1000000;
  5379. player->AddCoins(value);
  5380. if (client->GetPlayer() == player)
  5381. {
  5382. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5383. }
  5384. else {
  5385. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5386. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5387. }
  5388. }
  5389. else
  5390. {
  5391. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5392. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5393. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5394. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5395. }
  5396. }
  5397. else if (strcmp(sep->arg[0], "remove") == 0)
  5398. {
  5399. if (strcmp(sep->arg[1], "copper") == 0)
  5400. {
  5401. value = atoi64(sep->arg[2]);
  5402. player->RemoveCoins(value);
  5403. if (client->GetPlayer() == player)
  5404. {
  5405. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5406. }
  5407. else {
  5408. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5409. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5410. }
  5411. }
  5412. else if (strcmp(sep->arg[1], "silver") == 0)
  5413. {
  5414. value = atoi64(sep->arg[2]) * 100;
  5415. player->RemoveCoins(value);
  5416. if (client->GetPlayer() == player)
  5417. {
  5418. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5419. }
  5420. else {
  5421. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5422. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5423. }
  5424. }
  5425. else if (strcmp(sep->arg[1], "gold") == 0)
  5426. {
  5427. value = atoi64(sep->arg[2]) * 10000;
  5428. player->RemoveCoins(value);
  5429. if (client->GetPlayer() == player)
  5430. {
  5431. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  5432. }
  5433. else {
  5434. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  5435. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5436. }
  5437. }
  5438. else if (strcmp(sep->arg[1], "plat") == 0)
  5439. {
  5440. value = atoi64(sep->arg[2]) * 1000000;
  5441. player->RemoveCoins(value);
  5442. if (client->GetPlayer() == player)
  5443. {
  5444. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  5445. }
  5446. else {
  5447. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  5448. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5449. }
  5450. }
  5451. else
  5452. {
  5453. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5454. }
  5455. }
  5456. else if (strcmp(sep->arg[0], "set") == 0) {
  5457. if (strcmp(sep->arg[1], "tslevel") == 0) {
  5458. int8 level = atoi(sep->arg[2]);
  5459. if (level > 0 && level < 256) {
  5460. if (player) {
  5461. if (client->GetPlayer() == player)
  5462. client->ChangeTSLevel(player->GetTSLevel(), level);
  5463. else
  5464. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  5465. }
  5466. }
  5467. else
  5468. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  5469. }
  5470. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  5471. int8 tsclass = atoi(sep->arg[2]);
  5472. player->SetTradeskillClass(tsclass);
  5473. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  5474. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  5475. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  5476. player->SetCharSheetChanged(true);
  5477. }
  5478. }
  5479. }
  5480. else
  5481. {
  5482. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5483. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5484. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5485. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5486. }
  5487. }
  5488. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  5489. {
  5490. PrintSep(sep, "COMMAND_MODIFY");
  5491. // need at least 2 args for a valid command
  5492. if( sep && sep->arg[1] )
  5493. {
  5494. }
  5495. else
  5496. Command_Modify(client);
  5497. }
  5498. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  5499. {
  5500. PrintSep(sep, "COMMAND_MODIFY");
  5501. // need at least 2 args for a valid command
  5502. if( sep && sep->arg[1] )
  5503. {
  5504. }
  5505. else
  5506. Command_Modify(client);
  5507. }
  5508. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  5509. {
  5510. PrintSep(sep, "COMMAND_MODIFY");
  5511. // need at least 2 args for a valid command
  5512. if( sep && sep->arg[1] )
  5513. {
  5514. }
  5515. else
  5516. Command_Modify(client);
  5517. }
  5518. /*
  5519. Function: Command_ModifyQuest()
  5520. Purpose : to list players quest and completed quests
  5521. Params : Action : list, completed
  5522. : Target : Self, Player
  5523. Dev : Cynnar
  5524. Example : /modify quest list
  5525. : /modify quest completed
  5526. */
  5527. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  5528. {
  5529. PrintSep(sep, "COMMAND_MODIFY");
  5530. int64 value = 0;
  5531. Player* player = client->GetPlayer();
  5532. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5533. player = (Player*)player->GetTarget();
  5534. // need at least 2 args for a valid command
  5535. if (sep && sep->arg[1])
  5536. {
  5537. if (strcmp(sep->arg[0], "list") == 0)
  5538. {
  5539. map<int32, Quest*>* quests = player->GetPlayerQuests();
  5540. map<int32, Quest*>::iterator itr;
  5541. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  5542. if (quests->size() == 0)
  5543. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  5544. else
  5545. {
  5546. for (itr = quests->begin(); itr != quests->end(); itr++)
  5547. {
  5548. Quest* quest = itr->second;
  5549. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5550. }
  5551. }
  5552. }
  5553. else if (strcmp(sep->arg[0], "completed") == 0)
  5554. {
  5555. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  5556. map<int32, Quest*>::iterator itr;
  5557. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  5558. if (quests->size() == 0)
  5559. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  5560. else
  5561. {
  5562. for (itr = quests->begin(); itr != quests->end(); itr++)
  5563. {
  5564. Quest* quest = itr->second;
  5565. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5566. }
  5567. }
  5568. }
  5569. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  5570. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  5571. else if (strcmp(sep->arg[0], "remove") == 0)
  5572. {
  5573. int32 quest_id = 0;
  5574. if (sep && sep->arg[1] && sep->IsNumber(1))
  5575. quest_id = atoul(sep->arg[1]);
  5576. if (quest_id > 0)
  5577. {
  5578. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  5579. {
  5580. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5581. if (quest)
  5582. if (client->GetPlayer() == player)
  5583. {
  5584. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  5585. }
  5586. else
  5587. {
  5588. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  5589. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  5590. }
  5591. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  5592. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  5593. }
  5594. client->RemovePlayerQuest(quest_id);
  5595. client->GetCurrentZone()->SendQuestUpdates(client);
  5596. }
  5597. }
  5598. else if (strcmp(sep->arg[0], "advance") == 0)
  5599. {
  5600. int32 quest_id = 0;
  5601. int32 step = 0;
  5602. if (sep && sep->arg[1] && sep->IsNumber(1))
  5603. {
  5604. quest_id = atoul(sep->arg[1]);
  5605. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5606. if (sep && sep->arg[2] && sep->IsNumber(1))
  5607. {
  5608. step = atoul(sep->arg[2]);
  5609. if (quest_id > 0 && step > 0)
  5610. {
  5611. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  5612. {
  5613. if (client)
  5614. {
  5615. client->AddPendingQuestUpdate(quest_id, step);
  5616. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  5617. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  5618. }
  5619. }
  5620. }
  5621. else
  5622. {
  5623. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  5624. }
  5625. }
  5626. else
  5627. {
  5628. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  5629. }
  5630. }
  5631. else
  5632. {
  5633. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  5634. }
  5635. }
  5636. else
  5637. {
  5638. Command_Modify(client);
  5639. }
  5640. }
  5641. else
  5642. {
  5643. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  5644. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  5645. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  5646. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  5647. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  5648. }
  5649. }
  5650. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  5651. {
  5652. PrintSep(sep, "COMMAND_MODIFY");
  5653. // need at least 2 args for a valid command
  5654. if( sep && sep->arg[1] )
  5655. {
  5656. if (strcmp(sep->arg[0], "add") == 0) {
  5657. const char* skill_name = sep->argplus[1];
  5658. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5659. if (skill) {
  5660. Player* player = 0;
  5661. Client* to_client = 0;
  5662. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5663. player = (Player*)client->GetPlayer()->GetTarget();
  5664. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5665. }
  5666. else {
  5667. player = client->GetPlayer();
  5668. to_client = client;
  5669. }
  5670. if (player)
  5671. {
  5672. if (!player->GetSkills()->HasSkill(skill->skill_id))
  5673. {
  5674. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  5675. if (to_client == client) {
  5676. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  5677. }
  5678. else {
  5679. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  5680. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  5681. }
  5682. }
  5683. else
  5684. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  5685. }
  5686. }
  5687. else
  5688. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5689. }
  5690. else if (strcmp(sep->arg[0], "remove") == 0) {
  5691. const char* skill_name = sep->argplus[1];
  5692. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5693. if (skill) {
  5694. Player* player = 0;
  5695. Client* to_client = 0;
  5696. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5697. player = (Player*)client->GetPlayer()->GetTarget();
  5698. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5699. }
  5700. else {
  5701. player = client->GetPlayer();
  5702. to_client = client;
  5703. }
  5704. if (player)
  5705. {
  5706. if (player->GetSkills()->HasSkill(skill->skill_id))
  5707. {
  5708. player->RemoveSkillFromDB(skill, true);
  5709. if (client == to_client) {
  5710. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  5711. }
  5712. else {
  5713. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  5714. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  5715. }
  5716. }
  5717. else {
  5718. if (client == to_client)
  5719. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  5720. else
  5721. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  5722. }
  5723. }
  5724. }
  5725. else
  5726. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5727. }
  5728. else if (strcmp(sep->arg[0], "set") == 0) {
  5729. if (!sep->IsNumber(2)) {
  5730. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  5731. return;
  5732. }
  5733. const char* skill_name = sep->arg[1];
  5734. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5735. if (skill) {
  5736. int16 val = atoi(sep->arg[2]);
  5737. Player* player = 0;
  5738. Client* to_client = 0;
  5739. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5740. player = (Player*)client->GetPlayer()->GetTarget();
  5741. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5742. }
  5743. else {
  5744. player = client->GetPlayer();
  5745. to_client = client;
  5746. }
  5747. if (player)
  5748. {
  5749. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  5750. player->GetSkills()->SetSkill(skill->skill_id, val);
  5751. if (client != to_client)
  5752. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  5753. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  5754. }
  5755. else {
  5756. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  5757. }
  5758. }
  5759. }
  5760. else {
  5761. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5762. }
  5763. }
  5764. else {
  5765. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  5766. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  5767. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  5768. }
  5769. }
  5770. else {
  5771. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  5772. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  5773. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  5774. }
  5775. }
  5776. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  5777. {
  5778. PrintSep(sep, "COMMAND_MODIFY");
  5779. // need at least 2 args for a valid command
  5780. if( sep && sep->arg[1] )
  5781. {
  5782. }
  5783. else
  5784. Command_Modify(client);
  5785. }
  5786. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  5787. {
  5788. PrintSep(sep, "COMMAND_MODIFY");
  5789. // need at least 2 args for a valid command
  5790. if( sep && sep->arg[1] )
  5791. {
  5792. }
  5793. else
  5794. Command_Modify(client);
  5795. }
  5796. /*
  5797. Function: Command_MOTD()
  5798. Purpose : Displays server MOTD
  5799. Params :
  5800. Dev : LethalEncounter
  5801. Example : /motd
  5802. */
  5803. void Commands::Command_MOTD(Client* client)
  5804. {
  5805. if (client)
  5806. ClientPacketFunctions::SendMOTD(client);
  5807. }
  5808. /*
  5809. Function: Command_Pet()
  5810. Purpose : Handle Pet {Command} commands
  5811. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  5812. Dev :
  5813. Example : /pet preserve_master
  5814. */
  5815. void Commands::Command_Pet(Client* client, Seperator* sep)
  5816. {
  5817. PrintSep(sep, "COMMAND_PET");
  5818. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  5819. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  5820. if (strcmp(sep->arg[0], "hide") == 0) {
  5821. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  5822. Entity* pet = client->GetPlayer()->GetDeityPet();
  5823. if (pet) {
  5824. if (pet->IsPrivateSpawn())
  5825. client->GetPlayer()->HideDeityPet(false);
  5826. else
  5827. client->GetPlayer()->HideDeityPet(true);
  5828. }
  5829. pet = client->GetPlayer()->GetCosmeticPet();
  5830. if (pet) {
  5831. if (pet->IsPrivateSpawn())
  5832. client->GetPlayer()->HideCosmeticPet(false);
  5833. else
  5834. client->GetPlayer()->HideCosmeticPet(true);
  5835. }
  5836. return;
  5837. }
  5838. // below is for all combat pets
  5839. if (!client->GetPlayer()->HasPet()) {
  5840. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  5841. return;
  5842. }
  5843. if (strcmp(sep->arg[0], "stay") == 0) {
  5844. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  5845. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  5846. client->GetPlayer()->SetCharSheetChanged(true);
  5847. if (client->GetPlayer()->GetPet())
  5848. client->GetPlayer()->GetPet()->following = false;
  5849. if (client->GetPlayer()->GetCharmedPet())
  5850. client->GetPlayer()->GetCharmedPet()->following = false;
  5851. }
  5852. else if (strcmp(sep->arg[0], "follow") == 0) {
  5853. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  5854. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  5855. client->GetPlayer()->SetCharSheetChanged(true);
  5856. }
  5857. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  5858. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  5859. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  5860. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  5861. }
  5862. else {
  5863. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  5864. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  5865. }
  5866. client->GetPlayer()->SetCharSheetChanged(true);
  5867. }
  5868. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  5869. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  5870. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  5871. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  5872. }
  5873. else {
  5874. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  5875. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  5876. }
  5877. client->GetPlayer()->SetCharSheetChanged(true);
  5878. }
  5879. else if (strcmp(sep->arg[0], "backoff") == 0) {
  5880. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  5881. if (client->GetPlayer()->GetPet())
  5882. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  5883. if (client->GetPlayer()->GetCharmedPet())
  5884. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  5885. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  5886. client->GetPlayer()->SetCharSheetChanged(true);
  5887. }
  5888. else if (strcmp(sep->arg[0], "attack") == 0) {
  5889. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  5890. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  5891. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  5892. if (client->GetPlayer()->GetPet())
  5893. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  5894. if (client->GetPlayer()->GetCharmedPet())
  5895. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  5896. }
  5897. else
  5898. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  5899. }
  5900. else
  5901. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  5902. }
  5903. else if (strcmp(sep->arg[0], "getlost") == 0) {
  5904. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  5905. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  5906. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  5907. }
  5908. else
  5909. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  5910. }
  5911. /*
  5912. Function: Command_PetName()
  5913. Purpose : Pet your name (???)
  5914. Params :
  5915. Dev :
  5916. Example :
  5917. */
  5918. void Commands::Command_PetName(Client* client, Seperator* sep)
  5919. {
  5920. PrintSep(sep, "COMMAND_PETNAME");
  5921. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  5922. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  5923. }
  5924. /*
  5925. Function: Command_NamePet()
  5926. Purpose : Name your pet
  5927. Params :
  5928. Dev :
  5929. Example :
  5930. */
  5931. void Commands::Command_NamePet(Client* client, Seperator* sep)
  5932. {
  5933. PrintSep(sep, "COMMAND_NAME_PET");
  5934. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  5935. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  5936. }
  5937. /*
  5938. Function: Command_Rename()
  5939. Purpose : Renames existing pet
  5940. Params :
  5941. Dev :
  5942. Example :
  5943. */
  5944. void Commands::Command_Rename(Client* client, Seperator* sep)
  5945. {
  5946. PrintSep(sep, "COMMAND_RENAME");
  5947. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  5948. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  5949. }
  5950. /*
  5951. Function: Command_ConfirmRename()
  5952. Purpose : Confirms renaming your pet
  5953. Params :
  5954. Dev :
  5955. Example :
  5956. */
  5957. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  5958. {
  5959. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  5960. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  5961. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  5962. }
  5963. /*
  5964. Function: Command_PetOptions()
  5965. Purpose : Sets various pet options
  5966. Params :
  5967. Dev :
  5968. Example :
  5969. */
  5970. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  5971. {
  5972. PrintSep(sep, "COMMAND_PETOPTIONS");
  5973. Player* player = client->GetPlayer();
  5974. Spawn* target = player->GetTarget();
  5975. if (!target)
  5976. return;
  5977. if (target == player->GetPet())
  5978. client->SendPetOptionsWindow(player->GetPet()->GetName());
  5979. else if (target == player->GetCharmedPet())
  5980. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  5981. else if (target == player->GetCosmeticPet())
  5982. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  5983. else if (target == player->GetDeityPet())
  5984. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  5985. }
  5986. /*
  5987. Function: Command_Random()
  5988. Purpose : Handles /random dice roll in-game
  5989. Params : 1-100
  5990. Dev : Scatman
  5991. Example : /randon 1 100
  5992. */
  5993. void Commands::Command_Random(Client* client, Seperator* sep)
  5994. {
  5995. char message[256] = {0};
  5996. if (sep)
  5997. {
  5998. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  5999. 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])));
  6000. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6001. 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])));
  6002. else
  6003. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6004. }
  6005. else
  6006. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6007. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6008. }
  6009. /*
  6010. Function: Command_Randomize()
  6011. Purpose : Sets randomize (appearance) values for NPCs
  6012. Params : Attrib Name
  6013. Dev : Scatman
  6014. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6015. */
  6016. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6017. {
  6018. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6019. if (target)
  6020. {
  6021. if (target->IsNPC())
  6022. {
  6023. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6024. {
  6025. const char* value = sep->arg[0];
  6026. if (strncasecmp(value, "show", strlen(value)) == 0)
  6027. {
  6028. client->DisplayRandomizeFeatures(target->GetRandomize());
  6029. }
  6030. else
  6031. {
  6032. if (sep->arg[1] && sep->IsNumber(1))
  6033. {
  6034. int8 option = atoi(sep->arg[1]);
  6035. if (option == 0 || option == 1)
  6036. {
  6037. int32 feature = 0;
  6038. char feature_text[32] = {0};
  6039. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6040. feature = RANDOMIZE_GENDER;
  6041. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6042. }
  6043. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6044. feature = RANDOMIZE_RACE;
  6045. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6046. }
  6047. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6048. feature = RANDOMIZE_MODEL_TYPE;
  6049. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6050. }
  6051. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6052. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6053. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6054. }
  6055. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6056. feature = RANDOMIZE_HAIR_TYPE;
  6057. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6058. }
  6059. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6060. feature = RANDOMIZE_WING_TYPE;
  6061. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6062. }
  6063. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6064. feature = RANDOMIZE_CHEEK_TYPE;
  6065. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6066. }
  6067. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6068. feature = RANDOMIZE_CHIN_TYPE;
  6069. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6070. }
  6071. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6072. feature = RANDOMIZE_EAR_TYPE;
  6073. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6074. }
  6075. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6076. feature = RANDOMIZE_EYE_BROW_TYPE;
  6077. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6078. }
  6079. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6080. feature = RANDOMIZE_EYE_TYPE;
  6081. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6082. }
  6083. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6084. feature = RANDOMIZE_LIP_TYPE;
  6085. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6086. }
  6087. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6088. feature = RANDOMIZE_NOSE_TYPE;
  6089. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6090. }
  6091. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6092. feature = RANDOMIZE_EYE_COLOR;
  6093. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6094. }
  6095. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6096. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6097. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6098. }
  6099. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6100. feature = RANDOMIZE_HAIR_COLOR1;
  6101. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6102. }
  6103. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6104. feature = RANDOMIZE_HAIR_COLOR2;
  6105. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6106. }
  6107. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6108. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6109. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6110. }
  6111. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6112. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6113. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6114. }
  6115. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6116. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6117. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6118. }
  6119. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6120. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6121. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6122. }
  6123. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6124. feature = RANDOMIZE_SKIN_COLOR;
  6125. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6126. }
  6127. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6128. feature = RANDOMIZE_WING_COLOR1;
  6129. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6130. }
  6131. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6132. feature = RANDOMIZE_WING_COLOR2;
  6133. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6134. }
  6135. else {
  6136. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6137. 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'.");
  6138. }
  6139. if (feature > 0) {
  6140. if (option == 1) {
  6141. if (target->GetRandomize() & feature)
  6142. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6143. else {
  6144. target->AddRandomize(feature);
  6145. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6146. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6147. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6148. }
  6149. }
  6150. else {
  6151. if (target->GetRandomize() & feature) {
  6152. target->AddRandomize(-feature);
  6153. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6154. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6155. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6156. }
  6157. else
  6158. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6159. }
  6160. }
  6161. }
  6162. else
  6163. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6164. }
  6165. else
  6166. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6167. }
  6168. }
  6169. else {
  6170. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6171. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6172. 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'.");
  6173. }
  6174. }
  6175. else
  6176. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6177. }
  6178. else
  6179. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6180. }
  6181. /*
  6182. Function: Command_ShowCloak()
  6183. Purpose : Character Settings combo box for Show Cloak
  6184. Params : true/false
  6185. Dev : John Adams
  6186. Example :
  6187. */
  6188. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6189. {
  6190. Player* player = client->GetPlayer();
  6191. if (sep && sep->arg[0])
  6192. {
  6193. const char* value = sep->arg[0];
  6194. if (strncasecmp(value, "true", strlen(value)) == 0)
  6195. {
  6196. player->set_character_flag(CF_SHOW_CLOAK);
  6197. player->reset_character_flag(CF2_SHOW_RANGED);
  6198. }
  6199. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6200. player->reset_character_flag(CF_SHOW_CLOAK);
  6201. else
  6202. {
  6203. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6204. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6205. }
  6206. }
  6207. }
  6208. /*
  6209. Function: Command_ShowHelm()
  6210. Purpose : Character Settings combo box for Show Helm
  6211. Params : true/false
  6212. Dev : John Adams
  6213. Example :
  6214. */
  6215. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6216. {
  6217. Player* player = client->GetPlayer();
  6218. if (sep && sep->arg[0])
  6219. {
  6220. const char* value = sep->arg[0];
  6221. if (strncasecmp(value, "true", strlen(value)) == 0)
  6222. {
  6223. player->reset_character_flag(CF_HIDE_HELM);
  6224. player->set_character_flag(CF_HIDE_HOOD);
  6225. }
  6226. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6227. player->set_character_flag(CF_HIDE_HELM);
  6228. else
  6229. {
  6230. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6231. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6232. }
  6233. }
  6234. }
  6235. /*
  6236. Function: Command_ShowHood()
  6237. Purpose : Character Settings combo box for Show Hood
  6238. Params : true/false
  6239. Dev : John Adams
  6240. Example :
  6241. */
  6242. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6243. {
  6244. Player* player = client->GetPlayer();
  6245. if (sep && sep->arg[0])
  6246. {
  6247. const char* value = sep->arg[0];
  6248. if (strncasecmp(value, "true", strlen(value)) == 0)
  6249. {
  6250. player->reset_character_flag(CF_HIDE_HOOD);
  6251. player->set_character_flag(CF_HIDE_HELM);
  6252. }
  6253. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6254. player->set_character_flag(CF_HIDE_HOOD);
  6255. else
  6256. {
  6257. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6258. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6259. }
  6260. }
  6261. }
  6262. /*
  6263. Function: Command_ShowHoodHelm()
  6264. Purpose : Character Settings combo box for Show Helm or Hood
  6265. Params : true/false
  6266. Dev : John Adams
  6267. Example :
  6268. */
  6269. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6270. {
  6271. Player* player = client->GetPlayer();
  6272. if (sep && sep->arg[0])
  6273. {
  6274. const char* value = sep->arg[0];
  6275. if (strncasecmp(value, "true", strlen(value)) == 0)
  6276. {
  6277. player->reset_character_flag(CF_HIDE_HOOD);
  6278. player->reset_character_flag(CF_HIDE_HELM);
  6279. }
  6280. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6281. {
  6282. // don't think we ever wind up in here...
  6283. player->set_character_flag(CF_HIDE_HOOD);
  6284. player->set_character_flag(CF_HIDE_HELM);
  6285. }
  6286. else
  6287. {
  6288. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6289. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6290. }
  6291. }
  6292. }
  6293. /*
  6294. Function: Command_ShowRanged()
  6295. Purpose : Character Settings combo box for Show Ranged weapon
  6296. Params : true/false
  6297. Dev : John Adams
  6298. Example :
  6299. */
  6300. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6301. {
  6302. Player* player = client->GetPlayer();
  6303. if (sep && sep->arg[0])
  6304. {
  6305. const char* value = sep->arg[0];
  6306. if (strncasecmp(value, "true", strlen(value)) == 0)
  6307. {
  6308. player->set_character_flag(CF2_SHOW_RANGED);
  6309. player->reset_character_flag(CF_SHOW_CLOAK);
  6310. }
  6311. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6312. player->reset_character_flag(CF2_SHOW_RANGED);
  6313. else
  6314. {
  6315. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6316. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6317. }
  6318. }
  6319. }
  6320. /*
  6321. Function:
  6322. Purpose :
  6323. Params :
  6324. Dev :
  6325. Example :
  6326. */
  6327. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6328. {
  6329. Player* player = 0;
  6330. Client* to_client = 0;
  6331. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6332. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6333. switch(handler)
  6334. {
  6335. case COMMAND_SKILL:
  6336. {
  6337. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6338. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6339. break;
  6340. }
  6341. case COMMAND_SKILL_ADD:
  6342. {
  6343. if (sep && sep->arg[0])
  6344. {
  6345. const char* skill_name = sep->argplus[0];
  6346. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6347. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6348. {
  6349. player = to_client->GetPlayer();
  6350. if (player)
  6351. {
  6352. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6353. {
  6354. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6355. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6356. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6357. }
  6358. else
  6359. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6360. }
  6361. }
  6362. else if (skill) // add skill to yourself
  6363. {
  6364. player = client->GetPlayer();
  6365. if (player)
  6366. {
  6367. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6368. {
  6369. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6370. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6371. }
  6372. else
  6373. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6374. }
  6375. }
  6376. else
  6377. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6378. }
  6379. else
  6380. {
  6381. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6382. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6383. }
  6384. break;
  6385. }
  6386. case COMMAND_SKILL_REMOVE:
  6387. {
  6388. if (sep && sep->arg[0])
  6389. {
  6390. const char* skill_name = sep->argplus[0];
  6391. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6392. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6393. {
  6394. player = to_client->GetPlayer();
  6395. if (player)
  6396. {
  6397. if (player->GetSkills()->HasSkill(skill->skill_id))
  6398. {
  6399. player->RemoveSkillFromDB(skill, true);
  6400. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6401. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6402. }
  6403. else
  6404. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6405. }
  6406. }
  6407. else if(skill) // remove skill from yourself
  6408. {
  6409. Player* player = client->GetPlayer();
  6410. if (player)
  6411. {
  6412. if (player->GetSkills()->HasSkill(skill->skill_id))
  6413. {
  6414. player->RemoveSkillFromDB(skill, true);
  6415. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6416. }
  6417. else
  6418. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6419. }
  6420. }
  6421. else
  6422. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6423. }
  6424. else
  6425. {
  6426. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  6427. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6428. }
  6429. break;
  6430. }
  6431. case COMMAND_SKILL_LIST:
  6432. {
  6433. if (sep && sep->arg[0])
  6434. {
  6435. const char* skill_name = sep->argplus[0];
  6436. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  6437. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  6438. map<int32, Skill*>::iterator itr;
  6439. if (skills && skills->size() > 0)
  6440. {
  6441. for (itr = skills->begin(); itr != skills->end(); itr++)
  6442. {
  6443. Skill* skill = itr->second;
  6444. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  6445. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  6446. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  6447. }
  6448. }
  6449. }
  6450. else
  6451. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  6452. break;
  6453. }
  6454. }
  6455. }
  6456. /*
  6457. Function: Command_SpawnTemplate()
  6458. Purpose : Create or Use defined Spawn Templates
  6459. Params : create, save, rempve, list
  6460. Dev : John Adams
  6461. Example : /spawn template create "Test"
  6462. */
  6463. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  6464. {
  6465. if (sep == NULL || sep->arg[0] == NULL)
  6466. {
  6467. 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.");
  6468. return;
  6469. }
  6470. // got params, continue
  6471. const char * template_cmd = sep->arg[0];
  6472. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  6473. {
  6474. if (!sep->IsSet(1))
  6475. {
  6476. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  6477. 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.");
  6478. return;
  6479. }
  6480. map<int32, string>* template_names = 0;
  6481. if (sep->IsNumber(1))
  6482. {
  6483. int32 location_id = 0;
  6484. location_id = atoi(sep->arg[1]);
  6485. template_names = database.GetSpawnTemplateListByID(location_id);
  6486. }
  6487. else
  6488. {
  6489. const char* name = 0;
  6490. name = sep->argplus[1];
  6491. template_names = database.GetSpawnTemplateListByName(name);
  6492. }
  6493. if(!template_names)
  6494. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  6495. else
  6496. {
  6497. map<int32, string>::iterator itr;
  6498. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  6499. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  6500. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  6501. safe_delete(template_names);
  6502. }
  6503. }
  6504. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  6505. {
  6506. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6507. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  6508. {
  6509. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  6510. {
  6511. // first, lookup to see if template name already exists
  6512. const char* name = 0;
  6513. name = sep->argplus[1];
  6514. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  6515. if(!template_names)
  6516. {
  6517. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  6518. if( new_template_id > 0 )
  6519. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  6520. else
  6521. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  6522. }
  6523. else
  6524. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  6525. }
  6526. else
  6527. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  6528. }
  6529. else
  6530. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  6531. }
  6532. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  6533. {
  6534. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  6535. {
  6536. int32 template_id = 0;
  6537. template_id = atoi(sep->arg[1]);
  6538. if (database.RemoveSpawnTemplate(template_id))
  6539. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  6540. else
  6541. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  6542. }
  6543. else
  6544. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  6545. }
  6546. // Renamed create to spawn
  6547. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  6548. {
  6549. if (sep && sep->arg[1][0])
  6550. {
  6551. int32 new_location = 0;
  6552. if (sep->IsNumber(1))
  6553. {
  6554. int32 template_id = 0;
  6555. template_id = atoi(sep->arg[1]);
  6556. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  6557. if( new_location > 0 )
  6558. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  6559. else
  6560. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  6561. }
  6562. else
  6563. {
  6564. const char* name = 0;
  6565. name = sep->argplus[1];
  6566. new_location = database.CreateSpawnFromTemplateByName(client, name);
  6567. if( new_location > 0 )
  6568. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  6569. else
  6570. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  6571. }
  6572. }
  6573. else
  6574. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  6575. }
  6576. else
  6577. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  6578. }
  6579. void Commands::Command_Speed(Client* client, Seperator* sep) {
  6580. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  6581. float new_speed = atof(sep->arg[0]);
  6582. if (new_speed > 0.0f)
  6583. {
  6584. client->GetPlayer()->SetSpeed(new_speed);
  6585. client->GetPlayer()->SetCharSheetChanged(true);
  6586. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  6587. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  6588. }
  6589. else
  6590. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  6591. }
  6592. else{
  6593. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  6594. }
  6595. }
  6596. /*
  6597. Function: Command_StationMarketPlace()
  6598. Purpose : just trying to eat the console spam for now
  6599. Params :
  6600. Dev : John
  6601. */
  6602. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  6603. {
  6604. PrintSep(sep, "COMMAND_SMP");
  6605. // This will reduce the spam from once every 10 sec to once every 30 sec,
  6606. // can't seem to reduce it any more get rid of it completely...
  6607. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  6608. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  6609. if (packet) {
  6610. packet->setDataByName("account_id", client->GetAccountID());
  6611. packet->setDataByName("character_id", client->GetCharacterID());
  6612. packet->setDataByName("unknown1", 1, 5);
  6613. packet->setDataByName("unknown1", 26, 6);
  6614. packet->setDataByName("unknown2", 0xFFFFFFFF);
  6615. packet->setDataByName("unknown3", 248, 1);
  6616. client->QueuePacket(packet->serialize());
  6617. }
  6618. safe_delete(packet);
  6619. }
  6620. }
  6621. /*
  6622. Function: Command_StopDrinking()
  6623. Purpose : Stops player from auto-consuming drink
  6624. Params :
  6625. Dev : Zcoretri
  6626. Example : /stopdrinking
  6627. */
  6628. void Commands::Command_StopDrinking(Client* client)
  6629. {
  6630. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  6631. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  6632. }
  6633. /*
  6634. Function: Command_StopEating()
  6635. Purpose : Stops player from auto-consuming food
  6636. Params :
  6637. Dev : Zcoretri
  6638. Example : /stopeating
  6639. */
  6640. void Commands::Command_StopEating(Client* client)
  6641. {
  6642. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  6643. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  6644. }
  6645. /*
  6646. Function: Command_Title()
  6647. Purpose : Help for /title command
  6648. Params : n/a
  6649. Dev : Zcoretri
  6650. Example : /title
  6651. */
  6652. void Commands::Command_Title(Client* client)
  6653. {
  6654. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  6655. }
  6656. /*
  6657. Function: Command_TitleList()
  6658. Purpose : List available titles for player
  6659. Params : n/a
  6660. Dev : Zcoretri
  6661. Example : /title list
  6662. */
  6663. void Commands::Command_TitleList(Client* client)
  6664. {
  6665. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  6666. list<Title*>::iterator itr;
  6667. Title* title;
  6668. int16 i = 0;
  6669. client->Message(CHANNEL_COLOR_WHITE, "Listing available titles:");
  6670. for(itr = titles->begin(); itr != titles->end(); itr++)
  6671. {
  6672. title = *itr;
  6673. client->Message(CHANNEL_COLOR_WHITE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  6674. i++;
  6675. }
  6676. }
  6677. /*
  6678. Function: Command_TitleSetPrefix()
  6679. Purpose : Set Prefix title for player
  6680. Params : Title ID
  6681. Dev : Zcoretri
  6682. Example : /title setprefix 1
  6683. */
  6684. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  6685. {
  6686. if (sep && sep->arg[0] && sep->IsNumber(0))
  6687. {
  6688. int32 index = atoul(sep->arg[0]);
  6689. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  6690. client->SendTitleUpdate();
  6691. }
  6692. }
  6693. /*
  6694. Function: Command_TitleSetSuffix()
  6695. Purpose : Set Suffix title for player
  6696. Params : Title ID
  6697. Dev : Zcoretri
  6698. Example : /title setsuffix 1
  6699. */
  6700. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  6701. {
  6702. if (sep && sep->arg[0] && sep->IsNumber(0))
  6703. {
  6704. int32 index = atoul(sep->arg[0]);
  6705. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  6706. client->SendTitleUpdate();
  6707. }
  6708. }
  6709. /*
  6710. Function: Command_TitleFix()
  6711. Purpose : Fix title for player (???)
  6712. Params :
  6713. Dev : Zcoretri
  6714. Example :
  6715. */
  6716. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  6717. {
  6718. PrintSep(sep, "COMMAND_TITLE_FIX");
  6719. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  6720. }
  6721. /*
  6722. Function: Command_Toggle_Anonymous()
  6723. Purpose : Toggles player Anonymous
  6724. Params :
  6725. Dev : paulgh
  6726. Example : /anon
  6727. */
  6728. void Commands::Command_Toggle_Anonymous(Client* client)
  6729. {
  6730. Player* player = client->GetPlayer();
  6731. player->toggle_character_flag(CF_ANONYMOUS);
  6732. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  6733. if (player->get_character_flag(CF_ANONYMOUS))
  6734. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  6735. else
  6736. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  6737. }
  6738. /*
  6739. Function: Command_Toggle_AutoConsume()
  6740. Purpose : Toggles player food/drink auto consume
  6741. Params : unknown
  6742. Dev : paulgh
  6743. Example : /set_auto_consume
  6744. */
  6745. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  6746. {
  6747. Player* player = client->GetPlayer();
  6748. if (sep && sep->arg[0])
  6749. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  6750. if (sep && sep->arg[0] && sep->IsNumber(0))
  6751. {
  6752. int8 slot = atoi(sep->arg[0]);
  6753. int8 flag = atoi(sep->arg[1]);
  6754. if (slot == EQ2_FOOD_SLOT)
  6755. {
  6756. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  6757. player->SetCharSheetChanged(true);
  6758. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  6759. if (flag == 1)
  6760. client->Message(CHANNEL_COLOR_WHITE, "You decide to eat immediately whenever you become hungry.");
  6761. else
  6762. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the hunger.");
  6763. }
  6764. else
  6765. {
  6766. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  6767. player->SetCharSheetChanged(true);
  6768. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  6769. if (flag == 1)
  6770. client->Message(CHANNEL_COLOR_WHITE, "You decide to drink immediately whenever you become thirsty.");
  6771. else
  6772. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the thirst.");
  6773. }
  6774. }
  6775. }
  6776. /*
  6777. Function: Command_Toggle_BonusXP()
  6778. Purpose : Toggles player Bonus XP
  6779. Params :
  6780. Dev : John Adams
  6781. Example : /disable_char_bonus_exp
  6782. */
  6783. void Commands::Command_Toggle_BonusXP(Client* client)
  6784. {
  6785. Player* player = client->GetPlayer();
  6786. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  6787. player->SetCharSheetChanged(true);
  6788. }
  6789. /*
  6790. Function: Command_Toggle_CombatXP()
  6791. Purpose : Toggles player Adventure XP
  6792. Params :
  6793. Dev : John Adams
  6794. Example : /disable_combat_exp
  6795. */
  6796. void Commands::Command_Toggle_CombatXP(Client* client)
  6797. {
  6798. Player* player = client->GetPlayer();
  6799. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  6800. player->SetCharSheetChanged(true);
  6801. }
  6802. /*
  6803. Function: Command_Toggle_GMHide()
  6804. Purpose : Toggles hiding player GM status
  6805. Params :
  6806. Dev : Scatman
  6807. Example : /gm_hide
  6808. */
  6809. void Commands::Command_Toggle_GMHide(Client* client)
  6810. {
  6811. Player* player = client->GetPlayer();
  6812. player->toggle_character_flag(CF_HIDE_STATUS);
  6813. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  6814. }
  6815. /*
  6816. Function: Command_Toggle_GMVanish()
  6817. Purpose : Toggles hiding GM players from /who searches
  6818. Params :
  6819. Dev : Scatman
  6820. Example : /gm_vanish
  6821. */
  6822. void Commands::Command_Toggle_GMVanish(Client* client)
  6823. {
  6824. Player* player = client->GetPlayer();
  6825. player->toggle_character_flag(CF_GM_HIDDEN);
  6826. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  6827. }
  6828. /*
  6829. Function: Command_Toggle_Illusions()
  6830. Purpose : Toggles player illusion form
  6831. Params : not sure sep is needed, testing
  6832. Dev : paulgh
  6833. Example : /hide_illusions
  6834. */
  6835. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  6836. {
  6837. if (sep && sep->arg[0])
  6838. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  6839. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  6840. }
  6841. /*
  6842. Function: Command_Toggle_LFG()
  6843. Purpose : Toggles player LFG Flag
  6844. Params :
  6845. Dev : paulgh
  6846. Example : /lfg
  6847. */
  6848. void Commands::Command_Toggle_LFG(Client* client)
  6849. {
  6850. Player* player = client->GetPlayer();
  6851. player->toggle_character_flag(CF_LFG);
  6852. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  6853. if (player->get_character_flag(CF_LFG))
  6854. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  6855. else
  6856. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  6857. }
  6858. /*
  6859. Function: Command_Toggle_LFW()
  6860. Purpose : Toggles player LFW Flag
  6861. Params :
  6862. Dev : paulgh
  6863. Example : /lfw
  6864. */
  6865. void Commands::Command_Toggle_LFW(Client* client)
  6866. {
  6867. Player* player = client->GetPlayer();
  6868. player->toggle_character_flag(CF_LFW);
  6869. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  6870. if (player->get_character_flag(CF_LFW))
  6871. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  6872. else
  6873. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  6874. }
  6875. /*
  6876. Function: Command_Toggle_QuestXP()
  6877. Purpose : Toggles player Quest XP
  6878. Params :
  6879. Dev : John Adams
  6880. Example : /disable_quest_exp
  6881. */
  6882. void Commands::Command_Toggle_QuestXP(Client* client)
  6883. {
  6884. Player* player = client->GetPlayer();
  6885. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  6886. player->SetCharSheetChanged(true);
  6887. }
  6888. /*
  6889. Function: Command_Toggle_Roleplaying()
  6890. Purpose : Toggles player Roleplaying flag
  6891. Params :
  6892. Dev : paulgh
  6893. Example : /role
  6894. */
  6895. void Commands::Command_Toggle_Roleplaying(Client* client)
  6896. {
  6897. Player* player = client->GetPlayer();
  6898. player->toggle_character_flag(CF_ROLEPLAYING);
  6899. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  6900. if (player->get_character_flag(CF_ROLEPLAYING))
  6901. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  6902. else
  6903. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  6904. }
  6905. void Commands::Command_Toggle_Duels(Client* client)
  6906. {
  6907. Player* player = client->GetPlayer();
  6908. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  6909. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  6910. }
  6911. void Commands::Command_Toggle_Trades(Client* client)
  6912. {
  6913. Player* player = client->GetPlayer();
  6914. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  6915. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  6916. }
  6917. void Commands::Command_Toggle_Guilds(Client* client)
  6918. {
  6919. Player* player = client->GetPlayer();
  6920. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  6921. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  6922. }
  6923. void Commands::Command_Toggle_Groups(Client* client)
  6924. {
  6925. Player* player = client->GetPlayer();
  6926. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  6927. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  6928. }
  6929. void Commands::Command_Toggle_Raids(Client* client)
  6930. {
  6931. Player* player = client->GetPlayer();
  6932. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  6933. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  6934. }
  6935. void Commands::Command_Toggle_LON(Client* client)
  6936. {
  6937. Player* player = client->GetPlayer();
  6938. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  6939. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  6940. }
  6941. void Commands::Command_Toggle_VoiceChat(Client* client)
  6942. {
  6943. Player* player = client->GetPlayer();
  6944. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  6945. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  6946. }
  6947. /*
  6948. Function: Command_TradeStart()
  6949. Purpose : Starts item/coin trade between players
  6950. Params :
  6951. Dev :
  6952. Example :
  6953. */
  6954. #include "../Trade.h"
  6955. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  6956. {
  6957. PrintSep(sep, "COMMAND_START_TRADE");
  6958. Entity* trader = client->GetPlayer();
  6959. Entity* trader2 = 0;
  6960. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  6961. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  6962. if (spawn) {
  6963. if (spawn->IsEntity())
  6964. trader2 = (Entity*)spawn;
  6965. }
  6966. }
  6967. else if (client->GetPlayer()->GetTarget()) {
  6968. if (client->GetPlayer()->GetTarget()->IsEntity())
  6969. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  6970. }
  6971. // can only trade with player or bots
  6972. if (trader && trader2) {
  6973. if (trader == trader2) {
  6974. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  6975. }
  6976. else if (trader2->IsPlayer() || trader2->IsBot()) {
  6977. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  6978. if (trader->trade)
  6979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  6980. else if (trader2->trade)
  6981. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  6982. else {
  6983. Trade* trade = new Trade(trader, trader2);
  6984. trader->trade = trade;
  6985. trader2->trade = trade;
  6986. }
  6987. }
  6988. else {
  6989. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  6990. }
  6991. }
  6992. else
  6993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  6994. }
  6995. /*
  6996. Function: Command_Track()
  6997. Purpose : Starts/Stops Tracking for a player
  6998. Params :
  6999. Dev : Scatman
  7000. Example : /track
  7001. */
  7002. void Commands::Command_Track(Client* client)
  7003. {
  7004. if (!client->GetPlayer()->GetIsTracking())
  7005. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7006. else
  7007. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7008. }
  7009. /*
  7010. Function: Command_TradeAccept()
  7011. Purpose : Accepts item/coin trade between players
  7012. Params :
  7013. Dev :
  7014. Example :
  7015. */
  7016. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7017. {
  7018. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7019. Trade* trade = client->GetPlayer()->trade;
  7020. if (trade) {
  7021. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7022. if (trade_complete)
  7023. safe_delete(trade);
  7024. }
  7025. else
  7026. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7027. }
  7028. /*
  7029. Function: Command_TradeReject()
  7030. Purpose : Rejects item/coin trade between players
  7031. Params :
  7032. Dev :
  7033. Example :
  7034. */
  7035. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7036. {
  7037. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7038. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7039. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7040. }
  7041. /*
  7042. Function: Command_TradeCancel()
  7043. Purpose : Cancels item/coin trade between players
  7044. Params :
  7045. Dev :
  7046. Example :
  7047. */
  7048. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7049. {
  7050. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7051. Trade* trade = client->GetPlayer()->trade;
  7052. if (trade) {
  7053. trade->CancelTrade(client->GetPlayer());
  7054. safe_delete(trade);
  7055. }
  7056. else
  7057. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7058. }
  7059. /*
  7060. Function: Command_TradeSetCoin()
  7061. Purpose : Sets coin trade between players
  7062. Params :
  7063. Dev :
  7064. Example :
  7065. */
  7066. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7067. {
  7068. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7069. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7070. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7071. }
  7072. /*
  7073. Function: Command_TradeAddCoin()
  7074. Purpose : Adds coin to trade between players
  7075. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7076. Dev :
  7077. Example :
  7078. */
  7079. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7080. {
  7081. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7082. Trade* trade = client->GetPlayer()->trade;
  7083. if (trade) {
  7084. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7085. int32 amount = atoi(sep->arg[0]);
  7086. int64 val = 0;
  7087. switch (handler) {
  7088. case COMMAND_ADD_TRADE_COPPER:
  7089. {
  7090. val = amount;
  7091. trade->AddCoinToTrade(client->GetPlayer(), val);
  7092. break;
  7093. }
  7094. case COMMAND_ADD_TRADE_SILVER:
  7095. {
  7096. val = amount * 100;
  7097. trade->AddCoinToTrade(client->GetPlayer(), val);
  7098. break;
  7099. }
  7100. case COMMAND_ADD_TRADE_GOLD:
  7101. {
  7102. val = amount * 10000;
  7103. trade->AddCoinToTrade(client->GetPlayer(), val);
  7104. break;
  7105. }
  7106. case COMMAND_ADD_TRADE_PLAT:
  7107. {
  7108. val = amount * 1000000;
  7109. trade->AddCoinToTrade(client->GetPlayer(), val);
  7110. break;
  7111. }
  7112. default:
  7113. {
  7114. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7115. break;
  7116. }
  7117. }
  7118. }
  7119. else
  7120. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7121. }
  7122. else
  7123. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7124. }
  7125. /*
  7126. Function: Command_TradeRemoveCoin()
  7127. Purpose : Removes coin from trade between players
  7128. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7129. Dev :
  7130. Example :
  7131. */
  7132. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7133. {
  7134. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7135. Trade* trade = client->GetPlayer()->trade;
  7136. if (trade) {
  7137. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7138. int32 amount = atoi(sep->arg[0]);
  7139. int64 val = 0;
  7140. switch (handler) {
  7141. case COMMAND_REMOVE_TRADE_COPPER:
  7142. {
  7143. val = amount;
  7144. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7145. break;
  7146. }
  7147. case COMMAND_REMOVE_TRADE_SILVER:
  7148. {
  7149. val = amount * 100;
  7150. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7151. break;
  7152. }
  7153. case COMMAND_REMOVE_TRADE_GOLD:
  7154. {
  7155. val = amount * 10000;
  7156. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7157. break;
  7158. }
  7159. case COMMAND_REMOVE_TRADE_PLAT:
  7160. {
  7161. val = amount * 1000000;
  7162. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7163. break;
  7164. }
  7165. default:
  7166. {
  7167. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7168. break;
  7169. }
  7170. }
  7171. }
  7172. else
  7173. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7174. }
  7175. else
  7176. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7177. }
  7178. /*
  7179. Function: Command_TradeAddItem()
  7180. Purpose : Adds item to trade between players
  7181. Params :
  7182. Dev :
  7183. Example :
  7184. */
  7185. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7186. {
  7187. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7188. /*
  7189. arg[0] = item index
  7190. arg[1] = slot
  7191. arg[2] = quantity
  7192. */
  7193. if (!client->GetPlayer()->trade) {
  7194. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7195. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7196. return;
  7197. }
  7198. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7199. Item* item = 0;
  7200. int32 index = atoi(sep->arg[0]);
  7201. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7202. if (item) {
  7203. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7204. if (result == 1)
  7205. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7206. else if (result == 2)
  7207. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7208. else if (result == 3)
  7209. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7210. else if (result == 255)
  7211. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7212. }
  7213. else {
  7214. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7215. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7216. }
  7217. }
  7218. else
  7219. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7220. }
  7221. /*
  7222. Function: Command_TradeRemoveItem()
  7223. Purpose : Removes item from trade between players
  7224. Params :
  7225. Dev :
  7226. Example :
  7227. */
  7228. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7229. {
  7230. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7231. /*
  7232. arg[0] = trade window slot
  7233. */
  7234. Trade* trade = client->GetPlayer()->trade;
  7235. if (trade) {
  7236. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7237. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7238. }
  7239. else
  7240. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7241. }
  7242. else
  7243. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7244. }
  7245. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7246. {
  7247. Item *item = 0;
  7248. sint32 crc;
  7249. if (sep) {
  7250. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7251. if (client->GetVersion() < 1096) {
  7252. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7253. {
  7254. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7255. crc = atol(sep->arg[2]);
  7256. }
  7257. }
  7258. else {
  7259. // From the broker and links in chat
  7260. if (strcmp(sep->arg[0], "crc") == 0) {
  7261. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7262. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7263. crc = atol(sep->arg[3]);
  7264. }
  7265. }
  7266. // From inventory
  7267. if (strcmp(sep->arg[0], "dbid") == 0) {
  7268. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7269. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7270. crc = atol(sep->arg[4]);
  7271. }
  7272. }
  7273. }
  7274. if (item)
  7275. client->ShowDressingRoom(item, crc);
  7276. }
  7277. }
  7278. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7279. const char *channel_name, *password = NULL;
  7280. if (sep == NULL || !sep->IsSet(0)) {
  7281. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7282. return;
  7283. }
  7284. channel_name = sep->arg[0];
  7285. if (sep->IsSet(1))
  7286. password = sep->arg[1];
  7287. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7288. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7289. return;
  7290. }
  7291. if (chat.IsInChannel(client, channel_name)) {
  7292. client->Message(CHANNEL_COLOR_WHITE, "You are already in '%s'.", channel_name);
  7293. return;
  7294. }
  7295. if (chat.HasPassword(channel_name)) {
  7296. if (password == NULL) {
  7297. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': That channel is password protected.", channel_name);
  7298. return;
  7299. }
  7300. if (!chat.PasswordMatches(channel_name, password)) {
  7301. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': The password is not correc.t", channel_name);
  7302. return;
  7303. }
  7304. }
  7305. if (!chat.JoinChannel(client, channel_name))
  7306. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7307. }
  7308. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7309. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7310. Command_JoinChannel(client, sep);
  7311. }
  7312. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7313. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7314. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7315. PrintSep(sep, "tellchannel");
  7316. return;
  7317. }
  7318. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7319. }
  7320. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7321. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  7322. if (!p) return;
  7323. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7324. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  7325. //}
  7326. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7327. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  7328. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  7329. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  7330. if (packet) {
  7331. client->QueuePacket(packet->serialize());
  7332. safe_delete(packet);
  7333. }
  7334. }*/
  7335. /*if (client->GetCurrentZone()->Grid != nullptr) {
  7336. int32 numFaces = 0;
  7337. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  7338. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  7339. map<int32, vector<Face*> >::iterator itr;
  7340. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  7341. numFaces += (*itr).second.size();
  7342. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  7343. }*/
  7344. //uchar blah[] = {
  7345. // 1208 - OP_EQUpdateStoreCmd
  7346. // /*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
  7347. // /*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
  7348. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  7349. // /*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
  7350. /*};
  7351. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7352. int8 val = 0;
  7353. int16 pos = 0;
  7354. int idx = 0;
  7355. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  7356. pos = atoi(sep2->arg[idx]);
  7357. val = atoi(sep2->arg[idx+1]);
  7358. memset(blah+pos, val, 1);
  7359. idx+=2;
  7360. }
  7361. DumpPacket(blah, sizeof(blah));
  7362. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  7363. if (client->GetPlayer()->GetTarget()) {
  7364. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  7365. if (packet) {
  7366. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7367. packet->setDataByName("size", 0);
  7368. packet->setDataByName("unknown2", 0);
  7369. EQ2Packet* app = packet->serialize();
  7370. client->QueuePacket(app);
  7371. safe_delete(packet);
  7372. }
  7373. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  7374. if (set_pov) {
  7375. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7376. EQ2Packet* app_pov = set_pov->serialize();
  7377. client->QueuePacket(app_pov);
  7378. safe_delete(set_pov);
  7379. }
  7380. }
  7381. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7382. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  7383. if (packet) {
  7384. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  7385. packet->setDataByName("Type", atoi(sep2->arg[0]));
  7386. else
  7387. packet->setDataByName("Type", 2);
  7388. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  7389. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  7390. else
  7391. packet->setDataByName("race_id", 0);
  7392. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  7393. packet->setDataByName("gender", atoi(sep2->arg[2]));
  7394. else
  7395. packet->setDataByName("gender", 2);
  7396. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  7397. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  7398. else
  7399. packet->setDataByName("unknown", 0, 0);
  7400. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  7401. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  7402. else
  7403. packet->setDataByName("unknown", 0, 1);
  7404. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  7405. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  7406. else
  7407. packet->setDataByName("unknown", 0, 2);
  7408. client->QueuePacket(packet->serialize());
  7409. }
  7410. safe_delete(packet);
  7411. safe_delete(sep2);
  7412. }
  7413. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  7414. const char *channel_name;
  7415. if (sep == NULL || !sep->IsSet(0)) {
  7416. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  7417. PrintSep(sep);
  7418. return;
  7419. }
  7420. channel_name = sep->arg[0];
  7421. if (!chat.IsInChannel(client, channel_name))
  7422. client->Message(CHANNEL_COLOR_WHITE, "Unable to leave '%s': You are not in the channel.", channel_name);
  7423. else if (!chat.LeaveChannel(client, channel_name))
  7424. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  7425. }
  7426. /*
  7427. Function:
  7428. Purpose :
  7429. Params :
  7430. Dev :
  7431. Example :
  7432. */
  7433. void Commands::Command_WeaponStats(Client* client)
  7434. {
  7435. Player* player = client->GetPlayer();
  7436. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  7437. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  7438. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  7439. client->SimpleMessage(0, "Primary:");
  7440. if (primary) {
  7441. client->Message(0, "Name: %s", primary->name.c_str());
  7442. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  7443. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7444. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  7445. client->Message(0, "Proc Percent: %d%%", 0);
  7446. client->Message(0, "Procs Per Minute: %d", 0);
  7447. }
  7448. else {
  7449. client->SimpleMessage(0, "Name: fist");
  7450. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7451. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7452. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  7453. client->Message(0, "Proc Percent: %d%%", 0);
  7454. client->Message(0, "Procs Per Minute: %d", 0);
  7455. }
  7456. client->SimpleMessage(0, " ");
  7457. client->SimpleMessage(0, " ");
  7458. if (secondary) {
  7459. client->SimpleMessage(0, "Secondary:");
  7460. client->Message(0, "Name: %s", secondary->name.c_str());
  7461. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  7462. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  7463. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  7464. client->Message(0, "Proc Percent: %d%%", 0);
  7465. client->Message(0, "Procs Per Minute: %d", 0);
  7466. client->SimpleMessage(0, " ");
  7467. client->SimpleMessage(0, " ");
  7468. }
  7469. client->SimpleMessage(0, "Ranged:");
  7470. if (ranged) {
  7471. client->Message(0, "Name: %s", ranged->name.c_str());
  7472. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  7473. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  7474. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  7475. client->Message(0, "Proc Percent: %d%%", 0);
  7476. client->Message(0, "Procs Per Minute: %d", 0);
  7477. }
  7478. else
  7479. client->SimpleMessage(0, "None");
  7480. }
  7481. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  7482. const char *channel_name;
  7483. if (sep == NULL || !sep->IsSet(0)) {
  7484. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  7485. return;
  7486. }
  7487. channel_name = sep->arg[0];
  7488. if (!chat.ChannelExists(channel_name))
  7489. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  7490. else
  7491. chat.SendChannelUserList(client, channel_name);
  7492. }
  7493. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  7494. {
  7495. ZoneServer* zone = 0;
  7496. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  7497. if (zone_id > 0)
  7498. {
  7499. zone = zone_list.Get(zone_id, false);
  7500. if (zone)
  7501. {
  7502. zone->SetSafeX(client->GetPlayer()->GetX());
  7503. zone->SetSafeY(client->GetPlayer()->GetY());
  7504. zone->SetSafeZ(client->GetPlayer()->GetZ());
  7505. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  7506. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  7507. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  7508. else
  7509. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  7510. }
  7511. }
  7512. }
  7513. /*
  7514. Function:
  7515. Purpose :
  7516. Params :
  7517. Dev :
  7518. Example :
  7519. */
  7520. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  7521. {
  7522. ZoneInfo* zone_info = new ZoneInfo;
  7523. if (sep && sep->arg[0])
  7524. {
  7525. if (sep->IsNumber(0))
  7526. zone_info->id = atoi(sep->arg[0]);
  7527. else
  7528. zone_info->id = database.GetZoneID(sep->arg[0]);
  7529. if (zone_info->id > 0)
  7530. {
  7531. database.LoadZoneInfo(zone_info);
  7532. 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);
  7533. 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);
  7534. 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);
  7535. 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);
  7536. 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);
  7537. 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);
  7538. 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);
  7539. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  7540. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  7541. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  7542. }
  7543. else
  7544. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  7545. }
  7546. else
  7547. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  7548. safe_delete(zone_info);
  7549. }
  7550. /*
  7551. Function:
  7552. Purpose :
  7553. Params :
  7554. Dev :
  7555. Example :
  7556. */
  7557. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  7558. {
  7559. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  7560. {
  7561. ZoneServer* zone = 0;
  7562. int32 zone_id = 0;
  7563. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  7564. {
  7565. zone_id = atoi(sep->arg[0]);
  7566. zone = zone_list.Get(atoi(sep->arg[0]), false);
  7567. }
  7568. else
  7569. {
  7570. zone_id = database.GetZoneID(sep->arg[0]);
  7571. if (zone_id > 0)
  7572. zone = zone_list.Get(sep->arg[0], false);
  7573. }
  7574. if (zone_id > 0)
  7575. {
  7576. if (zone_set_values.count(string(sep->arg[1])) > 0)
  7577. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  7578. else
  7579. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  7580. }
  7581. else
  7582. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  7583. }
  7584. else
  7585. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  7586. }
  7587. void Commands::Command_Rain(Client* client, Seperator* sep) {
  7588. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  7589. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  7590. return;
  7591. }
  7592. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  7593. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  7594. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  7595. }
  7596. void Commands::Command_Wind(Client* client, Seperator* sep) {
  7597. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  7598. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  7599. return;
  7600. }
  7601. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  7602. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  7603. }
  7604. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  7605. Spawn* spawn = client->GetPlayer()->GetTarget();
  7606. if(spawn) {
  7607. client->SetMerchantTransaction(spawn);
  7608. if (spawn->GetMerchantID() > 0){
  7609. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  7610. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  7611. client->SendBuyMerchantList(sell);
  7612. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  7613. client->SendSellMerchantList(sell);
  7614. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  7615. client->SendBuyBackList(sell);
  7616. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  7617. if (packet) {
  7618. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  7619. packet->setDataByName("type", 16);
  7620. EQ2Packet* outapp = packet->serialize();
  7621. if (outapp)
  7622. client->QueuePacket(outapp);
  7623. safe_delete(packet);
  7624. }
  7625. }
  7626. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  7627. client->SendRepairList();
  7628. }
  7629. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  7630. }
  7631. void Commands::Command_Weather(Client* client, Seperator* sep)
  7632. {
  7633. //PrintSep(sep, "Weather");
  7634. if( sep && sep->arg[0] )
  7635. {
  7636. ZoneServer* zsZone = client->GetCurrentZone();
  7637. const char* value = sep->arg[0];
  7638. // process single-param commands first
  7639. if( strncasecmp(value, "details", strlen(value)) == 0 )
  7640. {
  7641. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  7642. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  7643. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  7644. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  7645. }
  7646. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  7647. {
  7648. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  7649. zsZone->ProcessWeather();
  7650. }
  7651. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  7652. {
  7653. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  7654. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  7655. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  7656. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  7657. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  7658. zsZone->SetWeatherPattern(1);
  7659. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  7660. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  7661. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  7662. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  7663. zsZone->ProcessWeather();
  7664. }
  7665. // process commands with params
  7666. if( sep->arg[1] )
  7667. {
  7668. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  7669. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  7670. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  7671. zsZone->SetWeatherType(atoi(sep->arg[1]));
  7672. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  7673. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  7674. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  7675. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  7676. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  7677. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  7678. }
  7679. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  7680. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  7681. zsZone->SetRain(zsZone->GetCurrentWeather());
  7682. }
  7683. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  7684. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  7685. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  7686. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  7687. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  7688. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  7689. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  7690. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  7691. }
  7692. }
  7693. else
  7694. {
  7695. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  7696. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  7697. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  7698. return;
  7699. }
  7700. }
  7701. void Commands::Command_Select(Client* client, Seperator* sep) {
  7702. if (sep && sep->arg[1]) {
  7703. Spawn* spawn = client->GetPlayer()->GetTarget();
  7704. if (spawn && strlen(sep->arg[1]) > 0)
  7705. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  7706. }
  7707. }
  7708. /*
  7709. Function: Command_ConsumeFood()
  7710. Purpose : Consume Food/Drink and apply mods
  7711. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  7712. Dev : Zcoretri
  7713. Example : /consume_food 22
  7714. */
  7715. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  7716. if (sep && sep->arg[0] && sep->IsNumber(0))
  7717. {
  7718. Player* player = client->GetPlayer();
  7719. int8 slot = atoi(sep->arg[0]);
  7720. Item* item = player->GetEquipmentList()->GetItem(slot);
  7721. if(item) {
  7722. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  7723. if(item->GetItemScript() && lua_interface){
  7724. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  7725. if (slot == 22)
  7726. client->Message(CHANNEL_COLOR_WHITE, "You eat a %s.", item->name.c_str());
  7727. else
  7728. client->Message(CHANNEL_COLOR_WHITE, "You drink a %s.", item->name.c_str());
  7729. }
  7730. }
  7731. if (item->details.count > 1) {
  7732. item->details.count -= 1;
  7733. item->save_needed = true;
  7734. }
  7735. else {
  7736. player->GetEquipmentList()->RemoveItem(slot, true);
  7737. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  7738. }
  7739. client->GetPlayer()->SetCharSheetChanged(true);
  7740. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7741. }
  7742. }
  7743. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  7744. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  7745. if (atoi(sep->arg[0]) == 1) {
  7746. client->GetPlayer()->GetInfoStruct()->vision = 4;
  7747. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  7748. client->GetPlayer()->SetCharSheetChanged(true);
  7749. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  7750. }
  7751. else {
  7752. client->GetPlayer()->GetInfoStruct()->vision = 0;
  7753. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  7754. client->GetPlayer()->SetCharSheetChanged(true);
  7755. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  7756. }
  7757. }
  7758. else
  7759. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  7760. }
  7761. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  7762. {
  7763. if(sep)
  7764. {
  7765. string data;
  7766. if(sep->arg[0]){
  7767. data = string(sep->arg[0]);
  7768. }
  7769. for(int i=1;i<sep->GetMaxArgNum();i++){
  7770. if(sep->arg[i])
  7771. data.append(" ").append(sep->arg[i]);
  7772. }
  7773. const char* target_name = 0;
  7774. int32 spawn_id = 0;
  7775. if(client->GetPlayer()->GetTarget())
  7776. {
  7777. target_name = client->GetPlayer()->GetTarget()->GetName();
  7778. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  7779. }
  7780. else
  7781. target_name = "N/A";
  7782. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  7783. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  7784. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  7785. else
  7786. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  7787. }
  7788. }
  7789. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  7790. PrintSep(sep, "Command_Attune_Inv");
  7791. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  7792. // Get the item index from the first parameter
  7793. int16 index = atoi(sep->arg[0]);
  7794. // Check to see if this is a valid item index for the player, if not exit out of the function
  7795. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  7796. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  7797. return;
  7798. }
  7799. // Get the item
  7800. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  7801. if(item) {
  7802. // Valid item lets check to make sure this item is attunable, if not return out
  7803. if (!item->CheckFlag(ATTUNEABLE)) {
  7804. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  7805. return;
  7806. }
  7807. // Remove the attunable flag
  7808. item->generic_info.item_flags -= ATTUNEABLE;
  7809. // Set the attuned flag
  7810. item->generic_info.item_flags += ATTUNED;
  7811. // Flag this item for saving
  7812. item->save_needed = true;
  7813. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  7814. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  7815. EQ2Packet* outapp = 0;
  7816. for (int32 i=0;i<packets.size();i++) {
  7817. outapp = packets[i];
  7818. if(outapp)
  7819. client->QueuePacket(outapp);
  7820. }
  7821. }
  7822. }
  7823. }
  7824. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  7825. PrintSep(sep, "Command_Reset_Zone_Timer");
  7826. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  7827. int32 db_id = atoul(sep->arg[0]);
  7828. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  7829. if (data) {
  7830. // TODO: add a check to timers to ensure it can be reset
  7831. // Delete the character from the instance
  7832. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  7833. data->instance_id = 0;
  7834. // Update the success time and set to 0 so the player can enter it again
  7835. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  7836. data->last_success_timestamp = 0;
  7837. }
  7838. }*/
  7839. }
  7840. void Commands::Command_Player(Client* client, Seperator* sep) {
  7841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  7842. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  7843. }
  7844. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  7845. // /player coins add 10
  7846. // /player coins add plat 10
  7847. Player* player = client->GetPlayer();
  7848. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7849. player = (Player*)player->GetTarget();
  7850. if (sep && sep->arg[0] && sep->arg[1]) {
  7851. const char* action = sep->arg[0];
  7852. int64 value = 0;
  7853. if (strncasecmp(action, "add", strlen(action)) == 0) {
  7854. if (sep->IsNumber(1)) {
  7855. value = atoi64(sep->arg[1]);
  7856. player->AddCoins(value);
  7857. if (client->GetPlayer() == player)
  7858. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  7859. else {
  7860. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7861. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7862. }
  7863. return;
  7864. }
  7865. else if (sep->arg[2] && sep->IsNumber(2)) {
  7866. const char* type = sep->arg[1];
  7867. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  7868. value = atoi64(sep->arg[2]);
  7869. }
  7870. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  7871. value = atoi64(sep->arg[2]) * 100;
  7872. }
  7873. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  7874. value = atoi64(sep->arg[2]) * 10000;
  7875. }
  7876. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  7877. value = atoi64(sep->arg[2]) * 1000000;
  7878. }
  7879. player->AddCoins(value);
  7880. if (client->GetPlayer() == player)
  7881. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  7882. else {
  7883. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7884. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7885. }
  7886. return;
  7887. }
  7888. }
  7889. }
  7890. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  7891. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  7892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  7893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  7894. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  7895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  7896. }
  7897. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  7898. PrintSep(sep, "ACHIEVEMENT_ADD");
  7899. if (sep && sep->IsSet(0)) {
  7900. int32 spell_id = atoul(sep->arg[1]);
  7901. int8 spell_tier = 0;
  7902. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  7903. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  7904. // addspellbookentry here
  7905. if (spell_tier >= data->maxRank) {
  7906. return;
  7907. }
  7908. if (!spell_tier) {
  7909. spell_tier = 1;
  7910. }
  7911. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  7912. {
  7913. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  7914. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  7915. client->GetPlayer()->UnlockSpell(spell);
  7916. client->SendSpellUpdate(spell);
  7917. }
  7918. else
  7919. {
  7920. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  7921. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  7922. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  7923. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  7924. client->GetPlayer()->UnlockSpell(spell);
  7925. client->SendSpellUpdate(spell);
  7926. }
  7927. // cast spell here
  7928. if (!spell_tier)
  7929. spell_tier = 1;
  7930. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  7931. if (spell) {
  7932. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  7933. }
  7934. }
  7935. else {
  7936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  7937. }
  7938. master_aa_list.DisplayAA(client, 0, 0);
  7939. }
  7940. void Commands::Command_Editor(Client* client, Seperator* sep) {
  7941. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  7942. if (packet) {
  7943. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  7944. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  7945. char command[255];
  7946. url = "browser " + url;
  7947. int32 spawn_id = 0;
  7948. int32 zone_id = 0;
  7949. string type;
  7950. if (client->GetCurrentZone())
  7951. zone_id = client->GetCurrentZone()->GetZoneID();
  7952. if (client->GetPlayer()->GetTarget()) {
  7953. Spawn* target = client->GetPlayer()->GetTarget();
  7954. if (target->IsWidget())
  7955. type = "widgets";
  7956. else if (target->IsSign())
  7957. type = "signs";
  7958. else if (target->IsObject())
  7959. type = "objects";
  7960. else if (target->IsNPC())
  7961. type = "npcs";
  7962. else if (target->IsGroundSpawn())
  7963. type = "ground";
  7964. else
  7965. type = "spawn";
  7966. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  7967. }
  7968. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  7969. packet->setDataByName("accept_command", command);
  7970. }
  7971. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  7972. char command[255];
  7973. url = "browser " + url;
  7974. if (client->GetPlayer()->GetTarget())
  7975. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  7976. packet->setDataByName("accept_command", command);
  7977. }
  7978. else {
  7979. string command = "browser " + url;
  7980. packet->setDataByName("accept_command", command.c_str());
  7981. }
  7982. packet->setDataByName("text", "Open the web editor?");
  7983. packet->setDataByName("accept_text", "Open");
  7984. packet->setDataByName("cancel_text", "Cancel");
  7985. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  7986. packet->setDataByName("unknown2", 50);
  7987. packet->setDataByName("unknown4", 1);
  7988. client->QueuePacket(packet->serialize());
  7989. safe_delete(packet);
  7990. }
  7991. }
  7992. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  7993. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  7994. return;
  7995. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  7996. if(client->GetCurrentRez()->active)
  7997. client->AcceptResurrection();
  7998. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  7999. }
  8000. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  8001. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  8002. return;
  8003. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  8004. if(client->GetCurrentRez()->active)
  8005. client->GetCurrentRez()->should_delete = true;
  8006. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  8007. }
  8008. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  8009. PrintSep(sep, "Switch_AA_Profile");
  8010. if (sep && sep->IsSet(0)) {
  8011. string type = sep->arg[0];
  8012. int8 newtemplate = atoul(sep->arg[1]);
  8013. master_aa_list.DisplayAA(client, newtemplate, 1);
  8014. }
  8015. }
  8016. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  8017. PrintSep(sep, "Get_AA_Xml");
  8018. if (sep && sep->IsSet(0)) {
  8019. string tabnum = sep->arg[0];
  8020. string spellid = sep->arg[1];
  8021. }
  8022. }
  8023. void Commands::Add_AA(Client* client, Seperator* sep) {
  8024. PrintSep(sep, "Add_AA");
  8025. if (sep && sep->IsSet(0)) {
  8026. int32 spell_id = atoul(sep->arg[1]);
  8027. int8 spell_tier = 0;
  8028. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  8029. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  8030. // addspellbookentry here
  8031. if (spell_tier >= data->maxRank) {
  8032. return;
  8033. }
  8034. if (!spell_tier) {
  8035. spell_tier = 1;
  8036. }
  8037. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  8038. {
  8039. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8040. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8041. client->GetPlayer()->UnlockSpell(spell);
  8042. client->SendSpellUpdate(spell);
  8043. }
  8044. else
  8045. {
  8046. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  8047. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  8048. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  8049. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8050. client->GetPlayer()->UnlockSpell(spell);
  8051. client->SendSpellUpdate(spell);
  8052. }
  8053. // cast spell here
  8054. if (!spell_tier)
  8055. spell_tier = 1;
  8056. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8057. if (spell) {
  8058. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  8059. }
  8060. }
  8061. else {
  8062. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  8063. }
  8064. master_aa_list.DisplayAA(client, 0, 0);
  8065. }
  8066. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  8067. PrintSep(sep, "Commit_AA_Profile");
  8068. if (sep && sep->IsSet(0)) {
  8069. }
  8070. }
  8071. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  8072. PrintSep(sep, "Begin_AA_Profile");
  8073. if (sep && sep->IsSet(0)) {
  8074. master_aa_list.DisplayAA(client, 100, 2);
  8075. }
  8076. }
  8077. void Commands::Back_AA(Client* client, Seperator* sep) {
  8078. if (sep && sep->IsSet(0)) {
  8079. PrintSep(sep, "Back_AA");
  8080. }
  8081. }
  8082. void Commands::Remove_AA(Client* client, Seperator* sep) {
  8083. if (sep && sep->IsSet(0)) {
  8084. PrintSep(sep, "Remove_AA");
  8085. }
  8086. }
  8087. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  8088. MasterAAList master_aa_list;
  8089. PrintSep(sep, "Cancel_AA_Profile");
  8090. master_aa_list.DisplayAA(client, 0, 0);
  8091. }
  8092. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  8093. if (sep && sep->IsSet(0)) {
  8094. PrintSep(sep, "Save_AA_Profile");
  8095. }
  8096. }
  8097. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  8098. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  8099. if (!sep->IsNumber(0)) return;
  8100. int32 request_id = atoul(sep->arg[0]);
  8101. if (!sep->IsNumber(1)) return;
  8102. sint32 item_id = atoi(sep->arg[1]);
  8103. if (client->IsCurrentTransmuteID(request_id)) {
  8104. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  8105. }
  8106. else if (client->IsCurrentTransmuteID(item_id)) {
  8107. if (!sep->IsSet(2)) return;
  8108. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  8109. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  8110. }
  8111. }
  8112. }