9
3

Commands.cpp 327 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250
  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. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  146. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  147. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  148. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  149. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  150. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  151. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  152. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  153. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  154. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  155. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  156. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  157. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  158. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  159. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  160. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  161. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  162. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  163. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  164. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  165. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  166. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  167. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  168. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  169. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  170. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  171. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  172. }
  173. Commands::~Commands() {
  174. safe_delete(remote_commands);
  175. }
  176. int32 Commands::GetSpawnSetType(string val){
  177. if(spawn_set_values.count(val) > 0)
  178. return spawn_set_values[val];
  179. return 0xFFFFFFFF;
  180. }
  181. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  182. if(!target)
  183. return false;
  184. int32 val = 0;
  185. try{
  186. 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))
  187. val = atoul(value);
  188. }
  189. catch(...){
  190. if(client)
  191. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  192. return false;
  193. }
  194. if(temporary && temp_value){
  195. char tmp[128] = {0};
  196. switch(type){
  197. case SPAWN_SET_VALUE_NAME:{
  198. sprintf(tmp, "%s", target->GetName());
  199. target->SetName(value);
  200. client->GetCurrentZone()->SendUpdateTitles(target);
  201. break;
  202. }
  203. case SPAWN_SET_VALUE_X_OFFSET:
  204. {
  205. sprintf(tmp, "%f", target->GetXOffset());
  206. target->SetXOffset(float(val));
  207. break;
  208. }
  209. case SPAWN_SET_VALUE_Y_OFFSET:
  210. {
  211. sprintf(tmp, "%f", target->GetYOffset());
  212. target->SetYOffset(float(val));
  213. break;
  214. }
  215. case SPAWN_SET_VALUE_Z_OFFSET:
  216. {
  217. sprintf(tmp, "%f", target->GetZOffset());
  218. target->SetZOffset(float(val));
  219. break;
  220. }
  221. case SPAWN_SET_VALUE_EXPIRE: {
  222. sprintf(tmp, "%u", target->GetExpireTime());
  223. target->SetExpireTime(val);
  224. break;
  225. }
  226. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  227. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  228. target->SetExpireOffsetTime(val);
  229. break;
  230. }
  231. case SPAWN_SET_VALUE_SUB_TITLE: {
  232. sprintf(tmp, "%s", target->GetSubTitle());
  233. target->SetSubTitle(value);
  234. client->GetCurrentZone()->SendUpdateTitles(target);
  235. break;
  236. }
  237. case SPAWN_SET_VALUE_LEVEL:{
  238. sprintf(tmp, "%i", target->GetLevel());
  239. target->SetLevel(val, send_update);
  240. break;
  241. }
  242. case SPAWN_SET_VALUE_DIFFICULTY:{
  243. sprintf(tmp, "%i", target->GetEncounterLevel());
  244. target->SetEncounterLevel(val, send_update);
  245. break;
  246. }
  247. case SPAWN_SET_VALUE_MODEL_TYPE:{
  248. sprintf(tmp, "%i", target->GetModelType());
  249. target->SetModelType(val, send_update);
  250. break;
  251. }
  252. case SPAWN_SET_VALUE_CLASS:{
  253. sprintf(tmp, "%i", target->GetAdventureClass());
  254. target->SetAdventureClass(val, send_update);
  255. break;
  256. }
  257. case SPAWN_SET_VALUE_GENDER:{
  258. sprintf(tmp, "%i", target->GetGender());
  259. target->SetGender(val, send_update);
  260. break;
  261. }
  262. case SPAWN_SET_VALUE_SHOW_NAME:{
  263. sprintf(tmp, "%i", target->GetShowName());
  264. target->SetShowName(val, send_update);
  265. break;
  266. }
  267. case SPAWN_SET_VALUE_ATTACKABLE:{
  268. sprintf(tmp, "%i", target->GetAttackable());
  269. target->SetAttackable(val, send_update);
  270. break;
  271. }
  272. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  273. sprintf(tmp, "%i", target->GetShowLevel());
  274. target->SetShowLevel(val, send_update);
  275. break;
  276. }
  277. case SPAWN_SET_VALUE_TARGETABLE:{
  278. sprintf(tmp, "%i", target->GetTargetable());
  279. target->SetTargetable(val, send_update);
  280. break;
  281. }
  282. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  283. sprintf(tmp, "%i", target->GetShowCommandIcon());
  284. target->SetShowCommandIcon(val, send_update);
  285. break;
  286. }
  287. case SPAWN_SET_VALUE_HAND_ICON:{
  288. sprintf(tmp, "%i", target->GetShowHandIcon());
  289. target->SetShowHandIcon(val, send_update);
  290. break;
  291. }
  292. case SPAWN_SET_VALUE_HAIR_TYPE:{
  293. if(target->IsEntity()){
  294. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  295. ((Entity*)target)->SetHairType(val, send_update);
  296. }
  297. break;
  298. }
  299. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  300. if(target->IsEntity()){
  301. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  302. ((Entity*)target)->SetHairType(val, send_update);
  303. }
  304. break;
  305. }
  306. case SPAWN_SET_VALUE_WING_TYPE:{
  307. if(target->IsEntity()){
  308. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  309. ((Entity*)target)->SetWingType(val, send_update);
  310. }
  311. break;
  312. }
  313. case SPAWN_SET_VALUE_CHEST_TYPE:{
  314. if(target->IsEntity()){
  315. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  316. ((Entity*)target)->SetChestType(val, send_update);
  317. }
  318. break;
  319. }
  320. case SPAWN_SET_VALUE_LEGS_TYPE:{
  321. if(target->IsEntity()){
  322. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  323. ((Entity*)target)->SetLegsType(val, send_update);
  324. }
  325. break;
  326. }
  327. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  328. if(target->IsEntity()){
  329. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  330. ((Entity*)target)->SetSogaHairType(val, send_update);
  331. }
  332. break;
  333. }
  334. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  335. if(target->IsEntity()){
  336. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  337. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  338. }
  339. break;
  340. }
  341. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  342. sprintf(tmp, "%i", target->GetSogaModelType());
  343. target->SetSogaModelType(val, send_update);
  344. break;
  345. }
  346. case SPAWN_SET_VALUE_SIZE:{
  347. sprintf(tmp, "%i", target->GetSize());
  348. target->SetSize(val, send_update);
  349. break;
  350. }
  351. case SPAWN_SET_VALUE_HP:{
  352. sprintf(tmp, "%i", target->GetHP());
  353. target->SetHP(val, send_update);
  354. break;
  355. }
  356. case SPAWN_SET_VALUE_POWER:{
  357. sprintf(tmp, "%i", target->GetPower());
  358. target->SetPower(val, send_update);
  359. break;
  360. }
  361. case SPAWN_SET_VALUE_HEROIC:{
  362. sprintf(tmp, "%i", target->GetHeroic());
  363. target->SetHeroic(val, send_update);
  364. break;
  365. }
  366. case SPAWN_SET_VALUE_RESPAWN:{
  367. sprintf(tmp, "%u", target->GetRespawnTime());
  368. target->SetRespawnTime(val);
  369. break;
  370. }
  371. case SPAWN_SET_VALUE_X:{
  372. sprintf(tmp, "%f", target->GetX());
  373. target->SetX(atof(value), send_update);
  374. break;
  375. }
  376. case SPAWN_SET_VALUE_Y:{
  377. sprintf(tmp, "%f", target->GetY());
  378. target->SetY(atof(value), send_update);
  379. break;
  380. }
  381. case SPAWN_SET_VALUE_Z:{
  382. sprintf(tmp, "%f", target->GetZ());
  383. target->SetZ(atof(value), send_update);
  384. break;
  385. }
  386. case SPAWN_SET_VALUE_HEADING:{
  387. sprintf(tmp, "%f", target->GetHeading());
  388. target->SetHeading(atof(value) + 360, send_update);
  389. break;
  390. }
  391. case SPAWN_SET_VALUE_VISUAL_STATE:{
  392. sprintf(tmp, "%i", target->GetVisualState());
  393. target->SetVisualState(val, send_update);
  394. break;
  395. }
  396. case SPAWN_SET_VALUE_ACTION_STATE:{
  397. sprintf(tmp, "%i", target->GetActionState());
  398. target->SetActionState(val, send_update);
  399. break;
  400. }
  401. case SPAWN_SET_VALUE_MOOD_STATE:{
  402. sprintf(tmp, "%i", target->GetMoodState());
  403. target->SetMoodState(val, send_update);
  404. break;
  405. }
  406. case SPAWN_SET_VALUE_INITIAL_STATE:{
  407. sprintf(tmp, "%i", target->GetInitialState());
  408. target->SetInitialState(val, send_update);
  409. break;
  410. }
  411. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  412. sprintf(tmp, "%i", target->GetActivityStatus());
  413. target->SetActivityStatus(val, send_update);
  414. break;
  415. }
  416. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  417. sprintf(tmp, "%i", target->GetCollisionRadius());
  418. target->SetCollisionRadius(val, send_update);
  419. break;
  420. }
  421. case SPAWN_SET_VALUE_DEVICE_ID: {
  422. if (target->IsObject()) {
  423. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  424. ((Object*)target)->SetDeviceID(val);
  425. }
  426. break;
  427. }
  428. case SPAWN_SET_VALUE_PITCH: {
  429. sprintf(tmp, "%f", target->GetPitch());
  430. target->SetPitch(atof(value), send_update);
  431. break;
  432. }
  433. case SPAWN_SET_VALUE_ROLL: {
  434. sprintf(tmp, "%f", target->GetRoll());
  435. target->SetRoll(atof(value), send_update);
  436. break;
  437. }
  438. case SPAWN_SET_VALUE_HIDE_HOOD: {
  439. sprintf(tmp, "%i", target->appearance.hide_hood);
  440. target->SetHideHood(val);
  441. break;
  442. }
  443. case SPAWN_SET_VALUE_EMOTE_STATE: {
  444. sprintf(tmp, "%i", target->appearance.emote_state);
  445. target->SetEmoteState(val);
  446. break;
  447. }
  448. case SPAWN_SET_VALUE_ICON: {
  449. sprintf(tmp, "%i", target->GetIconValue());
  450. target->SetIcon(val);
  451. break;
  452. }
  453. case SPAWN_SET_VALUE_PREFIX: {
  454. sprintf(tmp, "%s", target->GetPrefixTitle());
  455. target->SetPrefixTitle(value);
  456. client->GetCurrentZone()->SendUpdateTitles(target);
  457. break;
  458. }
  459. case SPAWN_SET_VALUE_SUFFIX: {
  460. sprintf(tmp, "%s", target->GetSuffixTitle());
  461. target->SetSuffixTitle(value);
  462. client->GetCurrentZone()->SendUpdateTitles(target);
  463. break;
  464. }
  465. case SPAWN_SET_VALUE_LASTNAME: {
  466. sprintf(tmp, "%s", target->GetLastName());
  467. target->SetLastName(value);
  468. client->GetCurrentZone()->SendUpdateTitles(target);
  469. break;
  470. }
  471. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  472. // nothing to do must reload spawns
  473. break;
  474. }
  475. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  476. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  477. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  478. break;
  479. }
  480. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  481. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  482. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  483. break;
  484. }
  485. *temp_value = string(tmp);
  486. }
  487. }
  488. else{
  489. switch(type){
  490. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  491. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  492. break;
  493. }
  494. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  495. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  496. break;
  497. }
  498. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  499. if (target->GetDatabaseID() > 0)
  500. {
  501. char query[256];
  502. snprintf(query, 256, "update spawn set expansion_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  503. if (database.RunQuery(query, strnlen(query, 256)))
  504. {
  505. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  506. }
  507. }
  508. break;
  509. }
  510. case SPAWN_SET_VALUE_NAME:{
  511. target->SetName(value);
  512. client->GetCurrentZone()->SendUpdateTitles(target);
  513. break;
  514. }
  515. case SPAWN_SET_VALUE_SUB_TITLE: {
  516. target->SetSubTitle(value);
  517. client->GetCurrentZone()->SendUpdateTitles(target);
  518. break;
  519. }
  520. case SPAWN_SET_VALUE_X_OFFSET:
  521. {
  522. target->SetXOffset(atof(value));
  523. break;
  524. }
  525. case SPAWN_SET_VALUE_Y_OFFSET:
  526. {
  527. target->SetYOffset(atof(value));
  528. break;
  529. }
  530. case SPAWN_SET_VALUE_Z_OFFSET:
  531. {
  532. target->SetZOffset(atof(value));
  533. break;
  534. }
  535. case SPAWN_SET_VALUE_EXPIRE: {
  536. target->SetExpireTime(val);
  537. break;
  538. }
  539. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  540. target->SetExpireOffsetTime(val);
  541. break;
  542. }
  543. case SPAWN_SET_VALUE_LEVEL:{
  544. target->SetLevel(val, send_update);
  545. break;
  546. }
  547. case SPAWN_SET_VALUE_DIFFICULTY:{
  548. target->SetEncounterLevel(val, send_update);
  549. break;
  550. }
  551. case SPAWN_SET_VALUE_MODEL_TYPE:{
  552. target->SetModelType(val, send_update);
  553. break;
  554. }
  555. case SPAWN_SET_VALUE_CLASS:{
  556. target->SetAdventureClass(val, send_update);
  557. break;
  558. }
  559. case SPAWN_SET_VALUE_GENDER:{
  560. target->SetGender(val, send_update);
  561. break;
  562. }
  563. case SPAWN_SET_VALUE_SHOW_NAME:{
  564. target->SetShowName(val, send_update);
  565. break;
  566. }
  567. case SPAWN_SET_VALUE_ATTACKABLE:{
  568. target->SetAttackable(val, send_update);
  569. break;
  570. }
  571. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  572. target->SetShowLevel(val, send_update);
  573. break;
  574. }
  575. case SPAWN_SET_VALUE_TARGETABLE:{
  576. target->SetTargetable(val, send_update);
  577. break;
  578. }
  579. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  580. target->SetShowCommandIcon(val, send_update);
  581. break;
  582. }
  583. case SPAWN_SET_VALUE_HAND_ICON:{
  584. target->SetShowHandIcon(val, send_update);
  585. break;
  586. }
  587. case SPAWN_SET_VALUE_HAIR_TYPE:{
  588. if(target->IsEntity())
  589. ((Entity*)target)->SetHairType(val, send_update);
  590. break;
  591. }
  592. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  593. if(target->IsEntity())
  594. ((Entity*)target)->SetHairType(val, send_update);
  595. break;
  596. }
  597. case SPAWN_SET_VALUE_WING_TYPE:{
  598. if(target->IsEntity())
  599. ((Entity*)target)->SetWingType(val, send_update);
  600. break;
  601. }
  602. case SPAWN_SET_VALUE_CHEST_TYPE:{
  603. if(target->IsEntity())
  604. ((Entity*)target)->SetChestType(val, send_update);
  605. break;
  606. }
  607. case SPAWN_SET_VALUE_LEGS_TYPE:{
  608. if(target->IsEntity())
  609. ((Entity*)target)->SetLegsType(val, send_update);
  610. break;
  611. }
  612. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  613. if(target->IsEntity())
  614. ((Entity*)target)->SetSogaHairType(val, send_update);
  615. break;
  616. }
  617. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  618. if(target->IsEntity())
  619. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  620. break;
  621. }
  622. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  623. target->SetSogaModelType(val, send_update);
  624. break;
  625. }
  626. case SPAWN_SET_VALUE_SIZE:{
  627. target->SetSize(val, send_update);
  628. break;
  629. }
  630. case SPAWN_SET_VALUE_HP:{
  631. target->SetHP(val, send_update);
  632. break;
  633. }
  634. case SPAWN_SET_VALUE_POWER:{
  635. target->SetPower(val, send_update);
  636. break;
  637. }
  638. case SPAWN_SET_VALUE_HEROIC:{
  639. target->SetHeroic(val, send_update);
  640. break;
  641. }
  642. case SPAWN_SET_VALUE_RESPAWN:{
  643. target->SetRespawnTime(val);
  644. break;
  645. }
  646. case SPAWN_SET_VALUE_X:{
  647. target->SetX(atof(value), send_update);
  648. target->SetSpawnOrigX(target->GetX());
  649. break;
  650. }
  651. case SPAWN_SET_VALUE_Y:{
  652. target->SetY(atof(value), send_update);
  653. target->SetSpawnOrigY(target->GetY());
  654. break;
  655. }
  656. case SPAWN_SET_VALUE_Z:{
  657. target->SetZ(atof(value), send_update);
  658. target->SetSpawnOrigZ(target->GetZ());
  659. break;
  660. }
  661. case SPAWN_SET_VALUE_HEADING:{
  662. target->SetHeading(atof(value), send_update);
  663. target->SetSpawnOrigHeading(target->GetHeading());
  664. break;
  665. }
  666. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  667. ZoneServer* zone = target->GetZone();
  668. if (!zone)
  669. zone = client->GetCurrentZone();
  670. if(zone->GetEntityCommandList(val))
  671. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  672. target->primary_command_list_id = val;
  673. break;
  674. }
  675. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  676. ZoneServer* zone = target->GetZone();
  677. if (!zone)
  678. zone = client->GetCurrentZone();
  679. if (zone->GetEntityCommandList(val))
  680. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  681. target->secondary_command_list_id = val;
  682. break;
  683. }
  684. case SPAWN_SET_VALUE_VISUAL_STATE:{
  685. target->SetVisualState(val, send_update);
  686. break;
  687. }
  688. case SPAWN_SET_VALUE_ACTION_STATE:{
  689. target->SetActionState(val, send_update);
  690. break;
  691. }
  692. case SPAWN_SET_VALUE_MOOD_STATE:{
  693. target->SetMoodState(val, send_update);
  694. break;
  695. }
  696. case SPAWN_SET_VALUE_INITIAL_STATE:{
  697. target->SetInitialState(val, send_update);
  698. break;
  699. }
  700. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  701. target->SetActivityStatus(val, send_update);
  702. break;
  703. }
  704. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  705. target->SetCollisionRadius(val, send_update);
  706. break;
  707. }
  708. case SPAWN_SET_VALUE_FACTION:{
  709. ZoneServer* zone = target->GetZone();
  710. if (!zone)
  711. zone = client->GetCurrentZone();
  712. target->faction_id = val;
  713. zone->RemoveDeadEnemyList(target);
  714. if(target->IsNPC())
  715. zone->AddEnemyList((NPC*)target);
  716. break;
  717. }
  718. case SPAWN_SET_VALUE_DEVICE_ID:{
  719. if (target->IsObject())
  720. ((Object*)target)->SetDeviceID(val);
  721. break;
  722. }
  723. case SPAWN_SET_VALUE_PITCH: {
  724. target->SetPitch(atof(value), send_update);
  725. target->SetSpawnOrigPitch(atof(value));
  726. break;
  727. }
  728. case SPAWN_SET_VALUE_ROLL: {
  729. target->SetRoll(atof(value), send_update);
  730. target->SetSpawnOrigRoll(atof(value));
  731. break;
  732. }
  733. case SPAWN_SET_VALUE_HIDE_HOOD: {
  734. target->SetHideHood(val);
  735. break;
  736. }
  737. case SPAWN_SET_VALUE_EMOTE_STATE: {
  738. target->SetEmoteState(val);
  739. break;
  740. }
  741. case SPAWN_SET_VALUE_ICON: {
  742. target->SetIcon(val);
  743. break;
  744. }
  745. case SPAWN_SET_VALUE_PREFIX: {
  746. target->SetPrefixTitle(value);
  747. client->GetCurrentZone()->SendUpdateTitles(target);
  748. break;
  749. }
  750. case SPAWN_SET_VALUE_SUFFIX: {
  751. target->SetSuffixTitle(value);
  752. client->GetCurrentZone()->SendUpdateTitles(target);
  753. break;
  754. }
  755. case SPAWN_SET_VALUE_LASTNAME: {
  756. target->SetLastName(value);
  757. client->GetCurrentZone()->SendUpdateTitles(target);
  758. break;
  759. }
  760. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  761. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  762. if(client){
  763. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  764. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  765. }
  766. return false;
  767. }
  768. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  769. return false;
  770. else{
  771. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  772. target->SetSpawnScript(value);
  773. }
  774. break;
  775. }
  776. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  777. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  778. if(client){
  779. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  780. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  781. }
  782. return false;
  783. }
  784. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  785. return false;
  786. else{
  787. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  788. target->SetSpawnScript(value);
  789. }
  790. break;
  791. }
  792. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  793. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  794. if(client){
  795. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  796. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  797. }
  798. return false;
  799. }
  800. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  801. return false;
  802. else
  803. target->SetSpawnScript(value);
  804. break;
  805. }
  806. }
  807. }
  808. return true;
  809. }
  810. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  811. the database fields always and also update the zone in memory if it's running. */
  812. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  813. if (client && zone_id > 0 && type > 0 && value) {
  814. sint32 int_value = 0;
  815. float float_value = 0;
  816. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  817. try {
  818. float_value = atof(value);
  819. }
  820. catch (...) {
  821. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  822. return false;
  823. }
  824. }
  825. 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) {
  826. try {
  827. int_value = atoi(value);
  828. }
  829. catch (...) {
  830. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  831. return false;
  832. }
  833. }
  834. switch (type) {
  835. case ZONE_SET_VALUE_EXPANSION_ID: {
  836. break;
  837. }
  838. case ZONE_SET_VALUE_NAME: {
  839. if (zone)
  840. zone->SetZoneName(const_cast<char*>(value));
  841. database.SaveZoneInfo(zone_id, "name", value);
  842. break;
  843. }
  844. case ZONE_SET_VALUE_FILE: {
  845. if (zone)
  846. zone->SetZoneFile(const_cast<char*>(value));
  847. database.SaveZoneInfo(zone_id, "file", value);
  848. break;
  849. }
  850. case ZONE_SET_VALUE_DESCRIPTION: {
  851. if (zone)
  852. zone->SetZoneDescription(const_cast<char*>(value));
  853. database.SaveZoneInfo(zone_id, "description", value);
  854. break;
  855. }
  856. case ZONE_SET_VALUE_SAFE_X: {
  857. if (zone)
  858. zone->SetSafeX(float_value);
  859. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  860. break;
  861. }
  862. case ZONE_SET_VALUE_SAFE_Y: {
  863. if (zone)
  864. zone->SetSafeY(float_value);
  865. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  866. break;
  867. }
  868. case ZONE_SET_VALUE_SAFE_Z: {
  869. if (zone)
  870. zone->SetSafeZ(float_value);
  871. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  872. break;
  873. }
  874. case ZONE_SET_VALUE_UNDERWORLD: {
  875. if (zone)
  876. zone->SetUnderWorld(float_value);
  877. database.SaveZoneInfo(zone_id, "underworld", float_value);
  878. break;
  879. }
  880. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  881. break;
  882. }
  883. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  884. break;
  885. }
  886. case ZONE_SET_VALUE_ZONE_TYPE: {
  887. break;
  888. }
  889. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  890. if (zone)
  891. zone->SetAlwaysLoaded(int_value == 1);
  892. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  893. break;
  894. }
  895. case ZONE_SET_VALUE_CITY_ZONE: {
  896. if (zone)
  897. zone->SetCityZone(int_value == 1);
  898. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  899. break;
  900. }
  901. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  902. if (zone)
  903. zone->SetWeatherAllowed(int_value == 1);
  904. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  905. break;
  906. }
  907. case ZONE_SET_VALUE_MIN_STATUS: {
  908. if (zone)
  909. zone->SetMinimumStatus(int_value);
  910. database.SaveZoneInfo(zone_id, "min_status", int_value);
  911. break;
  912. }
  913. case ZONE_SET_VALUE_MIN_LEVEL: {
  914. if (zone)
  915. zone->SetMinimumLevel(int_value);
  916. database.SaveZoneInfo(zone_id, "min_level", int_value);
  917. break;
  918. }
  919. case ZONE_SET_VALUE_MAX_LEVEL: {
  920. if (zone)
  921. zone->SetMaximumLevel(int_value);
  922. database.SaveZoneInfo(zone_id, "max_level", int_value);
  923. break;
  924. }
  925. case ZONE_SET_VALUE_START_ZONE: {
  926. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  927. break;
  928. }
  929. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  930. if (zone)
  931. zone->SetInstanceType(int_value);
  932. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  933. break;
  934. }
  935. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  936. if (zone)
  937. zone->SetDefaultReenterTime(int_value);
  938. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  939. break;
  940. }
  941. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  942. if (zone)
  943. zone->SetDefaultResetTime(int_value);
  944. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  945. break;
  946. }
  947. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  948. if (zone)
  949. zone->SetDefaultLockoutTime(int_value);
  950. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  951. break;
  952. }
  953. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  954. if (zone)
  955. zone->SetForceGroupZoneOption(int_value);
  956. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  957. break;
  958. }
  959. case ZONE_SET_VALUE_LUA_SCRIPT: {
  960. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  961. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  962. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  963. return false;
  964. }
  965. else {
  966. world.AddZoneScript(zone_id, const_cast<char*>(value));
  967. database.SaveZoneInfo(zone_id, "lua_script", value);
  968. }
  969. break;
  970. }
  971. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  972. if (zone)
  973. zone->SetShutdownTimer(int_value);
  974. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  975. break;
  976. }
  977. case ZONE_SET_VALUE_ZONE_MOTD: {
  978. if (zone)
  979. zone->SetZoneMOTD(string(value));
  980. database.SaveZoneInfo(zone_id, "zone_motd", value);
  981. break;
  982. }
  983. default: {
  984. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  985. return false;
  986. }
  987. }
  988. }
  989. else {
  990. if (client)
  991. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  992. return false;
  993. }
  994. return true;
  995. }
  996. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  997. if (index >= remote_commands->commands.size()) {
  998. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  999. return;
  1000. }
  1001. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1002. EQ2_RemoteCommandString* parent_command = 0;
  1003. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1004. Seperator* sep = 0;
  1005. if (command_parms->size > 0) {
  1006. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1007. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1008. parent_command = command;
  1009. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1010. safe_delete(sep);
  1011. if (command_parms->data.length() > (command->command.data.length() + 1))
  1012. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1013. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1014. }
  1015. else
  1016. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1017. }
  1018. int ndx = 0;
  1019. if (command->required_status > client->GetAdminStatus())
  1020. {
  1021. 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());
  1022. safe_delete(sep);
  1023. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1024. return;
  1025. }
  1026. Player* player = client->GetPlayer();
  1027. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1028. switch (command->handler) {
  1029. case COMMAND_RELOAD: {
  1030. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1031. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1032. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1033. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1034. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1035. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1036. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1037. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1038. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1039. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1040. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1041. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1042. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1043. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1044. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1045. break;
  1046. }
  1047. case COMMAND_RELOADSTRUCTS: {
  1048. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1049. configReader.ReloadStructs();
  1050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1051. break;
  1052. }
  1053. case COMMAND_RELOAD_QUESTS: {
  1054. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1055. master_quest_list.Reload();
  1056. client_list.ReloadQuests();
  1057. zone_list.ReloadClientQuests();
  1058. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1059. break;
  1060. }
  1061. case COMMAND_RELOAD_SPAWNS: {
  1062. client->GetCurrentZone()->ReloadSpawns();
  1063. break;
  1064. }
  1065. case COMMAND_RELOAD_SPELLS: {
  1066. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1067. zone_list.DeleteSpellProcess();
  1068. master_spell_list.Reload();
  1069. if (lua_interface)
  1070. lua_interface->ReloadSpells();
  1071. zone_list.LoadSpellProcess();
  1072. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1073. break;
  1074. }
  1075. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1076. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1077. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1078. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1079. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1080. break;
  1081. }
  1082. case COMMAND_RELOAD_ZONESCRIPTS: {
  1083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1084. world.ResetZoneScripts();
  1085. database.LoadZoneScriptData();
  1086. if (lua_interface)
  1087. lua_interface->DestroyZoneScripts();
  1088. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1089. break;
  1090. }
  1091. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1093. client->GetCurrentZone()->ClearEntityCommands();
  1094. database.LoadEntityCommands(client->GetCurrentZone());
  1095. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1096. break;
  1097. }
  1098. case COMMAND_RELOAD_FACTIONS: {
  1099. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1100. master_faction_list.Clear();
  1101. database.LoadFactionList();
  1102. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1103. break;
  1104. }
  1105. case COMMAND_RELOAD_MAIL: {
  1106. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1107. zone_list.ReloadMail();
  1108. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1109. break;
  1110. }
  1111. case COMMAND_RELOAD_GUILDS: {
  1112. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1113. world.ReloadGuilds();
  1114. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1115. break;
  1116. }
  1117. case COMMAND_RELOAD_LOCATIONS: {
  1118. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1119. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1120. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1121. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1122. break;
  1123. }
  1124. case COMMAND_READ: {
  1125. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1126. if (strcmp(sep->arg[0], "read") == 0) {
  1127. int32 item_index = atol(sep->arg[1]);
  1128. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1129. if (item) {
  1130. Spawn* spawn = cmdTarget;
  1131. int8 numpages = item->book_pages.size();
  1132. string page1 = string(item->book_pages[0]->page_text.data);
  1133. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  1134. string title = item->name;
  1135. if (packet) {
  1136. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  1137. packet->setDataByName("book_title", title.c_str());
  1138. packet->setDataByName("book_type", "simple");
  1139. packet->setDataByName("unknown2", 1);
  1140. packet->setDataByName("unknown5", 1, 4);
  1141. packet->setArrayLengthByName("num_pages", numpages);
  1142. for (int8 pages = 1; pages <= numpages; pages++) {
  1143. int8 pagenum = int8(item->book_pages[pages - 1]->page);
  1144. string page = string(item->book_pages[pages-1]->page_text.data);
  1145. int8 valign = int8(item->book_pages[pages - 1]->valign);
  1146. int8 halign = int8(item->book_pages[pages - 1]->halign);
  1147. packet->setArrayDataByName("page_text", page.c_str(), pagenum -1);
  1148. packet->setArrayDataByName("page_text_valign", valign , pagenum - 1);
  1149. packet->setArrayDataByName("page_text_halign", halign, pagenum - 1);
  1150. // Need to add support for images
  1151. }
  1152. client->QueuePacket(packet->serialize());
  1153. safe_delete(packet);
  1154. }
  1155. break;
  1156. }
  1157. }
  1158. }
  1159. }
  1160. case COMMAND_USEABILITY:{
  1161. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1162. if (client->GetPlayer()->GetHP() == 0) {
  1163. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1164. }
  1165. else {
  1166. int32 spell_id = atoul(sep->arg[0]);
  1167. int8 spell_tier = 0;
  1168. if (sep->arg[1][0] && sep->IsNumber(1))
  1169. spell_tier = atoi(sep->arg[1]);
  1170. else
  1171. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1172. if (!spell_tier)
  1173. spell_tier = 1;
  1174. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1175. if (spell) {
  1176. 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)
  1177. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1178. else
  1179. {
  1180. if (cmdTarget)
  1181. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1182. else
  1183. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1184. }
  1185. }
  1186. }
  1187. }
  1188. else if (cmdTarget && cmdTarget->IsWidget())
  1189. {
  1190. Widget* widget = (Widget*)cmdTarget;
  1191. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1192. }
  1193. else
  1194. {
  1195. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1196. }
  1197. break;
  1198. }
  1199. case COMMAND_INFO:{
  1200. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1201. if(strcmp(sep->arg[0], "inventory") == 0){
  1202. int32 item_index = atol(sep->arg[1]);
  1203. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1204. if(item){
  1205. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1206. break;
  1207. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1208. //DumpPacket(app);
  1209. client->QueuePacket(app);
  1210. if(item->GetItemScript() && lua_interface)
  1211. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1212. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1213. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id);
  1214. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1215. client->AddPendingQuest(quest);
  1216. }
  1217. }
  1218. else
  1219. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1220. }
  1221. else if(strcmp(sep->arg[0], "equipment") == 0){
  1222. int32 item_index = atol(sep->arg[1]);
  1223. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1224. if(item){
  1225. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1226. client->QueuePacket(app);
  1227. if(item->GetItemScript() && lua_interface)
  1228. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1229. }
  1230. else
  1231. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1232. }
  1233. 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){
  1234. int32 item_id = atoul(sep->arg[1]);
  1235. Item* item = master_item_list.GetItem(item_id);
  1236. if(item){
  1237. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1238. client->QueuePacket(app);
  1239. }
  1240. else
  1241. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1242. }
  1243. else if (strcmp(sep->arg[0], "spell") == 0) {
  1244. sint32 spell_id = atol(sep->arg[1]);
  1245. int8 tier = atoi(sep->arg[3]);
  1246. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1247. if (outapp)
  1248. client->QueuePacket(outapp);
  1249. else
  1250. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1251. }
  1252. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1253. sint32 spell_id = atol(sep->arg[2]);
  1254. int8 group = atoi(sep->arg[1]);
  1255. AltAdvanceData* data = 0;
  1256. SpellBookEntry* spellentry = 0;
  1257. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1258. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1259. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1260. if (outapp)
  1261. client->QueuePacket(outapp);
  1262. else
  1263. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1264. }
  1265. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1266. sint32 spell_id = atol(sep->arg[1]);
  1267. int8 tier = atoi(sep->arg[2]);
  1268. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1269. if (outapp)
  1270. client->QueuePacket(outapp);
  1271. else
  1272. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1273. }
  1274. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1275. sint32 recipe_id = atol(sep->arg[1]);
  1276. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1277. if(outapp)
  1278. client->QueuePacket(outapp);
  1279. else
  1280. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1281. }
  1282. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1283. int32 slot = atol(sep->arg[1]);
  1284. int32 spell_id = atol(sep->arg[2]);
  1285. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1286. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1287. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1288. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1289. if(outapp)
  1290. client->QueuePacket(outapp);
  1291. else
  1292. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1293. }
  1294. else if (strcmp(sep->arg[0], "effect") == 0) {
  1295. int32 spell_id = atol(sep->arg[1]);
  1296. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1297. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1298. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, 0x00);
  1299. if (outapp){
  1300. client->QueuePacket(outapp);
  1301. }
  1302. else
  1303. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1304. }
  1305. }
  1306. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1307. Item* item = player->item_list.GetOverflowItem();
  1308. if(item) {
  1309. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1310. client->QueuePacket(app);
  1311. }
  1312. else
  1313. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1314. }
  1315. else
  1316. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1317. break;
  1318. }
  1319. case COMMAND_USE_EQUIPPED_ITEM:{
  1320. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1321. int32 slot_id = atoul(sep->arg[0]);
  1322. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1323. if (item && item->generic_info.usable && item->GetItemScript())
  1324. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1325. }
  1326. break;
  1327. }
  1328. case COMMAND_USE_ITEM: {
  1329. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1330. int32 item_index = atoul(sep->arg[0]);
  1331. Item* item = player->item_list.GetItemFromIndex(item_index);
  1332. if (item && item->GetItemScript()) {
  1333. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1334. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1335. else {
  1336. if (item->generic_info.display_charges > 0) {
  1337. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1338. item->generic_info.display_charges -= 1;
  1339. item->save_needed = true;
  1340. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1341. }
  1342. }
  1343. }
  1344. }
  1345. break;
  1346. }
  1347. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1348. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1349. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1350. if (item) {
  1351. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1352. if(item->generic_info.item_type == 6) {
  1353. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1354. int8 old_slot = 0;
  1355. if (spell) {
  1356. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1357. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1358. player->RemoveSpellBookEntry(spell->GetSpellID());
  1359. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1360. player->UnlockSpell(spell);
  1361. client->SendSpellUpdate(spell);
  1362. database.DeleteItem(client->GetCharacterID(), item, 0);
  1363. player->item_list.RemoveItem(item, true);
  1364. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1365. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1366. }
  1367. }
  1368. else
  1369. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1370. }
  1371. else if(item->generic_info.item_type == 7){
  1372. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1373. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1374. // if valid recipe book and the player doesn't have it
  1375. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1376. client->Message(CHANNEL_COLOR_WHITE, "Your tradeskill level is not high enough to scribe this book.");
  1377. safe_delete(recipe_book);
  1378. }
  1379. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1380. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1381. // Add recipe book to the players list
  1382. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1383. // Get a list of all recipes this book contains
  1384. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1385. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1386. // Create the packet to send to update the players recipe list
  1387. PacketStruct* packet = 0;
  1388. if (client->GetRecipeListSent()) {
  1389. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1390. if (packet)
  1391. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1392. }
  1393. // loop through the list
  1394. vector<Recipe*>::iterator itr;
  1395. int16 i = 0;
  1396. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1397. // check to see if the player already has this recipe some how
  1398. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1399. // Player doesn't already have this recipe so lets add it
  1400. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1401. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1402. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1403. client->Message(CHANNEL_COLOR_WHITE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1404. if (packet && client->GetRecipeListSent()) {
  1405. packet->setArrayDataByName("id", recipe->GetID(), i);
  1406. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1407. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1408. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1409. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1410. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1411. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1412. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1413. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1414. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1415. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1416. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1417. i++;
  1418. }
  1419. }
  1420. }
  1421. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1422. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1423. database.DeleteItem(client->GetCharacterID(), item, 0);
  1424. client->GetPlayer()->item_list.RemoveItem(item, true);
  1425. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1426. if (packet && client->GetRecipeListSent())
  1427. client->QueuePacket(packet->serialize());
  1428. safe_delete(packet);
  1429. }
  1430. else {
  1431. if (recipe_book)
  1432. client->Message(CHANNEL_COLOR_WHITE, "You have already learned all you can from this item.");
  1433. safe_delete(recipe_book);
  1434. }
  1435. }
  1436. }
  1437. else
  1438. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1439. }
  1440. break;
  1441. }
  1442. case COMMAND_SUMMONITEM: {
  1443. if (sep && sep->IsNumber(0)) {
  1444. int32 item_id = atol(sep->arg[0]);
  1445. int32 quantity = 1;
  1446. if (sep->arg[1] && sep->IsNumber(1))
  1447. quantity = atoi(sep->arg[1]);
  1448. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1449. client->AddItemToBank(item_id,quantity);
  1450. }
  1451. else {
  1452. client->AddItem(item_id, quantity);
  1453. }
  1454. }
  1455. else {
  1456. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1457. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1458. }
  1459. break;
  1460. }
  1461. case COMMAND_COLLECTION_ADDITEM: {
  1462. // takes 2 params: collection_id, slot
  1463. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1464. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1465. if (item)
  1466. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1467. else
  1468. 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]));
  1469. }
  1470. else
  1471. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1472. break;
  1473. }
  1474. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1475. // takes 1 param: slot
  1476. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1477. int i = 0;
  1478. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1479. printf("\t%u: %s\n", i, sep->arg[i]);
  1480. i++;
  1481. }
  1482. break;
  1483. }
  1484. case COMMAND_WHO:{
  1485. const char* who = 0;
  1486. if(sep && sep->arg[0]){
  1487. //cout << "Who query: \n";
  1488. who = sep->argplus[0];
  1489. //cout << who << endl;
  1490. }
  1491. zone_list.ProcessWhoQuery(who, client);
  1492. break;
  1493. }
  1494. case COMMAND_SELECT_JUNCTION:{
  1495. 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__);
  1496. int32 choice = 0;
  1497. if(sep && sep->arg[0] && sep->IsNumber(0))
  1498. choice = atoul(sep->arg[0]);
  1499. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1500. client->HandlePlayerRevive(choice);
  1501. }
  1502. break;
  1503. }
  1504. case COMMAND_SPAWN_MOVE: {
  1505. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  1506. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1507. if (packet) {
  1508. float unknown2_3 = 0;
  1509. int8 placement_mode = 0;
  1510. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1511. if (sep && sep->arg[0][0]) {
  1512. if (strcmp(sep->arg[0], "wall") == 0) {
  1513. placement_mode = 2;
  1514. unknown2_3 = 150;
  1515. }
  1516. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1517. placement_mode = 1;
  1518. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1519. {
  1520. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1521. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1522. }
  1523. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1524. {
  1525. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1526. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1527. }
  1528. else if (strcmp(sep->arg[0], "myloc") == 0)
  1529. {
  1530. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1531. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1532. safe_delete(packet);
  1533. break;
  1534. }
  1535. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1536. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1537. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1538. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1539. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1540. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1541. safe_delete(packet);
  1542. break;
  1543. }
  1544. }
  1545. packet->setDataByName("placement_mode", placement_mode);
  1546. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1547. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1548. packet->setDataByName("unknown", 1); //size
  1549. packet->setDataByName("unknown2", 1); //size 2
  1550. packet->setDataByName("unknown2", .5, 1); //size 3
  1551. packet->setDataByName("unknown2", 3, 2);
  1552. packet->setDataByName("unknown2", unknown2_3, 3);
  1553. packet->setDataByName("max_distance", 500);
  1554. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1555. client->QueuePacket(packet->serialize());
  1556. safe_delete(packet);
  1557. }
  1558. }
  1559. else {
  1560. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1561. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1562. }
  1563. break;
  1564. }
  1565. case COMMAND_HAIL:{
  1566. Spawn* spawn = cmdTarget;
  1567. if(spawn && spawn->GetTargetable())
  1568. {
  1569. char tmp[75] = {0};
  1570. sprintf(tmp, "Hail, %s", spawn->GetName());
  1571. bool show_bubble = true;
  1572. if (spawn->IsNPC())
  1573. show_bubble = false;
  1574. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1575. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < 30){
  1576. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1577. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1578. else
  1579. spawn->ProcessMovement();
  1580. LogWrite(MISC__TODO, 0, "Check", "ProcessMovement has been called");
  1581. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer());
  1582. }
  1583. }
  1584. else {
  1585. string tmp = "Hail";
  1586. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1587. }
  1588. break;
  1589. }
  1590. case COMMAND_SAY:{
  1591. if (sep && sep->arg[0][0]) {
  1592. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1593. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1594. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1595. }
  1596. else
  1597. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1598. break;
  1599. }
  1600. case COMMAND_TELL:{
  1601. if(sep && sep->arg[0] && sep->argplus[1]){
  1602. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_TELL, sep->argplus[1]))
  1603. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1604. }else
  1605. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1606. break;
  1607. }
  1608. case COMMAND_SHOUT:{
  1609. if(sep && sep->arg[0][0])
  1610. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1611. else
  1612. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1613. break;
  1614. }
  1615. case COMMAND_AUCTION:{
  1616. if(sep && sep->arg[0][0])
  1617. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1618. else
  1619. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1620. break;
  1621. }
  1622. case COMMAND_OOC:{
  1623. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  1624. if(sep && sep->arg[0][0])
  1625. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OOC, sep->argplus[0]);
  1626. else
  1627. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  1628. break;
  1629. }
  1630. case COMMAND_EMOTE:{
  1631. if(sep && sep->arg[0][0])
  1632. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  1633. else
  1634. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  1635. break;
  1636. }
  1637. case COMMAND_RACE:{
  1638. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  1639. if(sep->arg[1][0] && sep->IsNumber(1)){
  1640. client->GetPlayer()->GetInfoStruct()->race = atoi(sep->arg[1]);
  1641. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  1642. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  1643. client->GetPlayer()->SetCharSheetChanged(true);
  1644. }
  1645. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  1646. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  1647. //client->QueuePacket(outapp);
  1648. }
  1649. else{
  1650. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  1651. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  1652. }
  1653. break;
  1654. }
  1655. case COMMAND_BANK_DEPOSIT:{
  1656. if(client->GetBanker() && sep && sep->arg[0]){
  1657. int64 amount = 0;
  1658. string deposit = string(sep->arg[0]);
  1659. amount = atoi64(deposit.c_str());
  1660. client->BankDeposit(amount);
  1661. }
  1662. break;
  1663. }
  1664. case COMMAND_BANK_WITHDRAWAL:{
  1665. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  1666. int64 amount = 0;
  1667. string deposit = string(sep->arg[0]);
  1668. amount = atoi64(deposit.c_str());
  1669. client->BankWithdrawal(amount);
  1670. }
  1671. break;
  1672. }
  1673. case COMMAND_BANK_CANCEL:{
  1674. Spawn* banker = cmdTarget;
  1675. client->Bank(banker, true);
  1676. break;
  1677. }
  1678. case COMMAND_BANK:{
  1679. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  1680. Spawn* banker = cmdTarget;
  1681. client->Bank(banker);
  1682. break;
  1683. }
  1684. case COMMAND_GUILD_BANK:{
  1685. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  1686. //Spawn* banker = client->GetPlayer()->GetTarget();
  1687. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  1688. break;
  1689. }
  1690. case COMMAND_START_MAIL: {
  1691. client->SetMailTransaction(cmdTarget);
  1692. client->SendMailList();
  1693. break;
  1694. }
  1695. case COMMAND_CANCEL_MAIL: {
  1696. client->SetMailTransaction(0);
  1697. break;
  1698. }
  1699. case COMMAND_GET_MAIL_MESSAGE: {
  1700. if (sep && sep->arg[0] && sep->IsNumber(0))
  1701. client->DisplayMailMessage(atoul(sep->arg[0]));
  1702. break;
  1703. }
  1704. case COMMAND_ADD_MAIL_PLAT: {
  1705. if (sep && sep->arg[0] && sep->IsNumber(0))
  1706. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1707. break;
  1708. }
  1709. case COMMAND_ADD_MAIL_GOLD: {
  1710. if (sep && sep->arg[0] && sep->IsNumber(0))
  1711. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  1712. break;
  1713. }
  1714. case COMMAND_ADD_MAIL_SILVER: {
  1715. if (sep && sep->arg[0] && sep->IsNumber(0))
  1716. client->AddMailCoin(0, atoul(sep->arg[0]));
  1717. break;
  1718. }
  1719. case COMMAND_ADD_MAIL_COPPER: {
  1720. if (sep && sep->arg[0] && sep->IsNumber(0))
  1721. client->AddMailCoin(atoul(sep->arg[0]));
  1722. break;
  1723. }
  1724. case COMMAND_SET_MAIL_ITEM: {
  1725. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1726. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1727. break;
  1728. }
  1729. case COMMAND_REMOVE_MAIL_PLAT: {
  1730. if (sep && sep->arg[0] && sep->IsNumber(0))
  1731. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1732. break;
  1733. }
  1734. case COMMAND_REMOVE_MAIL_GOLD: {
  1735. if (sep && sep->arg[0] && sep->IsNumber(0))
  1736. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  1737. break;
  1738. }
  1739. case COMMAND_REMOVE_MAIL_SILVER: {
  1740. if (sep && sep->arg[0] && sep->IsNumber(0))
  1741. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  1742. break;
  1743. }
  1744. case COMMAND_REMOVE_MAIL_COPPER: {
  1745. if (sep && sep->arg[0] && sep->IsNumber(0))
  1746. client->RemoveMailCoin(atoul(sep->arg[0]));
  1747. break;
  1748. }
  1749. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  1750. if (sep && sep->arg[0] && sep->IsNumber(0))
  1751. client->TakeMailAttachments(atoul(sep->arg[0]));
  1752. break;
  1753. }
  1754. case COMMAND_CANCEL_SEND_MAIL: {
  1755. client->CancelSendMail();
  1756. break;
  1757. }
  1758. case COMMAND_DELETE_MAIL_MESSAGE: {
  1759. if (sep && sep->arg[0] && sep->IsNumber(0))
  1760. client->DeleteMail(atoul(sep->arg[0]), true);
  1761. break;
  1762. }
  1763. case COMMAND_REPORT_SPAM: {
  1764. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1765. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1766. break;
  1767. }
  1768. case COMMAND_KILL:{
  1769. Spawn* dead = 0;
  1770. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  1771. dead=client->GetPlayer();
  1772. client->GetPlayer()->SetHP(0);
  1773. client->GetPlayer()->KillSpawn(dead);
  1774. }else{
  1775. dead= cmdTarget;
  1776. if(dead && dead->IsPlayer() == false){
  1777. dead->SetHP(0);
  1778. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  1779. client->GetCurrentZone()->RemoveSpawn(false, dead, true);
  1780. else
  1781. client->GetPlayer()->KillSpawn(dead);
  1782. }else{
  1783. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  1784. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  1785. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  1786. }
  1787. }
  1788. break;
  1789. }
  1790. case COMMAND_LEVEL:{
  1791. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  1792. int16 new_level = atoi(sep->arg[ndx]);
  1793. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  1794. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  1795. else {
  1796. if (new_level < 1)
  1797. new_level = 1;
  1798. if (new_level > 255)
  1799. new_level = 255;
  1800. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  1801. client->GetPlayer()->SetXP(1);
  1802. client->GetPlayer()->SetNeededXP();
  1803. }
  1804. }else
  1805. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  1806. break;
  1807. }
  1808. case COMMAND_SIT: {
  1809. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1810. if(client->GetPlayer()->GetHP() > 0){
  1811. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  1812. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  1813. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  1814. }
  1815. break;
  1816. }
  1817. case COMMAND_STAND: {
  1818. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1819. if(client->GetPlayer()->GetHP() > 0){
  1820. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  1821. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  1822. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  1823. }
  1824. break;
  1825. }
  1826. case COMMAND_CLASS:{
  1827. if(sep && sep->arg[ndx][0]){
  1828. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  1829. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  1830. }else
  1831. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  1832. break;
  1833. }
  1834. case COMMAND_GENDER:{
  1835. if(sep && sep->arg[ndx][0]){
  1836. client->GetPlayer()->GetInfoStruct()->gender = atoi(sep->arg[ndx]);
  1837. client->GetPlayer()->SetCharSheetChanged(true);
  1838. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  1839. }else{
  1840. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  1841. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  1842. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  1843. }
  1844. break;
  1845. }
  1846. case COMMAND_FLYMODE:{
  1847. if(sep && sep->arg[0] && sep->IsNumber(0)){
  1848. PrintSep(sep, "COMMAND_FLYMODE");
  1849. int8 val = atoi(sep->arg[0]);
  1850. ClientPacketFunctions::SendFlyMode(client, val);
  1851. }
  1852. else{
  1853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  1854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  1855. }
  1856. break;
  1857. }
  1858. case COMMAND_LOOT_LIST:{
  1859. Spawn* spawn = cmdTarget;
  1860. if(spawn && spawn->IsEntity()){
  1861. if (sep && sep->arg[0]) {
  1862. if (!spawn->GetDatabaseID())
  1863. {
  1864. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  1865. break;
  1866. }
  1867. else if (!spawn->IsNPC())
  1868. {
  1869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  1870. break;
  1871. }
  1872. bool reloadLoot = false;
  1873. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  1874. {
  1875. int32 loottable_id = atoul(sep->arg[1]);
  1876. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  1877. {
  1878. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  1879. reloadLoot = true;
  1880. }
  1881. else
  1882. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  1883. }
  1884. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  1885. {
  1886. int32 loottable_id = atoul(sep->arg[1]);
  1887. if (loottable_id > 0)
  1888. {
  1889. database.AddLootTableToSpawn(spawn, loottable_id);
  1890. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  1891. reloadLoot = true;
  1892. }
  1893. else
  1894. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  1895. }
  1896. else if (!stricmp(sep->arg[0], "clearall"))
  1897. {
  1898. if (database.RemoveSpawnLootTable(spawn, 0))
  1899. {
  1900. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  1901. reloadLoot = true;
  1902. }
  1903. else
  1904. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  1905. }
  1906. else
  1907. {
  1908. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  1909. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  1910. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  1911. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  1912. break;
  1913. }
  1914. if (reloadLoot)
  1915. {
  1916. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  1917. if (spawn->IsNPC())
  1918. {
  1919. Entity* ent = (Entity*)spawn;
  1920. ent->SetLootCoins(0);
  1921. ent->ClearLootList();
  1922. spawn->GetZone()->AddLoot((NPC*)spawn);
  1923. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  1924. }
  1925. }
  1926. break; // nothing further this is the end of these sub commands
  1927. }
  1928. else
  1929. {
  1930. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  1931. if (loot_list.size() > 0) {
  1932. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  1933. vector<int32>::iterator list_itr;
  1934. LootTable* table = 0;
  1935. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  1936. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  1937. if (table)
  1938. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  1939. }
  1940. }
  1941. Entity* target = (Entity*)spawn;
  1942. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", target->GetLootCoins());
  1943. vector<Item*>* items = target->GetLootItems();
  1944. if (items) {
  1945. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  1946. vector<Item*>::iterator itr;
  1947. Item* item = 0;
  1948. for (itr = items->begin(); itr != items->end(); itr++) {
  1949. item = *itr;
  1950. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  1951. }
  1952. }
  1953. else
  1954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  1955. }
  1956. }
  1957. break;
  1958. }
  1959. case COMMAND_LOOT_SETCOIN:{
  1960. Spawn* spawn = cmdTarget;
  1961. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1962. Entity* target = (Entity*)spawn;
  1963. target->SetLootCoins(atoul(sep->arg[0]));
  1964. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  1965. }
  1966. else
  1967. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  1968. break;
  1969. }
  1970. case COMMAND_LOOT_ADDITEM:{
  1971. Spawn* spawn = cmdTarget;
  1972. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1973. Entity* target = (Entity*)spawn;
  1974. int16 charges = 1;
  1975. if(sep->arg[1] && sep->IsNumber(1))
  1976. charges = atoi(sep->arg[1]);
  1977. target->AddLootItem(atoul(sep->arg[0]), charges);
  1978. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  1979. }
  1980. else
  1981. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  1982. break;
  1983. }
  1984. case COMMAND_LOOT_REMOVEITEM:{
  1985. Spawn* spawn = cmdTarget;
  1986. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1987. Entity* target = (Entity*)spawn;
  1988. target->LootItem(atoul(sep->arg[0]));
  1989. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  1990. }
  1991. else
  1992. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  1993. break;
  1994. }
  1995. case COMMAND_LOOT_CORPSE:
  1996. case COMMAND_DISARM:
  1997. case COMMAND_LOOT:{
  1998. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  1999. {
  2000. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2001. break;
  2002. }
  2003. if(cmdTarget && cmdTarget->IsEntity()){
  2004. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2005. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2006. client->OpenChest((Entity*)cmdTarget, true);
  2007. else
  2008. client->Loot((Entity*)cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2009. if (!((Entity*)cmdTarget)->HasLoot()){
  2010. if (((Entity*)cmdTarget)->IsNPC())
  2011. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2012. }
  2013. }
  2014. else
  2015. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2016. }
  2017. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2018. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2019. break;
  2020. }
  2021. case COMMAND_RELOADSPAWNSCRIPTS:{
  2022. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2023. if (lua_interface)
  2024. lua_interface->SetSpawnScriptsReloading(true);
  2025. world.ResetSpawnScripts();
  2026. database.LoadSpawnScriptData();
  2027. if(lua_interface) {
  2028. lua_interface->DestroySpawnScripts();
  2029. lua_interface->SetSpawnScriptsReloading(false);
  2030. }
  2031. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2032. break;
  2033. }
  2034. case COMMAND_RELOADLUASYSTEM:{
  2035. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2036. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2037. safe_delete(lua_interface);
  2038. lua_interface = new LuaInterface();
  2039. if(lua_interface)
  2040. lua_interface->SetSpawnScriptsReloading(true);
  2041. if(lua_interface && debug_clients.size() > 0){
  2042. map<Client*, int32>::iterator itr;
  2043. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2044. if(lua_interface)
  2045. lua_interface->UpdateDebugClients(itr->first);
  2046. }
  2047. }
  2048. world.ResetSpawnScripts();
  2049. database.LoadSpawnScriptData();
  2050. world.ResetZoneScripts();
  2051. database.LoadZoneScriptData();
  2052. int32 quest_count = database.LoadQuests();
  2053. zone_list.DeleteSpellProcess();
  2054. master_spell_list.Reload();
  2055. int32 spell_count = 0;
  2056. if(lua_interface) {
  2057. lua_interface->DestroySpawnScripts();
  2058. lua_interface->DestroySpells();
  2059. spell_count = database.LoadSpellScriptData();
  2060. lua_interface->SetSpawnScriptsReloading(false);
  2061. }
  2062. zone_list.LoadSpellProcess();
  2063. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2064. break;
  2065. }
  2066. case COMMAND_DECLINE_QUEST:{
  2067. int32 quest_id = 0;
  2068. if(sep && sep->arg[0] && sep->IsNumber(0))
  2069. quest_id = atoul(sep->arg[0]);
  2070. if(quest_id > 0){
  2071. Quest* quest = client->GetPendingQuest(quest_id);
  2072. if(quest){
  2073. client->RemovePendingQuest(quest);
  2074. if(lua_interface)
  2075. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2076. safe_delete(quest);
  2077. client->GetCurrentZone()->SendQuestUpdates(client);
  2078. }
  2079. }
  2080. break;
  2081. }
  2082. case COMMAND_DELETE_QUEST:{
  2083. int32 quest_id = 0;
  2084. if(sep && sep->arg[0] && sep->IsNumber(0))
  2085. quest_id = atoul(sep->arg[0]);
  2086. if(quest_id > 0){
  2087. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2088. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2089. if (quest)
  2090. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2091. }
  2092. client->RemovePlayerQuest(quest_id);
  2093. client->GetCurrentZone()->SendQuestUpdates(client);
  2094. }
  2095. break;
  2096. }
  2097. case COMMAND_ACCEPT_QUEST:{
  2098. int32 quest_id = 0;
  2099. if(sep && sep->arg[0] && sep->IsNumber(0))
  2100. quest_id = atoul(sep->arg[0]);
  2101. if(quest_id > 0){
  2102. Quest* quest = client->GetPendingQuest(quest_id);
  2103. if(quest){
  2104. client->RemovePendingQuest(quest);
  2105. client->AddPlayerQuest(quest);
  2106. client->GetCurrentZone()->SendQuestUpdates(client);
  2107. // If character has already completed this quest once update the given date in the database
  2108. if (client->GetPlayer()->GetCompletedPlayerQuests()->count(quest_id) > 0) {
  2109. Quest* quest2 = client->GetPlayer()->GetCompletedQuest(quest_id);
  2110. if (quest2)
  2111. quest->SetCompleteCount(quest2->GetCompleteCount());
  2112. database.SaveCharRepeatableQuest(client, quest_id, quest->GetCompleteCount());
  2113. }
  2114. }
  2115. }
  2116. break;
  2117. }
  2118. case COMMAND_NAME:{
  2119. if(sep && sep->arg[ndx][0]){
  2120. memset(client->GetPlayer()->GetInfoStruct()->name, 0, 40);
  2121. strncpy(client->GetPlayer()->GetInfoStruct()->name, sep->arg[ndx], 39);
  2122. client->GetPlayer()->SetCharSheetChanged(true);
  2123. }else
  2124. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2125. break;
  2126. }
  2127. case COMMAND_GROUPSAY:{
  2128. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2129. if(sep && sep->arg[0] && gmi)
  2130. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2131. break;
  2132. }
  2133. case COMMAND_GROUPINVITE: {
  2134. Entity* target = 0;
  2135. Client* target_client = 0;
  2136. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2137. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2138. return;
  2139. }
  2140. // name provided with command so it has to be a player, npc not supported here
  2141. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2142. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2143. if (target_client) {
  2144. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2145. target = 0;
  2146. else
  2147. target = target_client->GetPlayer();
  2148. }
  2149. }
  2150. // if name was not provided use the players target, npc or player supported here
  2151. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2152. target = (Entity*)client->GetPlayer()->GetTarget();
  2153. if (target->IsPlayer()) {
  2154. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2155. }
  2156. }
  2157. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2158. if (result == 0) {
  2159. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2160. if (target_client) {
  2161. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2162. if (packet) {
  2163. packet->setDataByName("type", 1);
  2164. packet->setDataByName("name", client->GetPlayer()->GetName());
  2165. packet->setDataByName("unknown2", 1);
  2166. target_client->QueuePacket(packet->serialize());
  2167. safe_delete(packet);
  2168. }
  2169. }
  2170. }
  2171. else if (result == 1)
  2172. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2173. else if (result == 2)
  2174. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2175. else if (result == 3)
  2176. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2177. else if (result == 4)
  2178. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2179. else if (result == 5)
  2180. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2181. else if (result == 6)
  2182. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2183. else
  2184. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2185. break;
  2186. }
  2187. case COMMAND_GROUPDISBAND: {
  2188. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2189. if (gmi) { // TODO: Leader check
  2190. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2191. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2192. }
  2193. break;
  2194. }
  2195. case COMMAND_GROUP_LEAVE: {
  2196. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2197. if (gmi) {
  2198. int32 group_id = gmi->group_id;
  2199. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2200. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2201. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2202. }
  2203. else {
  2204. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2205. }
  2206. client->SimpleMessage(CHANNEL_COLOR_GROUP, "You have left the group");
  2207. }
  2208. break;
  2209. }
  2210. case COMMAND_FRIEND_ADD:{
  2211. string name = "";
  2212. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2213. name = database.GetPlayerName(sep->arg[0]);
  2214. else if(cmdTarget && cmdTarget->IsPlayer())
  2215. name = string(cmdTarget->GetName());
  2216. if(name.length() > 0){
  2217. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2218. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2219. client->GetPlayer()->RemoveIgnore(name.c_str());
  2220. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2221. client->SendChatRelationship(3, name.c_str());
  2222. }
  2223. client->GetPlayer()->AddFriend(name.c_str(), true);
  2224. client->SendChatRelationship(0, name.c_str());
  2225. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2226. if(zone_list.GetClientByCharName(name))
  2227. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2228. }
  2229. else
  2230. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2231. }
  2232. else
  2233. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2234. break;
  2235. }
  2236. case COMMAND_FRIEND_REMOVE:{
  2237. string name = "";
  2238. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2239. name = database.GetPlayerName(sep->arg[0]);
  2240. else if(cmdTarget && cmdTarget->IsPlayer())
  2241. name = string(cmdTarget->GetName());
  2242. if(name.length() > 0){
  2243. client->GetPlayer()->RemoveFriend(name.c_str());
  2244. client->SendChatRelationship(1, name.c_str());
  2245. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2246. }
  2247. else
  2248. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2249. break;
  2250. }
  2251. case COMMAND_FRIENDS:{
  2252. break;
  2253. }
  2254. case COMMAND_IGNORE_ADD:{
  2255. string name = "";
  2256. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2257. name = database.GetPlayerName(sep->arg[0]);
  2258. else if(cmdTarget && cmdTarget->IsPlayer())
  2259. name = string(cmdTarget->GetName());
  2260. if(name.length() > 0){
  2261. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2262. if(client->GetPlayer()->IsFriend(name.c_str())){
  2263. client->GetPlayer()->RemoveFriend(name.c_str());
  2264. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2265. client->SendChatRelationship(1, name.c_str());
  2266. }
  2267. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2268. client->SendChatRelationship(2, name.c_str());
  2269. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2270. }
  2271. else
  2272. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2273. }
  2274. else
  2275. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2276. break;
  2277. }
  2278. case COMMAND_IGNORE_REMOVE:{
  2279. string name = "";
  2280. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2281. name = database.GetPlayerName(sep->arg[0]);
  2282. else if(cmdTarget && cmdTarget->IsPlayer())
  2283. name = string(cmdTarget->GetName());
  2284. if(name.length() > 0){
  2285. client->GetPlayer()->RemoveIgnore(name.c_str());
  2286. client->SendChatRelationship(3, name.c_str());
  2287. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2288. }
  2289. break;
  2290. }
  2291. case COMMAND_IGNORES:{
  2292. break;
  2293. }
  2294. case COMMAND_GROUP_KICK:{
  2295. Entity* kicked = 0;
  2296. Client* kicked_client = 0;
  2297. int32 group_id = 0;
  2298. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2299. return;
  2300. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2301. if (sep && sep->arg[0]) {
  2302. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2303. if (kicked_client)
  2304. kicked = kicked_client->GetPlayer();
  2305. }
  2306. else if (cmdTarget && cmdTarget->IsEntity()) {
  2307. kicked = (Entity*)cmdTarget;
  2308. }
  2309. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2310. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2311. if (kicked)
  2312. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2313. if(send_kicked_message)
  2314. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2315. else
  2316. client->Message(CHANNEL_COLOR_GROUP, "You kicked %s from the group", kicked->GetName());
  2317. if (kicked_client)
  2318. kicked_client->SimpleMessage(CHANNEL_COLOR_GROUP, "You were kicked from the group");
  2319. break;
  2320. }
  2321. case COMMAND_GROUP_MAKE_LEADER:{
  2322. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2323. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2324. return;
  2325. }
  2326. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2327. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2328. if (new_leader) {
  2329. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2330. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2331. }
  2332. }
  2333. else
  2334. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2335. }
  2336. else if (cmdTarget && cmdTarget->IsPlayer())
  2337. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2338. else
  2339. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2340. break;
  2341. }
  2342. case COMMAND_GROUP_ACCEPT_INVITE: {
  2343. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2344. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2345. if (result == 0)
  2346. client->SimpleMessage(CHANNEL_GROUP, "You have joined the group.");
  2347. else if (result == 1)
  2348. client->SimpleMessage(CHANNEL_GROUP, "You do not have a pending invite.");
  2349. else if (result == 2)
  2350. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - could not find leader.");
  2351. else
  2352. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - unknown error.");
  2353. }
  2354. break;
  2355. }
  2356. case COMMAND_GROUP_DECLINE_INVITE: {
  2357. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2358. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2359. }
  2360. break;
  2361. }
  2362. case COMMAND_SUMMON:{
  2363. char* search_name = 0;
  2364. if(sep && sep->arg[0][0])
  2365. search_name = sep->arg[0];
  2366. if(!search_name && !cmdTarget){
  2367. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2368. 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.");
  2369. }
  2370. else{
  2371. if(!client->Summon(search_name))
  2372. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2373. }
  2374. break;
  2375. }
  2376. case COMMAND_GOTO:{
  2377. const char* search_name = 0;
  2378. if(sep && sep->arg[0][0])
  2379. search_name = sep->argplus[0];
  2380. if(!search_name && !cmdTarget){
  2381. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2382. 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.");
  2383. }
  2384. else{
  2385. if(!client->GotoSpawn(search_name))
  2386. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2387. }
  2388. break;
  2389. }
  2390. case COMMAND_MOVE:{
  2391. bool success = false;
  2392. try{
  2393. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2394. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2395. if(app){
  2396. client->QueuePacket(app);
  2397. success = true;
  2398. }
  2399. }
  2400. }
  2401. catch(...){}
  2402. if(!success){
  2403. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2404. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2405. }
  2406. break;
  2407. }
  2408. case COMMAND_SETTIME:{
  2409. if(sep && sep->arg[0]){
  2410. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2411. if(sep->arg[1] && sep->IsNumber(1))
  2412. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2413. if(sep->arg[2] && sep->IsNumber(2))
  2414. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2415. if(sep->arg[3] && sep->IsNumber(3))
  2416. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2417. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2418. }
  2419. else{
  2420. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2421. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2422. }
  2423. break;
  2424. }
  2425. case COMMAND_VERSION:{
  2426. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2427. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2428. break;
  2429. }
  2430. case COMMAND_ZONE:{
  2431. string* zonename = 0;
  2432. int32 instanceID = 0;
  2433. const char* zone = 0;
  2434. int32 zone_id = 0;
  2435. bool listSearch = false;
  2436. bool isInstance = false;
  2437. ZoneServer* zsZone = 0;
  2438. if(sep && sep->arg[0][0])
  2439. {
  2440. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2441. listSearch = true;
  2442. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2443. {
  2444. zone_list.SendZoneList(client);
  2445. break;
  2446. }
  2447. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2448. {
  2449. if(sep->IsNumber(1))
  2450. instanceID = atol(sep->arg[1]);
  2451. }
  2452. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2453. {
  2454. PrintSep(sep, "ZONE LOCK");
  2455. if(sep->IsNumber(1))
  2456. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2457. else
  2458. zsZone = zone_list.Get(sep->arg[1], false);
  2459. if( zsZone )
  2460. {
  2461. zsZone->SetZoneLockState(true);
  2462. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2463. }
  2464. else
  2465. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2466. break;
  2467. }
  2468. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2469. {
  2470. PrintSep(sep, "ZONE UNLOCK");
  2471. if(sep->IsNumber(1))
  2472. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2473. else
  2474. zsZone = zone_list.Get(sep->arg[1], false);
  2475. if( zsZone )
  2476. {
  2477. zsZone->SetZoneLockState(false);
  2478. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2479. }
  2480. else
  2481. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2482. break;
  2483. }
  2484. else
  2485. {
  2486. if(sep->IsNumber(0))
  2487. {
  2488. zone_id = atoul(sep->arg[0]);
  2489. zonename = database.GetZoneName(zone_id);
  2490. if(zonename)
  2491. zone = zonename->c_str();
  2492. }
  2493. else
  2494. zone = sep->arg[0];
  2495. }
  2496. if(instanceID > 0)
  2497. {
  2498. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2499. if(zsInstance != NULL)
  2500. {
  2501. instanceID = zsInstance->GetInstanceID();
  2502. zone = zsInstance->GetZoneName();
  2503. zone_id = zsInstance->GetZoneID();
  2504. isInstance = true;
  2505. }
  2506. }
  2507. }
  2508. if(!listSearch)
  2509. {
  2510. if(!zone)
  2511. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2512. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2513. zone_id != client->GetCurrentZone()->GetZoneID())
  2514. {
  2515. if(database.VerifyZone(zone))
  2516. {
  2517. if(client->CheckZoneAccess(zone))
  2518. {
  2519. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zone);
  2520. if(isInstance)
  2521. client->Zone(instanceID,true,true);
  2522. else
  2523. client->Zone(zone);
  2524. }
  2525. }
  2526. else
  2527. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zone);
  2528. }
  2529. else
  2530. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2531. }
  2532. else
  2533. {
  2534. const char* name = 0;
  2535. if(sep && sep->arg[1][0])
  2536. {
  2537. map<int32, string>* zone_names;
  2538. name = sep->argplus[1];
  2539. sint16 status = client->GetAdminStatus();
  2540. if( status > 0 )
  2541. {
  2542. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2543. zone_names = database.GetZoneList(name, true);
  2544. }
  2545. else
  2546. zone_names = database.GetZoneList(name);
  2547. if(!zone_names)
  2548. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2549. else
  2550. {
  2551. map<int32, string>::iterator itr;
  2552. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2553. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2554. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2555. safe_delete(zone_names);
  2556. }
  2557. }
  2558. else
  2559. {
  2560. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2561. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2562. }
  2563. }
  2564. safe_delete(zonename);
  2565. break;
  2566. }
  2567. case COMMAND_USE: {
  2568. Spawn* target = cmdTarget;
  2569. if (target->IsWidget())
  2570. ((Widget*)target)->HandleUse(client, "use");
  2571. break;
  2572. }
  2573. case COMMAND_OPEN: {
  2574. Spawn* target = cmdTarget;
  2575. if (target->IsWidget())
  2576. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2577. break;
  2578. }
  2579. case COMMAND_CASTSPELL: {
  2580. if (sep && sep->arg[0] && sep->IsNumber(0))
  2581. {
  2582. int8 tier = 1;
  2583. if (sep->arg[1] && sep->IsNumber(1))
  2584. tier = atoul(sep->arg[1]);
  2585. int32 spellid = atoul(sep->arg[0]);
  2586. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2587. if (spell)
  2588. {
  2589. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2590. SpellProcess* spellProcess = 0;
  2591. // Get the current zones spell process
  2592. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2593. spellProcess->CastInstant(spell, (Entity*)client->GetPlayer(), (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2594. }
  2595. else
  2596. {
  2597. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2598. }
  2599. }
  2600. else if (sep && sep->arg[0])
  2601. {
  2602. database.FindSpell(client, (char*)sep->argplus[0]);
  2603. }
  2604. else
  2605. {
  2606. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2607. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2608. }
  2609. break;
  2610. }
  2611. case COMMAND_KNOWLEDGEWINDOWSORT: {
  2612. if (sep && sep->GetArgNumber() == 4)
  2613. {
  2614. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  2615. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  2616. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  2617. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  2618. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  2619. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  2620. ClientPacketFunctions::SendSkillSlotMappings(client);
  2621. }
  2622. else
  2623. {
  2624. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  2625. }
  2626. break;
  2627. }
  2628. case COMMAND_MOVE_ITEM:
  2629. {
  2630. int32 id = 0;
  2631. if (sep->IsNumber(0))
  2632. id = atoul(sep->arg[0]);
  2633. Spawn* spawn = 0;
  2634. if (id == 0)
  2635. {
  2636. spawn = cmdTarget;
  2637. }
  2638. else
  2639. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2640. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2641. break;
  2642. client->SendMoveObjectMode(spawn, 0);
  2643. break;
  2644. }
  2645. case COMMAND_PICKUP:
  2646. {
  2647. int32 id = 0;
  2648. if (sep->IsNumber(0))
  2649. id = atoul(sep->arg[0]);
  2650. Spawn* spawn = 0;
  2651. if (id == 0)
  2652. {
  2653. spawn = cmdTarget;
  2654. }
  2655. else
  2656. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2657. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2658. break;
  2659. client->AddItem(spawn->GetPickupItemID(), 1);
  2660. Query query;
  2661. query.RunQuery2(Q_INSERT, "delete from spawn_instance_data where spawn_id = %u and spawn_location_id = %u and pickup_item_id = %u", spawn->GetDatabaseID(), spawn->GetSpawnLocationID(), spawn->GetPickupItemID());
  2662. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  2663. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, true);
  2664. }
  2665. // we had a UI Window displayed, update the house items
  2666. if ( id > 0 )
  2667. client->GetCurrentZone()->SendHouseItems(client);
  2668. break;
  2669. }
  2670. case COMMAND_HOUSE_DEPOSIT:
  2671. {
  2672. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  2673. // arg0 = ??? (set to 3)
  2674. // arg1 = coin (in copper)
  2675. // arg2 = status? (not implemented yet)
  2676. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2677. if (ph && sep && sep->IsNumber(1))
  2678. {
  2679. int64 outVal = strtoull(sep->arg[1], NULL, 0);
  2680. if (client->GetPlayer()->RemoveCoins(outVal))
  2681. {
  2682. char query[256];
  2683. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  2684. if (itr != ph->depositsMap.end())
  2685. {
  2686. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %I64u, last_amount = %I64u where house_id = %u and instance_id = %u and name='%s'", Timer::GetUnixTimeStamp(), outVal, outVal, ph->house_id, ph->instance_id, client->GetPlayer()->GetName());
  2687. }
  2688. else
  2689. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %I64u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outVal);
  2690. if (database.RunQuery(query, strnlen(query, 256)))
  2691. {
  2692. ph->escrow_coins += outVal;
  2693. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins);
  2694. database.LoadDeposits(ph);
  2695. client->PlaySound("coin_cha_ching");
  2696. HouseZone* hz = world.GetHouseZone(ph->house_id);
  2697. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2698. }
  2699. else
  2700. {
  2701. client->GetPlayer()->AddCoins(outVal);
  2702. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  2703. }
  2704. }
  2705. }
  2706. break;
  2707. }
  2708. case COMMAND_HOUSE:
  2709. {
  2710. if (sep && sep->IsNumber(0))
  2711. {
  2712. int32 unique_id = atoi(sep->arg[0]);
  2713. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2714. HouseZone* hz = 0;
  2715. if (ph)
  2716. hz = world.GetHouseZone(ph->house_id);
  2717. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2718. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2719. }
  2720. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  2721. {
  2722. // inside a house or something? Send the access window
  2723. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2724. HouseZone* hz = 0;
  2725. if ( ph )
  2726. hz = world.GetHouseZone(ph->house_id);
  2727. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2728. client->GetCurrentZone()->SendHouseItems(client);
  2729. }
  2730. break;
  2731. }
  2732. case COMMAND_HOUSE_UI:
  2733. {
  2734. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  2735. {
  2736. int32 unique_id = atoi(sep->arg[0]);
  2737. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2738. HouseZone* hz = 0;
  2739. if ( ph )
  2740. hz = world.GetHouseZone(ph->house_id);
  2741. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2742. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  2743. }
  2744. break;
  2745. }
  2746. case COMMAND_PLACE_HOUSE_ITEM: {
  2747. if (sep && sep->IsNumber(0))
  2748. {
  2749. int32 uniqueid = atoi(sep->arg[0]);
  2750. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  2751. //Item* item = player->GetEquipmentList()->GetItem(slot);
  2752. if (item && item->IsHouseItem())
  2753. {
  2754. if (!client->HasOwnerOrEditAccess())
  2755. {
  2756. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  2757. break;
  2758. }
  2759. else if (!item->generic_info.appearance_id)
  2760. {
  2761. client->Message(CHANNEL_COLOR_RED, "This item has not been configured in the database, %s (%u) needs an entry where ?? has the model type id, eg. insert into item_appearances set item_id=%u,equip_type=??;", item->name.c_str(), item->details.item_id, item->details.item_id);
  2762. break;
  2763. }
  2764. if (client->GetTempPlacementSpawn())
  2765. {
  2766. Spawn* tmp = client->GetTempPlacementSpawn();
  2767. client->GetCurrentZone()->RemoveSpawn(false, tmp);
  2768. delete tmp;
  2769. client->SetTempPlacementSpawn(nullptr);
  2770. }
  2771. Spawn* spawn = new Object();
  2772. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2773. spawn->SetID(Spawn::NextID());
  2774. spawn->SetX(client->GetPlayer()->GetX());
  2775. spawn->SetY(client->GetPlayer()->GetY());
  2776. spawn->SetZ(client->GetPlayer()->GetZ());
  2777. spawn->SetHeading(client->GetPlayer()->GetHeading());
  2778. spawn->SetSpawnOrigX(spawn->GetX());
  2779. spawn->SetSpawnOrigY(spawn->GetY());
  2780. spawn->SetSpawnOrigZ(spawn->GetZ());
  2781. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  2782. spawn->appearance.targetable = 1;
  2783. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  2784. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  2785. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  2786. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  2787. spawn->SetZone(client->GetCurrentZone());
  2788. client->GetCurrentZone()->SendSpawn(spawn, client);
  2789. client->SetTempPlacementSpawn(spawn);
  2790. client->SetPlacementUniqueItemID(uniqueid);
  2791. client->SendMoveObjectMode(spawn, 0);
  2792. }
  2793. }
  2794. break;
  2795. }
  2796. case COMMAND_GM:
  2797. {
  2798. if (sep->arg[0] && sep->arg[1])
  2799. {
  2800. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  2801. if (strcmp(sep->arg[0], "vision") == 0)
  2802. {
  2803. client->GetPlayer()->SetGMVision(onOff);
  2804. #if defined(__GNUC__)
  2805. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  2806. #else
  2807. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  2808. #endif
  2809. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  2810. if (onOff)
  2811. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  2812. else
  2813. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  2814. }
  2815. else if (strcmp(sep->arg[0], "luadebug") == 0)
  2816. {
  2817. client->SetLuaDebugClient(onOff);
  2818. #if defined(__GNUC__)
  2819. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  2820. #else
  2821. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  2822. #endif
  2823. if (onOff)
  2824. {
  2825. if (lua_interface)
  2826. lua_interface->UpdateDebugClients(client);
  2827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  2828. }
  2829. else
  2830. {
  2831. if (lua_interface)
  2832. lua_interface->RemoveDebugClients(client);
  2833. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  2834. }
  2835. }
  2836. }
  2837. break;
  2838. }
  2839. case COMMAND_ATTACK:
  2840. case COMMAND_AUTO_ATTACK:{
  2841. int8 type = 1;
  2842. Player* player = client->GetPlayer();
  2843. if(!player)
  2844. break;
  2845. bool incombat = player->EngagedInCombat();
  2846. if(sep && sep->arg[0] && sep->IsNumber(0))
  2847. type = atoi(sep->arg[0]);
  2848. if(client->GetPlayer()->GetHP() == 0){
  2849. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  2850. break;
  2851. }
  2852. if(type == 0){
  2853. if(incombat)
  2854. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2855. player->InCombat(false);
  2856. player->InCombat(false, true);
  2857. player->SetRangeAttack(false);
  2858. }
  2859. else {
  2860. if(type == 2){
  2861. player->InCombat(false);
  2862. if(incombat && player->GetRangeAttack()){
  2863. player->SetRangeAttack(false);
  2864. player->InCombat(false, true);
  2865. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2866. }
  2867. else{
  2868. player->SetRangeAttack(true);
  2869. player->InCombat(true, true);
  2870. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2871. }
  2872. }
  2873. else {
  2874. player->InCombat(false, true);
  2875. player->SetRangeAttack(false);
  2876. player->InCombat(true);
  2877. if(!incombat)
  2878. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2879. }
  2880. /*else
  2881. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  2882. }
  2883. player->SetCharSheetChanged(true);
  2884. break;
  2885. }
  2886. case COMMAND_DEPOP:{
  2887. bool allow_respawns = false;
  2888. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2889. if(atoi(sep->arg[0]) == 1)
  2890. allow_respawns = true;
  2891. }
  2892. client->GetCurrentZone()->Depop(allow_respawns);
  2893. break;
  2894. }
  2895. case COMMAND_REPOP:{
  2896. client->GetCurrentZone()->Depop(false, true);
  2897. break;
  2898. }
  2899. case COMMAND_BUYBACK:{
  2900. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2901. // 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
  2902. int64 id = atoi64(sep->arg[0]);
  2903. // get the first int32, the item id
  2904. //int32 item_id = (int32)id;
  2905. // get the second int32, the unique id
  2906. int32 unique_id = (int32)(id>>32);
  2907. int8 quantity = atoi(sep->arg[1]);
  2908. if(quantity == 255)
  2909. quantity = 1;
  2910. client->BuyBack(unique_id, quantity);
  2911. }
  2912. break;
  2913. }
  2914. case COMMAND_MERCHANT_BUY:{
  2915. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2916. int32 item_id = atoul(sep->arg[0]);
  2917. int8 quantity = atoi(sep->arg[1]);
  2918. client->BuyItem(item_id, quantity);
  2919. }
  2920. break;
  2921. }
  2922. case COMMAND_MERCHANT_SELL:{
  2923. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2924. // 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
  2925. int64 id = atoi64(sep->arg[0]);
  2926. // get the first int32, the item id
  2927. int32 item_id = (int32)id;
  2928. // get the second int32, the unique id
  2929. int32 unique_id = (int32)(id>>32);
  2930. int8 quantity = atoi(sep->arg[1]);
  2931. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  2932. client->SellItem(item_id, quantity, unique_id);
  2933. }
  2934. break;
  2935. }
  2936. case COMMAND_MENDER_REPAIR: {
  2937. if (sep && sep->arg[0] && sep->IsNumber(0))
  2938. client->RepairItem(atoul(sep->arg[0]));
  2939. break;
  2940. }
  2941. case COMMAND_MENDER_REPAIR_ALL: {
  2942. client->RepairAllItems();
  2943. break;
  2944. }
  2945. case COMMAND_CANCEL_MERCHANT:{
  2946. client->SetMerchantTransaction(0);
  2947. break;
  2948. }
  2949. case COMMAND_START_MERCHANT:{
  2950. break;
  2951. }
  2952. case COMMAND_INVULNERABLE:{
  2953. sint8 val = -1;
  2954. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2955. val = atoi(sep->arg[0]);
  2956. //devn00b: Fix for linux builds
  2957. #if defined(__GNUC__)
  2958. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  2959. #else
  2960. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2961. #endif
  2962. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2963. client->GetPlayer()->SetInvulnerable(val==1);
  2964. if(client->GetPlayer()->GetInvulnerable())
  2965. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  2966. else
  2967. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  2968. }
  2969. if(val == -1)
  2970. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  2971. break;
  2972. }
  2973. case COMMAND_REPAIR: {
  2974. Spawn* spawn = cmdTarget;
  2975. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  2976. client->SendHailCommand(spawn);
  2977. client->SetMerchantTransaction(spawn);
  2978. client->SendRepairList();
  2979. }
  2980. break;
  2981. }
  2982. case COMMAND_LOTTO: {
  2983. Spawn* spawn = cmdTarget;
  2984. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  2985. client->SetMerchantTransaction(spawn);
  2986. client->ShowLottoWindow();
  2987. }
  2988. break;
  2989. }
  2990. case COMMAND_ACCEPT_REWARD:{
  2991. int32 unknown = 0;
  2992. int32 selectable_item_id = 0;
  2993. //Quest *quest = 0;
  2994. Collection *collection = 0;
  2995. /* no idea what the first argument is for (faction maybe?)
  2996. if the reward has a selectable item reward, it's sent as the second argument
  2997. if neither of these are included in the reward, there is no sep
  2998. 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
  2999. only 1 quest or collection reward may be displayed at a time */
  3000. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3001. unknown = atoul(sep->arg[0]);
  3002. selectable_item_id = atoul(sep->arg[1]);
  3003. }
  3004. //if ((quest = player->GetPendingQuestReward()))
  3005. // client->AcceptQuestRewards(quest, selectable_item_id);
  3006. /* the below needs to go away eventually and be redone */
  3007. int32 item_id = 0;
  3008. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3009. item_id = atoul(sep->arg[0]);
  3010. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3011. if(quest){
  3012. client->AcceptQuestReward(quest, item_id);
  3013. break;
  3014. }
  3015. if (collection = player->GetPendingCollectionReward())
  3016. client->AcceptCollectionRewards(collection, selectable_item_id);
  3017. else
  3018. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  3019. break;
  3020. }
  3021. case COMMAND_BUY_FROM_BROKER:{
  3022. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3023. int32 item_id = atoul(sep->arg[0]);
  3024. int16 quantity = atoul(sep->arg[1]);
  3025. client->AddItem(item_id, quantity);
  3026. }
  3027. break;
  3028. }
  3029. case COMMAND_SEARCH_STORES_PAGE:{
  3030. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3031. int32 page = atoul(sep->arg[0]);
  3032. client->SearchStore(page);
  3033. }
  3034. break;
  3035. }
  3036. case COMMAND_SEARCH_STORES:{
  3037. if(sep && sep->arg[0][0]){
  3038. const char* values = sep->argplus[0];
  3039. if(values){
  3040. map<string, string> str_values = TranslateBrokerRequest(values);
  3041. vector<Item*>* items = master_item_list.GetItems(str_values);
  3042. if(items){
  3043. client->SetItemSearch(items);
  3044. client->SearchStore(0);
  3045. }
  3046. }
  3047. }
  3048. break;
  3049. }
  3050. case COMMAND_LUADEBUG:{
  3051. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  3052. client->SetLuaDebugClient(true);
  3053. if(lua_interface)
  3054. lua_interface->UpdateDebugClients(client);
  3055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3056. }
  3057. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  3058. client->SetLuaDebugClient(false);
  3059. if(lua_interface)
  3060. lua_interface->RemoveDebugClients(client);
  3061. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3062. }
  3063. else{
  3064. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  3065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  3066. }
  3067. break;
  3068. }
  3069. case COMMAND_SPAWN_GROUP:
  3070. {
  3071. Spawn* target = cmdTarget;
  3072. if(target && target->IsPlayer() == false)
  3073. {
  3074. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  3075. {
  3076. if(target->GetSpawnLocationPlacementID() > 0)
  3077. {
  3078. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  3079. {
  3080. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  3081. if(id > 0)
  3082. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  3083. else
  3084. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  3085. target->SetSpawnGroupID(id);
  3086. target->AddSpawnToGroup(target);
  3087. }
  3088. else
  3089. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  3090. }
  3091. else
  3092. 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.");
  3093. }
  3094. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  3095. {
  3096. if(sep->arg[1] && sep->IsNumber(1))
  3097. {
  3098. int32 group_id = atoul(sep->arg[1]);
  3099. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  3100. if(leader)
  3101. {
  3102. leader->AddSpawnToGroup(target);
  3103. target->SetSpawnGroupID(group_id);
  3104. if(database.SpawnGroupAddSpawn(target, group_id))
  3105. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  3106. else
  3107. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  3108. }
  3109. else
  3110. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  3111. }
  3112. else
  3113. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  3114. }
  3115. else if(target->GetSpawnGroupID() == 0)
  3116. {
  3117. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  3118. }
  3119. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  3120. {
  3121. int32 group_id = target->GetSpawnGroupID();
  3122. target->RemoveSpawnFromGroup();
  3123. if(database.SpawnGroupRemoveSpawn(target, group_id))
  3124. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  3125. else
  3126. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  3127. }
  3128. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  3129. {
  3130. int32 group_id = target->GetSpawnGroupID();
  3131. if(sep->arg[1] && sep->IsNumber(1))
  3132. {
  3133. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  3134. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  3135. else
  3136. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  3137. }
  3138. else
  3139. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  3140. }
  3141. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  3142. {
  3143. int32 group_id = target->GetSpawnGroupID();
  3144. if(sep->arg[1] && sep->IsNumber(1))
  3145. {
  3146. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  3147. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  3148. else
  3149. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  3150. }
  3151. else
  3152. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  3153. }
  3154. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  3155. {
  3156. if(sep->arg[1] && sep->IsNumber(1))
  3157. {
  3158. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  3159. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  3160. else
  3161. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  3162. }
  3163. else
  3164. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  3165. }
  3166. else
  3167. {
  3168. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  3169. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  3170. }
  3171. }
  3172. else
  3173. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  3174. break;
  3175. }
  3176. case COMMAND_SPAWN_COMBINE:{
  3177. Spawn* spawn = cmdTarget;
  3178. float radius = 0;
  3179. bool failed = true;
  3180. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  3181. failed = false;
  3182. if(spawn->GetSpawnGroupID() > 0){
  3183. 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.");
  3184. }
  3185. else if(sep->IsNumber(0)){
  3186. radius = atof(sep->arg[0]);
  3187. client->CombineSpawns(radius, spawn);
  3188. }
  3189. else{
  3190. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  3191. client->AddCombineSpawn(spawn);
  3192. }
  3193. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  3194. client->RemoveCombineSpawn(spawn);
  3195. }
  3196. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  3197. const char* name = 0;
  3198. if(sep->arg[1] && sep->arg[1][0])
  3199. name = sep->argplus[1];
  3200. client->SaveCombineSpawns(name);
  3201. }
  3202. else
  3203. failed = true;
  3204. }
  3205. }
  3206. if(failed){
  3207. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  3208. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  3209. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  3210. }
  3211. break;
  3212. }
  3213. case COMMAND_SPAWN_CREATE:{
  3214. Spawn* spawn = 0;
  3215. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3216. spawn = new Object();
  3217. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3218. }
  3219. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3220. spawn = new GroundSpawn();
  3221. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3222. }
  3223. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3224. spawn = new Sign();
  3225. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3226. }
  3227. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3228. spawn = new NPC();
  3229. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3230. spawn->appearance.pos.collision_radius = 32;
  3231. spawn->secondary_command_list_id = 0;
  3232. spawn->primary_command_list_id = 0;
  3233. spawn->appearance.display_name = 1;
  3234. spawn->appearance.show_level = 1;
  3235. spawn->appearance.attackable = 1;
  3236. }
  3237. else{
  3238. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  3239. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  3240. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  3241. break;
  3242. }
  3243. spawn->SetID(Spawn::NextID());
  3244. spawn->SetX(client->GetPlayer()->GetX());
  3245. spawn->SetY(client->GetPlayer()->GetY());
  3246. spawn->SetZ(client->GetPlayer()->GetZ());
  3247. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3248. spawn->SetSpawnOrigX(spawn->GetX());
  3249. spawn->SetSpawnOrigY(spawn->GetY());
  3250. spawn->SetSpawnOrigZ(spawn->GetZ());
  3251. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3252. spawn->appearance.targetable = 1;
  3253. spawn->appearance.race = 255;
  3254. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3255. spawn->SetModelType(atoi(sep->arg[1]));
  3256. spawn->SetAdventureClass(atoi(sep->arg[2]));
  3257. spawn->SetLevel(atoi(sep->arg[3]));
  3258. spawn->SetName(sep->arg[4]);
  3259. if(sep->arg[5][0] && sep->IsNumber(5))
  3260. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  3261. if(sep->arg[6][0] && sep->IsNumber(6))
  3262. spawn->size = atoi(sep->arg[6]);
  3263. if(spawn->GetTotalHP() == 0){
  3264. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  3265. spawn->SetHP(25*spawn->GetLevel() + 1);
  3266. }
  3267. if(spawn->GetTotalPower() == 0){
  3268. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3269. spawn->SetPower(25*spawn->GetLevel() + 1);
  3270. }
  3271. client->GetCurrentZone()->AddSpawn(spawn);
  3272. break;
  3273. }
  3274. case COMMAND_SPAWN_EQUIPMENT:{
  3275. Spawn* spawn = cmdTarget;
  3276. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3277. int8 slot = atoi(sep->arg[0]);
  3278. int16 type = atoi(sep->arg[1]);
  3279. int8 red = 0;
  3280. int8 green = 0;
  3281. int8 blue = 0;
  3282. int8 h_red = 0;
  3283. int8 h_green = 0;
  3284. int8 h_blue = 0;
  3285. if(sep->arg[2])
  3286. red = atoi(sep->arg[2]);
  3287. if(sep->arg[3])
  3288. green = atoi(sep->arg[3]);
  3289. if(sep->arg[4])
  3290. blue = atoi(sep->arg[4]);
  3291. if(sep->arg[5])
  3292. h_red = atoi(sep->arg[5]);
  3293. if(sep->arg[6])
  3294. h_green = atoi(sep->arg[6]);
  3295. if(sep->arg[7])
  3296. h_blue = atoi(sep->arg[7]);
  3297. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3298. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3299. }
  3300. else{
  3301. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3302. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3303. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3304. }
  3305. break;
  3306. }
  3307. case COMMAND_SPAWN_DETAILS:{
  3308. Spawn* spawn = cmdTarget;
  3309. if (sep && sep->arg[0][0]) {
  3310. if (cmdTarget)
  3311. {
  3312. if (ToLower(string(sep->arg[0])) == "los")
  3313. {
  3314. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3315. if (hasLOS)
  3316. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3317. else
  3318. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3319. break;
  3320. }
  3321. else if (ToLower(string(sep->arg[0])) == "bestz")
  3322. {
  3323. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3324. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3325. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3326. break;
  3327. }
  3328. else if (ToLower(string(sep->arg[0])) == "pathto")
  3329. {
  3330. break;
  3331. }
  3332. else if (ToLower(string(sep->arg[0])) == "pathfrom")
  3333. {
  3334. break;
  3335. }
  3336. }
  3337. if (sep->IsNumber(0))
  3338. {
  3339. float radius = atof(sep->arg[0]);
  3340. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3341. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3342. break;
  3343. }
  3344. }
  3345. if(spawn){
  3346. const char* type = "NPC";
  3347. if(spawn->IsObject())
  3348. type = "Object";
  3349. else if(spawn->IsSign())
  3350. type = "Sign";
  3351. else if(spawn->IsWidget())
  3352. type = "Widget";
  3353. else if(spawn->IsGroundSpawn())
  3354. type = "GroundSpawn";
  3355. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3356. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3357. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3358. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3359. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3360. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3361. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3362. 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());
  3363. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3364. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3365. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3366. if(spawn->IsEntity()){
  3367. 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());
  3368. 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());
  3369. }
  3370. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3371. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3372. 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());
  3373. 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);
  3374. if (spawn->IsNPC())
  3375. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3376. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  3377. if (packet) {
  3378. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3379. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3380. packet->setDataByName("book_title", title.c_str());
  3381. packet->setDataByName("book_type", "simple");
  3382. packet->setDataByName("unknown2", 1);
  3383. packet->setDataByName("unknown5", 1, 4);
  3384. packet->setArrayLengthByName("num_pages", 4);
  3385. string details;
  3386. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3387. details += "Type: " + string(type) + "\n";
  3388. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3389. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3390. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3391. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3392. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3393. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3394. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3395. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3396. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3397. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3398. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3399. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3400. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3401. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3402. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3403. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3404. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3405. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3406. char x[16];
  3407. sprintf(x, "%.2f", spawn->GetX());
  3408. char y[16];
  3409. sprintf(y, "%.2f", spawn->GetY());
  3410. char z[16];
  3411. sprintf(z, "%.2f", spawn->GetZ());
  3412. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3413. string details2;
  3414. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3415. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3416. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3417. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3418. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3419. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3420. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3421. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3422. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3423. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3424. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3425. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3426. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3427. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3428. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3429. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3430. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3431. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3432. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3433. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3434. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3435. string details3;
  3436. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3437. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3438. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3439. string details4;
  3440. if (spawn->IsEntity()) {
  3441. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3442. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3443. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3444. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3445. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3446. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3447. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3448. if (spawn->IsNPC()) {
  3449. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3450. }
  3451. }
  3452. //details2 += "" + to_string() + "\n";
  3453. packet->setArrayDataByName("page_text", details.c_str());
  3454. packet->setArrayDataByName("page_text", details2.c_str(), 1);
  3455. packet->setArrayDataByName("page_text", details3.c_str(), 2);
  3456. packet->setArrayDataByName("page_text", details4.c_str(), 3);
  3457. client->QueuePacket(packet->serialize());
  3458. safe_delete(packet);
  3459. }
  3460. }
  3461. else {
  3462. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3463. 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.");
  3464. }
  3465. break;
  3466. }
  3467. case COMMAND_SPAWN_TARGET:{
  3468. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3469. int32 spawn_id = atoul(sep->arg[0]);
  3470. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3471. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3472. }
  3473. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3474. float distance = atof(sep->arg[1]);
  3475. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3476. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3477. }
  3478. else{
  3479. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3480. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3481. }
  3482. break;
  3483. }
  3484. case COMMAND_SPAWN_SET:
  3485. {
  3486. Spawn* spawn = cmdTarget;
  3487. sint16 set_type = -1;
  3488. string type_str;
  3489. if (spawn)
  3490. {
  3491. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3492. 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)
  3493. {
  3494. // set the type, which will be 0 if location or list or invalid
  3495. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3496. }
  3497. if(set_type > 0)
  3498. {
  3499. // check if spawn set is NOT a char update, or not location, or isn't a number
  3500. if(!(set_type >= SPAWN_SET_VALUE_PREFIX) && !(set_type <= SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL) && 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)
  3501. {
  3502. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3503. }
  3504. else
  3505. {
  3506. string name = string(spawn->GetName());
  3507. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1]))
  3508. {
  3509. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG)
  3510. {
  3511. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack flag.");
  3512. }
  3513. else if(set_type == SPAWN_SET_VALUE_NAME)
  3514. {
  3515. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3516. }
  3517. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3518. {
  3519. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3520. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3521. }
  3522. else
  3523. {
  3524. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3525. }
  3526. if(set_type != SPAWN_SET_VALUE_FACTION && set_type != SPAWN_SET_VALUE_EXPANSION_FLAG)
  3527. {
  3528. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->arg[1]);
  3529. }
  3530. 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))
  3531. {
  3532. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3533. {
  3534. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3535. }
  3536. else if(spawn->GetSpawnLocationID() > 0)
  3537. {
  3538. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3539. }
  3540. }
  3541. else
  3542. {
  3543. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3544. {
  3545. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3546. }
  3547. else if(spawn->GetDatabaseID() > 0)
  3548. {
  3549. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3550. }
  3551. }
  3552. }
  3553. }
  3554. }
  3555. else if(set_type == 0)
  3556. {
  3557. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3558. map<string, int8>::iterator itr;
  3559. int i=0;
  3560. string list;
  3561. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3562. {
  3563. if(i==10)
  3564. {
  3565. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3566. i = 0;
  3567. }
  3568. if(i>0)
  3569. {
  3570. list.append(", ").append(itr->first);
  3571. }
  3572. else
  3573. {
  3574. list = itr->first;
  3575. }
  3576. }
  3577. if(list.length() > 0)
  3578. {
  3579. // if 1 or more, display in client.
  3580. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3581. }
  3582. }
  3583. else
  3584. {
  3585. // syntax fail
  3586. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3587. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3588. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3589. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3590. }
  3591. }
  3592. break;
  3593. }
  3594. case COMMAND_SPAWN_REMOVE:{
  3595. Spawn* spawn = cmdTarget;
  3596. if(spawn && !spawn->IsPlayer()){
  3597. if(spawn->GetSpawnLocationID() > 0){
  3598. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3599. bool delete_spawn = false;
  3600. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3601. if(atoi(sep->arg[0]) == 1)
  3602. delete_spawn = true;
  3603. }
  3604. if(delete_spawn)
  3605. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, false);
  3606. else
  3607. spawn->SetSpawnLocationID(0);
  3608. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3609. }
  3610. else
  3611. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3612. }
  3613. else
  3614. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3615. }
  3616. else{
  3617. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3618. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3619. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Optionally, you can supply a 1 after the command to despawn it as well. IE /spawn remove 1");
  3620. }
  3621. break;
  3622. }
  3623. case COMMAND_SPAWN_LIST:{
  3624. if(sep && sep->arg[0][0]){
  3625. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3626. vector<string>::iterator itr;
  3627. if(results){
  3628. for(itr=results->begin();itr!=results->end();itr++){
  3629. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3630. }
  3631. safe_delete(results);
  3632. }
  3633. else
  3634. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3635. }
  3636. else{
  3637. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3638. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3639. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3640. }
  3641. break;
  3642. }
  3643. case COMMAND_SPAWN_ADD:{
  3644. Spawn* spawn = cmdTarget;
  3645. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3646. if(spawn->GetSpawnLocationID() > 0){
  3647. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3648. break;
  3649. }
  3650. if(spawn->GetDatabaseID() == 0){
  3651. if(database.SaveSpawnInfo(spawn)) {
  3652. char spawn_type[32];
  3653. memset(spawn_type, 0, sizeof(spawn_type));
  3654. if (spawn->IsNPC())
  3655. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3656. else if (spawn->IsObject())
  3657. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3658. else if (spawn->IsSign())
  3659. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3660. else if (spawn->IsGroundSpawn())
  3661. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3662. else
  3663. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3664. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3665. }
  3666. else
  3667. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3668. }
  3669. int32 spawn_group_id = 0;
  3670. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3671. spawn_group_id = database.GetNextSpawnLocation();
  3672. else
  3673. spawn_group_id = atol(sep->arg[0]);
  3674. int8 percent = 100;
  3675. if(sep->arg[2] && sep->IsNumber(2))
  3676. percent = atoi(sep->arg[2]);
  3677. spawn->SetSpawnLocationID(spawn_group_id);
  3678. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3679. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3680. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3681. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3682. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3683. else
  3684. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3685. }
  3686. else{
  3687. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3688. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3689. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3690. }
  3691. break;
  3692. }
  3693. case COMMAND_SPAWN:{
  3694. int32 id = 0;
  3695. Spawn* spawn = 0;
  3696. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3697. id = atol(sep->arg[0]);
  3698. spawn = client->GetCurrentZone()->GetSpawn(id);
  3699. }
  3700. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3701. id = 0;
  3702. if(!id || !spawn){
  3703. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3704. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3705. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3706. safe_delete(sep);
  3707. return;
  3708. }
  3709. if(sep && sep->arg[1][0]){
  3710. float x = atof(sep->arg[1]);
  3711. spawn->appearance.pos.X = x;
  3712. }
  3713. else
  3714. spawn->SetX(client->GetPlayer()->GetX(), false);
  3715. if(sep && sep->arg[2][0]){
  3716. float y = atof(sep->arg[2]);
  3717. spawn->appearance.pos.Y = y;
  3718. }
  3719. else
  3720. spawn->SetY(client->GetPlayer()->GetY(), false);
  3721. if(sep && sep->arg[3][0]){
  3722. float z = atof(sep->arg[3]);
  3723. spawn->appearance.pos.Z = z;
  3724. }
  3725. else
  3726. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3727. if(sep && sep->arg[4][0]){
  3728. float heading = atof(sep->arg[4]);
  3729. spawn->SetHeading(heading);
  3730. }
  3731. else
  3732. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3733. spawn->SetSpawnOrigX(spawn->GetX());
  3734. spawn->SetSpawnOrigY(spawn->GetY());
  3735. spawn->SetSpawnOrigZ(spawn->GetZ());
  3736. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3737. if(sep && sep->arg[5][0])
  3738. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3739. else
  3740. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3741. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3742. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3743. spawn->SetHP(spawn->GetTotalHP());
  3744. }
  3745. if(spawn->GetTotalPower() == 0){
  3746. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3747. spawn->SetPower(spawn->GetTotalPower());
  3748. }
  3749. const char* script = world.GetSpawnScript(id);
  3750. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3751. spawn->SetSpawnScript(string(script));
  3752. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  3753. client->GetCurrentZone()->AddSpawn(spawn);
  3754. if(spawn->IsNPC())
  3755. spawn->GetZone()->AddLoot((NPC*)spawn);
  3756. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3757. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3758. break;
  3759. }
  3760. case COMMAND_ADMINFLAG:
  3761. {
  3762. if(sep && sep->arg[0]){
  3763. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3764. sint16 new_status = atoi(sep->arg[1]);
  3765. if(tmp_status == -10)
  3766. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3767. else if(tmp_status >= client->GetAdminStatus())
  3768. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3769. else if (new_status > client->GetAdminStatus())
  3770. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3771. else{
  3772. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3773. if (!client2)
  3774. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3775. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3776. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3777. if (client2) {
  3778. client2->SetAdminStatus(new_status);
  3779. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3780. }
  3781. }
  3782. else
  3783. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3784. }
  3785. }else{
  3786. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3787. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3788. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3789. }
  3790. break;
  3791. }
  3792. case COMMAND_CANNEDEMOTE:{
  3793. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3794. break;
  3795. }
  3796. case COMMAND_BROADCAST: {
  3797. if (sep && sep->arg[0])
  3798. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3799. else
  3800. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3801. break;
  3802. }
  3803. case COMMAND_ANNOUNCE: {
  3804. if (sep && sep->arg[0])
  3805. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3806. else
  3807. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3808. break;
  3809. }
  3810. case COMMAND_RELOAD_ITEMS:{
  3811. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3812. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3813. database.ReloadItemList();
  3814. database.LoadMerchantInformation();
  3815. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3816. break;
  3817. }
  3818. case COMMAND_ENABLE_ABILITY_QUE:{
  3819. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3820. if(app)
  3821. client->QueuePacket(app);
  3822. break;
  3823. }
  3824. case COMMAND_ITEMSEARCH:{
  3825. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3826. if (packet) {
  3827. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3828. //packet->setDataByName("unknown", 1);
  3829. packet->setDataByName("unknown2", 5, 0);
  3830. packet->setDataByName("unknown2", 20, 1);
  3831. packet->setDataByName("unknown2", 58, 3);
  3832. packet->setDataByName("unknown2", 40, 4);
  3833. client->QueuePacket(packet->serialize());
  3834. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3835. if (packet2) {
  3836. packet2->setDataByName("char_id", client->GetCharacterID());
  3837. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3838. safe_delete(packet2);
  3839. }
  3840. safe_delete(packet);
  3841. }
  3842. break;
  3843. }
  3844. case COMMAND_ANIMTEST:{
  3845. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3846. if(command_packet){
  3847. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  3848. if (cmdTarget)
  3849. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  3850. command_packet->setDataByName ( "spawn_id" , id);
  3851. int animID = 1;
  3852. if(sep && sep->arg[0] && sep->IsNumber(0))
  3853. animID = atoi(sep->arg[0]);
  3854. VisualState* vs = NULL;
  3855. if(animID == 0)
  3856. {
  3857. vs = visual_states.FindVisualState(sep->arg[0]);
  3858. }
  3859. char msg[128];
  3860. sprintf(msg,"Animation Test ID: %i",animID);
  3861. command_packet->setMediumStringByName ( "emote_msg" , msg );
  3862. if(vs != NULL)
  3863. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  3864. else
  3865. command_packet->setDataByName ( "anim_type", animID );
  3866. command_packet->setDataByName ( "unknown0", 0 );
  3867. EQ2Packet* outapp = command_packet->serialize();
  3868. client->QueuePacket(outapp);
  3869. safe_delete(command_packet);
  3870. }
  3871. break;
  3872. }
  3873. case COMMAND_KICK:
  3874. {
  3875. if( sep == 0 || sep->arg[0] == 0)
  3876. {
  3877. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  3878. }
  3879. else
  3880. {
  3881. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  3882. if ( kickClient == client )
  3883. {
  3884. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  3885. break;
  3886. }
  3887. else if(kickClient != NULL)
  3888. {
  3889. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3890. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  3891. {
  3892. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3893. break;
  3894. }
  3895. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  3896. kickClient->Disconnect();
  3897. }
  3898. else
  3899. {
  3900. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3901. }
  3902. }
  3903. break;
  3904. }
  3905. case COMMAND_LOCK:
  3906. {
  3907. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  3908. int worldLocked = atoi(sep->arg[0]);
  3909. net.world_locked = worldLocked;
  3910. if ( worldLocked )
  3911. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  3912. else
  3913. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  3914. }
  3915. else
  3916. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  3917. break;
  3918. }
  3919. case COMMAND_BAN:{
  3920. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  3921. {
  3922. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  3923. }
  3924. else
  3925. {
  3926. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  3927. if ( kickClient == client )
  3928. {
  3929. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  3930. break;
  3931. }
  3932. else if(kickClient != NULL)
  3933. {
  3934. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3935. if ( maxStatus > client->GetAdminStatus( ) ||
  3936. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  3937. {
  3938. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3939. break;
  3940. }
  3941. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  3942. int perm = atol(sep->arg[1]);
  3943. if ( perm == 1 )
  3944. database.UpdateAdminStatus(sep->arg[0],-2);
  3945. else
  3946. database.UpdateAdminStatus(sep->arg[0],-1);
  3947. kickClient->Disconnect();
  3948. }
  3949. else
  3950. {
  3951. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3952. }
  3953. }
  3954. break;
  3955. }
  3956. case COMMAND_SET_COMBAT_VOICE:{
  3957. int32 value = 0;
  3958. if(sep && sep->arg[0] && sep->IsNumber(0))
  3959. value = atoi(sep->arg[0]);
  3960. client->GetPlayer()->SetCombatVoice(value);
  3961. break;
  3962. }
  3963. case COMMAND_SET_EMOTE_VOICE:{
  3964. int32 value = 0;
  3965. if(sep && sep->arg[0] && sep->IsNumber(0))
  3966. value = atoi(sep->arg[0]);
  3967. client->GetPlayer()->SetEmoteVoice(value);
  3968. break;
  3969. }
  3970. case COMMAND_GIVEITEM:{
  3971. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  3972. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  3973. if ( itemToClient == NULL )
  3974. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  3975. else
  3976. {
  3977. int32 item_id = atol(sep->arg[1]);
  3978. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  3979. itemToClient->AddItem(item_id);
  3980. }
  3981. }
  3982. else
  3983. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  3984. break;
  3985. }
  3986. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  3987. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  3988. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  3989. case COMMAND_SKILL :
  3990. case COMMAND_SKILL_ADD :
  3991. case COMMAND_SKILL_REMOVE :
  3992. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  3993. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  3994. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  3995. case COMMAND_ENTITYCOMMAND :
  3996. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  3997. case COMMAND_MERCHANT :
  3998. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  3999. case COMMAND_APPEARANCE :
  4000. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  4001. case COMMAND_TRACK : { Command_Track(client); break; }
  4002. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  4003. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  4004. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  4005. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  4006. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  4007. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  4008. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  4009. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  4010. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  4011. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  4012. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  4013. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  4014. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  4015. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  4016. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  4017. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  4018. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  4019. case COMMAND_LOCATION : { Command_Location(client); break; }
  4020. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  4021. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  4022. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  4023. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  4024. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  4025. case COMMAND_GRID : { Command_Grid(client); break; }
  4026. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  4027. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  4028. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  4029. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  4030. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  4031. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  4032. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  4033. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  4034. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  4035. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  4036. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  4037. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  4038. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  4039. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  4040. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  4041. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  4042. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  4043. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  4044. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  4045. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  4046. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  4047. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  4048. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  4049. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  4050. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  4051. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  4052. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  4053. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  4054. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  4055. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  4056. case COMMAND_MOTD : { Command_MOTD(client); break; }
  4057. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  4058. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  4059. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  4060. case COMMAND_TITLE : { Command_Title(client); break; }
  4061. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  4062. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  4063. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  4064. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  4065. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  4066. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  4067. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  4068. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  4069. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  4070. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  4071. case COMMAND_PET : { Command_Pet(client, sep); break; }
  4072. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  4073. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  4074. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  4075. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  4076. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  4077. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  4078. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  4079. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  4080. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  4081. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  4082. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  4083. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  4084. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  4085. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  4086. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  4087. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  4088. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  4089. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  4090. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  4091. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  4092. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  4093. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  4094. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  4095. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  4096. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  4097. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  4098. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  4099. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  4100. case COMMAND_MODIFY : { Command_Modify(client); break; }
  4101. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  4102. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  4103. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  4104. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  4105. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  4106. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  4107. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  4108. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  4109. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  4110. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  4111. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  4112. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  4113. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  4114. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  4115. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  4116. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  4117. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  4118. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  4119. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  4120. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  4121. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  4122. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  4123. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  4124. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  4125. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  4126. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  4127. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  4128. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  4129. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  4130. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  4131. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  4132. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  4133. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  4134. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  4135. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  4136. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  4137. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  4138. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  4139. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  4140. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  4141. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  4142. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  4143. case ADD_AA : { Add_AA(client, sep); break; }
  4144. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  4145. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  4146. case BACK_AA : { Back_AA(client, sep); break; }
  4147. case REMOVE_AA : { Remove_AA(client, sep); break; }
  4148. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  4149. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  4150. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  4151. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  4152. default:
  4153. {
  4154. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  4155. break;
  4156. }
  4157. }
  4158. safe_delete(sep);
  4159. }
  4160. /******************** New COMMAND Handler Functions ********************/
  4161. /*
  4162. Started breaking apart the huge switch() for commands into sepErate
  4163. functions so it is easier to locate the blocks of code by command
  4164. -- JA 2012.03.03
  4165. */
  4166. // sample function header
  4167. /*
  4168. Function:
  4169. Purpose :
  4170. Params :
  4171. Dev :
  4172. Example :
  4173. */
  4174. //void Commands::Command()
  4175. //{
  4176. //}
  4177. /*
  4178. Function: Command_AcceptAdvancement()
  4179. Purpose : Player accepts a new advancement option
  4180. Params : Spell ID
  4181. Dev : Jabantiz
  4182. */
  4183. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4184. {
  4185. Player *player = client->GetPlayer();
  4186. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4187. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4188. if (!player->HasSpell(trait->spellID, 0, true))
  4189. {
  4190. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4191. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4192. }
  4193. else
  4194. {
  4195. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4196. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4197. player->RemoveSpellBookEntry(spell->GetSpellID());
  4198. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4199. player->UnlockSpell(spell);
  4200. client->SendSpellUpdate(spell);
  4201. }
  4202. // Spell book update
  4203. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4204. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4205. }
  4206. /*
  4207. Function:
  4208. Purpose :
  4209. Params :
  4210. Dev :
  4211. Example :
  4212. */
  4213. void Commands::Command_AFK(Client* client, Seperator* sep)
  4214. {
  4215. Player* player = client->GetPlayer();
  4216. player->toggle_character_flag(CF_AFK);
  4217. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4218. if (player->get_character_flag(CF_AFK))
  4219. {
  4220. //LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4221. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK);
  4222. if (sep && sep->argplus[0])
  4223. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4224. else
  4225. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4226. string message = string(player->GetName()) + " is going afk.";
  4227. Spawn* target = player->GetTarget();
  4228. if (target && target != player)
  4229. {
  4230. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4231. player->GetGender() == 1 ? message += "he" : message += "she";
  4232. message += " is going afk.";
  4233. }
  4234. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4235. }
  4236. else
  4237. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK);
  4238. }
  4239. /*
  4240. Function: Command_Appearance()
  4241. Purpose : Handles /appearance commands
  4242. Params : list
  4243. Dev : Scatman
  4244. Example : /appearance list
  4245. */
  4246. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4247. {
  4248. if( handler == COMMAND_APPEARANCE )
  4249. {
  4250. // /appearance command by itself shows help (to be extended)
  4251. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4252. return;
  4253. }
  4254. else if( handler == COMMAND_APPEARANCE_LIST )
  4255. {
  4256. // /appearance list command expects "name" param
  4257. if (sep && sep->arg[0])
  4258. {
  4259. const char* appearance_name = sep->argplus[0];
  4260. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4261. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4262. if (appearances)
  4263. {
  4264. vector<int16>::iterator itr;
  4265. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4266. {
  4267. int16 id = *itr;
  4268. string name = database.GetAppearanceName(id);
  4269. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4270. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4271. }
  4272. safe_delete(appearances);
  4273. }
  4274. }
  4275. else // no param
  4276. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4277. }
  4278. }
  4279. /*
  4280. Function: Command_Claim()
  4281. Purpose :
  4282. Params :
  4283. Dev :
  4284. Example :
  4285. */
  4286. void Commands::Command_Claim(Client* client, Seperator* sep)
  4287. {
  4288. if (sep && sep->arg[0] && sep->IsNumber(0))
  4289. {
  4290. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4291. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4292. }
  4293. else
  4294. client->ShowClaimWindow();
  4295. }
  4296. /*
  4297. Function: Command_ClearAllQueued()
  4298. Purpose :
  4299. Params :
  4300. Dev :
  4301. Example :
  4302. */
  4303. void Commands::Command_ClearAllQueued(Client* client)
  4304. {
  4305. ZoneServer* zone = client->GetPlayer()->GetZone();
  4306. if (zone && zone->GetSpellProcess())
  4307. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4308. }
  4309. /*
  4310. Function: Command_CancelMaintained()
  4311. Purpose : Cancels maintained spells
  4312. Params : Maintained Spell Index
  4313. Dev : Zcoretri
  4314. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4315. */
  4316. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4317. {
  4318. if (sep && sep->arg[0] && sep->IsNumber(0))
  4319. {
  4320. int32 spell_index = atoul(sep->arg[0]);
  4321. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4322. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4323. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4324. // just not spelleffects/dets - Foof
  4325. //{
  4326. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell))
  4327. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4328. // }
  4329. //else
  4330. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4331. }
  4332. }
  4333. /*
  4334. Function: Command_Create()
  4335. Purpose : Handler for starting Tradeskilling table
  4336. Params :
  4337. Dev : Zcoretri
  4338. Example :
  4339. */
  4340. void Commands::Command_Create(Client* client, Seperator* sep)
  4341. {
  4342. PrintSep(sep, "COMMAND_CREATE");
  4343. client->SendRecipeList();
  4344. client->ShowRecipeBook();
  4345. }
  4346. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4347. {
  4348. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4349. if (sep && sep->arg[0] && sep->IsNumber(0))
  4350. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4351. }
  4352. /*
  4353. Function: Command_Distance()
  4354. Purpose : Displays distance from targeted spawn
  4355. Params :
  4356. Dev : Scatman
  4357. Example : /distance
  4358. */
  4359. void Commands::Command_Distance(Client* client)
  4360. {
  4361. Spawn* target = client->GetPlayer()->GetTarget();
  4362. if (target)
  4363. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4364. else
  4365. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4366. }
  4367. /*
  4368. Function: Command_Duel()
  4369. Purpose : Handle the /duel commands - not yet implemented
  4370. Params : unknown
  4371. Dev :
  4372. Example :
  4373. */
  4374. void Commands::Command_Duel(Client* client, Seperator* sep)
  4375. {
  4376. PrintSep(sep, "COMMAND_DUEL");
  4377. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4378. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4379. }
  4380. /*
  4381. Function: Command_DuelBet()
  4382. Purpose : Handle the /duel commands - not yet implemented
  4383. Params : unknown
  4384. Dev :
  4385. Example :
  4386. */
  4387. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4388. {
  4389. PrintSep(sep, "COMMAND_DUELBET");
  4390. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4391. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4392. }
  4393. /*
  4394. Function: Command_DuelAccept()
  4395. Purpose : Handle the /duel commands - not yet implemented
  4396. Params : unknown
  4397. Dev :
  4398. Example :
  4399. */
  4400. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4401. {
  4402. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4403. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4404. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4405. }
  4406. /*
  4407. Function: Command_DuelDecline()
  4408. Purpose : Handle the /duel commands - not yet implemented
  4409. Params : unknown
  4410. Dev :
  4411. Example :
  4412. */
  4413. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4414. {
  4415. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4416. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4417. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4418. }
  4419. /*
  4420. Function: Command_DuelSurrender()
  4421. Purpose : Handle the /duel commands - not yet implemented
  4422. Params : unknown
  4423. Dev :
  4424. Example :
  4425. */
  4426. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4427. {
  4428. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4429. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4430. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4431. // JA, just messin around ;)
  4432. char surrender[64];
  4433. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4434. zone_list.HandleGlobalAnnouncement(surrender);
  4435. }
  4436. /*
  4437. Function: Command_DuelToggle()
  4438. Purpose : Handle the /duel commands - not yet implemented
  4439. Params : unknown
  4440. Dev :
  4441. Example :
  4442. */
  4443. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4444. {
  4445. PrintSep(sep, "COMMAND_DUEL");
  4446. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4447. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4448. }
  4449. /*
  4450. Function:
  4451. Purpose :
  4452. Params :
  4453. Dev :
  4454. Example :
  4455. */
  4456. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4457. {
  4458. if( handler == COMMAND_ENTITYCOMMAND )
  4459. {
  4460. // /entitycommand command by itself shows help (to be extended)
  4461. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4462. return;
  4463. }
  4464. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4465. {
  4466. // /entitycommand list command expects "name" param
  4467. if (sep && sep->arg[0])
  4468. {
  4469. const char* entity_command_name = sep->argplus[0];
  4470. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4471. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4472. map<int32, vector<EntityCommand*>*>::iterator itr;
  4473. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4474. {
  4475. vector<EntityCommand*>* entity_command_list = itr->second;
  4476. vector<EntityCommand*>::iterator itr2;
  4477. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4478. {
  4479. EntityCommand* entity_command = *itr2;
  4480. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4481. 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);
  4482. }
  4483. }
  4484. }
  4485. else // no command name
  4486. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4487. }
  4488. }
  4489. /*
  4490. Function: Command_Follow()
  4491. Purpose : Handle the /follow command - not yet implemented
  4492. Params :
  4493. Dev :
  4494. Example :
  4495. */
  4496. void Commands::Command_Follow(Client* client, Seperator* sep)
  4497. {
  4498. PrintSep(sep, "COMMAND_FOLLOW");
  4499. // flag to toggle if the players target is in the players group
  4500. bool targetInGroup = false;
  4501. // get a pointer to the players group
  4502. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4503. // If the player has a group and has a target
  4504. if (gmi && client->GetPlayer()->GetTarget()) {
  4505. deque<GroupMemberInfo*>::iterator itr;
  4506. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4507. deque<GroupMemberInfo*>* members = world.GetGroupManager()->GetGroupMembers(gmi->group_id);
  4508. // Loop through the group members
  4509. for (itr = members->begin(); itr != members->end(); itr++) {
  4510. // If a group member matches a target
  4511. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4512. // toggle the flag and break the loop
  4513. targetInGroup = true;
  4514. break;
  4515. }
  4516. }
  4517. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4518. }
  4519. if (targetInGroup) {
  4520. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4521. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4522. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4523. client->GetPlayer()->info_changed = true;
  4524. client->GetPlayer()->changed = true;
  4525. }
  4526. else
  4527. client->Message(CHANNEL_COLOR_WHITE, "You must first select a group member to follow.");
  4528. }
  4529. /*
  4530. Function: Command_StopFollow()
  4531. Purpose : Handle the /stop_follow command - not yet implemented
  4532. Params :
  4533. Dev :
  4534. Example :
  4535. */
  4536. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4537. {
  4538. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4539. if (client->GetPlayer()->GetFollowTarget()) {
  4540. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4541. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4542. client->GetPlayer()->SetFollowTarget(0);
  4543. client->GetPlayer()->info_changed = true;
  4544. client->GetPlayer()->changed = true;
  4545. }
  4546. }
  4547. #include "../Zone/SPGrid.h"
  4548. /*
  4549. Function: Command_Grid()
  4550. Purpose : Show player's current Grid ID
  4551. Params :
  4552. Dev : Scatman
  4553. Example : /grid
  4554. */
  4555. void Commands::Command_Grid(Client* client)
  4556. {
  4557. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4558. if (client->GetCurrentZone()->Grid != nullptr) {
  4559. int32 grid = client->GetCurrentZone()->Grid->GetGridID(client->GetPlayer());
  4560. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4561. }
  4562. }
  4563. /*
  4564. Function: Command_Guild()
  4565. Purpose : Handler for all UI-related guild commands
  4566. Dev : Scatman
  4567. */
  4568. void Commands::Command_Guild(Client* client, Seperator* sep)
  4569. {
  4570. Guild* guild = client->GetPlayer()->GetGuild();
  4571. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  4572. {
  4573. const char* command = sep->arg[0];
  4574. int32 length = strlen(command);
  4575. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4576. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4577. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4578. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4579. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4580. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4581. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4582. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4583. guild->KickGuildMember(client, sep->arg[1]);
  4584. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4585. guild->DemoteGuildMember(client, sep->arg[1]);
  4586. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4587. guild->PromoteGuildMember(client, sep->arg[1]);
  4588. else if (strncmp(command, "points", length) == 0 && guild)
  4589. {
  4590. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4591. {
  4592. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4593. {
  4594. float points = atof(sep->arg[2]);
  4595. const char* option = sep->arg[3];
  4596. const char* comment = sep->argplus[4];
  4597. if (strncmp(option, "all", strlen(option)) == 0)
  4598. guild->AddPointsToAll(client, points, comment);
  4599. else if (strncmp(option, "online", strlen(option)) == 0)
  4600. guild->AddPointsToAllOnline(client, points, comment);
  4601. else if (strncmp(option, "group", strlen(option)) == 0)
  4602. guild->AddPointsToGroup(client, points, comment);
  4603. else if (strncmp(option, "raid", strlen(option)) == 0)
  4604. guild->AddPointsToRaid(client, points, comment);
  4605. else
  4606. guild->AddPointsToGuildMember(client, points, option, comment);
  4607. }
  4608. }
  4609. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4610. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4611. else
  4612. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4613. }
  4614. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4615. guild->SetMOTD(sep->argplus[1]);
  4616. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4617. {
  4618. if (sep->arg[1])
  4619. {
  4620. const char* option = sep->arg[1];
  4621. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4622. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4623. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4624. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4625. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4626. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4627. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4628. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4629. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4630. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4631. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4632. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4633. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4634. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4635. else
  4636. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4637. }
  4638. else
  4639. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4640. }
  4641. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4642. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4643. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4644. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4645. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4646. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4647. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4648. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4649. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4650. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4651. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4652. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4653. else if (strncmp(command, "invite", length) == 0 && guild)
  4654. {
  4655. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4656. guild->InvitePlayer(client, sep->arg[1]);
  4657. else
  4658. {
  4659. Spawn* target = client->GetPlayer()->GetTarget();
  4660. if (target)
  4661. {
  4662. if (target->IsPlayer())
  4663. guild->InvitePlayer(client, target->GetName());
  4664. else
  4665. client->Message(CHANNEL_COLOR_WHITE, "%s is not a player.", target->GetName());
  4666. }
  4667. }
  4668. }
  4669. else if (strncmp(command, "accept", length) == 0)
  4670. {
  4671. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4672. if (pgi && pgi->guild && pgi->invited_by)
  4673. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4674. client->SetPendingGuildInvite(0);
  4675. }
  4676. else if (strncmp(command, "decline", length) == 0)
  4677. {
  4678. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4679. if (pgi && pgi->guild && pgi->invited_by)
  4680. {
  4681. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4682. if (client_inviter)
  4683. client_inviter->Message(CHANNEL_COLOR_WHITE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4684. }
  4685. client->SetPendingGuildInvite(0);
  4686. }
  4687. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4688. {
  4689. const char* guild_name = sep->argplus[1];
  4690. if (!guild_list.GetGuild(guild_name))
  4691. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  4692. else
  4693. client->SimpleMessage(CHANNEL_COLOR_WHITE, "A guild with that name already exists.");
  4694. }
  4695. else if (strncmp(command, "search", length) == 0)
  4696. client->ShowGuildSearchWindow();
  4697. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4698. {
  4699. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4700. if (to_guild)
  4701. to_guild->SendGuildRecruitingDetails(client);
  4702. }
  4703. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4704. {
  4705. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4706. if (to_guild)
  4707. to_guild->SendGuildRecruitingImages(client);
  4708. }
  4709. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4710. {
  4711. if (sep->arg[1])
  4712. {
  4713. const char* option = sep->arg[1];
  4714. if (strncmp(option, "toggle", strlen(option)) == 0)
  4715. guild->ToggleGuildRecruiterAdventureClass(client);
  4716. }
  4717. else
  4718. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4719. }
  4720. else if (strncmp(command, "display_heraldry", length) == 0)
  4721. {
  4722. // JA: not sure this is right...
  4723. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4724. client->GetPlayer()->SetCharSheetChanged(true);
  4725. }
  4726. else
  4727. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4728. }
  4729. }
  4730. /*
  4731. Function: Command_GuildCreate()
  4732. Purpose : Display's in-game Guild Creation window
  4733. Dev : Scatman
  4734. */
  4735. void Commands::Command_CreateGuild(Client* client)
  4736. {
  4737. client->SendGuildCreateWindow();
  4738. }
  4739. /*
  4740. Function: Command_SetGuildOfficerNote()
  4741. Purpose :
  4742. Dev : Scatman
  4743. */
  4744. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4745. {
  4746. if (sep && sep->arg[0] && sep->arg[1])
  4747. {
  4748. Guild* guild = client->GetPlayer()->GetGuild();
  4749. if (guild)
  4750. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4751. }
  4752. }
  4753. /*
  4754. Function: Command_SetGuildMemberNote()
  4755. Purpose :
  4756. Dev : Scatman
  4757. */
  4758. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4759. {
  4760. if (sep && sep->arg[0] && sep->arg[1])
  4761. {
  4762. Guild* guild = client->GetPlayer()->GetGuild();
  4763. if (guild)
  4764. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4765. }
  4766. }
  4767. /*
  4768. Function: Command_GuildSay()
  4769. Purpose :
  4770. Dev : Scatman
  4771. */
  4772. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4773. {
  4774. Guild* guild = client->GetPlayer()->GetGuild();
  4775. if (guild)
  4776. {
  4777. if (sep && sep->arg[0])
  4778. guild->HandleGuildSay(client, sep->argplus[0]);
  4779. }
  4780. else
  4781. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4782. }
  4783. /*
  4784. Function: Command_OfficerSay()
  4785. Purpose :
  4786. Dev : Scatman
  4787. */
  4788. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4789. {
  4790. Guild* guild = client->GetPlayer()->GetGuild();
  4791. if (guild)
  4792. {
  4793. if (sep && sep->arg[0])
  4794. guild->HandleOfficerSay(client, sep->argplus[0]);
  4795. }
  4796. else
  4797. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4798. }
  4799. /*
  4800. Function: Command_Guilds()
  4801. Purpose : Shows help for /guild command
  4802. Params :
  4803. Dev : Scatman
  4804. Example :
  4805. */
  4806. void Commands::Command_Guilds(Client* client)
  4807. {
  4808. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4809. }
  4810. /*
  4811. Function: Command_GuildsAdd()
  4812. Purpose : Add's players to a guild
  4813. Params : guild_name|guild_id, player name
  4814. Dev : Scatman
  4815. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4816. */
  4817. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4818. {
  4819. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4820. {
  4821. Guild* guild = 0;
  4822. bool found = true;
  4823. if (sep->IsNumber(0))
  4824. {
  4825. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4826. if (!guild)
  4827. {
  4828. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4829. found = false;
  4830. }
  4831. }
  4832. else
  4833. {
  4834. guild = guild_list.GetGuild(sep->arg[0]);
  4835. if (!guild)
  4836. {
  4837. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4838. found = false;
  4839. }
  4840. }
  4841. if (found)
  4842. {
  4843. Client* to_client = 0;
  4844. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4845. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4846. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4847. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4848. if (to_client)
  4849. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  4850. else
  4851. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4852. }
  4853. }
  4854. else
  4855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  4856. }
  4857. /*
  4858. Function: Command_GuildsCreate()
  4859. Purpose : Creates a guild
  4860. Params : guild_name, player_name (optional)
  4861. Dev : Scatman
  4862. Example : /guilds create [guild name] (player name)
  4863. */
  4864. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  4865. {
  4866. if (sep && sep->arg[0])
  4867. {
  4868. const char* guild_name = sep->arg[0];
  4869. if (!guild_list.GetGuild(guild_name))
  4870. {
  4871. bool ret = false;
  4872. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4873. {
  4874. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4875. if (to_client)
  4876. {
  4877. world.CreateGuild(guild_name, to_client);
  4878. ret = true;
  4879. }
  4880. else
  4881. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  4882. }
  4883. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4884. {
  4885. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4886. if (to_client)
  4887. {
  4888. world.CreateGuild(guild_name, to_client);
  4889. ret = true;
  4890. }
  4891. }
  4892. else
  4893. {
  4894. world.CreateGuild(guild_name);
  4895. ret = true;
  4896. }
  4897. if (ret)
  4898. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  4899. else
  4900. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  4901. }
  4902. else
  4903. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  4904. }
  4905. else
  4906. 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.");
  4907. }
  4908. /*
  4909. Function: Command_GuildsDelete()
  4910. Purpose : Delete's a guild
  4911. Params : guild name
  4912. Dev : Scatman
  4913. Example : /guilds delete Test
  4914. */
  4915. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  4916. {
  4917. if (sep && sep->arg[0])
  4918. {
  4919. Guild* guild = 0;
  4920. bool found = true;
  4921. if (sep->IsNumber(0))
  4922. {
  4923. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4924. if (!guild)
  4925. {
  4926. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4927. found = false;
  4928. }
  4929. }
  4930. else
  4931. {
  4932. guild = guild_list.GetGuild(sep->arg[0]);
  4933. if (!guild)
  4934. {
  4935. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4936. found = false;
  4937. }
  4938. }
  4939. if (found)
  4940. {
  4941. guild->RemoveAllGuildMembers();
  4942. database.DeleteGuild(guild);
  4943. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  4944. guild_list.RemoveGuild(guild, true);
  4945. }
  4946. }
  4947. else
  4948. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  4949. }
  4950. /*
  4951. Function: Command_GuildsList()
  4952. Purpose : Lists current guilds on server
  4953. Params :
  4954. Dev : Scatman
  4955. Example : /guilds list
  4956. */
  4957. void Commands::Command_GuildsList(Client* client)
  4958. {
  4959. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  4960. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  4961. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  4962. if (guilds->size() == 0)
  4963. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  4964. else {
  4965. while (itr.Next()) {
  4966. Guild* guild = itr.second;
  4967. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  4968. }
  4969. }
  4970. }
  4971. /*
  4972. Function: Command_GuildsRemove()
  4973. Purpose : Removes a player from a guild
  4974. Params : guild name|guild id, player name
  4975. Dev : Scatman
  4976. Example : /guilds remove 1 Admin = removes Admin from guild 1
  4977. */
  4978. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  4979. {
  4980. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4981. {
  4982. Guild* guild = 0;
  4983. bool found = true;
  4984. if (sep->IsNumber(0))
  4985. {
  4986. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4987. if (!guild)
  4988. {
  4989. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4990. found = false;
  4991. }
  4992. }
  4993. else
  4994. {
  4995. guild = guild_list.GetGuild(sep->arg[0]);
  4996. if (!guild)
  4997. {
  4998. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4999. found = false;
  5000. }
  5001. }
  5002. if (found)
  5003. {
  5004. Client* to_client = 0;
  5005. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5006. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5007. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5008. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5009. if (to_client)
  5010. {
  5011. Player* to_player = to_client->GetPlayer();
  5012. if (to_player->GetGuild())
  5013. {
  5014. if (to_player->GetGuild() == guild)
  5015. {
  5016. guild->KickGuildMember(client, to_player->GetName());
  5017. }
  5018. else
  5019. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  5020. }
  5021. else
  5022. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  5023. }
  5024. else
  5025. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5026. }
  5027. }
  5028. else
  5029. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  5030. }
  5031. /*
  5032. Function: Command_InspectPlayer()
  5033. Purpose : Handle the Inspect functions
  5034. Params : Client to inspect
  5035. Dev : Scatman
  5036. Example : /inspect Scatman
  5037. */
  5038. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  5039. {
  5040. if (sep && sep->arg[0])
  5041. {
  5042. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  5043. if (inspect_client)
  5044. client->InspectPlayer(inspect_client->GetPlayer());
  5045. }
  5046. else
  5047. {
  5048. Spawn* target = client->GetPlayer()->GetTarget();
  5049. if (target && target->IsPlayer())
  5050. client->InspectPlayer((Player*)target);
  5051. }
  5052. }
  5053. /*
  5054. Function: Command_Inventory()
  5055. Purpose : Handle changes in player inventory
  5056. Params : <TBD>
  5057. Dev : All
  5058. Example : /inventory delete item_id
  5059. */
  5060. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  5061. {
  5062. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  5063. Player* player = client->GetPlayer();
  5064. if(sep && sep->arg[0][0])
  5065. {
  5066. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  5067. if(client->GetPlayer()->GetHP() == 0)
  5068. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  5069. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5070. {
  5071. int16 index = atoi(sep->arg[1]);
  5072. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5073. if(item)
  5074. {
  5075. if(item->GetItemScript() && lua_interface)
  5076. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  5077. int32 bag_id = item->details.inv_slot_id;
  5078. database.DeleteItem(client->GetCharacterID(), item, 0);
  5079. client->GetPlayer()->item_list.DestroyItem(index);
  5080. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  5081. client->QueuePacket(outapp);
  5082. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  5083. if (outapp)
  5084. client->QueuePacket(outapp);
  5085. }
  5086. }
  5087. 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))
  5088. {
  5089. int16 from_index = atoi(sep->arg[1]);
  5090. sint16 to_slot = atoi(sep->arg[2]);
  5091. sint32 bag_id = atol(sep->arg[3]);
  5092. int8 charges = atoi(sep->arg[4]);
  5093. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  5094. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  5095. {
  5096. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  5097. return;
  5098. }
  5099. sint32 old_inventory_id = 0;
  5100. if(item)
  5101. old_inventory_id = item->details.inv_slot_id;
  5102. //autobank
  5103. if (bag_id == -3 && to_slot == -1)
  5104. {
  5105. if (player->HasFreeBankSlot())
  5106. to_slot = player->FindFreeBankSlot();
  5107. else
  5108. {
  5109. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  5110. return;
  5111. }
  5112. }
  5113. //auto inventory
  5114. if (bag_id == 0 && to_slot == -1)
  5115. {
  5116. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5117. {
  5118. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  5119. return;
  5120. }
  5121. }
  5122. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  5123. client->QueuePacket(outapp);
  5124. //removed from bag send update
  5125. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  5126. {
  5127. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  5128. if(outapp)
  5129. client->QueuePacket(outapp);
  5130. }
  5131. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  5132. {
  5133. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  5134. if(outapp)
  5135. client->QueuePacket(outapp);
  5136. }
  5137. }
  5138. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  5139. {
  5140. if(client->GetPlayer()->EngagedInCombat())
  5141. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  5142. else
  5143. {
  5144. int16 index = atoi(sep->arg[1]);
  5145. int8 slot_id = 255;
  5146. if(sep->arg[2][0] && sep->IsNumber(2))
  5147. slot_id = atoi(sep->arg[2]);
  5148. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  5149. EQ2Packet* outapp = 0;
  5150. for(int32 i=0;i<packets.size();i++)
  5151. {
  5152. outapp = packets[i];
  5153. if(outapp)
  5154. client->QueuePacket(outapp);
  5155. }
  5156. client->GetPlayer()->ChangePrimaryWeapon();
  5157. client->GetPlayer()->ChangeSecondaryWeapon();
  5158. client->GetPlayer()->ChangeRangedWeapon();
  5159. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5160. client->QueuePacket(characterSheetPackets);
  5161. }
  5162. }
  5163. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5164. {
  5165. if (client->GetPlayer()->EngagedInCombat())
  5166. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5167. else {
  5168. int16 index = atoi(sep->arg[1]);
  5169. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5170. if (item) {
  5171. // client->GetPlayer()->item_list.DestroyItem(index);
  5172. if (item->item_sets.size() > 0) {
  5173. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5174. ItemSet* set = item->item_sets[i];
  5175. if (set->item_stack_size == 0)
  5176. set->item_stack_size += 1;
  5177. client->AddItem(set->item_id, set->item_stack_size);
  5178. }
  5179. }
  5180. }
  5181. client->RemoveItem(item, 1);
  5182. }
  5183. }
  5184. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5185. {
  5186. if(client->GetPlayer()->EngagedInCombat())
  5187. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5188. else
  5189. {
  5190. int16 index = atoi(sep->arg[1]);
  5191. sint32 bag_id = -999;
  5192. int8 to_slot = 255;
  5193. if(sep->arg[3][0])
  5194. {
  5195. if(sep->IsNumber(2))
  5196. bag_id = atol(sep->arg[2]);
  5197. if(sep->IsNumber(3))
  5198. to_slot = atoi(sep->arg[3]);
  5199. }
  5200. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  5201. EQ2Packet* outapp = 0;
  5202. for(int32 i=0;i<packets.size();i++)
  5203. {
  5204. outapp = packets[i];
  5205. if(outapp)
  5206. client->QueuePacket(outapp);
  5207. }
  5208. client->GetPlayer()->ChangePrimaryWeapon();
  5209. client->GetPlayer()->ChangeSecondaryWeapon();
  5210. client->GetPlayer()->ChangeRangedWeapon();
  5211. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5212. client->QueuePacket(characterSheetPackets);
  5213. }
  5214. }
  5215. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5216. {
  5217. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5218. int16 index1 = atoi(sep->arg[1]);
  5219. int16 index2 = atoi(sep->arg[2]);
  5220. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  5221. if(outapp)
  5222. client->QueuePacket(outapp);
  5223. else
  5224. {
  5225. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5226. return;
  5227. }
  5228. }
  5229. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5230. {
  5231. sint16 to_slot = atoi(sep->arg[1]);
  5232. sint32 bag_id = atoi(sep->arg[2]);
  5233. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5234. if (item) {
  5235. //auto inventory
  5236. if (bag_id == 0 && to_slot == -1)
  5237. {
  5238. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5239. {
  5240. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5241. return;
  5242. }
  5243. // Set the slot for the item
  5244. item->details.inv_slot_id = bag_id;
  5245. item->details.slot_id = to_slot;
  5246. // Flag the item so it gets saved in its new location
  5247. item->save_needed = true;
  5248. // Add the item to its new location
  5249. player->item_list.AddItem(item);
  5250. // Remove the item from the overflow list
  5251. player->item_list.RemoveOverflowItem(item);
  5252. // Send the inventory update packet
  5253. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5254. return;
  5255. }
  5256. else if (bag_id == -3 && to_slot == -1) {
  5257. // Auto Bank
  5258. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5259. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5260. return;
  5261. }
  5262. item->details.inv_slot_id = bag_id;
  5263. item->details.slot_id = to_slot;
  5264. item->save_needed = true;
  5265. player->item_list.AddItem(item);
  5266. player->item_list.RemoveOverflowItem(item);
  5267. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5268. }
  5269. else if (bag_id == -4) {
  5270. // Shared Bank
  5271. if (!player->item_list.SharedBankAddAllowed(item)) {
  5272. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5273. return;
  5274. }
  5275. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5276. if (tmp_item) {
  5277. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5278. return;
  5279. }
  5280. else {
  5281. item->details.inv_slot_id = bag_id;
  5282. item->details.slot_id = to_slot;
  5283. item->save_needed = true;
  5284. player->item_list.AddItem(item);
  5285. player->item_list.RemoveOverflowItem(item);
  5286. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5287. return;
  5288. }
  5289. }
  5290. else {
  5291. // Try to get an item from the given bag id and slot id
  5292. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5293. // Check to see if we got an item, if we do send an error,
  5294. // if we don't put the overflow item into this slot
  5295. if (tmp_item) {
  5296. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5297. }
  5298. else {
  5299. item->details.inv_slot_id = bag_id;
  5300. item->details.slot_id = to_slot;
  5301. item->save_needed = true;
  5302. player->item_list.AddItem(item);
  5303. player->item_list.RemoveOverflowItem(item);
  5304. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5305. return;
  5306. }
  5307. }
  5308. }
  5309. }
  5310. }
  5311. else
  5312. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5313. }
  5314. /*
  5315. Function: Command_IRC()
  5316. Purpose : Handle the IRC functions
  5317. Params : IRC Commands
  5318. Dev : Scatman
  5319. Example : /irc say #Channel Hello World!
  5320. */
  5321. void Commands::Command_IRC(Client* client, Seperator* sep)
  5322. {
  5323. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5324. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5325. return;
  5326. }
  5327. if (sep && sep->arg[0][0]) {
  5328. if (strcasecmp(sep->arg[0], "say") == 0) {
  5329. if (sep->arg[1][0] && sep->arg[2][0]) {
  5330. if (sep->IsNumber(sep->arg[1]))
  5331. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5332. else
  5333. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5334. }
  5335. else
  5336. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5337. }
  5338. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5339. if (sep->arg[1][0])
  5340. irc.JoinChannel(client, sep->arg[1]);
  5341. else
  5342. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5343. }
  5344. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5345. if (sep->arg[1][0])
  5346. irc.LeaveChannel(client, sep->arg[1]);
  5347. else
  5348. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5349. }
  5350. else if (strcasecmp(sep->arg[0], "list") == 0)
  5351. irc.ListChannels(client);
  5352. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5353. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5354. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5355. else
  5356. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5357. }
  5358. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5359. irc.DisconnectFromServer(client);
  5360. else
  5361. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5362. }
  5363. else
  5364. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5365. }
  5366. /*
  5367. Function: Command_Languages()
  5368. Purpose : Show's languages the player knows
  5369. Params :
  5370. Dev : Zcoretri
  5371. Example :
  5372. */
  5373. void Commands::Command_Languages(Client* client, Seperator* sep)
  5374. {
  5375. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5376. list<Language*>::iterator itr;
  5377. Language* language;
  5378. client->Message(CHANNEL_COLOR_WHITE, "You know the following languages:");
  5379. for(itr = languages->begin(); itr != languages->end(); itr++)
  5380. {
  5381. language = *itr;
  5382. client->Message(CHANNEL_COLOR_WHITE, "%s", language->GetName());
  5383. }
  5384. }
  5385. /*
  5386. Function: Command_SetLanguage()
  5387. Purpose : Handles language commands
  5388. Params : Language ID
  5389. Dev : Zcoretri
  5390. Example :
  5391. */
  5392. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5393. {
  5394. Player* player = client->GetPlayer();
  5395. if (sep && sep->arg[0])
  5396. {
  5397. if(!sep->IsNumber(0))
  5398. {
  5399. //String passed in
  5400. const char* value = sep->arg[0];
  5401. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5402. {
  5403. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5404. client->SendLanguagesUpdate(0);
  5405. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", value);
  5406. }
  5407. else
  5408. {
  5409. if(player->HasLanguage(value))
  5410. {
  5411. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5412. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5413. client->SendLanguagesUpdate(language->GetID());
  5414. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5415. }
  5416. else
  5417. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", value);
  5418. }
  5419. }
  5420. else
  5421. {
  5422. //Number passed in
  5423. int32 id = atoul(sep->arg[0]);
  5424. if(player->HasLanguage(id))
  5425. {
  5426. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5427. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5428. client->SendLanguagesUpdate(id);
  5429. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5430. }
  5431. else
  5432. {
  5433. Language* language = master_languages_list.GetLanguage(id);
  5434. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", language->GetName());
  5435. }
  5436. }
  5437. }
  5438. else
  5439. {
  5440. //No value was passed in
  5441. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5442. if(id > 0)
  5443. {
  5444. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5445. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking %s ", language->GetName());
  5446. }
  5447. else
  5448. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking Common");
  5449. }
  5450. }
  5451. /*
  5452. Function: Command_LastName()
  5453. Purpose : Sets player surname
  5454. Params : Name text
  5455. Dev : theFoof
  5456. Example :
  5457. */
  5458. void Commands::Command_LastName(Client* client, Seperator* sep)
  5459. {
  5460. if (!client)
  5461. return;
  5462. if (sep && sep->arg[0])
  5463. {
  5464. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5465. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5466. return;
  5467. }
  5468. client->RemovePendingLastName();
  5469. uchar* checkname = (uchar*)sep->arg[0];
  5470. bool valid_name = true;
  5471. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5472. if (!alpha_check(checkname[i])) {
  5473. valid_name = false;
  5474. break;
  5475. }
  5476. }
  5477. if (!valid_name) {
  5478. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5479. return;
  5480. }
  5481. string last_name = (string)sep->arg[0];
  5482. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5483. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5484. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5485. client->SetPendingLastName(last_name);
  5486. client->SendLastNameConfirmation();
  5487. }
  5488. else
  5489. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5490. }
  5491. }
  5492. /*
  5493. Function: Command_ConfirmLastName()
  5494. Purpose : Confirms setting of player surname
  5495. Params : Name text
  5496. Dev : theFoof
  5497. Example :
  5498. */
  5499. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5500. {
  5501. if (!client)
  5502. return;
  5503. string* name = client->GetPendingLastName();
  5504. if (name){
  5505. Player* player = client->GetPlayer();
  5506. player->SetLastName(name->c_str(), false);
  5507. client->SendTitleUpdate();
  5508. player->SetCharSheetChanged(true);
  5509. client->RemovePendingLastName();
  5510. }
  5511. }
  5512. /*
  5513. Function: Command_Location()
  5514. Purpose : Display's Help for /location commands
  5515. Params :
  5516. Dev : Scatman
  5517. Example : /location = show's help for command
  5518. */
  5519. void Commands::Command_Location(Client* client)
  5520. {
  5521. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5522. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5523. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5524. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5525. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5526. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5527. }
  5528. /*
  5529. Function: Command_LocationAdd()
  5530. Purpose : Add's a location to an existing location config
  5531. Params : location_id
  5532. Dev : Scatman
  5533. Example : /location add {location_id}
  5534. */
  5535. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5536. {
  5537. if (sep && sep->arg[0] && sep->IsNumber(0))
  5538. {
  5539. int32 location_id = atoul(sep->arg[0]);
  5540. float x = client->GetPlayer()->GetX();
  5541. float y = client->GetPlayer()->GetY();
  5542. float z = client->GetPlayer()->GetZ();
  5543. if (database.AddLocationPoint(location_id, x, y, z))
  5544. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5545. else
  5546. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5547. }
  5548. else
  5549. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5550. }
  5551. /*
  5552. Function: Command_LocationCreate()
  5553. Purpose : Creates a new location config
  5554. Params : location name, 0/1 for include_y (optional)
  5555. Dev : Scatman
  5556. Example : /location create Test 1 = creates a new location named Test with include_y True
  5557. */
  5558. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5559. {
  5560. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5561. {
  5562. const char* name = sep->arg[0];
  5563. bool include_y = false;
  5564. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5565. include_y = true;
  5566. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5567. if (location_id > 0)
  5568. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5569. else
  5570. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5571. }
  5572. else
  5573. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5574. }
  5575. /*
  5576. Function: Command_LocationDelete()
  5577. Purpose : Delete's a location config and all it's location points
  5578. Params : location_id
  5579. Dev : Scatman
  5580. Example : /location delete {location_id}
  5581. */
  5582. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5583. {
  5584. if (sep && sep->arg[0] && sep->IsNumber(0))
  5585. {
  5586. int32 location_id = atoul(sep->arg[0]);
  5587. if (database.DeleteLocation(location_id))
  5588. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5589. else
  5590. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5591. }
  5592. else
  5593. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5594. }
  5595. /*
  5596. Function: Command_LocationList()
  5597. Purpose : Display's a list of location points
  5598. Params : location_id
  5599. Dev : Scatman
  5600. Example : /location list {location_id}
  5601. */
  5602. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5603. {
  5604. if (sep && sep->arg[0])
  5605. {
  5606. const char* option = sep->arg[0];
  5607. if (strncmp(option, "locations", strlen(option)) == 0)
  5608. database.ListLocations(client);
  5609. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5610. {
  5611. int32 location_id = atoul(sep->arg[1]);
  5612. database.ListLocationPoints(client, location_id);
  5613. }
  5614. else
  5615. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5616. }
  5617. else
  5618. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5619. }
  5620. /*
  5621. Function: Command_LocationRemove()
  5622. Purpose : Removes a single location point from a location config
  5623. Params : location_point_id (gotten from /location list {id})
  5624. Dev : Scatman
  5625. Example : /location remove 1 = will remove location_point_id 1
  5626. */
  5627. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5628. {
  5629. if (sep && sep->arg[0] && sep->IsNumber(0))
  5630. {
  5631. int32 location_point_id = atoul(sep->arg[0]);
  5632. if (database.DeleteLocationPoint(location_point_id))
  5633. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5634. else
  5635. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5636. }
  5637. else
  5638. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5639. }
  5640. /*
  5641. Function: Command_Merchant()
  5642. Purpose : Handles Merchant commands
  5643. Params : list
  5644. Dev : Scatman
  5645. Example : /merchant list
  5646. */
  5647. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5648. {
  5649. if( handler == COMMAND_MERCHANT )
  5650. {
  5651. // /merchant command by itself shows help (to be extended)
  5652. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5653. return;
  5654. }
  5655. else if( handler == COMMAND_MERCHANT_LIST )
  5656. {
  5657. // /merchant list command expects "description" param
  5658. if (sep && sep->arg[0])
  5659. {
  5660. const char* merchant_description = sep->argplus[0];
  5661. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5662. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5663. map<int32, MerchantInfo*>::iterator itr;
  5664. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5665. {
  5666. string description = database.GetMerchantDescription(itr->first);
  5667. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5668. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5669. }
  5670. }
  5671. else // no description
  5672. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5673. }
  5674. }
  5675. /*
  5676. Function: Command_Modify()
  5677. Purpose : to replace our other "set" commands
  5678. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5679. Dev : John Adams
  5680. Example : /modify spell set name "Aegolism III"
  5681. */
  5682. void Commands::Command_Modify(Client* client)
  5683. {
  5684. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5685. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5686. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5687. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5688. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5689. }
  5690. /*
  5691. Function: Command_ModifySpawn()
  5692. Purpose : replace "spawn set" commands
  5693. Params : Action : the action to perform (or special handler)
  5694. : Field : the DB field to change
  5695. : Value : what to set the value to
  5696. : Target : what object to change (my target, or spawn_id)
  5697. Dev : John Adams
  5698. Example : /modify spawn set name "Lady Vox"
  5699. :
  5700. Note : Special Handlers, like "zoneto" for Signs
  5701. : /modify spawn zoneto
  5702. : Will set a sign's zone x/y/z to my current coords
  5703. */
  5704. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5705. {
  5706. PrintSep(sep, "COMMAND_MODIFY");
  5707. // need at least 2 args for a valid command
  5708. if( sep && sep->arg[1] )
  5709. {
  5710. // JA: just a quick implementation because I need it :)
  5711. if (strcmp(sep->arg[0], "zoneto") == 0)
  5712. {
  5713. if( sep->IsNumber(1) )
  5714. {
  5715. int32 spawn_id = atoul(sep->arg[1]);
  5716. float x_coord = client->GetPlayer()->GetX();
  5717. float y_coord = client->GetPlayer()->GetY();
  5718. float z_coord = client->GetPlayer()->GetZ();
  5719. float h_coord = client->GetPlayer()->GetHeading();
  5720. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5721. }
  5722. else
  5723. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5724. }
  5725. }
  5726. else
  5727. Command_Modify(client);
  5728. }
  5729. /*
  5730. Function: Command_ModifyCharacter()
  5731. Purpose : to replace our other "set" commands
  5732. Params : Action : Add, Remove
  5733. : Field : copper, silver, gold, plat
  5734. : Value : min 1, max unlimited
  5735. : Target : Self, Player
  5736. Dev : Cynnar
  5737. Example : /modify character add gold 50
  5738. : /modify character remove silver 25
  5739. */
  5740. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5741. {
  5742. PrintSep(sep, "COMMAND_MODIFY");
  5743. int64 value = 0;
  5744. Player* player = client->GetPlayer();
  5745. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5746. player = (Player*)player->GetTarget();
  5747. // need at least 2 args for a valid command
  5748. if( sep && sep->arg[1] )
  5749. {
  5750. if (strcmp(sep->arg[0], "add") == 0)
  5751. {
  5752. if (strcmp(sep->arg[1], "copper") == 0)
  5753. {
  5754. value = atoi64(sep->arg[2]);
  5755. player->AddCoins(value);
  5756. if (client->GetPlayer() == player)
  5757. {
  5758. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5759. }
  5760. else {
  5761. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5762. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5763. }
  5764. }
  5765. else if (strcmp(sep->arg[1], "silver") == 0)
  5766. {
  5767. value = atoi64(sep->arg[2]) * 100;
  5768. player->AddCoins(value);
  5769. if (client->GetPlayer() == player)
  5770. {
  5771. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5772. }
  5773. else {
  5774. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5775. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5776. }
  5777. }
  5778. else if (strcmp(sep->arg[1], "gold") == 0)
  5779. {
  5780. value = atoi64(sep->arg[2]) * 10000;
  5781. player->AddCoins(value);
  5782. if (client->GetPlayer() == player)
  5783. {
  5784. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5785. }
  5786. else {
  5787. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5788. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5789. }
  5790. }
  5791. else if (strcmp(sep->arg[1], "plat") == 0)
  5792. {
  5793. value = atoi64(sep->arg[2]) * 1000000;
  5794. player->AddCoins(value);
  5795. if (client->GetPlayer() == player)
  5796. {
  5797. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5798. }
  5799. else {
  5800. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5801. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5802. }
  5803. }
  5804. else
  5805. {
  5806. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5807. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5808. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5809. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5810. }
  5811. }
  5812. else if (strcmp(sep->arg[0], "remove") == 0)
  5813. {
  5814. if (strcmp(sep->arg[1], "copper") == 0)
  5815. {
  5816. value = atoi64(sep->arg[2]);
  5817. player->RemoveCoins(value);
  5818. if (client->GetPlayer() == player)
  5819. {
  5820. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5821. }
  5822. else {
  5823. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5824. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5825. }
  5826. }
  5827. else if (strcmp(sep->arg[1], "silver") == 0)
  5828. {
  5829. value = atoi64(sep->arg[2]) * 100;
  5830. player->RemoveCoins(value);
  5831. if (client->GetPlayer() == player)
  5832. {
  5833. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5834. }
  5835. else {
  5836. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5837. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5838. }
  5839. }
  5840. else if (strcmp(sep->arg[1], "gold") == 0)
  5841. {
  5842. value = atoi64(sep->arg[2]) * 10000;
  5843. player->RemoveCoins(value);
  5844. if (client->GetPlayer() == player)
  5845. {
  5846. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  5847. }
  5848. else {
  5849. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  5850. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5851. }
  5852. }
  5853. else if (strcmp(sep->arg[1], "plat") == 0)
  5854. {
  5855. value = atoi64(sep->arg[2]) * 1000000;
  5856. player->RemoveCoins(value);
  5857. if (client->GetPlayer() == player)
  5858. {
  5859. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  5860. }
  5861. else {
  5862. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  5863. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5864. }
  5865. }
  5866. else
  5867. {
  5868. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5869. }
  5870. }
  5871. else if (strcmp(sep->arg[0], "set") == 0) {
  5872. if (strcmp(sep->arg[1], "tslevel") == 0) {
  5873. int8 level = atoi(sep->arg[2]);
  5874. if (level > 0 && level < 256) {
  5875. if (player) {
  5876. if (client->GetPlayer() == player)
  5877. client->ChangeTSLevel(player->GetTSLevel(), level);
  5878. else
  5879. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  5880. }
  5881. }
  5882. else
  5883. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  5884. }
  5885. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  5886. int8 tsclass = atoi(sep->arg[2]);
  5887. player->SetTradeskillClass(tsclass);
  5888. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  5889. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  5890. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  5891. player->SetCharSheetChanged(true);
  5892. }
  5893. }
  5894. }
  5895. else
  5896. {
  5897. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5898. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5899. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5900. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5901. }
  5902. }
  5903. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  5904. {
  5905. PrintSep(sep, "COMMAND_MODIFY");
  5906. // need at least 2 args for a valid command
  5907. if( sep && sep->arg[1] )
  5908. {
  5909. }
  5910. else
  5911. Command_Modify(client);
  5912. }
  5913. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  5914. {
  5915. PrintSep(sep, "COMMAND_MODIFY");
  5916. // need at least 2 args for a valid command
  5917. if( sep && sep->arg[1] )
  5918. {
  5919. }
  5920. else
  5921. Command_Modify(client);
  5922. }
  5923. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  5924. {
  5925. PrintSep(sep, "COMMAND_MODIFY");
  5926. // need at least 2 args for a valid command
  5927. if( sep && sep->arg[1] )
  5928. {
  5929. }
  5930. else
  5931. Command_Modify(client);
  5932. }
  5933. /*
  5934. Function: Command_ModifyQuest()
  5935. Purpose : to list players quest and completed quests
  5936. Params : Action : list, completed
  5937. : Target : Self, Player
  5938. Dev : Cynnar
  5939. Example : /modify quest list
  5940. : /modify quest completed
  5941. */
  5942. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  5943. {
  5944. PrintSep(sep, "COMMAND_MODIFY");
  5945. int64 value = 0;
  5946. Player* player = client->GetPlayer();
  5947. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5948. player = (Player*)player->GetTarget();
  5949. // need at least 2 args for a valid command
  5950. if (sep && sep->arg[1])
  5951. {
  5952. if (strcmp(sep->arg[0], "list") == 0)
  5953. {
  5954. map<int32, Quest*>* quests = player->GetPlayerQuests();
  5955. map<int32, Quest*>::iterator itr;
  5956. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  5957. if (quests->size() == 0)
  5958. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  5959. else
  5960. {
  5961. for (itr = quests->begin(); itr != quests->end(); itr++)
  5962. {
  5963. Quest* quest = itr->second;
  5964. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5965. }
  5966. }
  5967. }
  5968. else if (strcmp(sep->arg[0], "completed") == 0)
  5969. {
  5970. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  5971. map<int32, Quest*>::iterator itr;
  5972. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  5973. if (quests->size() == 0)
  5974. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  5975. else
  5976. {
  5977. for (itr = quests->begin(); itr != quests->end(); itr++)
  5978. {
  5979. Quest* quest = itr->second;
  5980. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5981. }
  5982. }
  5983. }
  5984. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  5985. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  5986. else if (strcmp(sep->arg[0], "remove") == 0)
  5987. {
  5988. int32 quest_id = 0;
  5989. if (sep && sep->arg[1] && sep->IsNumber(1))
  5990. quest_id = atoul(sep->arg[1]);
  5991. if (quest_id > 0)
  5992. {
  5993. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  5994. {
  5995. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5996. if (quest)
  5997. if (client->GetPlayer() == player)
  5998. {
  5999. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  6000. }
  6001. else
  6002. {
  6003. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  6004. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  6005. }
  6006. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  6007. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  6008. }
  6009. client->RemovePlayerQuest(quest_id);
  6010. client->GetCurrentZone()->SendQuestUpdates(client);
  6011. }
  6012. }
  6013. else if (strcmp(sep->arg[0], "advance") == 0)
  6014. {
  6015. int32 quest_id = 0;
  6016. int32 step = 0;
  6017. if (sep && sep->arg[1] && sep->IsNumber(1))
  6018. {
  6019. quest_id = atoul(sep->arg[1]);
  6020. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6021. if (sep && sep->arg[2] && sep->IsNumber(1))
  6022. {
  6023. step = atoul(sep->arg[2]);
  6024. if (quest_id > 0 && step > 0)
  6025. {
  6026. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  6027. {
  6028. if (client)
  6029. {
  6030. client->AddPendingQuestUpdate(quest_id, step);
  6031. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  6032. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  6033. }
  6034. }
  6035. }
  6036. else
  6037. {
  6038. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  6039. }
  6040. }
  6041. else
  6042. {
  6043. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  6044. }
  6045. }
  6046. else
  6047. {
  6048. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  6049. }
  6050. }
  6051. else
  6052. {
  6053. Command_Modify(client);
  6054. }
  6055. }
  6056. else
  6057. {
  6058. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  6059. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  6060. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  6061. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  6062. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  6063. }
  6064. }
  6065. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  6066. {
  6067. PrintSep(sep, "COMMAND_MODIFY");
  6068. // need at least 2 args for a valid command
  6069. if( sep && sep->arg[1] )
  6070. {
  6071. if (strcmp(sep->arg[0], "add") == 0) {
  6072. const char* skill_name = sep->argplus[1];
  6073. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6074. if (skill) {
  6075. Player* player = 0;
  6076. Client* to_client = 0;
  6077. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6078. player = (Player*)client->GetPlayer()->GetTarget();
  6079. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6080. }
  6081. else {
  6082. player = client->GetPlayer();
  6083. to_client = client;
  6084. }
  6085. if (player)
  6086. {
  6087. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6088. {
  6089. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6090. if (to_client == client) {
  6091. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  6092. }
  6093. else {
  6094. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6095. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6096. }
  6097. }
  6098. else
  6099. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  6100. }
  6101. }
  6102. else
  6103. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6104. }
  6105. else if (strcmp(sep->arg[0], "remove") == 0) {
  6106. const char* skill_name = sep->argplus[1];
  6107. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6108. if (skill) {
  6109. Player* player = 0;
  6110. Client* to_client = 0;
  6111. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6112. player = (Player*)client->GetPlayer()->GetTarget();
  6113. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6114. }
  6115. else {
  6116. player = client->GetPlayer();
  6117. to_client = client;
  6118. }
  6119. if (player)
  6120. {
  6121. if (player->GetSkills()->HasSkill(skill->skill_id))
  6122. {
  6123. player->RemoveSkillFromDB(skill, true);
  6124. if (client == to_client) {
  6125. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  6126. }
  6127. else {
  6128. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6129. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6130. }
  6131. }
  6132. else {
  6133. if (client == to_client)
  6134. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  6135. else
  6136. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6137. }
  6138. }
  6139. }
  6140. else
  6141. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6142. }
  6143. else if (strcmp(sep->arg[0], "set") == 0) {
  6144. if (!sep->IsNumber(2)) {
  6145. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  6146. return;
  6147. }
  6148. const char* skill_name = sep->arg[1];
  6149. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6150. if (skill) {
  6151. int16 val = atoi(sep->arg[2]);
  6152. Player* player = 0;
  6153. Client* to_client = 0;
  6154. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6155. player = (Player*)client->GetPlayer()->GetTarget();
  6156. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6157. }
  6158. else {
  6159. player = client->GetPlayer();
  6160. to_client = client;
  6161. }
  6162. if (player)
  6163. {
  6164. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6165. player->GetSkills()->SetSkill(skill->skill_id, val);
  6166. if (client != to_client)
  6167. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6168. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6169. }
  6170. else {
  6171. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6172. }
  6173. }
  6174. }
  6175. else {
  6176. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6177. }
  6178. }
  6179. else {
  6180. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6181. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6182. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6183. }
  6184. }
  6185. else {
  6186. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6187. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6188. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6189. }
  6190. }
  6191. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6192. {
  6193. PrintSep(sep, "COMMAND_MODIFY");
  6194. // need at least 2 args for a valid command
  6195. if( sep && sep->arg[1] )
  6196. {
  6197. }
  6198. else
  6199. Command_Modify(client);
  6200. }
  6201. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6202. {
  6203. PrintSep(sep, "COMMAND_MODIFY");
  6204. // need at least 2 args for a valid command
  6205. if( sep && sep->arg[1] )
  6206. {
  6207. }
  6208. else
  6209. Command_Modify(client);
  6210. }
  6211. /*
  6212. Function: Command_MOTD()
  6213. Purpose : Displays server MOTD
  6214. Params :
  6215. Dev : LethalEncounter
  6216. Example : /motd
  6217. */
  6218. void Commands::Command_MOTD(Client* client)
  6219. {
  6220. if (client)
  6221. ClientPacketFunctions::SendMOTD(client);
  6222. }
  6223. /*
  6224. Function: Command_Pet()
  6225. Purpose : Handle Pet {Command} commands
  6226. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6227. Dev :
  6228. Example : /pet preserve_master
  6229. */
  6230. void Commands::Command_Pet(Client* client, Seperator* sep)
  6231. {
  6232. PrintSep(sep, "COMMAND_PET");
  6233. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6234. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6235. if (strcmp(sep->arg[0], "hide") == 0) {
  6236. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6237. Entity* pet = client->GetPlayer()->GetDeityPet();
  6238. if (pet) {
  6239. if (pet->IsPrivateSpawn())
  6240. client->GetPlayer()->HideDeityPet(false);
  6241. else
  6242. client->GetPlayer()->HideDeityPet(true);
  6243. }
  6244. pet = client->GetPlayer()->GetCosmeticPet();
  6245. if (pet) {
  6246. if (pet->IsPrivateSpawn())
  6247. client->GetPlayer()->HideCosmeticPet(false);
  6248. else
  6249. client->GetPlayer()->HideCosmeticPet(true);
  6250. }
  6251. return;
  6252. }
  6253. // below is for all combat pets
  6254. if (!client->GetPlayer()->HasPet()) {
  6255. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6256. return;
  6257. }
  6258. if (strcmp(sep->arg[0], "stay") == 0) {
  6259. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6260. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  6261. client->GetPlayer()->SetCharSheetChanged(true);
  6262. if (client->GetPlayer()->GetPet())
  6263. client->GetPlayer()->GetPet()->following = false;
  6264. if (client->GetPlayer()->GetCharmedPet())
  6265. client->GetPlayer()->GetCharmedPet()->following = false;
  6266. }
  6267. else if (strcmp(sep->arg[0], "follow") == 0) {
  6268. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6269. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  6270. client->GetPlayer()->SetCharSheetChanged(true);
  6271. }
  6272. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6273. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  6274. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6275. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  6276. }
  6277. else {
  6278. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6279. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  6280. }
  6281. client->GetPlayer()->SetCharSheetChanged(true);
  6282. }
  6283. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6284. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  6285. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6286. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  6287. }
  6288. else {
  6289. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6290. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  6291. }
  6292. client->GetPlayer()->SetCharSheetChanged(true);
  6293. }
  6294. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6295. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6296. if (client->GetPlayer()->GetPet())
  6297. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6298. if (client->GetPlayer()->GetCharmedPet())
  6299. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6300. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  6301. client->GetPlayer()->SetCharSheetChanged(true);
  6302. }
  6303. else if (strcmp(sep->arg[0], "attack") == 0) {
  6304. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6305. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6306. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6307. if (client->GetPlayer()->GetPet())
  6308. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6309. if (client->GetPlayer()->GetCharmedPet())
  6310. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6311. }
  6312. else
  6313. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6314. }
  6315. else
  6316. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6317. }
  6318. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6319. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6320. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6321. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6322. }
  6323. else
  6324. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6325. }
  6326. /*
  6327. Function: Command_PetName()
  6328. Purpose : Pet your name (???)
  6329. Params :
  6330. Dev :
  6331. Example :
  6332. */
  6333. void Commands::Command_PetName(Client* client, Seperator* sep)
  6334. {
  6335. PrintSep(sep, "COMMAND_PETNAME");
  6336. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6337. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6338. }
  6339. /*
  6340. Function: Command_NamePet()
  6341. Purpose : Name your pet
  6342. Params :
  6343. Dev :
  6344. Example :
  6345. */
  6346. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6347. {
  6348. PrintSep(sep, "COMMAND_NAME_PET");
  6349. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6350. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6351. }
  6352. /*
  6353. Function: Command_Rename()
  6354. Purpose : Renames existing pet
  6355. Params :
  6356. Dev :
  6357. Example :
  6358. */
  6359. void Commands::Command_Rename(Client* client, Seperator* sep)
  6360. {
  6361. PrintSep(sep, "COMMAND_RENAME");
  6362. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6363. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6364. }
  6365. /*
  6366. Function: Command_ConfirmRename()
  6367. Purpose : Confirms renaming your pet
  6368. Params :
  6369. Dev :
  6370. Example :
  6371. */
  6372. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6373. {
  6374. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6375. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6376. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6377. }
  6378. /*
  6379. Function: Command_PetOptions()
  6380. Purpose : Sets various pet options
  6381. Params :
  6382. Dev :
  6383. Example :
  6384. */
  6385. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6386. {
  6387. PrintSep(sep, "COMMAND_PETOPTIONS");
  6388. Player* player = client->GetPlayer();
  6389. Spawn* target = player->GetTarget();
  6390. if (!target)
  6391. return;
  6392. if (target == player->GetPet())
  6393. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6394. else if (target == player->GetCharmedPet())
  6395. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6396. else if (target == player->GetCosmeticPet())
  6397. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6398. else if (target == player->GetDeityPet())
  6399. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6400. }
  6401. /*
  6402. Function: Command_Random()
  6403. Purpose : Handles /random dice roll in-game
  6404. Params : 1-100
  6405. Dev : Scatman
  6406. Example : /randon 1 100
  6407. */
  6408. void Commands::Command_Random(Client* client, Seperator* sep)
  6409. {
  6410. char message[256] = {0};
  6411. if (sep)
  6412. {
  6413. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6414. 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])));
  6415. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6416. 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])));
  6417. else
  6418. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6419. }
  6420. else
  6421. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6422. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6423. }
  6424. /*
  6425. Function: Command_Randomize()
  6426. Purpose : Sets randomize (appearance) values for NPCs
  6427. Params : Attrib Name
  6428. Dev : Scatman
  6429. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6430. */
  6431. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6432. {
  6433. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6434. if (target)
  6435. {
  6436. if (target->IsNPC())
  6437. {
  6438. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6439. {
  6440. const char* value = sep->arg[0];
  6441. if (strncasecmp(value, "show", strlen(value)) == 0)
  6442. {
  6443. client->DisplayRandomizeFeatures(target->GetRandomize());
  6444. }
  6445. else
  6446. {
  6447. if (sep->arg[1] && sep->IsNumber(1))
  6448. {
  6449. int8 option = atoi(sep->arg[1]);
  6450. if (option == 0 || option == 1)
  6451. {
  6452. int32 feature = 0;
  6453. char feature_text[32] = {0};
  6454. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6455. feature = RANDOMIZE_GENDER;
  6456. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6457. }
  6458. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6459. feature = RANDOMIZE_RACE;
  6460. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6461. }
  6462. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6463. feature = RANDOMIZE_MODEL_TYPE;
  6464. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6465. }
  6466. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6467. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6468. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6469. }
  6470. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6471. feature = RANDOMIZE_HAIR_TYPE;
  6472. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6473. }
  6474. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6475. feature = RANDOMIZE_WING_TYPE;
  6476. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6477. }
  6478. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6479. feature = RANDOMIZE_CHEEK_TYPE;
  6480. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6481. }
  6482. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6483. feature = RANDOMIZE_CHIN_TYPE;
  6484. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6485. }
  6486. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6487. feature = RANDOMIZE_EAR_TYPE;
  6488. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6489. }
  6490. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6491. feature = RANDOMIZE_EYE_BROW_TYPE;
  6492. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6493. }
  6494. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6495. feature = RANDOMIZE_EYE_TYPE;
  6496. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6497. }
  6498. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6499. feature = RANDOMIZE_LIP_TYPE;
  6500. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6501. }
  6502. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6503. feature = RANDOMIZE_NOSE_TYPE;
  6504. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6505. }
  6506. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6507. feature = RANDOMIZE_EYE_COLOR;
  6508. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6509. }
  6510. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6511. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6512. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6513. }
  6514. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6515. feature = RANDOMIZE_HAIR_COLOR1;
  6516. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6517. }
  6518. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6519. feature = RANDOMIZE_HAIR_COLOR2;
  6520. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6521. }
  6522. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6523. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6524. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6525. }
  6526. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6527. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6528. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6529. }
  6530. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6531. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6532. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6533. }
  6534. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6535. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6536. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6537. }
  6538. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6539. feature = RANDOMIZE_SKIN_COLOR;
  6540. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6541. }
  6542. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6543. feature = RANDOMIZE_WING_COLOR1;
  6544. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6545. }
  6546. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6547. feature = RANDOMIZE_WING_COLOR2;
  6548. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6549. }
  6550. else {
  6551. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6552. 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'.");
  6553. }
  6554. if (feature > 0) {
  6555. if (option == 1) {
  6556. if (target->GetRandomize() & feature)
  6557. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6558. else {
  6559. target->AddRandomize(feature);
  6560. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6561. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6562. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6563. }
  6564. }
  6565. else {
  6566. if (target->GetRandomize() & feature) {
  6567. target->AddRandomize(-feature);
  6568. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6569. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6570. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6571. }
  6572. else
  6573. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6574. }
  6575. }
  6576. }
  6577. else
  6578. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6579. }
  6580. else
  6581. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6582. }
  6583. }
  6584. else {
  6585. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6586. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6587. 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'.");
  6588. }
  6589. }
  6590. else
  6591. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6592. }
  6593. else
  6594. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6595. }
  6596. /*
  6597. Function: Command_ShowCloak()
  6598. Purpose : Character Settings combo box for Show Cloak
  6599. Params : true/false
  6600. Dev : John Adams
  6601. Example :
  6602. */
  6603. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6604. {
  6605. Player* player = client->GetPlayer();
  6606. if (sep && sep->arg[0])
  6607. {
  6608. const char* value = sep->arg[0];
  6609. if (strncasecmp(value, "true", strlen(value)) == 0)
  6610. {
  6611. player->set_character_flag(CF_SHOW_CLOAK);
  6612. player->reset_character_flag(CF2_SHOW_RANGED);
  6613. }
  6614. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6615. player->reset_character_flag(CF_SHOW_CLOAK);
  6616. else
  6617. {
  6618. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6619. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6620. }
  6621. }
  6622. }
  6623. /*
  6624. Function: Command_ShowHelm()
  6625. Purpose : Character Settings combo box for Show Helm
  6626. Params : true/false
  6627. Dev : John Adams
  6628. Example :
  6629. */
  6630. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6631. {
  6632. Player* player = client->GetPlayer();
  6633. if (sep && sep->arg[0])
  6634. {
  6635. const char* value = sep->arg[0];
  6636. if (strncasecmp(value, "true", strlen(value)) == 0)
  6637. {
  6638. player->reset_character_flag(CF_HIDE_HELM);
  6639. player->set_character_flag(CF_HIDE_HOOD);
  6640. }
  6641. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6642. player->set_character_flag(CF_HIDE_HELM);
  6643. else
  6644. {
  6645. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6646. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6647. }
  6648. }
  6649. }
  6650. /*
  6651. Function: Command_ShowHood()
  6652. Purpose : Character Settings combo box for Show Hood
  6653. Params : true/false
  6654. Dev : John Adams
  6655. Example :
  6656. */
  6657. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6658. {
  6659. Player* player = client->GetPlayer();
  6660. if (sep && sep->arg[0])
  6661. {
  6662. const char* value = sep->arg[0];
  6663. if (strncasecmp(value, "true", strlen(value)) == 0)
  6664. {
  6665. player->reset_character_flag(CF_HIDE_HOOD);
  6666. player->set_character_flag(CF_HIDE_HELM);
  6667. }
  6668. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6669. player->set_character_flag(CF_HIDE_HOOD);
  6670. else
  6671. {
  6672. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6673. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6674. }
  6675. }
  6676. }
  6677. /*
  6678. Function: Command_ShowHoodHelm()
  6679. Purpose : Character Settings combo box for Show Helm or Hood
  6680. Params : true/false
  6681. Dev : John Adams
  6682. Example :
  6683. */
  6684. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6685. {
  6686. Player* player = client->GetPlayer();
  6687. if (sep && sep->arg[0])
  6688. {
  6689. const char* value = sep->arg[0];
  6690. if (strncasecmp(value, "true", strlen(value)) == 0)
  6691. {
  6692. player->reset_character_flag(CF_HIDE_HOOD);
  6693. player->reset_character_flag(CF_HIDE_HELM);
  6694. }
  6695. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6696. {
  6697. // don't think we ever wind up in here...
  6698. player->set_character_flag(CF_HIDE_HOOD);
  6699. player->set_character_flag(CF_HIDE_HELM);
  6700. }
  6701. else
  6702. {
  6703. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6704. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6705. }
  6706. }
  6707. }
  6708. /*
  6709. Function: Command_ShowRanged()
  6710. Purpose : Character Settings combo box for Show Ranged weapon
  6711. Params : true/false
  6712. Dev : John Adams
  6713. Example :
  6714. */
  6715. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6716. {
  6717. Player* player = client->GetPlayer();
  6718. if (sep && sep->arg[0])
  6719. {
  6720. const char* value = sep->arg[0];
  6721. if (strncasecmp(value, "true", strlen(value)) == 0)
  6722. {
  6723. player->set_character_flag(CF2_SHOW_RANGED);
  6724. player->reset_character_flag(CF_SHOW_CLOAK);
  6725. }
  6726. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6727. player->reset_character_flag(CF2_SHOW_RANGED);
  6728. else
  6729. {
  6730. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6731. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6732. }
  6733. }
  6734. }
  6735. /*
  6736. Function:
  6737. Purpose :
  6738. Params :
  6739. Dev :
  6740. Example :
  6741. */
  6742. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6743. {
  6744. Player* player = 0;
  6745. Client* to_client = 0;
  6746. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6747. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6748. switch(handler)
  6749. {
  6750. case COMMAND_SKILL:
  6751. {
  6752. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6753. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6754. break;
  6755. }
  6756. case COMMAND_SKILL_ADD:
  6757. {
  6758. if (sep && sep->arg[0])
  6759. {
  6760. const char* skill_name = sep->argplus[0];
  6761. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6762. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6763. {
  6764. player = to_client->GetPlayer();
  6765. if (player)
  6766. {
  6767. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6768. {
  6769. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6770. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6771. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6772. }
  6773. else
  6774. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6775. }
  6776. }
  6777. else if (skill) // add skill to yourself
  6778. {
  6779. player = client->GetPlayer();
  6780. if (player)
  6781. {
  6782. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6783. {
  6784. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6785. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6786. }
  6787. else
  6788. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6789. }
  6790. }
  6791. else
  6792. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6793. }
  6794. else
  6795. {
  6796. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6797. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6798. }
  6799. break;
  6800. }
  6801. case COMMAND_SKILL_REMOVE:
  6802. {
  6803. if (sep && sep->arg[0])
  6804. {
  6805. const char* skill_name = sep->argplus[0];
  6806. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6807. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6808. {
  6809. player = to_client->GetPlayer();
  6810. if (player)
  6811. {
  6812. if (player->GetSkills()->HasSkill(skill->skill_id))
  6813. {
  6814. player->RemoveSkillFromDB(skill, true);
  6815. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6816. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6817. }
  6818. else
  6819. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6820. }
  6821. }
  6822. else if(skill) // remove skill from yourself
  6823. {
  6824. Player* player = client->GetPlayer();
  6825. if (player)
  6826. {
  6827. if (player->GetSkills()->HasSkill(skill->skill_id))
  6828. {
  6829. player->RemoveSkillFromDB(skill, true);
  6830. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6831. }
  6832. else
  6833. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6834. }
  6835. }
  6836. else
  6837. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6838. }
  6839. else
  6840. {
  6841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  6842. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6843. }
  6844. break;
  6845. }
  6846. case COMMAND_SKILL_LIST:
  6847. {
  6848. if (sep && sep->arg[0])
  6849. {
  6850. const char* skill_name = sep->argplus[0];
  6851. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  6852. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  6853. map<int32, Skill*>::iterator itr;
  6854. if (skills && skills->size() > 0)
  6855. {
  6856. for (itr = skills->begin(); itr != skills->end(); itr++)
  6857. {
  6858. Skill* skill = itr->second;
  6859. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  6860. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  6861. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  6862. }
  6863. }
  6864. }
  6865. else
  6866. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  6867. break;
  6868. }
  6869. }
  6870. }
  6871. /*
  6872. Function: Command_SpawnTemplate()
  6873. Purpose : Create or Use defined Spawn Templates
  6874. Params : create, save, rempve, list
  6875. Dev : John Adams
  6876. Example : /spawn template create "Test"
  6877. */
  6878. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  6879. {
  6880. if (sep == NULL || sep->arg[0] == NULL)
  6881. {
  6882. 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.");
  6883. return;
  6884. }
  6885. // got params, continue
  6886. const char * template_cmd = sep->arg[0];
  6887. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  6888. {
  6889. if (!sep->IsSet(1))
  6890. {
  6891. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  6892. 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.");
  6893. return;
  6894. }
  6895. map<int32, string>* template_names = 0;
  6896. if (sep->IsNumber(1))
  6897. {
  6898. int32 location_id = 0;
  6899. location_id = atoi(sep->arg[1]);
  6900. template_names = database.GetSpawnTemplateListByID(location_id);
  6901. }
  6902. else
  6903. {
  6904. const char* name = 0;
  6905. name = sep->argplus[1];
  6906. template_names = database.GetSpawnTemplateListByName(name);
  6907. }
  6908. if(!template_names)
  6909. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  6910. else
  6911. {
  6912. map<int32, string>::iterator itr;
  6913. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  6914. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  6915. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  6916. safe_delete(template_names);
  6917. }
  6918. }
  6919. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  6920. {
  6921. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6922. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  6923. {
  6924. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  6925. {
  6926. // first, lookup to see if template name already exists
  6927. const char* name = 0;
  6928. name = sep->argplus[1];
  6929. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  6930. if(!template_names)
  6931. {
  6932. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  6933. if( new_template_id > 0 )
  6934. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  6935. else
  6936. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  6937. }
  6938. else
  6939. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  6940. }
  6941. else
  6942. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  6943. }
  6944. else
  6945. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  6946. }
  6947. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  6948. {
  6949. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  6950. {
  6951. int32 template_id = 0;
  6952. template_id = atoi(sep->arg[1]);
  6953. if (database.RemoveSpawnTemplate(template_id))
  6954. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  6955. else
  6956. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  6957. }
  6958. else
  6959. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  6960. }
  6961. // Renamed create to spawn
  6962. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  6963. {
  6964. if (sep && sep->arg[1][0])
  6965. {
  6966. int32 new_location = 0;
  6967. if (sep->IsNumber(1))
  6968. {
  6969. int32 template_id = 0;
  6970. template_id = atoi(sep->arg[1]);
  6971. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  6972. if( new_location > 0 )
  6973. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  6974. else
  6975. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  6976. }
  6977. else
  6978. {
  6979. const char* name = 0;
  6980. name = sep->argplus[1];
  6981. new_location = database.CreateSpawnFromTemplateByName(client, name);
  6982. if( new_location > 0 )
  6983. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  6984. else
  6985. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  6986. }
  6987. }
  6988. else
  6989. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  6990. }
  6991. else
  6992. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  6993. }
  6994. void Commands::Command_Speed(Client* client, Seperator* sep) {
  6995. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  6996. float new_speed = atof(sep->arg[0]);
  6997. if (new_speed > 0.0f)
  6998. {
  6999. client->GetPlayer()->SetSpeed(new_speed, true);
  7000. client->GetPlayer()->SetCharSheetChanged(true);
  7001. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  7002. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  7003. }
  7004. else
  7005. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  7006. }
  7007. else{
  7008. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  7009. }
  7010. }
  7011. /*
  7012. Function: Command_StationMarketPlace()
  7013. Purpose : just trying to eat the console spam for now
  7014. Params :
  7015. Dev : John
  7016. */
  7017. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  7018. {
  7019. PrintSep(sep, "COMMAND_SMP");
  7020. // This will reduce the spam from once every 10 sec to once every 30 sec,
  7021. // can't seem to reduce it any more get rid of it completely...
  7022. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  7023. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  7024. if (packet) {
  7025. packet->setDataByName("account_id", client->GetAccountID());
  7026. packet->setDataByName("character_id", client->GetCharacterID());
  7027. packet->setDataByName("unknown1", 1, 5);
  7028. packet->setDataByName("unknown1", 26, 6);
  7029. packet->setDataByName("unknown2", 0xFFFFFFFF);
  7030. packet->setDataByName("unknown3", 248, 1);
  7031. client->QueuePacket(packet->serialize());
  7032. }
  7033. safe_delete(packet);
  7034. }
  7035. }
  7036. /*
  7037. Function: Command_StopDrinking()
  7038. Purpose : Stops player from auto-consuming drink
  7039. Params :
  7040. Dev : Zcoretri
  7041. Example : /stopdrinking
  7042. */
  7043. void Commands::Command_StopDrinking(Client* client)
  7044. {
  7045. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  7046. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  7047. }
  7048. /*
  7049. Function: Command_StopEating()
  7050. Purpose : Stops player from auto-consuming food
  7051. Params :
  7052. Dev : Zcoretri
  7053. Example : /stopeating
  7054. */
  7055. void Commands::Command_StopEating(Client* client)
  7056. {
  7057. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  7058. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  7059. }
  7060. /*
  7061. Function: Command_Title()
  7062. Purpose : Help for /title command
  7063. Params : n/a
  7064. Dev : Zcoretri
  7065. Example : /title
  7066. */
  7067. void Commands::Command_Title(Client* client)
  7068. {
  7069. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  7070. }
  7071. /*
  7072. Function: Command_TitleList()
  7073. Purpose : List available titles for player
  7074. Params : n/a
  7075. Dev : Zcoretri
  7076. Example : /title list
  7077. */
  7078. void Commands::Command_TitleList(Client* client)
  7079. {
  7080. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  7081. list<Title*>::iterator itr;
  7082. Title* title;
  7083. int16 i = 0;
  7084. client->Message(CHANNEL_COLOR_WHITE, "Listing available titles:");
  7085. for(itr = titles->begin(); itr != titles->end(); itr++)
  7086. {
  7087. title = *itr;
  7088. client->Message(CHANNEL_COLOR_WHITE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  7089. i++;
  7090. }
  7091. }
  7092. /*
  7093. Function: Command_TitleSetPrefix()
  7094. Purpose : Set Prefix title for player
  7095. Params : Title ID
  7096. Dev : Zcoretri
  7097. Example : /title setprefix 1
  7098. */
  7099. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  7100. {
  7101. if (sep && sep->arg[0] && sep->IsNumber(0))
  7102. {
  7103. int32 index = atoul(sep->arg[0]);
  7104. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  7105. client->SendTitleUpdate();
  7106. }
  7107. }
  7108. /*
  7109. Function: Command_TitleSetSuffix()
  7110. Purpose : Set Suffix title for player
  7111. Params : Title ID
  7112. Dev : Zcoretri
  7113. Example : /title setsuffix 1
  7114. */
  7115. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  7116. {
  7117. if (sep && sep->arg[0] && sep->IsNumber(0))
  7118. {
  7119. int32 index = atoul(sep->arg[0]);
  7120. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  7121. client->SendTitleUpdate();
  7122. }
  7123. }
  7124. /*
  7125. Function: Command_TitleFix()
  7126. Purpose : Fix title for player (???)
  7127. Params :
  7128. Dev : Zcoretri
  7129. Example :
  7130. */
  7131. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  7132. {
  7133. PrintSep(sep, "COMMAND_TITLE_FIX");
  7134. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  7135. }
  7136. /*
  7137. Function: Command_Toggle_Anonymous()
  7138. Purpose : Toggles player Anonymous
  7139. Params :
  7140. Dev : paulgh
  7141. Example : /anon
  7142. */
  7143. void Commands::Command_Toggle_Anonymous(Client* client)
  7144. {
  7145. Player* player = client->GetPlayer();
  7146. player->toggle_character_flag(CF_ANONYMOUS);
  7147. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  7148. if (player->get_character_flag(CF_ANONYMOUS))
  7149. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  7150. else
  7151. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  7152. }
  7153. /*
  7154. Function: Command_Toggle_AutoConsume()
  7155. Purpose : Toggles player food/drink auto consume
  7156. Params : unknown
  7157. Dev : paulgh
  7158. Example : /set_auto_consume
  7159. */
  7160. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7161. {
  7162. Player* player = client->GetPlayer();
  7163. if (sep && sep->arg[0])
  7164. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7165. if (sep && sep->arg[0] && sep->IsNumber(0))
  7166. {
  7167. int8 slot = atoi(sep->arg[0]);
  7168. int8 flag = atoi(sep->arg[1]);
  7169. if (slot == EQ2_FOOD_SLOT)
  7170. {
  7171. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7172. player->SetCharSheetChanged(true);
  7173. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7174. if (flag == 1)
  7175. client->Message(CHANNEL_COLOR_WHITE, "You decide to eat immediately whenever you become hungry.");
  7176. else
  7177. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the hunger.");
  7178. }
  7179. else
  7180. {
  7181. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7182. player->SetCharSheetChanged(true);
  7183. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7184. if (flag == 1)
  7185. client->Message(CHANNEL_COLOR_WHITE, "You decide to drink immediately whenever you become thirsty.");
  7186. else
  7187. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the thirst.");
  7188. }
  7189. }
  7190. }
  7191. /*
  7192. Function: Command_Toggle_BonusXP()
  7193. Purpose : Toggles player Bonus XP
  7194. Params :
  7195. Dev : John Adams
  7196. Example : /disable_char_bonus_exp
  7197. */
  7198. void Commands::Command_Toggle_BonusXP(Client* client)
  7199. {
  7200. Player* player = client->GetPlayer();
  7201. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7202. player->SetCharSheetChanged(true);
  7203. }
  7204. /*
  7205. Function: Command_Toggle_CombatXP()
  7206. Purpose : Toggles player Adventure XP
  7207. Params :
  7208. Dev : John Adams
  7209. Example : /disable_combat_exp
  7210. */
  7211. void Commands::Command_Toggle_CombatXP(Client* client)
  7212. {
  7213. Player* player = client->GetPlayer();
  7214. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7215. player->SetCharSheetChanged(true);
  7216. }
  7217. /*
  7218. Function: Command_Toggle_GMHide()
  7219. Purpose : Toggles hiding player GM status
  7220. Params :
  7221. Dev : Scatman
  7222. Example : /gm_hide
  7223. */
  7224. void Commands::Command_Toggle_GMHide(Client* client)
  7225. {
  7226. Player* player = client->GetPlayer();
  7227. player->toggle_character_flag(CF_HIDE_STATUS);
  7228. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7229. }
  7230. /*
  7231. Function: Command_Toggle_GMVanish()
  7232. Purpose : Toggles hiding GM players from /who searches
  7233. Params :
  7234. Dev : Scatman
  7235. Example : /gm_vanish
  7236. */
  7237. void Commands::Command_Toggle_GMVanish(Client* client)
  7238. {
  7239. Player* player = client->GetPlayer();
  7240. player->toggle_character_flag(CF_GM_HIDDEN);
  7241. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7242. }
  7243. /*
  7244. Function: Command_Toggle_Illusions()
  7245. Purpose : Toggles player illusion form
  7246. Params : not sure sep is needed, testing
  7247. Dev : paulgh
  7248. Example : /hide_illusions
  7249. */
  7250. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7251. {
  7252. if (sep && sep->arg[0])
  7253. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7254. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7255. }
  7256. /*
  7257. Function: Command_Toggle_LFG()
  7258. Purpose : Toggles player LFG Flag
  7259. Params :
  7260. Dev : paulgh
  7261. Example : /lfg
  7262. */
  7263. void Commands::Command_Toggle_LFG(Client* client)
  7264. {
  7265. Player* player = client->GetPlayer();
  7266. player->toggle_character_flag(CF_LFG);
  7267. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7268. if (player->get_character_flag(CF_LFG))
  7269. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7270. else
  7271. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7272. }
  7273. /*
  7274. Function: Command_Toggle_LFW()
  7275. Purpose : Toggles player LFW Flag
  7276. Params :
  7277. Dev : paulgh
  7278. Example : /lfw
  7279. */
  7280. void Commands::Command_Toggle_LFW(Client* client)
  7281. {
  7282. Player* player = client->GetPlayer();
  7283. player->toggle_character_flag(CF_LFW);
  7284. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7285. if (player->get_character_flag(CF_LFW))
  7286. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7287. else
  7288. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7289. }
  7290. /*
  7291. Function: Command_Toggle_QuestXP()
  7292. Purpose : Toggles player Quest XP
  7293. Params :
  7294. Dev : John Adams
  7295. Example : /disable_quest_exp
  7296. */
  7297. void Commands::Command_Toggle_QuestXP(Client* client)
  7298. {
  7299. Player* player = client->GetPlayer();
  7300. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7301. player->SetCharSheetChanged(true);
  7302. }
  7303. /*
  7304. Function: Command_Toggle_Roleplaying()
  7305. Purpose : Toggles player Roleplaying flag
  7306. Params :
  7307. Dev : paulgh
  7308. Example : /role
  7309. */
  7310. void Commands::Command_Toggle_Roleplaying(Client* client)
  7311. {
  7312. Player* player = client->GetPlayer();
  7313. player->toggle_character_flag(CF_ROLEPLAYING);
  7314. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  7315. if (player->get_character_flag(CF_ROLEPLAYING))
  7316. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  7317. else
  7318. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  7319. }
  7320. void Commands::Command_Toggle_Duels(Client* client)
  7321. {
  7322. Player* player = client->GetPlayer();
  7323. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7324. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7325. }
  7326. void Commands::Command_Toggle_Trades(Client* client)
  7327. {
  7328. Player* player = client->GetPlayer();
  7329. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7330. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7331. }
  7332. void Commands::Command_Toggle_Guilds(Client* client)
  7333. {
  7334. Player* player = client->GetPlayer();
  7335. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7336. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7337. }
  7338. void Commands::Command_Toggle_Groups(Client* client)
  7339. {
  7340. Player* player = client->GetPlayer();
  7341. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7342. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7343. }
  7344. void Commands::Command_Toggle_Raids(Client* client)
  7345. {
  7346. Player* player = client->GetPlayer();
  7347. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7348. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7349. }
  7350. void Commands::Command_Toggle_LON(Client* client)
  7351. {
  7352. Player* player = client->GetPlayer();
  7353. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7354. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7355. }
  7356. void Commands::Command_Toggle_VoiceChat(Client* client)
  7357. {
  7358. Player* player = client->GetPlayer();
  7359. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7360. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7361. }
  7362. /*
  7363. Function: Command_TradeStart()
  7364. Purpose : Starts item/coin trade between players
  7365. Params :
  7366. Dev :
  7367. Example :
  7368. */
  7369. #include "../Trade.h"
  7370. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7371. {
  7372. PrintSep(sep, "COMMAND_START_TRADE");
  7373. Entity* trader = client->GetPlayer();
  7374. Entity* trader2 = 0;
  7375. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7376. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7377. if (spawn) {
  7378. if (spawn->IsEntity())
  7379. trader2 = (Entity*)spawn;
  7380. }
  7381. }
  7382. else if (client->GetPlayer()->GetTarget()) {
  7383. if (client->GetPlayer()->GetTarget()->IsEntity())
  7384. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7385. }
  7386. // can only trade with player or bots
  7387. if (trader && trader2) {
  7388. if (trader == trader2) {
  7389. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7390. }
  7391. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7392. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7393. if (trader->trade)
  7394. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7395. else if (trader2->trade)
  7396. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7397. else {
  7398. Trade* trade = new Trade(trader, trader2);
  7399. trader->trade = trade;
  7400. trader2->trade = trade;
  7401. }
  7402. }
  7403. else {
  7404. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  7405. }
  7406. }
  7407. else
  7408. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  7409. }
  7410. /*
  7411. Function: Command_Track()
  7412. Purpose : Starts/Stops Tracking for a player
  7413. Params :
  7414. Dev : Scatman
  7415. Example : /track
  7416. */
  7417. void Commands::Command_Track(Client* client)
  7418. {
  7419. if (!client->GetPlayer()->GetIsTracking())
  7420. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7421. else
  7422. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7423. }
  7424. /*
  7425. Function: Command_TradeAccept()
  7426. Purpose : Accepts item/coin trade between players
  7427. Params :
  7428. Dev :
  7429. Example :
  7430. */
  7431. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7432. {
  7433. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7434. Trade* trade = client->GetPlayer()->trade;
  7435. if (trade) {
  7436. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7437. if (trade_complete)
  7438. safe_delete(trade);
  7439. }
  7440. else
  7441. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7442. }
  7443. /*
  7444. Function: Command_TradeReject()
  7445. Purpose : Rejects item/coin trade between players
  7446. Params :
  7447. Dev :
  7448. Example :
  7449. */
  7450. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7451. {
  7452. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7453. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7454. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7455. }
  7456. /*
  7457. Function: Command_TradeCancel()
  7458. Purpose : Cancels item/coin trade between players
  7459. Params :
  7460. Dev :
  7461. Example :
  7462. */
  7463. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7464. {
  7465. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7466. Trade* trade = client->GetPlayer()->trade;
  7467. if (trade) {
  7468. trade->CancelTrade(client->GetPlayer());
  7469. safe_delete(trade);
  7470. }
  7471. else
  7472. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7473. }
  7474. /*
  7475. Function: Command_TradeSetCoin()
  7476. Purpose : Sets coin trade between players
  7477. Params :
  7478. Dev :
  7479. Example :
  7480. */
  7481. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7482. {
  7483. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7484. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7485. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7486. }
  7487. /*
  7488. Function: Command_TradeAddCoin()
  7489. Purpose : Adds coin to trade between players
  7490. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7491. Dev :
  7492. Example :
  7493. */
  7494. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7495. {
  7496. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7497. Trade* trade = client->GetPlayer()->trade;
  7498. if (trade) {
  7499. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7500. int32 amount = atoi(sep->arg[0]);
  7501. int64 val = 0;
  7502. switch (handler) {
  7503. case COMMAND_ADD_TRADE_COPPER:
  7504. {
  7505. val = amount;
  7506. trade->AddCoinToTrade(client->GetPlayer(), val);
  7507. break;
  7508. }
  7509. case COMMAND_ADD_TRADE_SILVER:
  7510. {
  7511. val = amount * 100;
  7512. trade->AddCoinToTrade(client->GetPlayer(), val);
  7513. break;
  7514. }
  7515. case COMMAND_ADD_TRADE_GOLD:
  7516. {
  7517. val = amount * 10000;
  7518. trade->AddCoinToTrade(client->GetPlayer(), val);
  7519. break;
  7520. }
  7521. case COMMAND_ADD_TRADE_PLAT:
  7522. {
  7523. val = amount * 1000000;
  7524. trade->AddCoinToTrade(client->GetPlayer(), val);
  7525. break;
  7526. }
  7527. default:
  7528. {
  7529. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7530. break;
  7531. }
  7532. }
  7533. }
  7534. else
  7535. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7536. }
  7537. else
  7538. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7539. }
  7540. /*
  7541. Function: Command_TradeRemoveCoin()
  7542. Purpose : Removes coin from trade between players
  7543. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7544. Dev :
  7545. Example :
  7546. */
  7547. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7548. {
  7549. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7550. Trade* trade = client->GetPlayer()->trade;
  7551. if (trade) {
  7552. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7553. int32 amount = atoi(sep->arg[0]);
  7554. int64 val = 0;
  7555. switch (handler) {
  7556. case COMMAND_REMOVE_TRADE_COPPER:
  7557. {
  7558. val = amount;
  7559. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7560. break;
  7561. }
  7562. case COMMAND_REMOVE_TRADE_SILVER:
  7563. {
  7564. val = amount * 100;
  7565. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7566. break;
  7567. }
  7568. case COMMAND_REMOVE_TRADE_GOLD:
  7569. {
  7570. val = amount * 10000;
  7571. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7572. break;
  7573. }
  7574. case COMMAND_REMOVE_TRADE_PLAT:
  7575. {
  7576. val = amount * 1000000;
  7577. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7578. break;
  7579. }
  7580. default:
  7581. {
  7582. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7583. break;
  7584. }
  7585. }
  7586. }
  7587. else
  7588. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7589. }
  7590. else
  7591. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7592. }
  7593. /*
  7594. Function: Command_TradeAddItem()
  7595. Purpose : Adds item to trade between players
  7596. Params :
  7597. Dev :
  7598. Example :
  7599. */
  7600. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7601. {
  7602. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7603. /*
  7604. arg[0] = item index
  7605. arg[1] = slot
  7606. arg[2] = quantity
  7607. */
  7608. if (!client->GetPlayer()->trade) {
  7609. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7610. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7611. return;
  7612. }
  7613. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7614. Item* item = 0;
  7615. int32 index = atoi(sep->arg[0]);
  7616. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7617. if (item) {
  7618. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7619. if (result == 1)
  7620. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7621. else if (result == 2)
  7622. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7623. else if (result == 3)
  7624. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7625. else if (result == 255)
  7626. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7627. }
  7628. else {
  7629. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7630. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7631. }
  7632. }
  7633. else
  7634. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7635. }
  7636. /*
  7637. Function: Command_TradeRemoveItem()
  7638. Purpose : Removes item from trade between players
  7639. Params :
  7640. Dev :
  7641. Example :
  7642. */
  7643. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7644. {
  7645. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7646. /*
  7647. arg[0] = trade window slot
  7648. */
  7649. Trade* trade = client->GetPlayer()->trade;
  7650. if (trade) {
  7651. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7652. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7653. }
  7654. else
  7655. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7656. }
  7657. else
  7658. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7659. }
  7660. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7661. {
  7662. Item *item = 0;
  7663. sint32 crc;
  7664. if (sep) {
  7665. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7666. if (client->GetVersion() < 1096) {
  7667. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7668. {
  7669. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7670. crc = atol(sep->arg[2]);
  7671. }
  7672. }
  7673. else {
  7674. // From the broker and links in chat
  7675. if (strcmp(sep->arg[0], "crc") == 0) {
  7676. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7677. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7678. crc = atol(sep->arg[3]);
  7679. }
  7680. }
  7681. // From inventory
  7682. if (strcmp(sep->arg[0], "dbid") == 0) {
  7683. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7684. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7685. crc = atol(sep->arg[4]);
  7686. }
  7687. }
  7688. }
  7689. if (item)
  7690. client->ShowDressingRoom(item, crc);
  7691. }
  7692. }
  7693. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7694. const char *channel_name, *password = NULL;
  7695. if (sep == NULL || !sep->IsSet(0)) {
  7696. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7697. return;
  7698. }
  7699. channel_name = sep->arg[0];
  7700. if (sep->IsSet(1))
  7701. password = sep->arg[1];
  7702. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7703. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7704. return;
  7705. }
  7706. if (chat.IsInChannel(client, channel_name)) {
  7707. client->Message(CHANNEL_COLOR_WHITE, "You are already in '%s'.", channel_name);
  7708. return;
  7709. }
  7710. if (chat.HasPassword(channel_name)) {
  7711. if (password == NULL) {
  7712. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': That channel is password protected.", channel_name);
  7713. return;
  7714. }
  7715. if (!chat.PasswordMatches(channel_name, password)) {
  7716. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': The password is not correc.t", channel_name);
  7717. return;
  7718. }
  7719. }
  7720. if (!chat.JoinChannel(client, channel_name))
  7721. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7722. }
  7723. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7724. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7725. Command_JoinChannel(client, sep);
  7726. }
  7727. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7728. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7729. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7730. PrintSep(sep, "tellchannel");
  7731. return;
  7732. }
  7733. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7734. }
  7735. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7736. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  7737. if (!p) return;
  7738. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7739. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  7740. //}
  7741. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7742. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  7743. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  7744. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  7745. if (packet) {
  7746. client->QueuePacket(packet->serialize());
  7747. safe_delete(packet);
  7748. }
  7749. }*/
  7750. /*if (client->GetCurrentZone()->Grid != nullptr) {
  7751. int32 numFaces = 0;
  7752. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  7753. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  7754. map<int32, vector<Face*> >::iterator itr;
  7755. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  7756. numFaces += (*itr).second.size();
  7757. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  7758. }*/
  7759. //uchar blah[] = {
  7760. // 1208 - OP_EQUpdateStoreCmd
  7761. // /*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
  7762. // /*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
  7763. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  7764. // /*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
  7765. /*};
  7766. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7767. int8 val = 0;
  7768. int16 pos = 0;
  7769. int idx = 0;
  7770. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  7771. pos = atoi(sep2->arg[idx]);
  7772. val = atoi(sep2->arg[idx+1]);
  7773. memset(blah+pos, val, 1);
  7774. idx+=2;
  7775. }
  7776. DumpPacket(blah, sizeof(blah));
  7777. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  7778. if (client->GetPlayer()->GetTarget()) {
  7779. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  7780. if (packet) {
  7781. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7782. packet->setDataByName("size", 0);
  7783. packet->setDataByName("unknown2", 0);
  7784. EQ2Packet* app = packet->serialize();
  7785. client->QueuePacket(app);
  7786. safe_delete(packet);
  7787. }
  7788. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  7789. if (set_pov) {
  7790. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7791. EQ2Packet* app_pov = set_pov->serialize();
  7792. client->QueuePacket(app_pov);
  7793. safe_delete(set_pov);
  7794. }
  7795. }
  7796. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7797. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  7798. if (packet) {
  7799. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  7800. packet->setDataByName("Type", atoi(sep2->arg[0]));
  7801. else
  7802. packet->setDataByName("Type", 2);
  7803. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  7804. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  7805. else
  7806. packet->setDataByName("race_id", 0);
  7807. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  7808. packet->setDataByName("gender", atoi(sep2->arg[2]));
  7809. else
  7810. packet->setDataByName("gender", 2);
  7811. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  7812. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  7813. else
  7814. packet->setDataByName("unknown", 0, 0);
  7815. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  7816. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  7817. else
  7818. packet->setDataByName("unknown", 0, 1);
  7819. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  7820. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  7821. else
  7822. packet->setDataByName("unknown", 0, 2);
  7823. client->QueuePacket(packet->serialize());
  7824. }
  7825. safe_delete(packet);
  7826. safe_delete(sep2);
  7827. }
  7828. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  7829. const char *channel_name;
  7830. if (sep == NULL || !sep->IsSet(0)) {
  7831. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  7832. PrintSep(sep);
  7833. return;
  7834. }
  7835. channel_name = sep->arg[0];
  7836. if (!chat.IsInChannel(client, channel_name))
  7837. client->Message(CHANNEL_COLOR_WHITE, "Unable to leave '%s': You are not in the channel.", channel_name);
  7838. else if (!chat.LeaveChannel(client, channel_name))
  7839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  7840. }
  7841. /*
  7842. Function:
  7843. Purpose :
  7844. Params :
  7845. Dev :
  7846. Example :
  7847. */
  7848. void Commands::Command_WeaponStats(Client* client)
  7849. {
  7850. Player* player = client->GetPlayer();
  7851. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  7852. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  7853. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  7854. client->SimpleMessage(0, "Primary:");
  7855. if (primary) {
  7856. client->Message(0, "Name: %s", primary->name.c_str());
  7857. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  7858. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7859. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  7860. client->Message(0, "Proc Percent: %d%%", 0);
  7861. client->Message(0, "Procs Per Minute: %d", 0);
  7862. }
  7863. else {
  7864. client->SimpleMessage(0, "Name: fist");
  7865. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7866. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7867. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  7868. client->Message(0, "Proc Percent: %d%%", 0);
  7869. client->Message(0, "Procs Per Minute: %d", 0);
  7870. }
  7871. client->SimpleMessage(0, " ");
  7872. client->SimpleMessage(0, " ");
  7873. if (secondary) {
  7874. client->SimpleMessage(0, "Secondary:");
  7875. client->Message(0, "Name: %s", secondary->name.c_str());
  7876. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  7877. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  7878. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  7879. client->Message(0, "Proc Percent: %d%%", 0);
  7880. client->Message(0, "Procs Per Minute: %d", 0);
  7881. client->SimpleMessage(0, " ");
  7882. client->SimpleMessage(0, " ");
  7883. }
  7884. client->SimpleMessage(0, "Ranged:");
  7885. if (ranged) {
  7886. client->Message(0, "Name: %s", ranged->name.c_str());
  7887. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  7888. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  7889. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  7890. client->Message(0, "Proc Percent: %d%%", 0);
  7891. client->Message(0, "Procs Per Minute: %d", 0);
  7892. }
  7893. else
  7894. client->SimpleMessage(0, "None");
  7895. }
  7896. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  7897. const char *channel_name;
  7898. if (sep == NULL || !sep->IsSet(0)) {
  7899. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  7900. return;
  7901. }
  7902. channel_name = sep->arg[0];
  7903. if (!chat.ChannelExists(channel_name))
  7904. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  7905. else
  7906. chat.SendChannelUserList(client, channel_name);
  7907. }
  7908. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  7909. {
  7910. ZoneServer* zone = 0;
  7911. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  7912. if (zone_id > 0)
  7913. {
  7914. zone = zone_list.Get(zone_id, false);
  7915. if (zone)
  7916. {
  7917. zone->SetSafeX(client->GetPlayer()->GetX());
  7918. zone->SetSafeY(client->GetPlayer()->GetY());
  7919. zone->SetSafeZ(client->GetPlayer()->GetZ());
  7920. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  7921. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  7922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  7923. else
  7924. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  7925. }
  7926. }
  7927. }
  7928. /*
  7929. Function:
  7930. Purpose :
  7931. Params :
  7932. Dev :
  7933. Example :
  7934. */
  7935. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  7936. {
  7937. ZoneInfo* zone_info = new ZoneInfo;
  7938. if (sep && sep->arg[0])
  7939. {
  7940. if (sep->IsNumber(0))
  7941. zone_info->id = atoi(sep->arg[0]);
  7942. else
  7943. zone_info->id = database.GetZoneID(sep->arg[0]);
  7944. if (zone_info->id > 0)
  7945. {
  7946. database.LoadZoneInfo(zone_info);
  7947. 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);
  7948. 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);
  7949. 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);
  7950. 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);
  7951. 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);
  7952. 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);
  7953. 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);
  7954. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  7955. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  7956. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  7957. }
  7958. else
  7959. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  7960. }
  7961. else
  7962. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  7963. safe_delete(zone_info);
  7964. }
  7965. /*
  7966. Function:
  7967. Purpose :
  7968. Params :
  7969. Dev :
  7970. Example :
  7971. */
  7972. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  7973. {
  7974. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  7975. {
  7976. ZoneServer* zone = 0;
  7977. int32 zone_id = 0;
  7978. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  7979. {
  7980. zone_id = atoi(sep->arg[0]);
  7981. zone = zone_list.Get(atoi(sep->arg[0]), false);
  7982. }
  7983. else
  7984. {
  7985. zone_id = database.GetZoneID(sep->arg[0]);
  7986. if (zone_id > 0)
  7987. zone = zone_list.Get(sep->arg[0], false);
  7988. }
  7989. if (zone_id > 0)
  7990. {
  7991. if (zone_set_values.count(string(sep->arg[1])) > 0)
  7992. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  7993. else
  7994. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  7995. }
  7996. else
  7997. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  7998. }
  7999. else
  8000. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  8001. }
  8002. void Commands::Command_Rain(Client* client, Seperator* sep) {
  8003. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8004. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  8005. return;
  8006. }
  8007. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  8008. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  8009. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  8010. }
  8011. void Commands::Command_Wind(Client* client, Seperator* sep) {
  8012. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8013. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  8014. return;
  8015. }
  8016. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  8017. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  8018. }
  8019. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  8020. Spawn* spawn = client->GetPlayer()->GetTarget();
  8021. if(spawn) {
  8022. client->SetMerchantTransaction(spawn);
  8023. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  8024. client->SendHailCommand(spawn);
  8025. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  8026. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  8027. client->SendBuyMerchantList(sell);
  8028. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  8029. client->SendSellMerchantList(sell);
  8030. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  8031. client->SendBuyBackList(sell);
  8032. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  8033. if (packet) {
  8034. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  8035. packet->setDataByName("type", 16);
  8036. EQ2Packet* outapp = packet->serialize();
  8037. if (outapp)
  8038. client->QueuePacket(outapp);
  8039. safe_delete(packet);
  8040. }
  8041. }
  8042. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  8043. client->SendRepairList();
  8044. }
  8045. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  8046. }
  8047. void Commands::Command_Weather(Client* client, Seperator* sep)
  8048. {
  8049. //PrintSep(sep, "Weather");
  8050. if( sep && sep->arg[0] )
  8051. {
  8052. ZoneServer* zsZone = client->GetCurrentZone();
  8053. const char* value = sep->arg[0];
  8054. // process single-param commands first
  8055. if( strncasecmp(value, "details", strlen(value)) == 0 )
  8056. {
  8057. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  8058. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  8059. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  8060. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  8061. }
  8062. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  8063. {
  8064. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  8065. zsZone->ProcessWeather();
  8066. }
  8067. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  8068. {
  8069. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  8070. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  8071. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  8072. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  8073. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  8074. zsZone->SetWeatherPattern(1);
  8075. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  8076. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  8077. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  8078. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  8079. zsZone->ProcessWeather();
  8080. }
  8081. // process commands with params
  8082. if( sep->arg[1] )
  8083. {
  8084. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  8085. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  8086. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  8087. zsZone->SetWeatherType(atoi(sep->arg[1]));
  8088. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  8089. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  8090. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  8091. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  8092. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  8093. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  8094. }
  8095. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  8096. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  8097. zsZone->SetRain(zsZone->GetCurrentWeather());
  8098. }
  8099. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  8100. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  8101. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  8102. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  8103. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  8104. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  8105. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  8106. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  8107. }
  8108. }
  8109. else
  8110. {
  8111. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  8112. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  8113. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  8114. return;
  8115. }
  8116. }
  8117. void Commands::Command_Select(Client* client, Seperator* sep) {
  8118. if (sep && sep->arg[1]) {
  8119. Spawn* spawn = client->GetPlayer()->GetTarget();
  8120. if (spawn && strlen(sep->arg[1]) > 0)
  8121. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  8122. }
  8123. }
  8124. /*
  8125. Function: Command_ConsumeFood()
  8126. Purpose : Consume Food/Drink and apply mods
  8127. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  8128. Dev : Zcoretri
  8129. Example : /consume_food 22
  8130. */
  8131. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  8132. if (sep && sep->arg[0] && sep->IsNumber(0))
  8133. {
  8134. Player* player = client->GetPlayer();
  8135. int8 slot = atoi(sep->arg[0]);
  8136. Item* item = player->GetEquipmentList()->GetItem(slot);
  8137. if(item) {
  8138. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  8139. if(item->GetItemScript() && lua_interface){
  8140. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  8141. if (slot == 22)
  8142. client->Message(CHANNEL_COLOR_WHITE, "You eat a %s.", item->name.c_str());
  8143. else
  8144. client->Message(CHANNEL_COLOR_WHITE, "You drink a %s.", item->name.c_str());
  8145. }
  8146. }
  8147. if (item->details.count > 1) {
  8148. item->details.count -= 1;
  8149. item->save_needed = true;
  8150. }
  8151. else {
  8152. player->GetEquipmentList()->RemoveItem(slot, true);
  8153. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  8154. }
  8155. client->GetPlayer()->SetCharSheetChanged(true);
  8156. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8157. }
  8158. }
  8159. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  8160. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  8161. if (atoi(sep->arg[0]) == 1) {
  8162. client->GetPlayer()->GetInfoStruct()->vision = 4;
  8163. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  8164. client->GetPlayer()->SetCharSheetChanged(true);
  8165. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  8166. }
  8167. else {
  8168. client->GetPlayer()->GetInfoStruct()->vision = 0;
  8169. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  8170. client->GetPlayer()->SetCharSheetChanged(true);
  8171. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  8172. }
  8173. }
  8174. else
  8175. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  8176. }
  8177. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  8178. {
  8179. if(sep)
  8180. {
  8181. string data;
  8182. if(sep->arg[0]){
  8183. data = string(sep->arg[0]);
  8184. }
  8185. for(int i=1;i<sep->GetMaxArgNum();i++){
  8186. if(sep->arg[i])
  8187. data.append(" ").append(sep->arg[i]);
  8188. }
  8189. const char* target_name = 0;
  8190. int32 spawn_id = 0;
  8191. if(client->GetPlayer()->GetTarget())
  8192. {
  8193. target_name = client->GetPlayer()->GetTarget()->GetName();
  8194. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  8195. }
  8196. else
  8197. target_name = "N/A";
  8198. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  8199. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  8200. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  8201. else
  8202. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  8203. }
  8204. }
  8205. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  8206. PrintSep(sep, "Command_Attune_Inv");
  8207. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  8208. // Get the item index from the first parameter
  8209. int16 index = atoi(sep->arg[0]);
  8210. // Check to see if this is a valid item index for the player, if not exit out of the function
  8211. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  8212. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  8213. return;
  8214. }
  8215. // Get the item
  8216. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  8217. if(item) {
  8218. // Valid item lets check to make sure this item is attunable, if not return out
  8219. if (!item->CheckFlag(ATTUNEABLE)) {
  8220. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  8221. return;
  8222. }
  8223. // Remove the attunable flag
  8224. item->generic_info.item_flags -= ATTUNEABLE;
  8225. // Set the attuned flag
  8226. item->generic_info.item_flags += ATTUNED;
  8227. // Flag this item for saving
  8228. item->save_needed = true;
  8229. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  8230. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  8231. EQ2Packet* outapp = 0;
  8232. for (int32 i=0;i<packets.size();i++) {
  8233. outapp = packets[i];
  8234. if(outapp)
  8235. client->QueuePacket(outapp);
  8236. }
  8237. }
  8238. }
  8239. }
  8240. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  8241. PrintSep(sep, "Command_Reset_Zone_Timer");
  8242. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  8243. int32 db_id = atoul(sep->arg[0]);
  8244. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  8245. if (data) {
  8246. // TODO: add a check to timers to ensure it can be reset
  8247. // Delete the character from the instance
  8248. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  8249. data->instance_id = 0;
  8250. // Update the success time and set to 0 so the player can enter it again
  8251. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  8252. data->last_success_timestamp = 0;
  8253. }
  8254. }*/
  8255. }
  8256. void Commands::Command_Player(Client* client, Seperator* sep) {
  8257. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  8258. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  8259. }
  8260. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  8261. // /player coins add 10
  8262. // /player coins add plat 10
  8263. Player* player = client->GetPlayer();
  8264. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  8265. player = (Player*)player->GetTarget();
  8266. if (sep && sep->arg[0] && sep->arg[1]) {
  8267. const char* action = sep->arg[0];
  8268. int64 value = 0;
  8269. if (strncasecmp(action, "add", strlen(action)) == 0) {
  8270. if (sep->IsNumber(1)) {
  8271. value = atoi64(sep->arg[1]);
  8272. player->AddCoins(value);
  8273. if (client->GetPlayer() == player)
  8274. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  8275. else {
  8276. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  8277. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  8278. }
  8279. return;
  8280. }
  8281. else if (sep->arg[2] && sep->IsNumber(2)) {
  8282. const char* type = sep->arg[1];
  8283. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  8284. value = atoi64(sep->arg[2]);
  8285. }
  8286. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  8287. value = atoi64(sep->arg[2]) * 100;
  8288. }
  8289. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  8290. value = atoi64(sep->arg[2]) * 10000;
  8291. }
  8292. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  8293. value = atoi64(sep->arg[2]) * 1000000;
  8294. }
  8295. player->AddCoins(value);
  8296. if (client->GetPlayer() == player)
  8297. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  8298. else {
  8299. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  8300. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  8301. }
  8302. return;
  8303. }
  8304. }
  8305. }
  8306. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  8307. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  8308. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  8309. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  8310. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  8311. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  8312. }
  8313. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  8314. PrintSep(sep, "ACHIEVEMENT_ADD");
  8315. if (sep && sep->IsSet(0)) {
  8316. int32 spell_id = atoul(sep->arg[1]);
  8317. int8 spell_tier = 0;
  8318. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  8319. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  8320. // addspellbookentry here
  8321. if (spell_tier >= data->maxRank) {
  8322. return;
  8323. }
  8324. if (!spell_tier) {
  8325. spell_tier = 1;
  8326. }
  8327. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  8328. {
  8329. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8330. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8331. client->GetPlayer()->UnlockSpell(spell);
  8332. client->SendSpellUpdate(spell);
  8333. }
  8334. else
  8335. {
  8336. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  8337. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  8338. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  8339. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8340. client->GetPlayer()->UnlockSpell(spell);
  8341. client->SendSpellUpdate(spell);
  8342. }
  8343. // cast spell here
  8344. if (!spell_tier)
  8345. spell_tier = 1;
  8346. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8347. if (spell) {
  8348. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  8349. }
  8350. }
  8351. else {
  8352. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  8353. }
  8354. master_aa_list.DisplayAA(client, 0, 0);
  8355. }
  8356. void Commands::Command_Editor(Client* client, Seperator* sep) {
  8357. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  8358. if (packet) {
  8359. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  8360. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  8361. char command[255];
  8362. url = "browser " + url;
  8363. int32 spawn_id = 0;
  8364. int32 zone_id = 0;
  8365. string type;
  8366. if (client->GetCurrentZone())
  8367. zone_id = client->GetCurrentZone()->GetZoneID();
  8368. if (client->GetPlayer()->GetTarget()) {
  8369. Spawn* target = client->GetPlayer()->GetTarget();
  8370. if (target->IsWidget())
  8371. type = "widgets";
  8372. else if (target->IsSign())
  8373. type = "signs";
  8374. else if (target->IsObject())
  8375. type = "objects";
  8376. else if (target->IsNPC())
  8377. type = "npcs";
  8378. else if (target->IsGroundSpawn())
  8379. type = "ground";
  8380. else
  8381. type = "spawn";
  8382. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  8383. }
  8384. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  8385. packet->setDataByName("accept_command", command);
  8386. }
  8387. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  8388. char command[255];
  8389. url = "browser " + url;
  8390. if (client->GetPlayer()->GetTarget())
  8391. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  8392. packet->setDataByName("accept_command", command);
  8393. }
  8394. else {
  8395. string command = "browser " + url;
  8396. packet->setDataByName("accept_command", command.c_str());
  8397. }
  8398. packet->setDataByName("text", "Open the web editor?");
  8399. packet->setDataByName("accept_text", "Open");
  8400. packet->setDataByName("cancel_text", "Cancel");
  8401. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  8402. packet->setDataByName("unknown2", 50);
  8403. packet->setDataByName("unknown4", 1);
  8404. client->QueuePacket(packet->serialize());
  8405. safe_delete(packet);
  8406. }
  8407. }
  8408. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  8409. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  8410. return;
  8411. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  8412. if(client->GetCurrentRez()->active)
  8413. client->AcceptResurrection();
  8414. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  8415. }
  8416. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  8417. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  8418. return;
  8419. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  8420. if(client->GetCurrentRez()->active)
  8421. client->GetCurrentRez()->should_delete = true;
  8422. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  8423. }
  8424. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  8425. PrintSep(sep, "Switch_AA_Profile");
  8426. if (sep && sep->IsSet(0)) {
  8427. string type = sep->arg[0];
  8428. int8 newtemplate = atoul(sep->arg[1]);
  8429. master_aa_list.DisplayAA(client, newtemplate, 1);
  8430. }
  8431. }
  8432. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  8433. PrintSep(sep, "Get_AA_Xml");
  8434. if (sep && sep->IsSet(0)) {
  8435. string tabnum = sep->arg[0];
  8436. string spellid = sep->arg[1];
  8437. }
  8438. }
  8439. void Commands::Add_AA(Client* client, Seperator* sep) {
  8440. PrintSep(sep, "Add_AA");
  8441. if (sep && sep->IsSet(0)) {
  8442. int32 spell_id = atoul(sep->arg[1]);
  8443. int8 spell_tier = 0;
  8444. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  8445. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  8446. // addspellbookentry here
  8447. if (spell_tier >= data->maxRank) {
  8448. return;
  8449. }
  8450. if (!spell_tier) {
  8451. spell_tier = 1;
  8452. }
  8453. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  8454. {
  8455. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8456. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8457. client->GetPlayer()->UnlockSpell(spell);
  8458. client->SendSpellUpdate(spell);
  8459. }
  8460. else
  8461. {
  8462. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  8463. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  8464. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  8465. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8466. client->GetPlayer()->UnlockSpell(spell);
  8467. client->SendSpellUpdate(spell);
  8468. }
  8469. // cast spell here
  8470. if (!spell_tier)
  8471. spell_tier = 1;
  8472. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8473. if (spell) {
  8474. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  8475. }
  8476. }
  8477. else {
  8478. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  8479. }
  8480. master_aa_list.DisplayAA(client, 0, 0);
  8481. }
  8482. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  8483. PrintSep(sep, "Commit_AA_Profile");
  8484. if (sep && sep->IsSet(0)) {
  8485. }
  8486. }
  8487. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  8488. PrintSep(sep, "Begin_AA_Profile");
  8489. if (sep && sep->IsSet(0)) {
  8490. master_aa_list.DisplayAA(client, 100, 2);
  8491. }
  8492. }
  8493. void Commands::Back_AA(Client* client, Seperator* sep) {
  8494. if (sep && sep->IsSet(0)) {
  8495. PrintSep(sep, "Back_AA");
  8496. }
  8497. }
  8498. void Commands::Remove_AA(Client* client, Seperator* sep) {
  8499. if (sep && sep->IsSet(0)) {
  8500. PrintSep(sep, "Remove_AA");
  8501. }
  8502. }
  8503. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  8504. MasterAAList master_aa_list;
  8505. PrintSep(sep, "Cancel_AA_Profile");
  8506. master_aa_list.DisplayAA(client, 0, 0);
  8507. }
  8508. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  8509. if (sep && sep->IsSet(0)) {
  8510. PrintSep(sep, "Save_AA_Profile");
  8511. }
  8512. }
  8513. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  8514. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  8515. if (!sep->IsNumber(0)) return;
  8516. int32 request_id = atoul(sep->arg[0]);
  8517. if (!sep->IsNumber(1)) return;
  8518. sint32 item_id = atoi(sep->arg[1]);
  8519. if (client->IsCurrentTransmuteID(request_id)) {
  8520. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  8521. }
  8522. else if (client->IsCurrentTransmuteID(item_id)) {
  8523. if (!sep->IsSet(2)) return;
  8524. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  8525. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  8526. }
  8527. }
  8528. }