Commands.cpp 319 KB

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