Commands.cpp 310 KB

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