Commands.cpp 310 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749
  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 if (sep && sep->arg[0][0] && sep->IsNumber(0))
  3004. {
  3005. float radius = atof(sep->arg[0]);
  3006. if ( !client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius) )
  3007. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3008. }
  3009. else {
  3010. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will display information about the currently selected spawn, or in the case of specifying a numerical radius will show minor details about spawns in the players radius.");
  3012. }
  3013. break;
  3014. }
  3015. case COMMAND_SPAWN_TARGET:{
  3016. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3017. int32 spawn_id = atoul(sep->arg[0]);
  3018. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3019. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3020. }
  3021. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3022. float distance = atof(sep->arg[1]);
  3023. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3024. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3025. }
  3026. else{
  3027. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3028. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3029. }
  3030. break;
  3031. }
  3032. case COMMAND_SPAWN_SET:
  3033. {
  3034. Spawn* spawn = client->GetPlayer()->GetTarget();
  3035. sint16 set_type = -1;
  3036. string type_str;
  3037. if (spawn)
  3038. {
  3039. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3040. 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)
  3041. {
  3042. // set the type, which will be 0 if location or list or invalid
  3043. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3044. }
  3045. if(set_type > 0)
  3046. {
  3047. // check if spawn set is NOT a char update, or not location, or isn't a number
  3048. 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)
  3049. {
  3050. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3051. }
  3052. else
  3053. {
  3054. string name = string(spawn->GetName());
  3055. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1]))
  3056. {
  3057. if(set_type == SPAWN_SET_VALUE_NAME)
  3058. {
  3059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3060. }
  3061. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3062. {
  3063. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3064. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3065. }
  3066. else
  3067. {
  3068. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3069. }
  3070. if(set_type != SPAWN_SET_VALUE_FACTION)
  3071. {
  3072. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->arg[1]);
  3073. }
  3074. 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))
  3075. {
  3076. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3077. {
  3078. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3079. }
  3080. else if(spawn->GetSpawnLocationID() > 0)
  3081. {
  3082. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3083. }
  3084. }
  3085. else
  3086. {
  3087. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3088. {
  3089. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3090. }
  3091. else if(spawn->GetDatabaseID() > 0)
  3092. {
  3093. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3094. }
  3095. }
  3096. }
  3097. }
  3098. }
  3099. else if(set_type == 0)
  3100. {
  3101. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3102. map<string, int8>::iterator itr;
  3103. int i=0;
  3104. string list;
  3105. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3106. {
  3107. if(i==10)
  3108. {
  3109. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3110. i = 0;
  3111. }
  3112. if(i>0)
  3113. {
  3114. list.append(", ").append(itr->first);
  3115. }
  3116. else
  3117. {
  3118. list = itr->first;
  3119. }
  3120. }
  3121. if(list.length() > 0)
  3122. {
  3123. // if 1 or more, display in client.
  3124. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3125. }
  3126. }
  3127. else
  3128. {
  3129. // syntax fail
  3130. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3132. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3133. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3134. }
  3135. }
  3136. break;
  3137. }
  3138. case COMMAND_SPAWN_REMOVE:{
  3139. Spawn* spawn = client->GetPlayer()->GetTarget();
  3140. if(spawn && !spawn->IsPlayer()){
  3141. if(spawn->GetSpawnLocationID() > 0){
  3142. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3143. bool delete_spawn = false;
  3144. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3145. if(atoi(sep->arg[0]) == 1)
  3146. delete_spawn = true;
  3147. }
  3148. if(delete_spawn)
  3149. client->GetCurrentZone()->RemoveSpawn(spawn, true, false);
  3150. else
  3151. spawn->SetSpawnLocationID(0);
  3152. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3153. }
  3154. else
  3155. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3156. }
  3157. else
  3158. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3159. }
  3160. else{
  3161. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3162. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3163. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Optionally, you can supply a 1 after the command to despawn it as well. IE /spawn remove 1");
  3164. }
  3165. break;
  3166. }
  3167. case COMMAND_SPAWN_LIST:{
  3168. if(sep && sep->arg[0][0]){
  3169. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3170. vector<string>::iterator itr;
  3171. if(results){
  3172. for(itr=results->begin();itr!=results->end();itr++){
  3173. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3174. }
  3175. safe_delete(results);
  3176. }
  3177. else
  3178. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3179. }
  3180. else{
  3181. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3182. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3183. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3184. }
  3185. break;
  3186. }
  3187. case COMMAND_SPAWN_ADD:{
  3188. Spawn* spawn = client->GetPlayer()->GetTarget();
  3189. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3190. if(spawn->GetSpawnLocationID() > 0){
  3191. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3192. break;
  3193. }
  3194. if(spawn->GetDatabaseID() == 0){
  3195. if(database.SaveSpawnInfo(spawn)) {
  3196. char spawn_type[32];
  3197. memset(spawn_type, 0, sizeof(spawn_type));
  3198. if (spawn->IsNPC())
  3199. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3200. else if (spawn->IsObject())
  3201. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3202. else if (spawn->IsSign())
  3203. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3204. else if (spawn->IsGroundSpawn())
  3205. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3206. else
  3207. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3208. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3209. }
  3210. else
  3211. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3212. }
  3213. int32 spawn_group_id = 0;
  3214. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3215. spawn_group_id = database.GetNextSpawnLocation();
  3216. else
  3217. spawn_group_id = atol(sep->arg[0]);
  3218. int8 percent = 100;
  3219. if(sep->arg[2] && sep->IsNumber(2))
  3220. percent = atoi(sep->arg[2]);
  3221. spawn->SetSpawnLocationID(spawn_group_id);
  3222. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3223. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3224. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3225. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3226. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3227. else
  3228. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3229. }
  3230. else{
  3231. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3232. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3233. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3234. }
  3235. break;
  3236. }
  3237. case COMMAND_SPAWN:{
  3238. int32 id = 0;
  3239. Spawn* spawn = 0;
  3240. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3241. id = atol(sep->arg[0]);
  3242. spawn = client->GetCurrentZone()->GetSpawn(id);
  3243. }
  3244. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3245. id = 0;
  3246. if(!id || !spawn){
  3247. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3248. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3249. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3250. safe_delete(sep);
  3251. return;
  3252. }
  3253. if(sep && sep->arg[1][0]){
  3254. float x = atof(sep->arg[1]);
  3255. spawn->appearance.pos.X = x;
  3256. }
  3257. else
  3258. spawn->SetX(client->GetPlayer()->GetX(), false);
  3259. if(sep && sep->arg[2][0]){
  3260. float y = atof(sep->arg[2]);
  3261. spawn->appearance.pos.Y = y;
  3262. }
  3263. else
  3264. spawn->SetY(client->GetPlayer()->GetY(), false);
  3265. if(sep && sep->arg[3][0]){
  3266. float z = atof(sep->arg[3]);
  3267. spawn->appearance.pos.Z = z;
  3268. }
  3269. else
  3270. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3271. if(sep && sep->arg[4][0]){
  3272. float heading = atof(sep->arg[4]);
  3273. spawn->SetHeading(heading);
  3274. }
  3275. else
  3276. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3277. spawn->SetSpawnOrigX(spawn->GetX());
  3278. spawn->SetSpawnOrigY(spawn->GetY());
  3279. spawn->SetSpawnOrigZ(spawn->GetZ());
  3280. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3281. if(sep && sep->arg[5][0])
  3282. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3283. else
  3284. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3285. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3286. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3287. spawn->SetHP(spawn->GetTotalHP());
  3288. }
  3289. if(spawn->GetTotalPower() == 0){
  3290. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3291. spawn->SetPower(spawn->GetTotalPower());
  3292. }
  3293. const char* script = world.GetSpawnScript(id);
  3294. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3295. spawn->SetSpawnScript(string(script));
  3296. client->GetCurrentZone()->AddSpawn(spawn);
  3297. if(spawn->IsNPC())
  3298. spawn->GetZone()->AddLoot((NPC*)spawn);
  3299. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3300. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3301. break;
  3302. }
  3303. case COMMAND_ADMINFLAG:
  3304. {
  3305. if(sep && sep->arg[0]){
  3306. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3307. sint16 new_status = atoi(sep->arg[1]);
  3308. if(tmp_status == -10)
  3309. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3310. else if(tmp_status >= client->GetAdminStatus())
  3311. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3312. else if (new_status > client->GetAdminStatus())
  3313. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3314. else{
  3315. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3316. if (!client2)
  3317. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3318. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3319. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3320. if (client2) {
  3321. client2->SetAdminStatus(new_status);
  3322. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3323. }
  3324. }
  3325. else
  3326. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3327. }
  3328. }else{
  3329. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3330. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3331. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3332. }
  3333. break;
  3334. }
  3335. case COMMAND_CANNEDEMOTE:{
  3336. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3337. break;
  3338. }
  3339. case COMMAND_BROADCAST: {
  3340. if (sep && sep->arg[0])
  3341. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3342. else
  3343. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3344. break;
  3345. }
  3346. case COMMAND_ANNOUNCE: {
  3347. if (sep && sep->arg[0])
  3348. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3349. else
  3350. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3351. break;
  3352. }
  3353. case COMMAND_RELOAD_ITEMS:{
  3354. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3355. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3356. database.ReloadItemList();
  3357. database.LoadMerchantInformation();
  3358. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3359. break;
  3360. }
  3361. case COMMAND_ENABLE_ABILITY_QUE:{
  3362. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3363. if(app)
  3364. client->QueuePacket(app);
  3365. break;
  3366. }
  3367. case COMMAND_ITEMSEARCH:{
  3368. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3369. if(packet){
  3370. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3371. //packet->setDataByName("unknown", 1);
  3372. packet->setDataByName("unknown2", 5, 0);
  3373. packet->setDataByName("unknown2", 20, 1);
  3374. packet->setDataByName("unknown2", 58, 3);
  3375. packet->setDataByName("unknown2", 40, 4);
  3376. client->QueuePacket(packet->serialize());
  3377. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3378. if(packet2){
  3379. packet2->setDataByName("char_id", client->GetCharacterID());
  3380. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3381. safe_delete(packet2);
  3382. }
  3383. safe_delete(packet);
  3384. }
  3385. break;
  3386. }
  3387. case COMMAND_ANIMTEST:{
  3388. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3389. if(command_packet){
  3390. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  3391. if (client->GetPlayer()->HasTarget())
  3392. id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget());
  3393. command_packet->setDataByName ( "spawn_id" , id);
  3394. int animID = 1;
  3395. if(sep && sep->arg[0] && sep->IsNumber(0))
  3396. animID = atoi(sep->arg[0]);
  3397. VisualState* vs = NULL;
  3398. if(animID == 0)
  3399. {
  3400. vs = visual_states.FindVisualState(sep->arg[0]);
  3401. }
  3402. char msg[128];
  3403. sprintf(msg,"Animation Test ID: %i",animID);
  3404. command_packet->setMediumStringByName ( "emote_msg" , msg );
  3405. if(vs != NULL)
  3406. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  3407. else
  3408. command_packet->setDataByName ( "anim_type", animID );
  3409. command_packet->setDataByName ( "unknown0", 0 );
  3410. EQ2Packet* outapp = command_packet->serialize();
  3411. client->QueuePacket(outapp);
  3412. safe_delete(command_packet);
  3413. }
  3414. break;
  3415. }
  3416. case COMMAND_KICK:
  3417. {
  3418. if( sep == 0 || sep->arg[0] == 0)
  3419. {
  3420. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  3421. }
  3422. else
  3423. {
  3424. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  3425. if ( kickClient == client )
  3426. {
  3427. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  3428. break;
  3429. }
  3430. else if(kickClient != NULL)
  3431. {
  3432. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3433. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  3434. {
  3435. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3436. break;
  3437. }
  3438. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  3439. kickClient->Disconnect();
  3440. }
  3441. else
  3442. {
  3443. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3444. }
  3445. }
  3446. break;
  3447. }
  3448. case COMMAND_LOCK:
  3449. {
  3450. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  3451. int worldLocked = atoi(sep->arg[0]);
  3452. net.world_locked = worldLocked;
  3453. if ( worldLocked )
  3454. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  3455. else
  3456. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  3457. }
  3458. else
  3459. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  3460. break;
  3461. }
  3462. case COMMAND_BAN:{
  3463. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  3464. {
  3465. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  3466. }
  3467. else
  3468. {
  3469. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  3470. if ( kickClient == client )
  3471. {
  3472. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  3473. break;
  3474. }
  3475. else if(kickClient != NULL)
  3476. {
  3477. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3478. if ( maxStatus > client->GetAdminStatus( ) ||
  3479. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  3480. {
  3481. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3482. break;
  3483. }
  3484. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  3485. int perm = atol(sep->arg[1]);
  3486. if ( perm == 1 )
  3487. database.UpdateAdminStatus(sep->arg[0],-2);
  3488. else
  3489. database.UpdateAdminStatus(sep->arg[0],-1);
  3490. kickClient->Disconnect();
  3491. }
  3492. else
  3493. {
  3494. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3495. }
  3496. }
  3497. break;
  3498. }
  3499. case COMMAND_SET_COMBAT_VOICE:{
  3500. int32 value = 0;
  3501. if(sep && sep->arg[0] && sep->IsNumber(0))
  3502. value = atoi(sep->arg[0]);
  3503. client->GetPlayer()->SetCombatVoice(value);
  3504. break;
  3505. }
  3506. case COMMAND_SET_EMOTE_VOICE:{
  3507. int32 value = 0;
  3508. if(sep && sep->arg[0] && sep->IsNumber(0))
  3509. value = atoi(sep->arg[0]);
  3510. client->GetPlayer()->SetEmoteVoice(value);
  3511. break;
  3512. }
  3513. case COMMAND_GIVEITEM:{
  3514. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  3515. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  3516. if ( itemToClient == NULL )
  3517. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  3518. else
  3519. {
  3520. int32 item_id = atol(sep->arg[1]);
  3521. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  3522. itemToClient->AddItem(item_id);
  3523. }
  3524. }
  3525. else
  3526. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  3527. break;
  3528. }
  3529. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  3530. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  3531. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  3532. case COMMAND_SKILL :
  3533. case COMMAND_SKILL_ADD :
  3534. case COMMAND_SKILL_REMOVE :
  3535. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  3536. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  3537. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  3538. case COMMAND_ENTITYCOMMAND :
  3539. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  3540. case COMMAND_MERCHANT :
  3541. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  3542. case COMMAND_APPEARANCE :
  3543. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  3544. case COMMAND_TRACK : { Command_Track(client); break; }
  3545. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  3546. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  3547. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  3548. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  3549. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  3550. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  3551. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  3552. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  3553. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  3554. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  3555. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  3556. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  3557. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  3558. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  3559. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  3560. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  3561. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  3562. case COMMAND_LOCATION : { Command_Location(client); break; }
  3563. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  3564. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  3565. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  3566. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  3567. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  3568. case COMMAND_GRID : { Command_Grid(client); break; }
  3569. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  3570. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  3571. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  3572. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  3573. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  3574. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  3575. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  3576. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  3577. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  3578. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  3579. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  3580. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  3581. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  3582. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  3583. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  3584. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  3585. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  3586. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  3587. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  3588. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  3589. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  3590. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  3591. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  3592. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  3593. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  3594. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  3595. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  3596. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  3597. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  3598. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  3599. case COMMAND_MOTD : { Command_MOTD(client); break; }
  3600. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  3601. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  3602. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  3603. case COMMAND_TITLE : { Command_Title(client); break; }
  3604. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  3605. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  3606. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  3607. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  3608. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  3609. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  3610. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  3611. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  3612. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  3613. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  3614. case COMMAND_PET : { Command_Pet(client, sep); break; }
  3615. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  3616. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  3617. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  3618. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  3619. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  3620. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  3621. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  3622. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  3623. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  3624. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  3625. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  3626. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  3627. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  3628. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  3629. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  3630. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  3631. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  3632. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  3633. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  3634. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  3635. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  3636. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  3637. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  3638. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  3639. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  3640. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  3641. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  3642. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  3643. case COMMAND_MODIFY : { Command_Modify(client); break; }
  3644. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  3645. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  3646. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  3647. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  3648. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  3649. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  3650. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  3651. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  3652. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  3653. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  3654. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  3655. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  3656. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  3657. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  3658. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  3659. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  3660. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  3661. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  3662. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  3663. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  3664. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  3665. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  3666. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  3667. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  3668. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  3669. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  3670. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  3671. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  3672. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  3673. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  3674. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  3675. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  3676. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  3677. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  3678. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  3679. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  3680. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  3681. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  3682. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  3683. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  3684. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  3685. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  3686. case ADD_AA : { Add_AA(client, sep); break; }
  3687. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  3688. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  3689. case BACK_AA : { Back_AA(client, sep); break; }
  3690. case REMOVE_AA : { Remove_AA(client, sep); break; }
  3691. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  3692. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  3693. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  3694. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  3695. default:
  3696. {
  3697. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  3698. break;
  3699. }
  3700. }
  3701. safe_delete(sep);
  3702. }
  3703. /******************** New COMMAND Handler Functions ********************/
  3704. /*
  3705. Started breaking apart the huge switch() for commands into sepErate
  3706. functions so it is easier to locate the blocks of code by command
  3707. -- JA 2012.03.03
  3708. */
  3709. // sample function header
  3710. /*
  3711. Function:
  3712. Purpose :
  3713. Params :
  3714. Dev :
  3715. Example :
  3716. */
  3717. //void Commands::Command()
  3718. //{
  3719. //}
  3720. /*
  3721. Function: Command_AcceptAdvancement()
  3722. Purpose : Player accepts a new advancement option
  3723. Params : Spell ID
  3724. Dev : Jabantiz
  3725. */
  3726. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  3727. {
  3728. Player *player = client->GetPlayer();
  3729. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  3730. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  3731. if (!player->HasSpell(trait->spellID, 0, true))
  3732. {
  3733. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  3734. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  3735. }
  3736. else
  3737. {
  3738. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  3739. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  3740. player->RemoveSpellBookEntry(spell->GetSpellID());
  3741. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  3742. player->UnlockSpell(spell);
  3743. client->SendSpellUpdate(spell);
  3744. }
  3745. // Spell book update
  3746. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  3747. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  3748. }
  3749. /*
  3750. Function:
  3751. Purpose :
  3752. Params :
  3753. Dev :
  3754. Example :
  3755. */
  3756. void Commands::Command_AFK(Client* client, Seperator* sep)
  3757. {
  3758. Player* player = client->GetPlayer();
  3759. player->toggle_character_flag(CF_AFK);
  3760. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  3761. if (player->get_character_flag(CF_AFK))
  3762. {
  3763. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  3764. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  3765. if (sep && sep->argplus[0])
  3766. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  3767. else
  3768. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  3769. string message = string(player->GetName()) + " is going afk.";
  3770. Spawn* target = player->GetTarget();
  3771. if (target && target != player)
  3772. {
  3773. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  3774. player->GetGender() == 1 ? message += "he" : message += "she";
  3775. message += " is going afk.";
  3776. }
  3777. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  3778. }
  3779. /*else
  3780. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  3781. }
  3782. /*
  3783. Function: Command_Appearance()
  3784. Purpose : Handles /appearance commands
  3785. Params : list
  3786. Dev : Scatman
  3787. Example : /appearance list
  3788. */
  3789. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  3790. {
  3791. if( handler == COMMAND_APPEARANCE )
  3792. {
  3793. // /appearance command by itself shows help (to be extended)
  3794. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  3795. return;
  3796. }
  3797. else if( handler == COMMAND_APPEARANCE_LIST )
  3798. {
  3799. // /appearance list command expects "name" param
  3800. if (sep && sep->arg[0])
  3801. {
  3802. const char* appearance_name = sep->argplus[0];
  3803. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  3804. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  3805. if (appearances)
  3806. {
  3807. vector<int16>::iterator itr;
  3808. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  3809. {
  3810. int16 id = *itr;
  3811. string name = database.GetAppearanceName(id);
  3812. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  3813. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  3814. }
  3815. safe_delete(appearances);
  3816. }
  3817. }
  3818. else // no param
  3819. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  3820. }
  3821. }
  3822. /*
  3823. Function: Command_Claim()
  3824. Purpose :
  3825. Params :
  3826. Dev :
  3827. Example :
  3828. */
  3829. void Commands::Command_Claim(Client* client, Seperator* sep)
  3830. {
  3831. if (sep && sep->arg[0] && sep->IsNumber(0))
  3832. {
  3833. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  3834. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  3835. }
  3836. else
  3837. client->ShowClaimWindow();
  3838. }
  3839. /*
  3840. Function: Command_ClearAllQueued()
  3841. Purpose :
  3842. Params :
  3843. Dev :
  3844. Example :
  3845. */
  3846. void Commands::Command_ClearAllQueued(Client* client)
  3847. {
  3848. ZoneServer* zone = client->GetPlayer()->GetZone();
  3849. if (zone && zone->GetSpellProcess())
  3850. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  3851. }
  3852. /*
  3853. Function: Command_CancelMaintained()
  3854. Purpose : Cancels maintained spells
  3855. Params : Maintained Spell Index
  3856. Dev : Zcoretri
  3857. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  3858. */
  3859. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  3860. {
  3861. if (sep && sep->arg[0] && sep->IsNumber(0))
  3862. {
  3863. int32 spell_index = atoul(sep->arg[0]);
  3864. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  3865. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  3866. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  3867. // just not spelleffects/dets - Foof
  3868. //{
  3869. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell))
  3870. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  3871. // }
  3872. //else
  3873. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  3874. }
  3875. }
  3876. /*
  3877. Function: Command_Create()
  3878. Purpose : Handler for starting Tradeskilling table
  3879. Params :
  3880. Dev : Zcoretri
  3881. Example :
  3882. */
  3883. void Commands::Command_Create(Client* client, Seperator* sep)
  3884. {
  3885. PrintSep(sep, "COMMAND_CREATE");
  3886. client->SendRecipeList();
  3887. client->ShowRecipeBook();
  3888. }
  3889. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  3890. {
  3891. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  3892. if (sep && sep->arg[0] && sep->IsNumber(0))
  3893. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  3894. }
  3895. /*
  3896. Function: Command_Distance()
  3897. Purpose : Displays distance from targeted spawn
  3898. Params :
  3899. Dev : Scatman
  3900. Example : /distance
  3901. */
  3902. void Commands::Command_Distance(Client* client)
  3903. {
  3904. Spawn* target = client->GetPlayer()->GetTarget();
  3905. if (target)
  3906. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  3907. else
  3908. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  3909. }
  3910. /*
  3911. Function: Command_Duel()
  3912. Purpose : Handle the /duel commands - not yet implemented
  3913. Params : unknown
  3914. Dev :
  3915. Example :
  3916. */
  3917. void Commands::Command_Duel(Client* client, Seperator* sep)
  3918. {
  3919. PrintSep(sep, "COMMAND_DUEL");
  3920. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  3921. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  3922. }
  3923. /*
  3924. Function: Command_DuelBet()
  3925. Purpose : Handle the /duel commands - not yet implemented
  3926. Params : unknown
  3927. Dev :
  3928. Example :
  3929. */
  3930. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  3931. {
  3932. PrintSep(sep, "COMMAND_DUELBET");
  3933. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  3934. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  3935. }
  3936. /*
  3937. Function: Command_DuelAccept()
  3938. Purpose : Handle the /duel commands - not yet implemented
  3939. Params : unknown
  3940. Dev :
  3941. Example :
  3942. */
  3943. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  3944. {
  3945. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  3946. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  3947. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  3948. }
  3949. /*
  3950. Function: Command_DuelDecline()
  3951. Purpose : Handle the /duel commands - not yet implemented
  3952. Params : unknown
  3953. Dev :
  3954. Example :
  3955. */
  3956. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  3957. {
  3958. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  3959. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  3960. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  3961. }
  3962. /*
  3963. Function: Command_DuelSurrender()
  3964. Purpose : Handle the /duel commands - not yet implemented
  3965. Params : unknown
  3966. Dev :
  3967. Example :
  3968. */
  3969. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  3970. {
  3971. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  3972. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  3973. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  3974. // JA, just messin around ;)
  3975. char surrender[64];
  3976. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  3977. zone_list.HandleGlobalAnnouncement(surrender);
  3978. }
  3979. /*
  3980. Function: Command_DuelToggle()
  3981. Purpose : Handle the /duel commands - not yet implemented
  3982. Params : unknown
  3983. Dev :
  3984. Example :
  3985. */
  3986. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  3987. {
  3988. PrintSep(sep, "COMMAND_DUEL");
  3989. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  3990. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  3991. }
  3992. /*
  3993. Function:
  3994. Purpose :
  3995. Params :
  3996. Dev :
  3997. Example :
  3998. */
  3999. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4000. {
  4001. if( handler == COMMAND_ENTITYCOMMAND )
  4002. {
  4003. // /entitycommand command by itself shows help (to be extended)
  4004. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4005. return;
  4006. }
  4007. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4008. {
  4009. // /entitycommand list command expects "name" param
  4010. if (sep && sep->arg[0])
  4011. {
  4012. const char* entity_command_name = sep->argplus[0];
  4013. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4014. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4015. map<int32, vector<EntityCommand*>*>::iterator itr;
  4016. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4017. {
  4018. vector<EntityCommand*>* entity_command_list = itr->second;
  4019. vector<EntityCommand*>::iterator itr2;
  4020. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4021. {
  4022. EntityCommand* entity_command = *itr2;
  4023. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4024. 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);
  4025. }
  4026. }
  4027. }
  4028. else // no command name
  4029. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4030. }
  4031. }
  4032. /*
  4033. Function: Command_Follow()
  4034. Purpose : Handle the /follow command - not yet implemented
  4035. Params :
  4036. Dev :
  4037. Example :
  4038. */
  4039. void Commands::Command_Follow(Client* client, Seperator* sep)
  4040. {
  4041. PrintSep(sep, "COMMAND_FOLLOW");
  4042. // flag to toggle if the players target is in the players group
  4043. bool targetInGroup = false;
  4044. // get a pointer to the players group
  4045. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4046. // If the player has a group and has a target
  4047. if (gmi && client->GetPlayer()->GetTarget()) {
  4048. deque<GroupMemberInfo*>::iterator itr;
  4049. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4050. deque<GroupMemberInfo*>* members = world.GetGroupManager()->GetGroupMembers(gmi->group_id);
  4051. // Loop through the group members
  4052. for (itr = members->begin(); itr != members->end(); itr++) {
  4053. // If a group member matches a target
  4054. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4055. // toggle the flag and break the loop
  4056. targetInGroup = true;
  4057. break;
  4058. }
  4059. }
  4060. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4061. }
  4062. if (targetInGroup) {
  4063. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4064. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4065. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4066. client->GetPlayer()->info_changed = true;
  4067. client->GetPlayer()->changed = true;
  4068. }
  4069. else
  4070. client->Message(CHANNEL_COLOR_WHITE, "You must first select a group member to follow.");
  4071. }
  4072. /*
  4073. Function: Command_StopFollow()
  4074. Purpose : Handle the /stop_follow command - not yet implemented
  4075. Params :
  4076. Dev :
  4077. Example :
  4078. */
  4079. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4080. {
  4081. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4082. if (client->GetPlayer()->GetFollowTarget()) {
  4083. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4084. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4085. client->GetPlayer()->SetFollowTarget(0);
  4086. client->GetPlayer()->info_changed = true;
  4087. client->GetPlayer()->changed = true;
  4088. }
  4089. }
  4090. #include "../Zone/SPGrid.h"
  4091. /*
  4092. Function: Command_Grid()
  4093. Purpose : Show player's current Grid ID
  4094. Params :
  4095. Dev : Scatman
  4096. Example : /grid
  4097. */
  4098. void Commands::Command_Grid(Client* client)
  4099. {
  4100. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4101. if (client->GetCurrentZone()->Grid != nullptr) {
  4102. int32 grid = client->GetCurrentZone()->Grid->GetGridID(client->GetPlayer());
  4103. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4104. }
  4105. }
  4106. /*
  4107. Function: Command_Guild()
  4108. Purpose : Handler for all UI-related guild commands
  4109. Dev : Scatman
  4110. */
  4111. void Commands::Command_Guild(Client* client, Seperator* sep)
  4112. {
  4113. Guild* guild = client->GetPlayer()->GetGuild();
  4114. if (sep && sep->arg[0])
  4115. {
  4116. const char* command = sep->arg[0];
  4117. int32 length = strlen(command);
  4118. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4119. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4120. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4121. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4122. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4123. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4124. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4125. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4126. guild->KickGuildMember(client, sep->arg[1]);
  4127. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4128. guild->DemoteGuildMember(client, sep->arg[1]);
  4129. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4130. guild->PromoteGuildMember(client, sep->arg[1]);
  4131. else if (strncmp(command, "points", length) == 0 && guild)
  4132. {
  4133. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4134. {
  4135. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4136. {
  4137. float points = atof(sep->arg[2]);
  4138. const char* option = sep->arg[3];
  4139. const char* comment = sep->argplus[4];
  4140. if (strncmp(option, "all", strlen(option)) == 0)
  4141. guild->AddPointsToAll(client, points, comment);
  4142. else if (strncmp(option, "online", strlen(option)) == 0)
  4143. guild->AddPointsToAllOnline(client, points, comment);
  4144. else if (strncmp(option, "group", strlen(option)) == 0)
  4145. guild->AddPointsToGroup(client, points, comment);
  4146. else if (strncmp(option, "raid", strlen(option)) == 0)
  4147. guild->AddPointsToRaid(client, points, comment);
  4148. else
  4149. guild->AddPointsToGuildMember(client, points, option, comment);
  4150. }
  4151. }
  4152. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4153. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4154. else
  4155. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4156. }
  4157. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4158. guild->SetMOTD(sep->argplus[1]);
  4159. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4160. {
  4161. if (sep->arg[1])
  4162. {
  4163. const char* option = sep->arg[1];
  4164. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4165. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4166. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4167. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4168. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4169. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4170. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4171. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4172. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4173. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4174. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4175. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4176. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4177. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4178. else
  4179. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4180. }
  4181. else
  4182. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4183. }
  4184. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4185. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4186. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4187. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4188. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4189. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4190. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4191. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4192. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4193. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4194. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4195. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4196. else if (strncmp(command, "invite", length) == 0 && guild)
  4197. {
  4198. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4199. guild->InvitePlayer(client, sep->arg[1]);
  4200. else
  4201. {
  4202. Spawn* target = client->GetPlayer()->GetTarget();
  4203. if (target)
  4204. {
  4205. if (target->IsPlayer())
  4206. guild->InvitePlayer(client, target->GetName());
  4207. else
  4208. client->Message(CHANNEL_COLOR_WHITE, "%s is not a player.", target->GetName());
  4209. }
  4210. }
  4211. }
  4212. else if (strncmp(command, "accept", length) == 0)
  4213. {
  4214. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4215. if (pgi && pgi->guild && pgi->invited_by)
  4216. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4217. client->SetPendingGuildInvite(0);
  4218. }
  4219. else if (strncmp(command, "decline", length) == 0)
  4220. {
  4221. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4222. if (pgi && pgi->guild && pgi->invited_by)
  4223. {
  4224. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4225. if (client_inviter)
  4226. client_inviter->Message(CHANNEL_COLOR_WHITE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4227. }
  4228. client->SetPendingGuildInvite(0);
  4229. }
  4230. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4231. {
  4232. const char* guild_name = sep->argplus[0];
  4233. if (!guild_list.GetGuild(guild_name))
  4234. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo()->group_id);
  4235. else
  4236. client->SimpleMessage(CHANNEL_COLOR_WHITE, "A guild with that name already exists.");
  4237. }
  4238. else if (strncmp(command, "search", length) == 0)
  4239. client->ShowGuildSearchWindow();
  4240. else if (strncmp(command, "recruiting_details", 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->SendGuildRecruitingDetails(client);
  4245. }
  4246. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4247. {
  4248. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4249. if (to_guild)
  4250. to_guild->SendGuildRecruitingImages(client);
  4251. }
  4252. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4253. {
  4254. if (sep->arg[1])
  4255. {
  4256. const char* option = sep->arg[1];
  4257. if (strncmp(option, "toggle", strlen(option)) == 0)
  4258. guild->ToggleGuildRecruiterAdventureClass(client);
  4259. }
  4260. else
  4261. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4262. }
  4263. else if (strncmp(command, "display_heraldry", length) == 0)
  4264. {
  4265. // JA: not sure this is right...
  4266. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4267. client->GetPlayer()->SetCharSheetChanged(true);
  4268. }
  4269. else
  4270. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4271. }
  4272. }
  4273. /*
  4274. Function: Command_GuildCreate()
  4275. Purpose : Display's in-game Guild Creation window
  4276. Dev : Scatman
  4277. */
  4278. void Commands::Command_CreateGuild(Client* client)
  4279. {
  4280. client->SendGuildCreateWindow();
  4281. }
  4282. /*
  4283. Function: Command_SetGuildOfficerNote()
  4284. Purpose :
  4285. Dev : Scatman
  4286. */
  4287. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4288. {
  4289. if (sep && sep->arg[0] && sep->arg[1])
  4290. {
  4291. Guild* guild = client->GetPlayer()->GetGuild();
  4292. if (guild)
  4293. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4294. }
  4295. }
  4296. /*
  4297. Function: Command_SetGuildMemberNote()
  4298. Purpose :
  4299. Dev : Scatman
  4300. */
  4301. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4302. {
  4303. if (sep && sep->arg[0] && sep->arg[1])
  4304. {
  4305. Guild* guild = client->GetPlayer()->GetGuild();
  4306. if (guild)
  4307. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4308. }
  4309. }
  4310. /*
  4311. Function: Command_GuildSay()
  4312. Purpose :
  4313. Dev : Scatman
  4314. */
  4315. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4316. {
  4317. Guild* guild = client->GetPlayer()->GetGuild();
  4318. if (guild)
  4319. {
  4320. if (sep && sep->arg[0])
  4321. guild->HandleGuildSay(client, sep->argplus[0]);
  4322. }
  4323. else
  4324. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4325. }
  4326. /*
  4327. Function: Command_OfficerSay()
  4328. Purpose :
  4329. Dev : Scatman
  4330. */
  4331. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4332. {
  4333. Guild* guild = client->GetPlayer()->GetGuild();
  4334. if (guild)
  4335. {
  4336. if (sep && sep->arg[0])
  4337. guild->HandleOfficerSay(client, sep->argplus[0]);
  4338. }
  4339. else
  4340. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4341. }
  4342. /*
  4343. Function: Command_Guilds()
  4344. Purpose : Shows help for /guild command
  4345. Params :
  4346. Dev : Scatman
  4347. Example :
  4348. */
  4349. void Commands::Command_Guilds(Client* client)
  4350. {
  4351. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4352. }
  4353. /*
  4354. Function: Command_GuildsAdd()
  4355. Purpose : Add's players to a guild
  4356. Params : guild_name|guild_id, player name
  4357. Dev : Scatman
  4358. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4359. */
  4360. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4361. {
  4362. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4363. {
  4364. Guild* guild = 0;
  4365. bool found = true;
  4366. if (sep->IsNumber(0))
  4367. {
  4368. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4369. if (!guild)
  4370. {
  4371. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4372. found = false;
  4373. }
  4374. }
  4375. else
  4376. {
  4377. guild = guild_list.GetGuild(sep->arg[0]);
  4378. if (!guild)
  4379. {
  4380. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4381. found = false;
  4382. }
  4383. }
  4384. if (found)
  4385. {
  4386. Client* to_client = 0;
  4387. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4388. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4389. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4390. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4391. if (to_client)
  4392. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  4393. else
  4394. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4395. }
  4396. }
  4397. else
  4398. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  4399. }
  4400. /*
  4401. Function: Command_GuildsCreate()
  4402. Purpose : Creates a guild
  4403. Params : guild_name, player_name (optional)
  4404. Dev : Scatman
  4405. Example : /guilds create [guild name] (player name)
  4406. */
  4407. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  4408. {
  4409. if (sep && sep->arg[0])
  4410. {
  4411. const char* guild_name = sep->arg[0];
  4412. if (!guild_list.GetGuild(guild_name))
  4413. {
  4414. bool ret = false;
  4415. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4416. {
  4417. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4418. if (to_client)
  4419. {
  4420. world.CreateGuild(guild_name, to_client);
  4421. ret = true;
  4422. }
  4423. else
  4424. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  4425. }
  4426. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4427. {
  4428. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4429. if (to_client)
  4430. {
  4431. world.CreateGuild(guild_name, to_client);
  4432. ret = true;
  4433. }
  4434. }
  4435. else
  4436. {
  4437. world.CreateGuild(guild_name);
  4438. ret = true;
  4439. }
  4440. if (ret)
  4441. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  4442. else
  4443. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  4444. }
  4445. else
  4446. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  4447. }
  4448. else
  4449. 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.");
  4450. }
  4451. /*
  4452. Function: Command_GuildsDelete()
  4453. Purpose : Delete's a guild
  4454. Params : guild name
  4455. Dev : Scatman
  4456. Example : /guilds delete Test
  4457. */
  4458. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  4459. {
  4460. if (sep && sep->arg[0])
  4461. {
  4462. Guild* guild = 0;
  4463. bool found = true;
  4464. if (sep->IsNumber(0))
  4465. {
  4466. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4467. if (!guild)
  4468. {
  4469. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4470. found = false;
  4471. }
  4472. }
  4473. else
  4474. {
  4475. guild = guild_list.GetGuild(sep->arg[0]);
  4476. if (!guild)
  4477. {
  4478. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4479. found = false;
  4480. }
  4481. }
  4482. if (found)
  4483. {
  4484. guild->RemoveAllGuildMembers();
  4485. database.DeleteGuild(guild);
  4486. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  4487. guild_list.RemoveGuild(guild, true);
  4488. }
  4489. }
  4490. else
  4491. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  4492. }
  4493. /*
  4494. Function: Command_GuildsList()
  4495. Purpose : Lists current guilds on server
  4496. Params :
  4497. Dev : Scatman
  4498. Example : /guilds list
  4499. */
  4500. void Commands::Command_GuildsList(Client* client)
  4501. {
  4502. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  4503. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  4504. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  4505. if (guilds->size() == 0)
  4506. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  4507. else {
  4508. while (itr.Next()) {
  4509. Guild* guild = itr.second;
  4510. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  4511. }
  4512. }
  4513. }
  4514. /*
  4515. Function: Command_GuildsRemove()
  4516. Purpose : Removes a player from a guild
  4517. Params : guild name|guild id, player name
  4518. Dev : Scatman
  4519. Example : /guilds remove 1 Admin = removes Admin from guild 1
  4520. */
  4521. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  4522. {
  4523. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4524. {
  4525. Guild* guild = 0;
  4526. bool found = true;
  4527. if (sep->IsNumber(0))
  4528. {
  4529. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4530. if (!guild)
  4531. {
  4532. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4533. found = false;
  4534. }
  4535. }
  4536. else
  4537. {
  4538. guild = guild_list.GetGuild(sep->arg[0]);
  4539. if (!guild)
  4540. {
  4541. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4542. found = false;
  4543. }
  4544. }
  4545. if (found)
  4546. {
  4547. Client* to_client = 0;
  4548. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4549. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4550. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4551. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4552. if (to_client)
  4553. {
  4554. Player* to_player = to_client->GetPlayer();
  4555. if (to_player->GetGuild())
  4556. {
  4557. if (to_player->GetGuild() == guild)
  4558. {
  4559. guild->KickGuildMember(client, to_player->GetName());
  4560. }
  4561. else
  4562. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  4563. }
  4564. else
  4565. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  4566. }
  4567. else
  4568. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4569. }
  4570. }
  4571. else
  4572. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  4573. }
  4574. /*
  4575. Function: Command_InspectPlayer()
  4576. Purpose : Handle the Inspect functions
  4577. Params : Client to inspect
  4578. Dev : Scatman
  4579. Example : /inspect Scatman
  4580. */
  4581. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  4582. {
  4583. if (sep && sep->arg[0])
  4584. {
  4585. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  4586. if (inspect_client)
  4587. client->InspectPlayer(inspect_client->GetPlayer());
  4588. }
  4589. else
  4590. {
  4591. Spawn* target = client->GetPlayer()->GetTarget();
  4592. if (target && target->IsPlayer())
  4593. client->InspectPlayer((Player*)target);
  4594. }
  4595. }
  4596. /*
  4597. Function: Command_Inventory()
  4598. Purpose : Handle changes in player inventory
  4599. Params : <TBD>
  4600. Dev : All
  4601. Example : /inventory delete item_id
  4602. */
  4603. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  4604. {
  4605. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  4606. Player* player = client->GetPlayer();
  4607. if(sep && sep->arg[0][0])
  4608. {
  4609. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  4610. if(client->GetPlayer()->GetHP() == 0)
  4611. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  4612. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  4613. {
  4614. int16 index = atoi(sep->arg[1]);
  4615. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  4616. if(item)
  4617. {
  4618. if(item->GetItemScript() && lua_interface)
  4619. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  4620. int32 bag_id = item->details.inv_slot_id;
  4621. database.DeleteItem(client->GetCharacterID(), item, 0);
  4622. client->GetPlayer()->item_list.DestroyItem(index);
  4623. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4624. client->QueuePacket(outapp);
  4625. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  4626. if (outapp)
  4627. client->QueuePacket(outapp);
  4628. }
  4629. }
  4630. 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))
  4631. {
  4632. int16 from_index = atoi(sep->arg[1]);
  4633. sint16 to_slot = atoi(sep->arg[2]);
  4634. sint32 bag_id = atol(sep->arg[3]);
  4635. int8 charges = atoi(sep->arg[4]);
  4636. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  4637. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  4638. {
  4639. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  4640. return;
  4641. }
  4642. sint32 old_inventory_id = 0;
  4643. if(item)
  4644. old_inventory_id = item->details.inv_slot_id;
  4645. //autobank
  4646. if (bag_id == -3 && to_slot == -1)
  4647. {
  4648. if (player->HasFreeBankSlot())
  4649. to_slot = player->FindFreeBankSlot();
  4650. else
  4651. {
  4652. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  4653. return;
  4654. }
  4655. }
  4656. //auto inventory
  4657. if (bag_id == 0 && to_slot == -1)
  4658. {
  4659. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  4660. {
  4661. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  4662. return;
  4663. }
  4664. }
  4665. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  4666. client->QueuePacket(outapp);
  4667. //removed from bag send update
  4668. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  4669. {
  4670. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  4671. if(outapp)
  4672. client->QueuePacket(outapp);
  4673. }
  4674. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  4675. {
  4676. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  4677. if(outapp)
  4678. client->QueuePacket(outapp);
  4679. }
  4680. }
  4681. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  4682. {
  4683. if(client->GetPlayer()->EngagedInCombat())
  4684. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  4685. else
  4686. {
  4687. int16 index = atoi(sep->arg[1]);
  4688. int8 slot_id = 255;
  4689. if(sep->arg[2][0] && sep->IsNumber(2))
  4690. slot_id = atoi(sep->arg[2]);
  4691. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  4692. EQ2Packet* outapp = 0;
  4693. for(int32 i=0;i<packets.size();i++)
  4694. {
  4695. outapp = packets[i];
  4696. if(outapp)
  4697. client->QueuePacket(outapp);
  4698. }
  4699. client->GetPlayer()->ChangePrimaryWeapon();
  4700. client->GetPlayer()->ChangeSecondaryWeapon();
  4701. client->GetPlayer()->ChangeRangedWeapon();
  4702. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  4703. client->QueuePacket(characterSheetPackets);
  4704. }
  4705. }
  4706. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  4707. {
  4708. if (client->GetPlayer()->EngagedInCombat())
  4709. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  4710. else {
  4711. int16 index = atoi(sep->arg[1]);
  4712. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  4713. if (item) {
  4714. // client->GetPlayer()->item_list.DestroyItem(index);
  4715. if (item->item_sets.size() > 0) {
  4716. for (int32 i = 0; i < item->item_sets.size(); i++) {
  4717. ItemSet* set = item->item_sets[i];
  4718. if (set->item_stack_size == 0)
  4719. set->item_stack_size += 1;
  4720. client->AddItem(set->item_id, set->item_stack_size);
  4721. }
  4722. }
  4723. }
  4724. client->RemoveItem(item, 1);
  4725. }
  4726. }
  4727. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  4728. {
  4729. if(client->GetPlayer()->EngagedInCombat())
  4730. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  4731. else
  4732. {
  4733. int16 index = atoi(sep->arg[1]);
  4734. sint32 bag_id = -999;
  4735. int8 to_slot = 255;
  4736. if(sep->arg[3][0])
  4737. {
  4738. if(sep->IsNumber(2))
  4739. bag_id = atol(sep->arg[2]);
  4740. if(sep->IsNumber(3))
  4741. to_slot = atoi(sep->arg[3]);
  4742. }
  4743. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  4744. EQ2Packet* outapp = 0;
  4745. for(int32 i=0;i<packets.size();i++)
  4746. {
  4747. outapp = packets[i];
  4748. if(outapp)
  4749. client->QueuePacket(outapp);
  4750. }
  4751. client->GetPlayer()->ChangePrimaryWeapon();
  4752. client->GetPlayer()->ChangeSecondaryWeapon();
  4753. client->GetPlayer()->ChangeRangedWeapon();
  4754. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  4755. client->QueuePacket(characterSheetPackets);
  4756. }
  4757. }
  4758. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  4759. {
  4760. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4761. int16 index1 = atoi(sep->arg[1]);
  4762. int16 index2 = atoi(sep->arg[2]);
  4763. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  4764. if(outapp)
  4765. client->QueuePacket(outapp);
  4766. else
  4767. {
  4768. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  4769. return;
  4770. }
  4771. }
  4772. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  4773. {
  4774. sint16 to_slot = atoi(sep->arg[1]);
  4775. sint32 bag_id = atoi(sep->arg[2]);
  4776. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  4777. if (item) {
  4778. //auto inventory
  4779. if (bag_id == 0 && to_slot == -1)
  4780. {
  4781. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  4782. {
  4783. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  4784. return;
  4785. }
  4786. // Set the slot for the item
  4787. item->details.inv_slot_id = bag_id;
  4788. item->details.slot_id = to_slot;
  4789. // Flag the item so it gets saved in its new location
  4790. item->save_needed = true;
  4791. // Add the item to its new location
  4792. player->item_list.AddItem(item);
  4793. // Remove the item from the overflow list
  4794. player->item_list.RemoveOverflowItem(item);
  4795. // Send the inventory update packet
  4796. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4797. return;
  4798. }
  4799. else if (bag_id == -3 && to_slot == -1) {
  4800. // Auto Bank
  4801. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  4802. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  4803. return;
  4804. }
  4805. item->details.inv_slot_id = bag_id;
  4806. item->details.slot_id = to_slot;
  4807. item->save_needed = true;
  4808. player->item_list.AddItem(item);
  4809. player->item_list.RemoveOverflowItem(item);
  4810. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4811. }
  4812. else if (bag_id == -4) {
  4813. // Shared Bank
  4814. if (!player->item_list.SharedBankAddAllowed(item)) {
  4815. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  4816. return;
  4817. }
  4818. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  4819. if (tmp_item) {
  4820. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  4821. return;
  4822. }
  4823. else {
  4824. item->details.inv_slot_id = bag_id;
  4825. item->details.slot_id = to_slot;
  4826. item->save_needed = true;
  4827. player->item_list.AddItem(item);
  4828. player->item_list.RemoveOverflowItem(item);
  4829. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4830. return;
  4831. }
  4832. }
  4833. else {
  4834. // Try to get an item from the given bag id and slot id
  4835. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  4836. // Check to see if we got an item, if we do send an error,
  4837. // if we don't put the overflow item into this slot
  4838. if (tmp_item) {
  4839. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  4840. }
  4841. else {
  4842. item->details.inv_slot_id = bag_id;
  4843. item->details.slot_id = to_slot;
  4844. item->save_needed = true;
  4845. player->item_list.AddItem(item);
  4846. player->item_list.RemoveOverflowItem(item);
  4847. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4848. return;
  4849. }
  4850. }
  4851. }
  4852. }
  4853. }
  4854. else
  4855. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  4856. }
  4857. /*
  4858. Function: Command_IRC()
  4859. Purpose : Handle the IRC functions
  4860. Params : IRC Commands
  4861. Dev : Scatman
  4862. Example : /irc say #Channel Hello World!
  4863. */
  4864. void Commands::Command_IRC(Client* client, Seperator* sep)
  4865. {
  4866. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  4867. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  4868. return;
  4869. }
  4870. if (sep && sep->arg[0][0]) {
  4871. if (strcasecmp(sep->arg[0], "say") == 0) {
  4872. if (sep->arg[1][0] && sep->arg[2][0]) {
  4873. if (sep->IsNumber(sep->arg[1]))
  4874. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  4875. else
  4876. irc.Say(client, sep->arg[1], sep->argplus[2]);
  4877. }
  4878. else
  4879. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  4880. }
  4881. else if (strcasecmp(sep->arg[0], "join") == 0) {
  4882. if (sep->arg[1][0])
  4883. irc.JoinChannel(client, sep->arg[1]);
  4884. else
  4885. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  4886. }
  4887. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  4888. if (sep->arg[1][0])
  4889. irc.LeaveChannel(client, sep->arg[1]);
  4890. else
  4891. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  4892. }
  4893. else if (strcasecmp(sep->arg[0], "list") == 0)
  4894. irc.ListChannels(client);
  4895. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  4896. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  4897. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  4898. else
  4899. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  4900. }
  4901. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  4902. irc.DisconnectFromServer(client);
  4903. else
  4904. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  4905. }
  4906. else
  4907. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  4908. }
  4909. /*
  4910. Function: Command_Languages()
  4911. Purpose : Show's languages the player knows
  4912. Params :
  4913. Dev : Zcoretri
  4914. Example :
  4915. */
  4916. void Commands::Command_Languages(Client* client, Seperator* sep)
  4917. {
  4918. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  4919. list<Language*>::iterator itr;
  4920. Language* language;
  4921. client->Message(CHANNEL_COLOR_WHITE, "You know the following languages:");
  4922. for(itr = languages->begin(); itr != languages->end(); itr++)
  4923. {
  4924. language = *itr;
  4925. client->Message(CHANNEL_COLOR_WHITE, "%s", language->GetName());
  4926. }
  4927. }
  4928. /*
  4929. Function: Command_SetLanguage()
  4930. Purpose : Handles language commands
  4931. Params : Language ID
  4932. Dev : Zcoretri
  4933. Example :
  4934. */
  4935. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  4936. {
  4937. Player* player = client->GetPlayer();
  4938. if (sep && sep->arg[0])
  4939. {
  4940. if(!sep->IsNumber(0))
  4941. {
  4942. //String passed in
  4943. const char* value = sep->arg[0];
  4944. if(strncasecmp(value, "Common", strlen(value)) == 0)
  4945. {
  4946. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  4947. client->SendLanguagesUpdate(0);
  4948. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", value);
  4949. }
  4950. else
  4951. {
  4952. if(player->HasLanguage(value))
  4953. {
  4954. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  4955. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  4956. client->SendLanguagesUpdate(language->GetID());
  4957. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  4958. }
  4959. else
  4960. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", value);
  4961. }
  4962. }
  4963. else
  4964. {
  4965. //Number passed in
  4966. int32 id = atoul(sep->arg[0]);
  4967. if(player->HasLanguage(id))
  4968. {
  4969. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  4970. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  4971. client->SendLanguagesUpdate(id);
  4972. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  4973. }
  4974. else
  4975. {
  4976. Language* language = master_languages_list.GetLanguage(id);
  4977. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", language->GetName());
  4978. }
  4979. }
  4980. }
  4981. else
  4982. {
  4983. //No value was passed in
  4984. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  4985. if(id > 0)
  4986. {
  4987. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  4988. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking %s ", language->GetName());
  4989. }
  4990. else
  4991. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking Common");
  4992. }
  4993. }
  4994. /*
  4995. Function: Command_LastName()
  4996. Purpose : Sets player surname
  4997. Params : Name text
  4998. Dev : theFoof
  4999. Example :
  5000. */
  5001. void Commands::Command_LastName(Client* client, Seperator* sep)
  5002. {
  5003. if (!client)
  5004. return;
  5005. if (sep && sep->arg[0])
  5006. {
  5007. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5008. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5009. return;
  5010. }
  5011. client->RemovePendingLastName();
  5012. uchar* checkname = (uchar*)sep->arg[0];
  5013. bool valid_name = true;
  5014. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5015. if (!alpha_check(checkname[i])) {
  5016. valid_name = false;
  5017. break;
  5018. }
  5019. }
  5020. if (!valid_name) {
  5021. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5022. return;
  5023. }
  5024. string last_name = (string)sep->arg[0];
  5025. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5026. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5027. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5028. client->SetPendingLastName(last_name);
  5029. client->SendLastNameConfirmation();
  5030. }
  5031. else
  5032. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5033. }
  5034. }
  5035. /*
  5036. Function: Command_ConfirmLastName()
  5037. Purpose : Confirms setting of player surname
  5038. Params : Name text
  5039. Dev : theFoof
  5040. Example :
  5041. */
  5042. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5043. {
  5044. if (!client)
  5045. return;
  5046. string* name = client->GetPendingLastName();
  5047. if (name){
  5048. Player* player = client->GetPlayer();
  5049. player->SetLastName(name->c_str(), false);
  5050. client->SendTitleUpdate();
  5051. player->SetCharSheetChanged(true);
  5052. client->RemovePendingLastName();
  5053. }
  5054. }
  5055. /*
  5056. Function: Command_Location()
  5057. Purpose : Display's Help for /location commands
  5058. Params :
  5059. Dev : Scatman
  5060. Example : /location = show's help for command
  5061. */
  5062. void Commands::Command_Location(Client* client)
  5063. {
  5064. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5066. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5067. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5068. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5069. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5070. }
  5071. /*
  5072. Function: Command_LocationAdd()
  5073. Purpose : Add's a location to an existing location config
  5074. Params : location_id
  5075. Dev : Scatman
  5076. Example : /location add {location_id}
  5077. */
  5078. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5079. {
  5080. if (sep && sep->arg[0] && sep->IsNumber(0))
  5081. {
  5082. int32 location_id = atoul(sep->arg[0]);
  5083. float x = client->GetPlayer()->GetX();
  5084. float y = client->GetPlayer()->GetY();
  5085. float z = client->GetPlayer()->GetZ();
  5086. if (database.AddLocationPoint(location_id, x, y, z))
  5087. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5088. else
  5089. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5090. }
  5091. else
  5092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5093. }
  5094. /*
  5095. Function: Command_LocationCreate()
  5096. Purpose : Creates a new location config
  5097. Params : location name, 0/1 for include_y (optional)
  5098. Dev : Scatman
  5099. Example : /location create Test 1 = creates a new location named Test with include_y True
  5100. */
  5101. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5102. {
  5103. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5104. {
  5105. const char* name = sep->arg[0];
  5106. bool include_y = false;
  5107. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5108. include_y = true;
  5109. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5110. if (location_id > 0)
  5111. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5112. else
  5113. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5114. }
  5115. else
  5116. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5117. }
  5118. /*
  5119. Function: Command_LocationDelete()
  5120. Purpose : Delete's a location config and all it's location points
  5121. Params : location_id
  5122. Dev : Scatman
  5123. Example : /location delete {location_id}
  5124. */
  5125. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5126. {
  5127. if (sep && sep->arg[0] && sep->IsNumber(0))
  5128. {
  5129. int32 location_id = atoul(sep->arg[0]);
  5130. if (database.DeleteLocation(location_id))
  5131. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5132. else
  5133. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5134. }
  5135. else
  5136. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5137. }
  5138. /*
  5139. Function: Command_LocationList()
  5140. Purpose : Display's a list of location points
  5141. Params : location_id
  5142. Dev : Scatman
  5143. Example : /location list {location_id}
  5144. */
  5145. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5146. {
  5147. if (sep && sep->arg[0])
  5148. {
  5149. const char* option = sep->arg[0];
  5150. if (strncmp(option, "locations", strlen(option)) == 0)
  5151. database.ListLocations(client);
  5152. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5153. {
  5154. int32 location_id = atoul(sep->arg[1]);
  5155. database.ListLocationPoints(client, location_id);
  5156. }
  5157. else
  5158. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5159. }
  5160. else
  5161. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5162. }
  5163. /*
  5164. Function: Command_LocationRemove()
  5165. Purpose : Removes a single location point from a location config
  5166. Params : location_point_id (gotten from /location list {id})
  5167. Dev : Scatman
  5168. Example : /location remove 1 = will remove location_point_id 1
  5169. */
  5170. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5171. {
  5172. if (sep && sep->arg[0] && sep->IsNumber(0))
  5173. {
  5174. int32 location_point_id = atoul(sep->arg[0]);
  5175. if (database.DeleteLocationPoint(location_point_id))
  5176. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5177. else
  5178. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5179. }
  5180. else
  5181. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5182. }
  5183. /*
  5184. Function: Command_Merchant()
  5185. Purpose : Handles Merchant commands
  5186. Params : list
  5187. Dev : Scatman
  5188. Example : /merchant list
  5189. */
  5190. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5191. {
  5192. if( handler == COMMAND_MERCHANT )
  5193. {
  5194. // /merchant command by itself shows help (to be extended)
  5195. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5196. return;
  5197. }
  5198. else if( handler == COMMAND_MERCHANT_LIST )
  5199. {
  5200. // /merchant list command expects "description" param
  5201. if (sep && sep->arg[0])
  5202. {
  5203. const char* merchant_description = sep->argplus[0];
  5204. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5205. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5206. map<int32, MerchantInfo*>::iterator itr;
  5207. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5208. {
  5209. string description = database.GetMerchantDescription(itr->first);
  5210. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5211. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5212. }
  5213. }
  5214. else // no description
  5215. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5216. }
  5217. }
  5218. /*
  5219. Function: Command_Modify()
  5220. Purpose : to replace our other "set" commands
  5221. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5222. Dev : John Adams
  5223. Example : /modify spell set name "Aegolism III"
  5224. */
  5225. void Commands::Command_Modify(Client* client)
  5226. {
  5227. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5228. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5229. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5230. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5231. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5232. }
  5233. /*
  5234. Function: Command_ModifySpawn()
  5235. Purpose : replace "spawn set" commands
  5236. Params : Action : the action to perform (or special handler)
  5237. : Field : the DB field to change
  5238. : Value : what to set the value to
  5239. : Target : what object to change (my target, or spawn_id)
  5240. Dev : John Adams
  5241. Example : /modify spawn set name "Lady Vox"
  5242. :
  5243. Note : Special Handlers, like "zoneto" for Signs
  5244. : /modify spawn zoneto
  5245. : Will set a sign's zone x/y/z to my current coords
  5246. */
  5247. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5248. {
  5249. PrintSep(sep, "COMMAND_MODIFY");
  5250. // need at least 2 args for a valid command
  5251. if( sep && sep->arg[1] )
  5252. {
  5253. // JA: just a quick implementation because I need it :)
  5254. if (strcmp(sep->arg[0], "zoneto") == 0)
  5255. {
  5256. if( sep->IsNumber(1) )
  5257. {
  5258. int32 spawn_id = atoul(sep->arg[1]);
  5259. float x_coord = client->GetPlayer()->GetX();
  5260. float y_coord = client->GetPlayer()->GetY();
  5261. float z_coord = client->GetPlayer()->GetZ();
  5262. float h_coord = client->GetPlayer()->GetHeading();
  5263. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5264. }
  5265. else
  5266. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5267. }
  5268. }
  5269. else
  5270. Command_Modify(client);
  5271. }
  5272. /*
  5273. Function: Command_ModifyCharacter()
  5274. Purpose : to replace our other "set" commands
  5275. Params : Action : Add, Remove
  5276. : Field : copper, silver, gold, plat
  5277. : Value : min 1, max unlimited
  5278. : Target : Self, Player
  5279. Dev : Cynnar
  5280. Example : /modify character add gold 50
  5281. : /modify character remove silver 25
  5282. */
  5283. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5284. {
  5285. PrintSep(sep, "COMMAND_MODIFY");
  5286. int64 value = 0;
  5287. Player* player = client->GetPlayer();
  5288. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5289. player = (Player*)player->GetTarget();
  5290. // need at least 2 args for a valid command
  5291. if( sep && sep->arg[1] )
  5292. {
  5293. if (strcmp(sep->arg[0], "add") == 0)
  5294. {
  5295. if (strcmp(sep->arg[1], "copper") == 0)
  5296. {
  5297. value = atoi64(sep->arg[2]);
  5298. player->AddCoins(value);
  5299. if (client->GetPlayer() == player)
  5300. {
  5301. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5302. }
  5303. else {
  5304. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5305. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5306. }
  5307. }
  5308. else if (strcmp(sep->arg[1], "silver") == 0)
  5309. {
  5310. value = atoi64(sep->arg[2]) * 100;
  5311. player->AddCoins(value);
  5312. if (client->GetPlayer() == player)
  5313. {
  5314. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5315. }
  5316. else {
  5317. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5318. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5319. }
  5320. }
  5321. else if (strcmp(sep->arg[1], "gold") == 0)
  5322. {
  5323. value = atoi64(sep->arg[2]) * 10000;
  5324. player->AddCoins(value);
  5325. if (client->GetPlayer() == player)
  5326. {
  5327. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5328. }
  5329. else {
  5330. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5331. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5332. }
  5333. }
  5334. else if (strcmp(sep->arg[1], "plat") == 0)
  5335. {
  5336. value = atoi64(sep->arg[2]) * 1000000;
  5337. player->AddCoins(value);
  5338. if (client->GetPlayer() == player)
  5339. {
  5340. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5341. }
  5342. else {
  5343. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5344. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5345. }
  5346. }
  5347. else
  5348. {
  5349. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5350. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5351. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5352. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5353. }
  5354. }
  5355. else if (strcmp(sep->arg[0], "remove") == 0)
  5356. {
  5357. if (strcmp(sep->arg[1], "copper") == 0)
  5358. {
  5359. value = atoi64(sep->arg[2]);
  5360. player->RemoveCoins(value);
  5361. if (client->GetPlayer() == player)
  5362. {
  5363. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5364. }
  5365. else {
  5366. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5367. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5368. }
  5369. }
  5370. else if (strcmp(sep->arg[1], "silver") == 0)
  5371. {
  5372. value = atoi64(sep->arg[2]) * 100;
  5373. player->RemoveCoins(value);
  5374. if (client->GetPlayer() == player)
  5375. {
  5376. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5377. }
  5378. else {
  5379. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5380. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5381. }
  5382. }
  5383. else if (strcmp(sep->arg[1], "gold") == 0)
  5384. {
  5385. value = atoi64(sep->arg[2]) * 10000;
  5386. player->RemoveCoins(value);
  5387. if (client->GetPlayer() == player)
  5388. {
  5389. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  5390. }
  5391. else {
  5392. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  5393. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5394. }
  5395. }
  5396. else if (strcmp(sep->arg[1], "plat") == 0)
  5397. {
  5398. value = atoi64(sep->arg[2]) * 1000000;
  5399. player->RemoveCoins(value);
  5400. if (client->GetPlayer() == player)
  5401. {
  5402. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  5403. }
  5404. else {
  5405. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  5406. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5407. }
  5408. }
  5409. else
  5410. {
  5411. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5412. }
  5413. }
  5414. else if (strcmp(sep->arg[0], "set") == 0) {
  5415. if (strcmp(sep->arg[1], "tslevel") == 0) {
  5416. int8 level = atoi(sep->arg[2]);
  5417. if (level > 0 && level < 256) {
  5418. if (player) {
  5419. if (client->GetPlayer() == player)
  5420. client->ChangeTSLevel(player->GetTSLevel(), level);
  5421. else
  5422. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  5423. }
  5424. }
  5425. else
  5426. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  5427. }
  5428. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  5429. int8 tsclass = atoi(sep->arg[2]);
  5430. player->SetTradeskillClass(tsclass);
  5431. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  5432. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  5433. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  5434. player->SetCharSheetChanged(true);
  5435. }
  5436. }
  5437. }
  5438. else
  5439. {
  5440. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5441. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5442. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5443. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5444. }
  5445. }
  5446. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  5447. {
  5448. PrintSep(sep, "COMMAND_MODIFY");
  5449. // need at least 2 args for a valid command
  5450. if( sep && sep->arg[1] )
  5451. {
  5452. }
  5453. else
  5454. Command_Modify(client);
  5455. }
  5456. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  5457. {
  5458. PrintSep(sep, "COMMAND_MODIFY");
  5459. // need at least 2 args for a valid command
  5460. if( sep && sep->arg[1] )
  5461. {
  5462. }
  5463. else
  5464. Command_Modify(client);
  5465. }
  5466. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  5467. {
  5468. PrintSep(sep, "COMMAND_MODIFY");
  5469. // need at least 2 args for a valid command
  5470. if( sep && sep->arg[1] )
  5471. {
  5472. }
  5473. else
  5474. Command_Modify(client);
  5475. }
  5476. /*
  5477. Function: Command_ModifyQuest()
  5478. Purpose : to list players quest and completed quests
  5479. Params : Action : list, completed
  5480. : Target : Self, Player
  5481. Dev : Cynnar
  5482. Example : /modify quest list
  5483. : /modify quest completed
  5484. */
  5485. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  5486. {
  5487. PrintSep(sep, "COMMAND_MODIFY");
  5488. int64 value = 0;
  5489. Player* player = client->GetPlayer();
  5490. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5491. player = (Player*)player->GetTarget();
  5492. // need at least 2 args for a valid command
  5493. if (sep && sep->arg[1])
  5494. {
  5495. if (strcmp(sep->arg[0], "list") == 0)
  5496. {
  5497. map<int32, Quest*>* quests = player->GetPlayerQuests();
  5498. map<int32, Quest*>::iterator itr;
  5499. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  5500. if (quests->size() == 0)
  5501. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  5502. else
  5503. {
  5504. for (itr = quests->begin(); itr != quests->end(); itr++)
  5505. {
  5506. Quest* quest = itr->second;
  5507. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5508. }
  5509. }
  5510. }
  5511. else if (strcmp(sep->arg[0], "completed") == 0)
  5512. {
  5513. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  5514. map<int32, Quest*>::iterator itr;
  5515. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  5516. if (quests->size() == 0)
  5517. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  5518. else
  5519. {
  5520. for (itr = quests->begin(); itr != quests->end(); itr++)
  5521. {
  5522. Quest* quest = itr->second;
  5523. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5524. }
  5525. }
  5526. }
  5527. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  5528. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  5529. else if (strcmp(sep->arg[0], "remove") == 0)
  5530. {
  5531. int32 quest_id = 0;
  5532. if (sep && sep->arg[1] && sep->IsNumber(1))
  5533. quest_id = atoul(sep->arg[1]);
  5534. if (quest_id > 0)
  5535. {
  5536. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  5537. {
  5538. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5539. if (quest)
  5540. if (client->GetPlayer() == player)
  5541. {
  5542. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  5543. }
  5544. else
  5545. {
  5546. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  5547. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  5548. }
  5549. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  5550. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  5551. }
  5552. client->RemovePlayerQuest(quest_id);
  5553. client->GetCurrentZone()->SendQuestUpdates(client);
  5554. }
  5555. }
  5556. else if (strcmp(sep->arg[0], "advance") == 0)
  5557. {
  5558. int32 quest_id = 0;
  5559. int32 step = 0;
  5560. if (sep && sep->arg[1] && sep->IsNumber(1))
  5561. {
  5562. quest_id = atoul(sep->arg[1]);
  5563. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5564. if (sep && sep->arg[2] && sep->IsNumber(1))
  5565. {
  5566. step = atoul(sep->arg[2]);
  5567. if (quest_id > 0 && step > 0)
  5568. {
  5569. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  5570. {
  5571. if (client)
  5572. {
  5573. client->AddPendingQuestUpdate(quest_id, step);
  5574. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  5575. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  5576. }
  5577. }
  5578. }
  5579. else
  5580. {
  5581. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  5582. }
  5583. }
  5584. else
  5585. {
  5586. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  5587. }
  5588. }
  5589. else
  5590. {
  5591. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  5592. }
  5593. }
  5594. else
  5595. {
  5596. Command_Modify(client);
  5597. }
  5598. }
  5599. else
  5600. {
  5601. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  5602. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  5603. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  5604. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  5605. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  5606. }
  5607. }
  5608. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  5609. {
  5610. PrintSep(sep, "COMMAND_MODIFY");
  5611. // need at least 2 args for a valid command
  5612. if( sep && sep->arg[1] )
  5613. {
  5614. if (strcmp(sep->arg[0], "add") == 0) {
  5615. const char* skill_name = sep->argplus[1];
  5616. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5617. if (skill) {
  5618. Player* player = 0;
  5619. Client* to_client = 0;
  5620. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5621. player = (Player*)client->GetPlayer()->GetTarget();
  5622. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5623. }
  5624. else {
  5625. player = client->GetPlayer();
  5626. to_client = client;
  5627. }
  5628. if (player)
  5629. {
  5630. if (!player->GetSkills()->HasSkill(skill->skill_id))
  5631. {
  5632. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  5633. if (to_client == client) {
  5634. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  5635. }
  5636. else {
  5637. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  5638. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  5639. }
  5640. }
  5641. else
  5642. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  5643. }
  5644. }
  5645. else
  5646. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5647. }
  5648. else if (strcmp(sep->arg[0], "remove") == 0) {
  5649. const char* skill_name = sep->argplus[1];
  5650. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5651. if (skill) {
  5652. Player* player = 0;
  5653. Client* to_client = 0;
  5654. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5655. player = (Player*)client->GetPlayer()->GetTarget();
  5656. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5657. }
  5658. else {
  5659. player = client->GetPlayer();
  5660. to_client = client;
  5661. }
  5662. if (player)
  5663. {
  5664. if (player->GetSkills()->HasSkill(skill->skill_id))
  5665. {
  5666. player->RemoveSkillFromDB(skill, true);
  5667. if (client == to_client) {
  5668. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  5669. }
  5670. else {
  5671. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  5672. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  5673. }
  5674. }
  5675. else {
  5676. if (client == to_client)
  5677. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  5678. else
  5679. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  5680. }
  5681. }
  5682. }
  5683. else
  5684. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5685. }
  5686. else if (strcmp(sep->arg[0], "set") == 0) {
  5687. if (!sep->IsNumber(2)) {
  5688. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  5689. return;
  5690. }
  5691. const char* skill_name = sep->arg[1];
  5692. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5693. if (skill) {
  5694. int16 val = atoi(sep->arg[2]);
  5695. Player* player = 0;
  5696. Client* to_client = 0;
  5697. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5698. player = (Player*)client->GetPlayer()->GetTarget();
  5699. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5700. }
  5701. else {
  5702. player = client->GetPlayer();
  5703. to_client = client;
  5704. }
  5705. if (player)
  5706. {
  5707. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  5708. player->GetSkills()->SetSkill(skill->skill_id, val);
  5709. if (client != to_client)
  5710. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  5711. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  5712. }
  5713. else {
  5714. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  5715. }
  5716. }
  5717. }
  5718. else {
  5719. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  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. else {
  5729. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  5730. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  5731. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  5732. }
  5733. }
  5734. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  5735. {
  5736. PrintSep(sep, "COMMAND_MODIFY");
  5737. // need at least 2 args for a valid command
  5738. if( sep && sep->arg[1] )
  5739. {
  5740. }
  5741. else
  5742. Command_Modify(client);
  5743. }
  5744. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  5745. {
  5746. PrintSep(sep, "COMMAND_MODIFY");
  5747. // need at least 2 args for a valid command
  5748. if( sep && sep->arg[1] )
  5749. {
  5750. }
  5751. else
  5752. Command_Modify(client);
  5753. }
  5754. /*
  5755. Function: Command_MOTD()
  5756. Purpose : Displays server MOTD
  5757. Params :
  5758. Dev : LethalEncounter
  5759. Example : /motd
  5760. */
  5761. void Commands::Command_MOTD(Client* client)
  5762. {
  5763. if (client)
  5764. ClientPacketFunctions::SendMOTD(client);
  5765. }
  5766. /*
  5767. Function: Command_Pet()
  5768. Purpose : Handle Pet {Command} commands
  5769. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  5770. Dev :
  5771. Example : /pet preserve_master
  5772. */
  5773. void Commands::Command_Pet(Client* client, Seperator* sep)
  5774. {
  5775. PrintSep(sep, "COMMAND_PET");
  5776. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  5777. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  5778. if (strcmp(sep->arg[0], "hide") == 0) {
  5779. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  5780. Entity* pet = client->GetPlayer()->GetDeityPet();
  5781. if (pet) {
  5782. if (pet->IsPrivateSpawn())
  5783. client->GetPlayer()->HideDeityPet(false);
  5784. else
  5785. client->GetPlayer()->HideDeityPet(true);
  5786. }
  5787. pet = client->GetPlayer()->GetCosmeticPet();
  5788. if (pet) {
  5789. if (pet->IsPrivateSpawn())
  5790. client->GetPlayer()->HideCosmeticPet(false);
  5791. else
  5792. client->GetPlayer()->HideCosmeticPet(true);
  5793. }
  5794. return;
  5795. }
  5796. // below is for all combat pets
  5797. if (!client->GetPlayer()->HasPet()) {
  5798. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  5799. return;
  5800. }
  5801. if (strcmp(sep->arg[0], "stay") == 0) {
  5802. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  5803. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  5804. client->GetPlayer()->SetCharSheetChanged(true);
  5805. if (client->GetPlayer()->GetPet())
  5806. client->GetPlayer()->GetPet()->following = false;
  5807. if (client->GetPlayer()->GetCharmedPet())
  5808. client->GetPlayer()->GetCharmedPet()->following = false;
  5809. }
  5810. else if (strcmp(sep->arg[0], "follow") == 0) {
  5811. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  5812. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  5813. client->GetPlayer()->SetCharSheetChanged(true);
  5814. }
  5815. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  5816. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  5817. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  5818. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  5819. }
  5820. else {
  5821. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  5822. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  5823. }
  5824. client->GetPlayer()->SetCharSheetChanged(true);
  5825. }
  5826. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  5827. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  5828. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  5829. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  5830. }
  5831. else {
  5832. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  5833. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  5834. }
  5835. client->GetPlayer()->SetCharSheetChanged(true);
  5836. }
  5837. else if (strcmp(sep->arg[0], "backoff") == 0) {
  5838. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  5839. if (client->GetPlayer()->GetPet())
  5840. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  5841. if (client->GetPlayer()->GetCharmedPet())
  5842. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  5843. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  5844. client->GetPlayer()->SetCharSheetChanged(true);
  5845. }
  5846. else if (strcmp(sep->arg[0], "attack") == 0) {
  5847. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  5848. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  5849. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  5850. if (client->GetPlayer()->GetPet())
  5851. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  5852. if (client->GetPlayer()->GetCharmedPet())
  5853. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  5854. }
  5855. else
  5856. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  5857. }
  5858. else
  5859. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  5860. }
  5861. else if (strcmp(sep->arg[0], "getlost") == 0) {
  5862. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  5863. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  5864. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  5865. }
  5866. else
  5867. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  5868. }
  5869. /*
  5870. Function: Command_PetName()
  5871. Purpose : Pet your name (???)
  5872. Params :
  5873. Dev :
  5874. Example :
  5875. */
  5876. void Commands::Command_PetName(Client* client, Seperator* sep)
  5877. {
  5878. PrintSep(sep, "COMMAND_PETNAME");
  5879. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  5880. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  5881. }
  5882. /*
  5883. Function: Command_NamePet()
  5884. Purpose : Name your pet
  5885. Params :
  5886. Dev :
  5887. Example :
  5888. */
  5889. void Commands::Command_NamePet(Client* client, Seperator* sep)
  5890. {
  5891. PrintSep(sep, "COMMAND_NAME_PET");
  5892. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  5893. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  5894. }
  5895. /*
  5896. Function: Command_Rename()
  5897. Purpose : Renames existing pet
  5898. Params :
  5899. Dev :
  5900. Example :
  5901. */
  5902. void Commands::Command_Rename(Client* client, Seperator* sep)
  5903. {
  5904. PrintSep(sep, "COMMAND_RENAME");
  5905. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  5906. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  5907. }
  5908. /*
  5909. Function: Command_ConfirmRename()
  5910. Purpose : Confirms renaming your pet
  5911. Params :
  5912. Dev :
  5913. Example :
  5914. */
  5915. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  5916. {
  5917. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  5918. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  5919. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  5920. }
  5921. /*
  5922. Function: Command_PetOptions()
  5923. Purpose : Sets various pet options
  5924. Params :
  5925. Dev :
  5926. Example :
  5927. */
  5928. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  5929. {
  5930. PrintSep(sep, "COMMAND_PETOPTIONS");
  5931. Player* player = client->GetPlayer();
  5932. Spawn* target = player->GetTarget();
  5933. if (!target)
  5934. return;
  5935. if (target == player->GetPet())
  5936. client->SendPetOptionsWindow(player->GetPet()->GetName());
  5937. else if (target == player->GetCharmedPet())
  5938. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  5939. else if (target == player->GetCosmeticPet())
  5940. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  5941. else if (target == player->GetDeityPet())
  5942. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  5943. }
  5944. /*
  5945. Function: Command_Random()
  5946. Purpose : Handles /random dice roll in-game
  5947. Params : 1-100
  5948. Dev : Scatman
  5949. Example : /randon 1 100
  5950. */
  5951. void Commands::Command_Random(Client* client, Seperator* sep)
  5952. {
  5953. char message[256] = {0};
  5954. if (sep)
  5955. {
  5956. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  5957. 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])));
  5958. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  5959. 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])));
  5960. else
  5961. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  5962. }
  5963. else
  5964. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  5965. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  5966. }
  5967. /*
  5968. Function: Command_Randomize()
  5969. Purpose : Sets randomize (appearance) values for NPCs
  5970. Params : Attrib Name
  5971. Dev : Scatman
  5972. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  5973. */
  5974. void Commands::Command_Randomize(Client* client, Seperator* sep)
  5975. {
  5976. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  5977. if (target)
  5978. {
  5979. if (target->IsNPC())
  5980. {
  5981. if (sep && sep->arg[0] && !sep->IsNumber(0))
  5982. {
  5983. const char* value = sep->arg[0];
  5984. if (strncasecmp(value, "show", strlen(value)) == 0)
  5985. {
  5986. client->DisplayRandomizeFeatures(target->GetRandomize());
  5987. }
  5988. else
  5989. {
  5990. if (sep->arg[1] && sep->IsNumber(1))
  5991. {
  5992. int8 option = atoi(sep->arg[1]);
  5993. if (option == 0 || option == 1)
  5994. {
  5995. int32 feature = 0;
  5996. char feature_text[32] = {0};
  5997. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  5998. feature = RANDOMIZE_GENDER;
  5999. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6000. }
  6001. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6002. feature = RANDOMIZE_RACE;
  6003. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6004. }
  6005. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6006. feature = RANDOMIZE_MODEL_TYPE;
  6007. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6008. }
  6009. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6010. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6011. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6012. }
  6013. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6014. feature = RANDOMIZE_HAIR_TYPE;
  6015. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6016. }
  6017. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6018. feature = RANDOMIZE_WING_TYPE;
  6019. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6020. }
  6021. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6022. feature = RANDOMIZE_CHEEK_TYPE;
  6023. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6024. }
  6025. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6026. feature = RANDOMIZE_CHIN_TYPE;
  6027. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6028. }
  6029. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6030. feature = RANDOMIZE_EAR_TYPE;
  6031. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6032. }
  6033. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6034. feature = RANDOMIZE_EYE_BROW_TYPE;
  6035. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6036. }
  6037. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6038. feature = RANDOMIZE_EYE_TYPE;
  6039. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6040. }
  6041. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6042. feature = RANDOMIZE_LIP_TYPE;
  6043. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6044. }
  6045. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6046. feature = RANDOMIZE_NOSE_TYPE;
  6047. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6048. }
  6049. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6050. feature = RANDOMIZE_EYE_COLOR;
  6051. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6052. }
  6053. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6054. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6055. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6056. }
  6057. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6058. feature = RANDOMIZE_HAIR_COLOR1;
  6059. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6060. }
  6061. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6062. feature = RANDOMIZE_HAIR_COLOR2;
  6063. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6064. }
  6065. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6066. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6067. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6068. }
  6069. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6070. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6071. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6072. }
  6073. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6074. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6075. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6076. }
  6077. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6078. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6079. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6080. }
  6081. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6082. feature = RANDOMIZE_SKIN_COLOR;
  6083. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6084. }
  6085. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6086. feature = RANDOMIZE_WING_COLOR1;
  6087. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6088. }
  6089. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6090. feature = RANDOMIZE_WING_COLOR2;
  6091. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6092. }
  6093. else {
  6094. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6095. 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'.");
  6096. }
  6097. if (feature > 0) {
  6098. if (option == 1) {
  6099. if (target->GetRandomize() & feature)
  6100. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6101. else {
  6102. target->AddRandomize(feature);
  6103. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6104. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6105. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6106. }
  6107. }
  6108. else {
  6109. if (target->GetRandomize() & feature) {
  6110. target->AddRandomize(-feature);
  6111. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6112. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6113. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6114. }
  6115. else
  6116. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6117. }
  6118. }
  6119. }
  6120. else
  6121. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6122. }
  6123. else
  6124. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6125. }
  6126. }
  6127. else {
  6128. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6129. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6130. 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'.");
  6131. }
  6132. }
  6133. else
  6134. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6135. }
  6136. else
  6137. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6138. }
  6139. /*
  6140. Function: Command_ShowCloak()
  6141. Purpose : Character Settings combo box for Show Cloak
  6142. Params : true/false
  6143. Dev : John Adams
  6144. Example :
  6145. */
  6146. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6147. {
  6148. Player* player = client->GetPlayer();
  6149. if (sep && sep->arg[0])
  6150. {
  6151. const char* value = sep->arg[0];
  6152. if (strncasecmp(value, "true", strlen(value)) == 0)
  6153. {
  6154. player->set_character_flag(CF_SHOW_CLOAK);
  6155. player->reset_character_flag(CF2_SHOW_RANGED);
  6156. }
  6157. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6158. player->reset_character_flag(CF_SHOW_CLOAK);
  6159. else
  6160. {
  6161. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6162. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6163. }
  6164. }
  6165. }
  6166. /*
  6167. Function: Command_ShowHelm()
  6168. Purpose : Character Settings combo box for Show Helm
  6169. Params : true/false
  6170. Dev : John Adams
  6171. Example :
  6172. */
  6173. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6174. {
  6175. Player* player = client->GetPlayer();
  6176. if (sep && sep->arg[0])
  6177. {
  6178. const char* value = sep->arg[0];
  6179. if (strncasecmp(value, "true", strlen(value)) == 0)
  6180. {
  6181. player->reset_character_flag(CF_HIDE_HELM);
  6182. player->set_character_flag(CF_HIDE_HOOD);
  6183. }
  6184. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6185. player->set_character_flag(CF_HIDE_HELM);
  6186. else
  6187. {
  6188. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6189. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6190. }
  6191. }
  6192. }
  6193. /*
  6194. Function: Command_ShowHood()
  6195. Purpose : Character Settings combo box for Show Hood
  6196. Params : true/false
  6197. Dev : John Adams
  6198. Example :
  6199. */
  6200. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6201. {
  6202. Player* player = client->GetPlayer();
  6203. if (sep && sep->arg[0])
  6204. {
  6205. const char* value = sep->arg[0];
  6206. if (strncasecmp(value, "true", strlen(value)) == 0)
  6207. {
  6208. player->reset_character_flag(CF_HIDE_HOOD);
  6209. player->set_character_flag(CF_HIDE_HELM);
  6210. }
  6211. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6212. player->set_character_flag(CF_HIDE_HOOD);
  6213. else
  6214. {
  6215. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6216. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6217. }
  6218. }
  6219. }
  6220. /*
  6221. Function: Command_ShowHoodHelm()
  6222. Purpose : Character Settings combo box for Show Helm or Hood
  6223. Params : true/false
  6224. Dev : John Adams
  6225. Example :
  6226. */
  6227. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6228. {
  6229. Player* player = client->GetPlayer();
  6230. if (sep && sep->arg[0])
  6231. {
  6232. const char* value = sep->arg[0];
  6233. if (strncasecmp(value, "true", strlen(value)) == 0)
  6234. {
  6235. player->reset_character_flag(CF_HIDE_HOOD);
  6236. player->reset_character_flag(CF_HIDE_HELM);
  6237. }
  6238. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6239. {
  6240. // don't think we ever wind up in here...
  6241. player->set_character_flag(CF_HIDE_HOOD);
  6242. player->set_character_flag(CF_HIDE_HELM);
  6243. }
  6244. else
  6245. {
  6246. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6247. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6248. }
  6249. }
  6250. }
  6251. /*
  6252. Function: Command_ShowRanged()
  6253. Purpose : Character Settings combo box for Show Ranged weapon
  6254. Params : true/false
  6255. Dev : John Adams
  6256. Example :
  6257. */
  6258. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6259. {
  6260. Player* player = client->GetPlayer();
  6261. if (sep && sep->arg[0])
  6262. {
  6263. const char* value = sep->arg[0];
  6264. if (strncasecmp(value, "true", strlen(value)) == 0)
  6265. {
  6266. player->set_character_flag(CF2_SHOW_RANGED);
  6267. player->reset_character_flag(CF_SHOW_CLOAK);
  6268. }
  6269. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6270. player->reset_character_flag(CF2_SHOW_RANGED);
  6271. else
  6272. {
  6273. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6274. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6275. }
  6276. }
  6277. }
  6278. /*
  6279. Function:
  6280. Purpose :
  6281. Params :
  6282. Dev :
  6283. Example :
  6284. */
  6285. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6286. {
  6287. Player* player = 0;
  6288. Client* to_client = 0;
  6289. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6290. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6291. switch(handler)
  6292. {
  6293. case COMMAND_SKILL:
  6294. {
  6295. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6296. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6297. break;
  6298. }
  6299. case COMMAND_SKILL_ADD:
  6300. {
  6301. if (sep && sep->arg[0])
  6302. {
  6303. const char* skill_name = sep->argplus[0];
  6304. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6305. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6306. {
  6307. player = to_client->GetPlayer();
  6308. if (player)
  6309. {
  6310. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6311. {
  6312. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6313. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6314. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6315. }
  6316. else
  6317. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6318. }
  6319. }
  6320. else if (skill) // add skill to yourself
  6321. {
  6322. player = client->GetPlayer();
  6323. if (player)
  6324. {
  6325. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6326. {
  6327. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6328. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6329. }
  6330. else
  6331. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6332. }
  6333. }
  6334. else
  6335. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6336. }
  6337. else
  6338. {
  6339. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6340. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6341. }
  6342. break;
  6343. }
  6344. case COMMAND_SKILL_REMOVE:
  6345. {
  6346. if (sep && sep->arg[0])
  6347. {
  6348. const char* skill_name = sep->argplus[0];
  6349. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6350. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6351. {
  6352. player = to_client->GetPlayer();
  6353. if (player)
  6354. {
  6355. if (player->GetSkills()->HasSkill(skill->skill_id))
  6356. {
  6357. player->RemoveSkillFromDB(skill, true);
  6358. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6359. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6360. }
  6361. else
  6362. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6363. }
  6364. }
  6365. else if(skill) // remove skill from yourself
  6366. {
  6367. Player* player = client->GetPlayer();
  6368. if (player)
  6369. {
  6370. if (player->GetSkills()->HasSkill(skill->skill_id))
  6371. {
  6372. player->RemoveSkillFromDB(skill, true);
  6373. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6374. }
  6375. else
  6376. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6377. }
  6378. }
  6379. else
  6380. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6381. }
  6382. else
  6383. {
  6384. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  6385. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6386. }
  6387. break;
  6388. }
  6389. case COMMAND_SKILL_LIST:
  6390. {
  6391. if (sep && sep->arg[0])
  6392. {
  6393. const char* skill_name = sep->argplus[0];
  6394. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  6395. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  6396. map<int32, Skill*>::iterator itr;
  6397. if (skills && skills->size() > 0)
  6398. {
  6399. for (itr = skills->begin(); itr != skills->end(); itr++)
  6400. {
  6401. Skill* skill = itr->second;
  6402. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  6403. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  6404. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  6405. }
  6406. }
  6407. }
  6408. else
  6409. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  6410. break;
  6411. }
  6412. }
  6413. }
  6414. /*
  6415. Function: Command_SpawnTemplate()
  6416. Purpose : Create or Use defined Spawn Templates
  6417. Params : create, save, rempve, list
  6418. Dev : John Adams
  6419. Example : /spawn template create "Test"
  6420. */
  6421. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  6422. {
  6423. if (sep == NULL || sep->arg[0] == NULL)
  6424. {
  6425. 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.");
  6426. return;
  6427. }
  6428. // got params, continue
  6429. const char * template_cmd = sep->arg[0];
  6430. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  6431. {
  6432. if (!sep->IsSet(1))
  6433. {
  6434. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  6435. 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.");
  6436. return;
  6437. }
  6438. map<int32, string>* template_names = 0;
  6439. if (sep->IsNumber(1))
  6440. {
  6441. int32 location_id = 0;
  6442. location_id = atoi(sep->arg[1]);
  6443. template_names = database.GetSpawnTemplateListByID(location_id);
  6444. }
  6445. else
  6446. {
  6447. const char* name = 0;
  6448. name = sep->argplus[1];
  6449. template_names = database.GetSpawnTemplateListByName(name);
  6450. }
  6451. if(!template_names)
  6452. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  6453. else
  6454. {
  6455. map<int32, string>::iterator itr;
  6456. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  6457. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  6458. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  6459. safe_delete(template_names);
  6460. }
  6461. }
  6462. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  6463. {
  6464. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6465. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  6466. {
  6467. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  6468. {
  6469. // first, lookup to see if template name already exists
  6470. const char* name = 0;
  6471. name = sep->argplus[1];
  6472. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  6473. if(!template_names)
  6474. {
  6475. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  6476. if( new_template_id > 0 )
  6477. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  6478. else
  6479. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  6480. }
  6481. else
  6482. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  6483. }
  6484. else
  6485. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  6486. }
  6487. else
  6488. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  6489. }
  6490. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  6491. {
  6492. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  6493. {
  6494. int32 template_id = 0;
  6495. template_id = atoi(sep->arg[1]);
  6496. if (database.RemoveSpawnTemplate(template_id))
  6497. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  6498. else
  6499. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  6500. }
  6501. else
  6502. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  6503. }
  6504. // Renamed create to spawn
  6505. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  6506. {
  6507. if (sep && sep->arg[1][0])
  6508. {
  6509. int32 new_location = 0;
  6510. if (sep->IsNumber(1))
  6511. {
  6512. int32 template_id = 0;
  6513. template_id = atoi(sep->arg[1]);
  6514. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  6515. if( new_location > 0 )
  6516. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  6517. else
  6518. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  6519. }
  6520. else
  6521. {
  6522. const char* name = 0;
  6523. name = sep->argplus[1];
  6524. new_location = database.CreateSpawnFromTemplateByName(client, name);
  6525. if( new_location > 0 )
  6526. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  6527. else
  6528. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  6529. }
  6530. }
  6531. else
  6532. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  6533. }
  6534. else
  6535. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  6536. }
  6537. void Commands::Command_Speed(Client* client, Seperator* sep) {
  6538. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  6539. float new_speed = atof(sep->arg[0]);
  6540. if (new_speed > 0.0f)
  6541. {
  6542. client->GetPlayer()->SetSpeed(new_speed);
  6543. client->GetPlayer()->SetCharSheetChanged(true);
  6544. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  6545. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  6546. }
  6547. else
  6548. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  6549. }
  6550. else{
  6551. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  6552. }
  6553. }
  6554. /*
  6555. Function: Command_StationMarketPlace()
  6556. Purpose : just trying to eat the console spam for now
  6557. Params :
  6558. Dev : John
  6559. */
  6560. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  6561. {
  6562. PrintSep(sep, "COMMAND_SMP");
  6563. // This will reduce the spam from once every 10 sec to once every 30 sec,
  6564. // can't seem to reduce it any more get rid of it completely...
  6565. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  6566. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  6567. if (packet) {
  6568. packet->setDataByName("account_id", client->GetAccountID());
  6569. packet->setDataByName("character_id", client->GetCharacterID());
  6570. packet->setDataByName("unknown1", 1, 5);
  6571. packet->setDataByName("unknown1", 26, 6);
  6572. packet->setDataByName("unknown2", 0xFFFFFFFF);
  6573. packet->setDataByName("unknown3", 248, 1);
  6574. client->QueuePacket(packet->serialize());
  6575. }
  6576. safe_delete(packet);
  6577. }
  6578. }
  6579. /*
  6580. Function: Command_StopDrinking()
  6581. Purpose : Stops player from auto-consuming drink
  6582. Params :
  6583. Dev : Zcoretri
  6584. Example : /stopdrinking
  6585. */
  6586. void Commands::Command_StopDrinking(Client* client)
  6587. {
  6588. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  6589. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  6590. }
  6591. /*
  6592. Function: Command_StopEating()
  6593. Purpose : Stops player from auto-consuming food
  6594. Params :
  6595. Dev : Zcoretri
  6596. Example : /stopeating
  6597. */
  6598. void Commands::Command_StopEating(Client* client)
  6599. {
  6600. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  6601. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  6602. }
  6603. /*
  6604. Function: Command_Title()
  6605. Purpose : Help for /title command
  6606. Params : n/a
  6607. Dev : Zcoretri
  6608. Example : /title
  6609. */
  6610. void Commands::Command_Title(Client* client)
  6611. {
  6612. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  6613. }
  6614. /*
  6615. Function: Command_TitleList()
  6616. Purpose : List available titles for player
  6617. Params : n/a
  6618. Dev : Zcoretri
  6619. Example : /title list
  6620. */
  6621. void Commands::Command_TitleList(Client* client)
  6622. {
  6623. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  6624. list<Title*>::iterator itr;
  6625. Title* title;
  6626. int16 i = 0;
  6627. client->Message(CHANNEL_COLOR_WHITE, "Listing available titles:");
  6628. for(itr = titles->begin(); itr != titles->end(); itr++)
  6629. {
  6630. title = *itr;
  6631. client->Message(CHANNEL_COLOR_WHITE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  6632. i++;
  6633. }
  6634. }
  6635. /*
  6636. Function: Command_TitleSetPrefix()
  6637. Purpose : Set Prefix title for player
  6638. Params : Title ID
  6639. Dev : Zcoretri
  6640. Example : /title setprefix 1
  6641. */
  6642. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  6643. {
  6644. if (sep && sep->arg[0] && sep->IsNumber(0))
  6645. {
  6646. int32 index = atoul(sep->arg[0]);
  6647. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  6648. client->SendTitleUpdate();
  6649. }
  6650. }
  6651. /*
  6652. Function: Command_TitleSetSuffix()
  6653. Purpose : Set Suffix title for player
  6654. Params : Title ID
  6655. Dev : Zcoretri
  6656. Example : /title setsuffix 1
  6657. */
  6658. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  6659. {
  6660. if (sep && sep->arg[0] && sep->IsNumber(0))
  6661. {
  6662. int32 index = atoul(sep->arg[0]);
  6663. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  6664. client->SendTitleUpdate();
  6665. }
  6666. }
  6667. /*
  6668. Function: Command_TitleFix()
  6669. Purpose : Fix title for player (???)
  6670. Params :
  6671. Dev : Zcoretri
  6672. Example :
  6673. */
  6674. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  6675. {
  6676. PrintSep(sep, "COMMAND_TITLE_FIX");
  6677. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  6678. }
  6679. /*
  6680. Function: Command_Toggle_Anonymous()
  6681. Purpose : Toggles player Anonymous
  6682. Params :
  6683. Dev : paulgh
  6684. Example : /anon
  6685. */
  6686. void Commands::Command_Toggle_Anonymous(Client* client)
  6687. {
  6688. Player* player = client->GetPlayer();
  6689. player->toggle_character_flag(CF_ANONYMOUS);
  6690. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  6691. if (player->get_character_flag(CF_ANONYMOUS))
  6692. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  6693. else
  6694. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  6695. }
  6696. /*
  6697. Function: Command_Toggle_AutoConsume()
  6698. Purpose : Toggles player food/drink auto consume
  6699. Params : unknown
  6700. Dev : paulgh
  6701. Example : /set_auto_consume
  6702. */
  6703. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  6704. {
  6705. Player* player = client->GetPlayer();
  6706. if (sep && sep->arg[0])
  6707. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  6708. if (sep && sep->arg[0] && sep->IsNumber(0))
  6709. {
  6710. int8 slot = atoi(sep->arg[0]);
  6711. int8 flag = atoi(sep->arg[1]);
  6712. if (slot == EQ2_FOOD_SLOT)
  6713. {
  6714. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  6715. player->SetCharSheetChanged(true);
  6716. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  6717. if (flag == 1)
  6718. client->Message(CHANNEL_COLOR_WHITE, "You decide to eat immediately whenever you become hungry.");
  6719. else
  6720. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the hunger.");
  6721. }
  6722. else
  6723. {
  6724. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  6725. player->SetCharSheetChanged(true);
  6726. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  6727. if (flag == 1)
  6728. client->Message(CHANNEL_COLOR_WHITE, "You decide to drink immediately whenever you become thirsty.");
  6729. else
  6730. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the thirst.");
  6731. }
  6732. }
  6733. }
  6734. /*
  6735. Function: Command_Toggle_BonusXP()
  6736. Purpose : Toggles player Bonus XP
  6737. Params :
  6738. Dev : John Adams
  6739. Example : /disable_char_bonus_exp
  6740. */
  6741. void Commands::Command_Toggle_BonusXP(Client* client)
  6742. {
  6743. Player* player = client->GetPlayer();
  6744. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  6745. player->SetCharSheetChanged(true);
  6746. }
  6747. /*
  6748. Function: Command_Toggle_CombatXP()
  6749. Purpose : Toggles player Adventure XP
  6750. Params :
  6751. Dev : John Adams
  6752. Example : /disable_combat_exp
  6753. */
  6754. void Commands::Command_Toggle_CombatXP(Client* client)
  6755. {
  6756. Player* player = client->GetPlayer();
  6757. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  6758. player->SetCharSheetChanged(true);
  6759. }
  6760. /*
  6761. Function: Command_Toggle_GMHide()
  6762. Purpose : Toggles hiding player GM status
  6763. Params :
  6764. Dev : Scatman
  6765. Example : /gm_hide
  6766. */
  6767. void Commands::Command_Toggle_GMHide(Client* client)
  6768. {
  6769. Player* player = client->GetPlayer();
  6770. player->toggle_character_flag(CF_HIDE_STATUS);
  6771. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  6772. }
  6773. /*
  6774. Function: Command_Toggle_GMVanish()
  6775. Purpose : Toggles hiding GM players from /who searches
  6776. Params :
  6777. Dev : Scatman
  6778. Example : /gm_vanish
  6779. */
  6780. void Commands::Command_Toggle_GMVanish(Client* client)
  6781. {
  6782. Player* player = client->GetPlayer();
  6783. player->toggle_character_flag(CF_GM_HIDDEN);
  6784. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  6785. }
  6786. /*
  6787. Function: Command_Toggle_Illusions()
  6788. Purpose : Toggles player illusion form
  6789. Params : not sure sep is needed, testing
  6790. Dev : paulgh
  6791. Example : /hide_illusions
  6792. */
  6793. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  6794. {
  6795. if (sep && sep->arg[0])
  6796. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  6797. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  6798. }
  6799. /*
  6800. Function: Command_Toggle_LFG()
  6801. Purpose : Toggles player LFG Flag
  6802. Params :
  6803. Dev : paulgh
  6804. Example : /lfg
  6805. */
  6806. void Commands::Command_Toggle_LFG(Client* client)
  6807. {
  6808. Player* player = client->GetPlayer();
  6809. player->toggle_character_flag(CF_LFG);
  6810. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  6811. if (player->get_character_flag(CF_LFG))
  6812. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  6813. else
  6814. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  6815. }
  6816. /*
  6817. Function: Command_Toggle_LFW()
  6818. Purpose : Toggles player LFW Flag
  6819. Params :
  6820. Dev : paulgh
  6821. Example : /lfw
  6822. */
  6823. void Commands::Command_Toggle_LFW(Client* client)
  6824. {
  6825. Player* player = client->GetPlayer();
  6826. player->toggle_character_flag(CF_LFW);
  6827. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  6828. if (player->get_character_flag(CF_LFW))
  6829. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  6830. else
  6831. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  6832. }
  6833. /*
  6834. Function: Command_Toggle_QuestXP()
  6835. Purpose : Toggles player Quest XP
  6836. Params :
  6837. Dev : John Adams
  6838. Example : /disable_quest_exp
  6839. */
  6840. void Commands::Command_Toggle_QuestXP(Client* client)
  6841. {
  6842. Player* player = client->GetPlayer();
  6843. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  6844. player->SetCharSheetChanged(true);
  6845. }
  6846. /*
  6847. Function: Command_Toggle_Roleplaying()
  6848. Purpose : Toggles player Roleplaying flag
  6849. Params :
  6850. Dev : paulgh
  6851. Example : /role
  6852. */
  6853. void Commands::Command_Toggle_Roleplaying(Client* client)
  6854. {
  6855. Player* player = client->GetPlayer();
  6856. player->toggle_character_flag(CF_ROLEPLAYING);
  6857. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  6858. if (player->get_character_flag(CF_ROLEPLAYING))
  6859. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  6860. else
  6861. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  6862. }
  6863. void Commands::Command_Toggle_Duels(Client* client)
  6864. {
  6865. Player* player = client->GetPlayer();
  6866. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  6867. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  6868. }
  6869. void Commands::Command_Toggle_Trades(Client* client)
  6870. {
  6871. Player* player = client->GetPlayer();
  6872. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  6873. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  6874. }
  6875. void Commands::Command_Toggle_Guilds(Client* client)
  6876. {
  6877. Player* player = client->GetPlayer();
  6878. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  6879. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  6880. }
  6881. void Commands::Command_Toggle_Groups(Client* client)
  6882. {
  6883. Player* player = client->GetPlayer();
  6884. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  6885. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  6886. }
  6887. void Commands::Command_Toggle_Raids(Client* client)
  6888. {
  6889. Player* player = client->GetPlayer();
  6890. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  6891. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  6892. }
  6893. void Commands::Command_Toggle_LON(Client* client)
  6894. {
  6895. Player* player = client->GetPlayer();
  6896. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  6897. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  6898. }
  6899. void Commands::Command_Toggle_VoiceChat(Client* client)
  6900. {
  6901. Player* player = client->GetPlayer();
  6902. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  6903. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  6904. }
  6905. /*
  6906. Function: Command_TradeStart()
  6907. Purpose : Starts item/coin trade between players
  6908. Params :
  6909. Dev :
  6910. Example :
  6911. */
  6912. #include "../Trade.h"
  6913. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  6914. {
  6915. PrintSep(sep, "COMMAND_START_TRADE");
  6916. Entity* trader = client->GetPlayer();
  6917. Entity* trader2 = 0;
  6918. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  6919. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  6920. if (spawn) {
  6921. if (spawn->IsEntity())
  6922. trader2 = (Entity*)spawn;
  6923. }
  6924. }
  6925. else if (client->GetPlayer()->GetTarget()) {
  6926. if (client->GetPlayer()->GetTarget()->IsEntity())
  6927. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  6928. }
  6929. // can only trade with player or bots
  6930. if (trader && trader2) {
  6931. if (trader == trader2) {
  6932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  6933. }
  6934. else if (trader2->IsPlayer() || trader2->IsBot()) {
  6935. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  6936. if (trader->trade)
  6937. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  6938. else if (trader2->trade)
  6939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  6940. else {
  6941. Trade* trade = new Trade(trader, trader2);
  6942. trader->trade = trade;
  6943. trader2->trade = trade;
  6944. }
  6945. }
  6946. else {
  6947. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  6948. }
  6949. }
  6950. else
  6951. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  6952. }
  6953. /*
  6954. Function: Command_Track()
  6955. Purpose : Starts/Stops Tracking for a player
  6956. Params :
  6957. Dev : Scatman
  6958. Example : /track
  6959. */
  6960. void Commands::Command_Track(Client* client)
  6961. {
  6962. if (!client->GetPlayer()->GetIsTracking())
  6963. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  6964. else
  6965. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  6966. }
  6967. /*
  6968. Function: Command_TradeAccept()
  6969. Purpose : Accepts item/coin trade between players
  6970. Params :
  6971. Dev :
  6972. Example :
  6973. */
  6974. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  6975. {
  6976. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  6977. Trade* trade = client->GetPlayer()->trade;
  6978. if (trade) {
  6979. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  6980. if (trade_complete)
  6981. safe_delete(trade);
  6982. }
  6983. else
  6984. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  6985. }
  6986. /*
  6987. Function: Command_TradeReject()
  6988. Purpose : Rejects item/coin trade between players
  6989. Params :
  6990. Dev :
  6991. Example :
  6992. */
  6993. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  6994. {
  6995. PrintSep(sep, "COMMAND_REJECT_TRADE");
  6996. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  6997. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  6998. }
  6999. /*
  7000. Function: Command_TradeCancel()
  7001. Purpose : Cancels item/coin trade between players
  7002. Params :
  7003. Dev :
  7004. Example :
  7005. */
  7006. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7007. {
  7008. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7009. Trade* trade = client->GetPlayer()->trade;
  7010. if (trade) {
  7011. trade->CancelTrade(client->GetPlayer());
  7012. safe_delete(trade);
  7013. }
  7014. else
  7015. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7016. }
  7017. /*
  7018. Function: Command_TradeSetCoin()
  7019. Purpose : Sets coin trade between players
  7020. Params :
  7021. Dev :
  7022. Example :
  7023. */
  7024. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7025. {
  7026. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7027. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7028. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7029. }
  7030. /*
  7031. Function: Command_TradeAddCoin()
  7032. Purpose : Adds coin to trade between players
  7033. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7034. Dev :
  7035. Example :
  7036. */
  7037. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7038. {
  7039. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7040. Trade* trade = client->GetPlayer()->trade;
  7041. if (trade) {
  7042. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7043. int32 amount = atoi(sep->arg[0]);
  7044. int64 val = 0;
  7045. switch (handler) {
  7046. case COMMAND_ADD_TRADE_COPPER:
  7047. {
  7048. val = amount;
  7049. trade->AddCoinToTrade(client->GetPlayer(), val);
  7050. break;
  7051. }
  7052. case COMMAND_ADD_TRADE_SILVER:
  7053. {
  7054. val = amount * 100;
  7055. trade->AddCoinToTrade(client->GetPlayer(), val);
  7056. break;
  7057. }
  7058. case COMMAND_ADD_TRADE_GOLD:
  7059. {
  7060. val = amount * 10000;
  7061. trade->AddCoinToTrade(client->GetPlayer(), val);
  7062. break;
  7063. }
  7064. case COMMAND_ADD_TRADE_PLAT:
  7065. {
  7066. val = amount * 1000000;
  7067. trade->AddCoinToTrade(client->GetPlayer(), val);
  7068. break;
  7069. }
  7070. default:
  7071. {
  7072. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7073. break;
  7074. }
  7075. }
  7076. }
  7077. else
  7078. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7079. }
  7080. else
  7081. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7082. }
  7083. /*
  7084. Function: Command_TradeRemoveCoin()
  7085. Purpose : Removes coin from trade between players
  7086. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7087. Dev :
  7088. Example :
  7089. */
  7090. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7091. {
  7092. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7093. Trade* trade = client->GetPlayer()->trade;
  7094. if (trade) {
  7095. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7096. int32 amount = atoi(sep->arg[0]);
  7097. int64 val = 0;
  7098. switch (handler) {
  7099. case COMMAND_REMOVE_TRADE_COPPER:
  7100. {
  7101. val = amount;
  7102. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7103. break;
  7104. }
  7105. case COMMAND_REMOVE_TRADE_SILVER:
  7106. {
  7107. val = amount * 100;
  7108. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7109. break;
  7110. }
  7111. case COMMAND_REMOVE_TRADE_GOLD:
  7112. {
  7113. val = amount * 10000;
  7114. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7115. break;
  7116. }
  7117. case COMMAND_REMOVE_TRADE_PLAT:
  7118. {
  7119. val = amount * 1000000;
  7120. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7121. break;
  7122. }
  7123. default:
  7124. {
  7125. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7126. break;
  7127. }
  7128. }
  7129. }
  7130. else
  7131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7132. }
  7133. else
  7134. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7135. }
  7136. /*
  7137. Function: Command_TradeAddItem()
  7138. Purpose : Adds item to trade between players
  7139. Params :
  7140. Dev :
  7141. Example :
  7142. */
  7143. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7144. {
  7145. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7146. /*
  7147. arg[0] = item index
  7148. arg[1] = slot
  7149. arg[2] = quantity
  7150. */
  7151. if (!client->GetPlayer()->trade) {
  7152. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7153. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7154. return;
  7155. }
  7156. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7157. Item* item = 0;
  7158. int32 index = atoi(sep->arg[0]);
  7159. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7160. if (item) {
  7161. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7162. if (result == 1)
  7163. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7164. else if (result == 2)
  7165. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7166. else if (result == 3)
  7167. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7168. else if (result == 255)
  7169. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7170. }
  7171. else {
  7172. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7173. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7174. }
  7175. }
  7176. else
  7177. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7178. }
  7179. /*
  7180. Function: Command_TradeRemoveItem()
  7181. Purpose : Removes item from trade between players
  7182. Params :
  7183. Dev :
  7184. Example :
  7185. */
  7186. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7187. {
  7188. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7189. /*
  7190. arg[0] = trade window slot
  7191. */
  7192. Trade* trade = client->GetPlayer()->trade;
  7193. if (trade) {
  7194. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7195. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7196. }
  7197. else
  7198. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7199. }
  7200. else
  7201. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7202. }
  7203. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7204. {
  7205. Item *item = 0;
  7206. sint32 crc;
  7207. if (sep) {
  7208. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7209. if (client->GetVersion() < 1096) {
  7210. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7211. {
  7212. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7213. crc = atol(sep->arg[2]);
  7214. }
  7215. }
  7216. else {
  7217. // From the broker and links in chat
  7218. if (strcmp(sep->arg[0], "crc") == 0) {
  7219. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7220. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7221. crc = atol(sep->arg[3]);
  7222. }
  7223. }
  7224. // From inventory
  7225. if (strcmp(sep->arg[0], "dbid") == 0) {
  7226. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7227. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7228. crc = atol(sep->arg[4]);
  7229. }
  7230. }
  7231. }
  7232. if (item)
  7233. client->ShowDressingRoom(item, crc);
  7234. }
  7235. }
  7236. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7237. const char *channel_name, *password = NULL;
  7238. if (sep == NULL || !sep->IsSet(0)) {
  7239. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7240. return;
  7241. }
  7242. channel_name = sep->arg[0];
  7243. if (sep->IsSet(1))
  7244. password = sep->arg[1];
  7245. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7246. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7247. return;
  7248. }
  7249. if (chat.IsInChannel(client, channel_name)) {
  7250. client->Message(CHANNEL_COLOR_WHITE, "You are already in '%s'.", channel_name);
  7251. return;
  7252. }
  7253. if (chat.HasPassword(channel_name)) {
  7254. if (password == NULL) {
  7255. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': That channel is password protected.", channel_name);
  7256. return;
  7257. }
  7258. if (!chat.PasswordMatches(channel_name, password)) {
  7259. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': The password is not correc.t", channel_name);
  7260. return;
  7261. }
  7262. }
  7263. if (!chat.JoinChannel(client, channel_name))
  7264. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7265. }
  7266. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7267. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7268. Command_JoinChannel(client, sep);
  7269. }
  7270. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7271. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7272. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7273. PrintSep(sep, "tellchannel");
  7274. return;
  7275. }
  7276. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7277. }
  7278. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7279. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  7280. if (!p) return;
  7281. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7282. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  7283. //}
  7284. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7285. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  7286. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  7287. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  7288. if (packet) {
  7289. client->QueuePacket(packet->serialize());
  7290. safe_delete(packet);
  7291. }
  7292. }*/
  7293. /*if (client->GetCurrentZone()->Grid != nullptr) {
  7294. int32 numFaces = 0;
  7295. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  7296. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  7297. map<int32, vector<Face*> >::iterator itr;
  7298. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  7299. numFaces += (*itr).second.size();
  7300. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  7301. }*/
  7302. //uchar blah[] = {
  7303. // 1208 - OP_EQUpdateStoreCmd
  7304. // /*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
  7305. // /*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
  7306. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  7307. // /*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
  7308. /*};
  7309. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7310. int8 val = 0;
  7311. int16 pos = 0;
  7312. int idx = 0;
  7313. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  7314. pos = atoi(sep2->arg[idx]);
  7315. val = atoi(sep2->arg[idx+1]);
  7316. memset(blah+pos, val, 1);
  7317. idx+=2;
  7318. }
  7319. DumpPacket(blah, sizeof(blah));
  7320. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  7321. if (client->GetPlayer()->GetTarget()) {
  7322. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  7323. if (packet) {
  7324. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7325. packet->setDataByName("size", 0);
  7326. packet->setDataByName("unknown2", 0);
  7327. EQ2Packet* app = packet->serialize();
  7328. client->QueuePacket(app);
  7329. safe_delete(packet);
  7330. }
  7331. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  7332. if (set_pov) {
  7333. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7334. EQ2Packet* app_pov = set_pov->serialize();
  7335. client->QueuePacket(app_pov);
  7336. safe_delete(set_pov);
  7337. }
  7338. }
  7339. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7340. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  7341. if (packet) {
  7342. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  7343. packet->setDataByName("Type", atoi(sep2->arg[0]));
  7344. else
  7345. packet->setDataByName("Type", 2);
  7346. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  7347. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  7348. else
  7349. packet->setDataByName("race_id", 0);
  7350. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  7351. packet->setDataByName("gender", atoi(sep2->arg[2]));
  7352. else
  7353. packet->setDataByName("gender", 2);
  7354. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  7355. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  7356. else
  7357. packet->setDataByName("unknown", 0, 0);
  7358. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  7359. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  7360. else
  7361. packet->setDataByName("unknown", 0, 1);
  7362. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  7363. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  7364. else
  7365. packet->setDataByName("unknown", 0, 2);
  7366. client->QueuePacket(packet->serialize());
  7367. }
  7368. safe_delete(packet);
  7369. safe_delete(sep2);
  7370. }
  7371. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  7372. const char *channel_name;
  7373. if (sep == NULL || !sep->IsSet(0)) {
  7374. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  7375. PrintSep(sep);
  7376. return;
  7377. }
  7378. channel_name = sep->arg[0];
  7379. if (!chat.IsInChannel(client, channel_name))
  7380. client->Message(CHANNEL_COLOR_WHITE, "Unable to leave '%s': You are not in the channel.", channel_name);
  7381. else if (!chat.LeaveChannel(client, channel_name))
  7382. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  7383. }
  7384. /*
  7385. Function:
  7386. Purpose :
  7387. Params :
  7388. Dev :
  7389. Example :
  7390. */
  7391. void Commands::Command_WeaponStats(Client* client)
  7392. {
  7393. Player* player = client->GetPlayer();
  7394. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  7395. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  7396. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  7397. client->SimpleMessage(0, "Primary:");
  7398. if (primary) {
  7399. client->Message(0, "Name: %s", primary->name.c_str());
  7400. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  7401. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7402. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  7403. client->Message(0, "Proc Percent: %d%%", 0);
  7404. client->Message(0, "Procs Per Minute: %d", 0);
  7405. }
  7406. else {
  7407. client->SimpleMessage(0, "Name: fist");
  7408. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7409. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7410. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  7411. client->Message(0, "Proc Percent: %d%%", 0);
  7412. client->Message(0, "Procs Per Minute: %d", 0);
  7413. }
  7414. client->SimpleMessage(0, " ");
  7415. client->SimpleMessage(0, " ");
  7416. if (secondary) {
  7417. client->SimpleMessage(0, "Secondary:");
  7418. client->Message(0, "Name: %s", secondary->name.c_str());
  7419. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  7420. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  7421. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  7422. client->Message(0, "Proc Percent: %d%%", 0);
  7423. client->Message(0, "Procs Per Minute: %d", 0);
  7424. client->SimpleMessage(0, " ");
  7425. client->SimpleMessage(0, " ");
  7426. }
  7427. client->SimpleMessage(0, "Ranged:");
  7428. if (ranged) {
  7429. client->Message(0, "Name: %s", ranged->name.c_str());
  7430. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  7431. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  7432. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  7433. client->Message(0, "Proc Percent: %d%%", 0);
  7434. client->Message(0, "Procs Per Minute: %d", 0);
  7435. }
  7436. else
  7437. client->SimpleMessage(0, "None");
  7438. }
  7439. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  7440. const char *channel_name;
  7441. if (sep == NULL || !sep->IsSet(0)) {
  7442. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  7443. return;
  7444. }
  7445. channel_name = sep->arg[0];
  7446. if (!chat.ChannelExists(channel_name))
  7447. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  7448. else
  7449. chat.SendChannelUserList(client, channel_name);
  7450. }
  7451. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  7452. {
  7453. ZoneServer* zone = 0;
  7454. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  7455. if (zone_id > 0)
  7456. {
  7457. zone = zone_list.Get(zone_id, false);
  7458. if (zone)
  7459. {
  7460. zone->SetSafeX(client->GetPlayer()->GetX());
  7461. zone->SetSafeY(client->GetPlayer()->GetY());
  7462. zone->SetSafeZ(client->GetPlayer()->GetZ());
  7463. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  7464. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  7465. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  7466. else
  7467. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  7468. }
  7469. }
  7470. }
  7471. /*
  7472. Function:
  7473. Purpose :
  7474. Params :
  7475. Dev :
  7476. Example :
  7477. */
  7478. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  7479. {
  7480. ZoneInfo* zone_info = new ZoneInfo;
  7481. if (sep && sep->arg[0])
  7482. {
  7483. if (sep->IsNumber(0))
  7484. zone_info->id = atoi(sep->arg[0]);
  7485. else
  7486. zone_info->id = database.GetZoneID(sep->arg[0]);
  7487. if (zone_info->id > 0)
  7488. {
  7489. database.LoadZoneInfo(zone_info);
  7490. 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);
  7491. 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);
  7492. 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);
  7493. 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);
  7494. 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);
  7495. 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);
  7496. 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);
  7497. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  7498. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  7499. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  7500. }
  7501. else
  7502. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  7503. }
  7504. else
  7505. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  7506. safe_delete(zone_info);
  7507. }
  7508. /*
  7509. Function:
  7510. Purpose :
  7511. Params :
  7512. Dev :
  7513. Example :
  7514. */
  7515. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  7516. {
  7517. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  7518. {
  7519. ZoneServer* zone = 0;
  7520. int32 zone_id = 0;
  7521. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  7522. {
  7523. zone_id = atoi(sep->arg[0]);
  7524. zone = zone_list.Get(atoi(sep->arg[0]), false);
  7525. }
  7526. else
  7527. {
  7528. zone_id = database.GetZoneID(sep->arg[0]);
  7529. if (zone_id > 0)
  7530. zone = zone_list.Get(sep->arg[0], false);
  7531. }
  7532. if (zone_id > 0)
  7533. {
  7534. if (zone_set_values.count(string(sep->arg[1])) > 0)
  7535. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  7536. else
  7537. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  7538. }
  7539. else
  7540. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  7541. }
  7542. else
  7543. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  7544. }
  7545. void Commands::Command_Rain(Client* client, Seperator* sep) {
  7546. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  7547. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  7548. return;
  7549. }
  7550. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  7551. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  7552. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  7553. }
  7554. void Commands::Command_Wind(Client* client, Seperator* sep) {
  7555. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  7556. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  7557. return;
  7558. }
  7559. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  7560. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  7561. }
  7562. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  7563. Spawn* spawn = client->GetPlayer()->GetTarget();
  7564. if(spawn) {
  7565. client->SetMerchantTransaction(spawn);
  7566. if (spawn->GetMerchantID() > 0){
  7567. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  7568. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  7569. client->SendBuyMerchantList(sell);
  7570. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  7571. client->SendSellMerchantList(sell);
  7572. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  7573. client->SendBuyBackList(sell);
  7574. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  7575. if (packet) {
  7576. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  7577. packet->setDataByName("type", 16);
  7578. EQ2Packet* outapp = packet->serialize();
  7579. if (outapp)
  7580. client->QueuePacket(outapp);
  7581. safe_delete(packet);
  7582. }
  7583. }
  7584. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  7585. client->SendRepairList();
  7586. }
  7587. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  7588. }
  7589. void Commands::Command_Weather(Client* client, Seperator* sep)
  7590. {
  7591. //PrintSep(sep, "Weather");
  7592. if( sep && sep->arg[0] )
  7593. {
  7594. ZoneServer* zsZone = client->GetCurrentZone();
  7595. const char* value = sep->arg[0];
  7596. // process single-param commands first
  7597. if( strncasecmp(value, "details", strlen(value)) == 0 )
  7598. {
  7599. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  7600. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  7601. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  7602. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  7603. }
  7604. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  7605. {
  7606. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  7607. zsZone->ProcessWeather();
  7608. }
  7609. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  7610. {
  7611. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  7612. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  7613. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  7614. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  7615. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  7616. zsZone->SetWeatherPattern(1);
  7617. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  7618. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  7619. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  7620. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  7621. zsZone->ProcessWeather();
  7622. }
  7623. // process commands with params
  7624. if( sep->arg[1] )
  7625. {
  7626. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  7627. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  7628. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  7629. zsZone->SetWeatherType(atoi(sep->arg[1]));
  7630. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  7631. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  7632. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  7633. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  7634. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  7635. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  7636. }
  7637. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  7638. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  7639. zsZone->SetRain(zsZone->GetCurrentWeather());
  7640. }
  7641. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  7642. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  7643. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  7644. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  7645. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  7646. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  7647. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  7648. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  7649. }
  7650. }
  7651. else
  7652. {
  7653. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  7654. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  7655. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  7656. return;
  7657. }
  7658. }
  7659. void Commands::Command_Select(Client* client, Seperator* sep) {
  7660. if (sep && sep->arg[1]) {
  7661. Spawn* spawn = client->GetPlayer()->GetTarget();
  7662. if (spawn && strlen(sep->arg[1]) > 0)
  7663. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  7664. }
  7665. }
  7666. /*
  7667. Function: Command_ConsumeFood()
  7668. Purpose : Consume Food/Drink and apply mods
  7669. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  7670. Dev : Zcoretri
  7671. Example : /consume_food 22
  7672. */
  7673. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  7674. if (sep && sep->arg[0] && sep->IsNumber(0))
  7675. {
  7676. Player* player = client->GetPlayer();
  7677. int8 slot = atoi(sep->arg[0]);
  7678. Item* item = player->GetEquipmentList()->GetItem(slot);
  7679. if(item) {
  7680. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  7681. if(item->GetItemScript() && lua_interface){
  7682. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  7683. if (slot == 22)
  7684. client->Message(CHANNEL_COLOR_WHITE, "You eat a %s.", item->name.c_str());
  7685. else
  7686. client->Message(CHANNEL_COLOR_WHITE, "You drink a %s.", item->name.c_str());
  7687. }
  7688. }
  7689. if (item->details.count > 1) {
  7690. item->details.count -= 1;
  7691. item->save_needed = true;
  7692. }
  7693. else {
  7694. player->GetEquipmentList()->RemoveItem(slot, true);
  7695. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  7696. }
  7697. client->GetPlayer()->SetCharSheetChanged(true);
  7698. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7699. }
  7700. }
  7701. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  7702. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  7703. if (atoi(sep->arg[0]) == 1) {
  7704. client->GetPlayer()->GetInfoStruct()->vision = 4;
  7705. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  7706. client->GetPlayer()->SetCharSheetChanged(true);
  7707. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  7708. }
  7709. else {
  7710. client->GetPlayer()->GetInfoStruct()->vision = 0;
  7711. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  7712. client->GetPlayer()->SetCharSheetChanged(true);
  7713. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  7714. }
  7715. }
  7716. else
  7717. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  7718. }
  7719. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  7720. {
  7721. if(sep)
  7722. {
  7723. string data;
  7724. if(sep->arg[0]){
  7725. data = string(sep->arg[0]);
  7726. }
  7727. for(int i=1;i<sep->GetMaxArgNum();i++){
  7728. if(sep->arg[i])
  7729. data.append(" ").append(sep->arg[i]);
  7730. }
  7731. const char* target_name = 0;
  7732. int32 spawn_id = 0;
  7733. if(client->GetPlayer()->GetTarget())
  7734. {
  7735. target_name = client->GetPlayer()->GetTarget()->GetName();
  7736. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  7737. }
  7738. else
  7739. target_name = "N/A";
  7740. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  7741. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  7742. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  7743. else
  7744. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  7745. }
  7746. }
  7747. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  7748. PrintSep(sep, "Command_Attune_Inv");
  7749. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  7750. // Get the item index from the first parameter
  7751. int16 index = atoi(sep->arg[0]);
  7752. // Check to see if this is a valid item index for the player, if not exit out of the function
  7753. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  7754. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  7755. return;
  7756. }
  7757. // Get the item
  7758. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  7759. if(item) {
  7760. // Valid item lets check to make sure this item is attunable, if not return out
  7761. if (!item->CheckFlag(ATTUNEABLE)) {
  7762. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  7763. return;
  7764. }
  7765. // Remove the attunable flag
  7766. item->generic_info.item_flags -= ATTUNEABLE;
  7767. // Set the attuned flag
  7768. item->generic_info.item_flags += ATTUNED;
  7769. // Flag this item for saving
  7770. item->save_needed = true;
  7771. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  7772. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  7773. EQ2Packet* outapp = 0;
  7774. for (int32 i=0;i<packets.size();i++) {
  7775. outapp = packets[i];
  7776. if(outapp)
  7777. client->QueuePacket(outapp);
  7778. }
  7779. }
  7780. }
  7781. }
  7782. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  7783. PrintSep(sep, "Command_Reset_Zone_Timer");
  7784. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  7785. int32 db_id = atoul(sep->arg[0]);
  7786. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  7787. if (data) {
  7788. // TODO: add a check to timers to ensure it can be reset
  7789. // Delete the character from the instance
  7790. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  7791. data->instance_id = 0;
  7792. // Update the success time and set to 0 so the player can enter it again
  7793. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  7794. data->last_success_timestamp = 0;
  7795. }
  7796. }*/
  7797. }
  7798. void Commands::Command_Player(Client* client, Seperator* sep) {
  7799. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  7800. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  7801. }
  7802. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  7803. // /player coins add 10
  7804. // /player coins add plat 10
  7805. Player* player = client->GetPlayer();
  7806. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7807. player = (Player*)player->GetTarget();
  7808. if (sep && sep->arg[0] && sep->arg[1]) {
  7809. const char* action = sep->arg[0];
  7810. int64 value = 0;
  7811. if (strncasecmp(action, "add", strlen(action)) == 0) {
  7812. if (sep->IsNumber(1)) {
  7813. value = atoi64(sep->arg[1]);
  7814. player->AddCoins(value);
  7815. if (client->GetPlayer() == player)
  7816. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  7817. else {
  7818. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7819. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7820. }
  7821. return;
  7822. }
  7823. else if (sep->arg[2] && sep->IsNumber(2)) {
  7824. const char* type = sep->arg[1];
  7825. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  7826. value = atoi64(sep->arg[2]);
  7827. }
  7828. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  7829. value = atoi64(sep->arg[2]) * 100;
  7830. }
  7831. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  7832. value = atoi64(sep->arg[2]) * 10000;
  7833. }
  7834. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  7835. value = atoi64(sep->arg[2]) * 1000000;
  7836. }
  7837. player->AddCoins(value);
  7838. if (client->GetPlayer() == player)
  7839. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  7840. else {
  7841. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7842. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7843. }
  7844. return;
  7845. }
  7846. }
  7847. }
  7848. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  7849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  7850. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  7851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  7852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  7853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  7854. }
  7855. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  7856. PrintSep(sep, "ACHIEVEMENT_ADD");
  7857. if (sep && sep->IsSet(0)) {
  7858. int32 spell_id = atoul(sep->arg[1]);
  7859. int8 spell_tier = 0;
  7860. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  7861. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  7862. // addspellbookentry here
  7863. if (spell_tier >= data->maxRank) {
  7864. return;
  7865. }
  7866. if (!spell_tier) {
  7867. spell_tier = 1;
  7868. }
  7869. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  7870. {
  7871. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  7872. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  7873. client->GetPlayer()->UnlockSpell(spell);
  7874. client->SendSpellUpdate(spell);
  7875. }
  7876. else
  7877. {
  7878. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  7879. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  7880. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  7881. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  7882. client->GetPlayer()->UnlockSpell(spell);
  7883. client->SendSpellUpdate(spell);
  7884. }
  7885. // cast spell here
  7886. if (!spell_tier)
  7887. spell_tier = 1;
  7888. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  7889. if (spell) {
  7890. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  7891. }
  7892. }
  7893. else {
  7894. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  7895. }
  7896. master_aa_list.DisplayAA(client, 0, 0);
  7897. }
  7898. void Commands::Command_Editor(Client* client, Seperator* sep) {
  7899. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  7900. if (packet) {
  7901. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  7902. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  7903. char command[255];
  7904. url = "browser " + url;
  7905. int32 spawn_id = 0;
  7906. int32 zone_id = 0;
  7907. string type;
  7908. if (client->GetCurrentZone())
  7909. zone_id = client->GetCurrentZone()->GetZoneID();
  7910. if (client->GetPlayer()->GetTarget()) {
  7911. Spawn* target = client->GetPlayer()->GetTarget();
  7912. if (target->IsWidget())
  7913. type = "widgets";
  7914. else if (target->IsSign())
  7915. type = "signs";
  7916. else if (target->IsObject())
  7917. type = "objects";
  7918. else if (target->IsNPC())
  7919. type = "npcs";
  7920. else if (target->IsGroundSpawn())
  7921. type = "ground";
  7922. else
  7923. type = "spawn";
  7924. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  7925. }
  7926. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  7927. packet->setDataByName("accept_command", command);
  7928. }
  7929. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  7930. char command[255];
  7931. url = "browser " + url;
  7932. if (client->GetPlayer()->GetTarget())
  7933. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  7934. packet->setDataByName("accept_command", command);
  7935. }
  7936. else {
  7937. string command = "browser " + url;
  7938. packet->setDataByName("accept_command", command.c_str());
  7939. }
  7940. packet->setDataByName("text", "Open the web editor?");
  7941. packet->setDataByName("accept_text", "Open");
  7942. packet->setDataByName("cancel_text", "Cancel");
  7943. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  7944. packet->setDataByName("unknown2", 50);
  7945. packet->setDataByName("unknown4", 1);
  7946. client->QueuePacket(packet->serialize());
  7947. safe_delete(packet);
  7948. }
  7949. }
  7950. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  7951. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  7952. return;
  7953. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  7954. if(client->GetCurrentRez()->active)
  7955. client->AcceptResurrection();
  7956. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  7957. }
  7958. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  7959. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  7960. return;
  7961. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  7962. if(client->GetCurrentRez()->active)
  7963. client->GetCurrentRez()->should_delete = true;
  7964. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  7965. }
  7966. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  7967. PrintSep(sep, "Switch_AA_Profile");
  7968. if (sep && sep->IsSet(0)) {
  7969. string type = sep->arg[0];
  7970. int8 newtemplate = atoul(sep->arg[1]);
  7971. master_aa_list.DisplayAA(client, newtemplate, 1);
  7972. }
  7973. }
  7974. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  7975. PrintSep(sep, "Get_AA_Xml");
  7976. if (sep && sep->IsSet(0)) {
  7977. string tabnum = sep->arg[0];
  7978. string spellid = sep->arg[1];
  7979. }
  7980. }
  7981. void Commands::Add_AA(Client* client, Seperator* sep) {
  7982. PrintSep(sep, "Add_AA");
  7983. if (sep && sep->IsSet(0)) {
  7984. int32 spell_id = atoul(sep->arg[1]);
  7985. int8 spell_tier = 0;
  7986. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  7987. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  7988. // addspellbookentry here
  7989. if (spell_tier >= data->maxRank) {
  7990. return;
  7991. }
  7992. if (!spell_tier) {
  7993. spell_tier = 1;
  7994. }
  7995. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  7996. {
  7997. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  7998. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  7999. client->GetPlayer()->UnlockSpell(spell);
  8000. client->SendSpellUpdate(spell);
  8001. }
  8002. else
  8003. {
  8004. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  8005. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  8006. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  8007. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8008. client->GetPlayer()->UnlockSpell(spell);
  8009. client->SendSpellUpdate(spell);
  8010. }
  8011. // cast spell here
  8012. if (!spell_tier)
  8013. spell_tier = 1;
  8014. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8015. if (spell) {
  8016. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  8017. }
  8018. }
  8019. else {
  8020. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  8021. }
  8022. master_aa_list.DisplayAA(client, 0, 0);
  8023. }
  8024. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  8025. PrintSep(sep, "Commit_AA_Profile");
  8026. if (sep && sep->IsSet(0)) {
  8027. }
  8028. }
  8029. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  8030. PrintSep(sep, "Begin_AA_Profile");
  8031. if (sep && sep->IsSet(0)) {
  8032. master_aa_list.DisplayAA(client, 100, 2);
  8033. }
  8034. }
  8035. void Commands::Back_AA(Client* client, Seperator* sep) {
  8036. if (sep && sep->IsSet(0)) {
  8037. PrintSep(sep, "Back_AA");
  8038. }
  8039. }
  8040. void Commands::Remove_AA(Client* client, Seperator* sep) {
  8041. if (sep && sep->IsSet(0)) {
  8042. PrintSep(sep, "Remove_AA");
  8043. }
  8044. }
  8045. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  8046. MasterAAList master_aa_list;
  8047. PrintSep(sep, "Cancel_AA_Profile");
  8048. master_aa_list.DisplayAA(client, 0, 0);
  8049. }
  8050. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  8051. if (sep && sep->IsSet(0)) {
  8052. PrintSep(sep, "Save_AA_Profile");
  8053. }
  8054. }
  8055. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  8056. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  8057. if (!sep->IsNumber(0)) return;
  8058. int32 request_id = atoul(sep->arg[0]);
  8059. if (!sep->IsNumber(1)) return;
  8060. sint32 item_id = atoi(sep->arg[1]);
  8061. if (client->IsCurrentTransmuteID(request_id)) {
  8062. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  8063. }
  8064. else if (client->IsCurrentTransmuteID(item_id)) {
  8065. if (!sep->IsSet(2)) return;
  8066. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  8067. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  8068. }
  8069. }
  8070. }