Commands.cpp 318 KB

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