Commands.cpp 421 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624
  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 "../Bots/Bot.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["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  146. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  147. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  148. spawn_set_values["skin_color"] = SPAWN_SET_SKIN_COLOR;
  149. spawn_set_values["aaxp_rewards"] = SPAWN_SET_AAXP_REWARDS;
  150. spawn_set_values["hair_color1"] = SPAWN_SET_HAIR_COLOR1;
  151. spawn_set_values["hair_color2"] = SPAWN_SET_HAIR_COLOR2;
  152. spawn_set_values["hair_type_color"] = SPAWN_SET_HAIR_TYPE_COLOR;
  153. spawn_set_values["hair_face_color"] = SPAWN_SET_HAIR_FACE_COLOR;
  154. spawn_set_values["hair_type_highlight_color"] = SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR;
  155. spawn_set_values["face_hairlight_color"] = SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR;
  156. spawn_set_values["hair_highlight"] = SPAWN_SET_HAIR_HIGHLIGHT;
  157. spawn_set_values["model_color"] = SPAWN_SET_MODEL_COLOR;
  158. spawn_set_values["eye_color"] = SPAWN_SET_EYE_COLOR;
  159. spawn_set_values["soga_skin_color"] = SPAWN_SET_SOGA_SKIN_COLOR;
  160. spawn_set_values["soga_hair_color1"] = SPAWN_SET_SOGA_HAIR_COLOR1;
  161. spawn_set_values["soga_hair_color2"] = SPAWN_SET_SOGA_HAIR_COLOR2;
  162. spawn_set_values["soga_hair_type_color"] = SPAWN_SET_SOGA_HAIR_TYPE_COLOR;
  163. spawn_set_values["soga_hair_face_color"] = SPAWN_SET_SOGA_HAIR_FACE_COLOR;
  164. spawn_set_values["soga_hair_type_highlight_color"] = SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR;
  165. spawn_set_values["soga_face_hairlight_color"] = SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR;
  166. spawn_set_values["soga_hair_highlight"] = SPAWN_SET_SOGA_HAIR_HIGHLIGHT;
  167. spawn_set_values["soga_model_color"] = SPAWN_SET_SOGA_MODEL_COLOR;
  168. spawn_set_values["soga_eye_color"] = SPAWN_SET_SOGA_EYE_COLOR;
  169. spawn_set_values["cheek_type"] = SPAWN_SET_CHEEK_TYPE;
  170. spawn_set_values["chin_type"] = SPAWN_SET_CHIN_TYPE;
  171. spawn_set_values["ear_type"] = SPAWN_SET_EAR_TYPE;
  172. spawn_set_values["eye_brow_type"] = SPAWN_SET_EYE_BROW_TYPE;
  173. spawn_set_values["eye_type"] = SPAWN_SET_EYE_TYPE;
  174. spawn_set_values["lip_type"] = SPAWN_SET_LIP_TYPE;
  175. spawn_set_values["nose_type"] = SPAWN_SET_NOSE_TYPE;
  176. spawn_set_values["body_size"] = SPAWN_SET_BODY_SIZE;
  177. spawn_set_values["body_age"] = SPAWN_SET_BODY_AGE;
  178. spawn_set_values["soga_cheek_type"] = SPAWN_SET_SOGA_CHEEK_TYPE;
  179. spawn_set_values["soga_chin_type"] = SPAWN_SET_SOGA_CHIN_TYPE;
  180. spawn_set_values["soga_ear_type"] = SPAWN_SET_SOGA_EAR_TYPE;
  181. spawn_set_values["soga_eye_brow_type"] = SPAWN_SET_SOGA_EYE_BROW_TYPE;
  182. spawn_set_values["soga_eye_type"] = SPAWN_SET_SOGA_EYE_TYPE;
  183. spawn_set_values["soga_lip_type"] = SPAWN_SET_SOGA_LIP_TYPE;
  184. spawn_set_values["soga_nose_type"] = SPAWN_SET_SOGA_NOSE_TYPE;
  185. spawn_set_values["soga_body_size"] = SPAWN_SET_SOGA_BODY_SIZE;
  186. spawn_set_values["soga_body_age"] = SPAWN_SET_SOGA_BODY_AGE;
  187. spawn_set_values["attack_type"] = SPAWN_SET_ATTACK_TYPE;
  188. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  189. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  190. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  191. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  192. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  193. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  194. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  195. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  196. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  197. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  198. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  199. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  200. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  201. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  202. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  203. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  204. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  205. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  206. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  207. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  208. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  209. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  210. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  211. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  212. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  213. }
  214. Commands::~Commands() {
  215. safe_delete(remote_commands);
  216. }
  217. int32 Commands::GetSpawnSetType(string val){
  218. if(spawn_set_values.count(val) > 0)
  219. return spawn_set_values[val];
  220. return 0xFFFFFFFF;
  221. }
  222. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value, int8 index){
  223. if(!target)
  224. return false;
  225. int32 val = 0;
  226. try{
  227. if(type != SPAWN_SET_VALUE_NAME &&
  228. !(type >= SPAWN_SET_VALUE_SPAWN_SCRIPT && type <= SPAWN_SET_VALUE_SUB_TITLE) && !(type >= SPAWN_SET_VALUE_PREFIX && type <= SPAWN_SET_VALUE_EXPANSION_FLAG || type == SPAWN_SET_VALUE_HOLIDAY_FLAG))
  229. {
  230. switch(type)
  231. {
  232. case SPAWN_SET_SKIN_COLOR:
  233. case SPAWN_SET_HAIR_COLOR1:
  234. case SPAWN_SET_HAIR_COLOR2:
  235. case SPAWN_SET_HAIR_TYPE_COLOR:
  236. case SPAWN_SET_HAIR_FACE_COLOR:
  237. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  238. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  239. case SPAWN_SET_HAIR_HIGHLIGHT:
  240. case SPAWN_SET_EYE_COLOR:
  241. case SPAWN_SET_SOGA_SKIN_COLOR:
  242. case SPAWN_SET_SOGA_HAIR_COLOR1:
  243. case SPAWN_SET_SOGA_HAIR_COLOR2:
  244. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  245. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  246. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  247. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  248. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  249. case SPAWN_SET_SOGA_EYE_COLOR:
  250. // ignore these are colors can't pass as a integer value
  251. break;
  252. default:
  253. val = atoul(value);
  254. }
  255. }
  256. }
  257. catch(...){
  258. if(client)
  259. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  260. return false;
  261. }
  262. if(temporary){
  263. char tmp[128] = {0};
  264. switch(type){
  265. case SPAWN_SET_VALUE_NAME:{
  266. sprintf(tmp, "%s", target->GetName());
  267. target->SetName(value);
  268. if(target->GetZone())
  269. target->GetZone()->SendUpdateTitles(target);
  270. break;
  271. }
  272. case SPAWN_SET_VALUE_X_OFFSET:
  273. {
  274. sprintf(tmp, "%f", target->GetXOffset());
  275. target->SetXOffset(float(val));
  276. break;
  277. }
  278. case SPAWN_SET_VALUE_Y_OFFSET:
  279. {
  280. sprintf(tmp, "%f", target->GetYOffset());
  281. target->SetYOffset(float(val));
  282. break;
  283. }
  284. case SPAWN_SET_VALUE_Z_OFFSET:
  285. {
  286. sprintf(tmp, "%f", target->GetZOffset());
  287. target->SetZOffset(float(val));
  288. break;
  289. }
  290. case SPAWN_SET_VALUE_EXPIRE: {
  291. sprintf(tmp, "%u", target->GetExpireTime());
  292. target->SetExpireTime(val);
  293. break;
  294. }
  295. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  296. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  297. target->SetExpireOffsetTime(val);
  298. break;
  299. }
  300. case SPAWN_SET_VALUE_SUB_TITLE: {
  301. sprintf(tmp, "%s", target->GetSubTitle());
  302. target->SetSubTitle(value);
  303. if(target->GetZone())
  304. target->GetZone()->SendUpdateTitles(target);
  305. break;
  306. }
  307. case SPAWN_SET_VALUE_LEVEL:{
  308. sprintf(tmp, "%i", target->GetLevel());
  309. target->SetLevel(val, send_update);
  310. break;
  311. }
  312. case SPAWN_SET_VALUE_DIFFICULTY:{
  313. sprintf(tmp, "%i", target->GetEncounterLevel());
  314. target->SetEncounterLevel(val, send_update);
  315. break;
  316. }
  317. case SPAWN_SET_VALUE_MODEL_TYPE:{
  318. sprintf(tmp, "%i", target->GetModelType());
  319. target->SetModelType(val, send_update);
  320. break;
  321. }
  322. case SPAWN_SET_VALUE_CLASS:{
  323. sprintf(tmp, "%i", target->GetAdventureClass());
  324. target->SetAdventureClass(val, send_update);
  325. break;
  326. }
  327. case SPAWN_SET_VALUE_GENDER:{
  328. sprintf(tmp, "%i", target->GetGender());
  329. target->SetGender(val, send_update);
  330. break;
  331. }
  332. case SPAWN_SET_VALUE_SHOW_NAME:{
  333. sprintf(tmp, "%i", target->GetShowName());
  334. target->SetShowName(val, send_update);
  335. break;
  336. }
  337. case SPAWN_SET_VALUE_ATTACKABLE:{
  338. sprintf(tmp, "%i", target->GetAttackable());
  339. target->SetAttackable(val, send_update);
  340. break;
  341. }
  342. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  343. sprintf(tmp, "%i", target->GetShowLevel());
  344. target->SetShowLevel(val, send_update);
  345. break;
  346. }
  347. case SPAWN_SET_VALUE_TARGETABLE:{
  348. sprintf(tmp, "%i", target->GetTargetable());
  349. target->SetTargetable(val, send_update);
  350. break;
  351. }
  352. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  353. sprintf(tmp, "%i", target->GetShowCommandIcon());
  354. target->SetShowCommandIcon(val, send_update);
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_HAND_ICON:{
  358. sprintf(tmp, "%i", target->GetShowHandIcon());
  359. target->SetShowHandIcon(val, send_update);
  360. break;
  361. }
  362. case SPAWN_SET_VALUE_HAIR_TYPE:{
  363. if(target->IsEntity()){
  364. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  365. ((Entity*)target)->SetHairType(val, send_update);
  366. }
  367. break;
  368. }
  369. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  370. if(target->IsEntity()){
  371. sprintf(tmp, "%i", ((Entity*)target)->GetFacialHairType());
  372. ((Entity*)target)->SetFacialHairType(val, send_update);
  373. }
  374. break;
  375. }
  376. case SPAWN_SET_VALUE_WING_TYPE:{
  377. if(target->IsEntity()){
  378. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  379. ((Entity*)target)->SetWingType(val, send_update);
  380. }
  381. break;
  382. }
  383. case SPAWN_SET_VALUE_CHEST_TYPE:{
  384. if(target->IsEntity()){
  385. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  386. ((Entity*)target)->SetChestType(val, send_update);
  387. }
  388. break;
  389. }
  390. case SPAWN_SET_VALUE_LEGS_TYPE:{
  391. if(target->IsEntity()){
  392. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  393. ((Entity*)target)->SetLegsType(val, send_update);
  394. }
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  398. if(target->IsEntity()){
  399. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  400. ((Entity*)target)->SetSogaHairType(val, send_update);
  401. }
  402. break;
  403. }
  404. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  405. if(target->IsEntity()){
  406. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  407. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  408. }
  409. break;
  410. }
  411. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  412. sprintf(tmp, "%i", target->GetSogaModelType());
  413. target->SetSogaModelType(val, send_update);
  414. break;
  415. }
  416. case SPAWN_SET_VALUE_SIZE:{
  417. sprintf(tmp, "%i", target->GetSize());
  418. target->SetSize(val, send_update);
  419. break;
  420. }
  421. case SPAWN_SET_VALUE_HP:{
  422. sprintf(tmp, "%i", target->GetHP());
  423. target->SetHP(val, send_update);
  424. break;
  425. }
  426. case SPAWN_SET_VALUE_POWER:{
  427. sprintf(tmp, "%i", target->GetPower());
  428. target->SetPower(val, send_update);
  429. break;
  430. }
  431. case SPAWN_SET_VALUE_HEROIC:{
  432. sprintf(tmp, "%i", target->GetHeroic());
  433. target->SetHeroic(val, send_update);
  434. break;
  435. }
  436. case SPAWN_SET_VALUE_RESPAWN:{
  437. sprintf(tmp, "%u", target->GetRespawnTime());
  438. target->SetRespawnTime(val);
  439. break;
  440. }
  441. case SPAWN_SET_VALUE_X:{
  442. sprintf(tmp, "%f", target->GetX());
  443. target->SetX(atof(value), send_update);
  444. break;
  445. }
  446. case SPAWN_SET_VALUE_Y:{
  447. sprintf(tmp, "%f", target->GetY());
  448. target->SetY(atof(value), send_update);
  449. break;
  450. }
  451. case SPAWN_SET_VALUE_Z:{
  452. sprintf(tmp, "%f", target->GetZ());
  453. target->SetZ(atof(value), send_update);
  454. break;
  455. }
  456. case SPAWN_SET_VALUE_HEADING:{
  457. sprintf(tmp, "%f", target->GetHeading());
  458. target->SetHeading(atof(value) + 360, send_update);
  459. break;
  460. }
  461. case SPAWN_SET_VALUE_VISUAL_STATE:{
  462. sprintf(tmp, "%i", target->GetVisualState());
  463. target->SetVisualState(val, send_update);
  464. break;
  465. }
  466. case SPAWN_SET_VALUE_ACTION_STATE:{
  467. sprintf(tmp, "%i", target->GetActionState());
  468. target->SetActionState(val, send_update);
  469. break;
  470. }
  471. case SPAWN_SET_VALUE_MOOD_STATE:{
  472. sprintf(tmp, "%i", target->GetMoodState());
  473. target->SetMoodState(val, send_update);
  474. break;
  475. }
  476. case SPAWN_SET_VALUE_INITIAL_STATE:{
  477. sprintf(tmp, "%i", target->GetInitialState());
  478. target->SetInitialState(val, send_update);
  479. break;
  480. }
  481. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  482. sprintf(tmp, "%i", target->GetActivityStatus());
  483. target->SetActivityStatus(val, send_update);
  484. break;
  485. }
  486. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  487. sprintf(tmp, "%i", target->GetCollisionRadius());
  488. target->SetCollisionRadius(val, send_update);
  489. break;
  490. }
  491. case SPAWN_SET_VALUE_DEVICE_ID: {
  492. if (target->IsObject()) {
  493. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  494. ((Object*)target)->SetDeviceID(val);
  495. }
  496. break;
  497. }
  498. case SPAWN_SET_VALUE_PITCH: {
  499. sprintf(tmp, "%f", target->GetPitch());
  500. target->SetPitch(atof(value), send_update);
  501. break;
  502. }
  503. case SPAWN_SET_VALUE_ROLL: {
  504. sprintf(tmp, "%f", target->GetRoll());
  505. target->SetRoll(atof(value), send_update);
  506. break;
  507. }
  508. case SPAWN_SET_VALUE_HIDE_HOOD: {
  509. sprintf(tmp, "%i", target->appearance.hide_hood);
  510. target->SetHideHood(val);
  511. break;
  512. }
  513. case SPAWN_SET_VALUE_EMOTE_STATE: {
  514. sprintf(tmp, "%i", target->appearance.emote_state);
  515. target->SetEmoteState(val);
  516. break;
  517. }
  518. case SPAWN_SET_VALUE_ICON: {
  519. sprintf(tmp, "%i", target->GetIconValue());
  520. target->SetIcon(val);
  521. break;
  522. }
  523. case SPAWN_SET_VALUE_PREFIX: {
  524. sprintf(tmp, "%s", target->GetPrefixTitle());
  525. target->SetPrefixTitle(value);
  526. if(target->GetZone())
  527. target->GetZone()->SendUpdateTitles(target);
  528. break;
  529. }
  530. case SPAWN_SET_VALUE_SUFFIX: {
  531. sprintf(tmp, "%s", target->GetSuffixTitle());
  532. target->SetSuffixTitle(value);
  533. if(target->GetZone())
  534. target->GetZone()->SendUpdateTitles(target);
  535. break;
  536. }
  537. case SPAWN_SET_VALUE_LASTNAME: {
  538. sprintf(tmp, "%s", target->GetLastName());
  539. target->SetLastName(value);
  540. if(target->GetZone())
  541. target->GetZone()->SendUpdateTitles(target);
  542. break;
  543. }
  544. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  545. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  546. // nothing to do must reload spawns
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  550. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  551. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  552. break;
  553. }
  554. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  555. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  556. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  557. break;
  558. }
  559. case SPAWN_SET_VALUE_FACTION:{
  560. sprintf(tmp, "%i", target->faction_id);
  561. ZoneServer* zone = target->GetZone();
  562. if (!zone && client)
  563. zone = client->GetCurrentZone();
  564. target->faction_id = atoul(value);
  565. if(zone)
  566. {
  567. zone->RemoveDeadEnemyList(target);
  568. if(target->IsNPC())
  569. zone->AddEnemyList((NPC*)target);
  570. }
  571. break;
  572. }
  573. case SPAWN_SET_SKIN_COLOR:
  574. case SPAWN_SET_HAIR_COLOR1:
  575. case SPAWN_SET_HAIR_COLOR2:
  576. case SPAWN_SET_HAIR_TYPE_COLOR:
  577. case SPAWN_SET_HAIR_FACE_COLOR:
  578. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  579. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  580. case SPAWN_SET_HAIR_HIGHLIGHT:
  581. case SPAWN_SET_MODEL_COLOR:
  582. case SPAWN_SET_EYE_COLOR:
  583. case SPAWN_SET_SOGA_SKIN_COLOR:
  584. case SPAWN_SET_SOGA_HAIR_COLOR1:
  585. case SPAWN_SET_SOGA_HAIR_COLOR2:
  586. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  587. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  588. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  589. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  590. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  591. case SPAWN_SET_SOGA_MODEL_COLOR:
  592. case SPAWN_SET_SOGA_EYE_COLOR:
  593. {
  594. if (target->IsEntity())
  595. {
  596. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  597. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  598. {
  599. EQ2_Color clr;
  600. clr.red = atoul(skinsep->arg[0]);
  601. clr.green = atoul(skinsep->arg[1]);
  602. clr.blue = atoul(skinsep->arg[2]);
  603. switch(type)
  604. {
  605. case SPAWN_SET_SKIN_COLOR:
  606. ((Entity*)target)->SetSkinColor(clr);
  607. break;
  608. case SPAWN_SET_HAIR_COLOR1:
  609. ((Entity*)target)->SetHairColor1(clr);
  610. break;
  611. case SPAWN_SET_HAIR_COLOR2:
  612. ((Entity*)target)->SetHairColor2(clr);
  613. break;
  614. case SPAWN_SET_HAIR_TYPE_COLOR:
  615. ((Entity*)target)->SetHairColor(clr);
  616. break;
  617. case SPAWN_SET_HAIR_FACE_COLOR:
  618. ((Entity*)target)->SetFacialHairColor(clr);
  619. break;
  620. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  621. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  622. break;
  623. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  624. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  625. break;
  626. case SPAWN_SET_HAIR_HIGHLIGHT:
  627. ((Entity*)target)->SetHairHighlightColor(clr);
  628. break;
  629. case SPAWN_SET_MODEL_COLOR:
  630. ((Entity*)target)->SetModelColor(clr);
  631. break;
  632. case SPAWN_SET_EYE_COLOR:
  633. ((Entity*)target)->SetEyeColor(clr);
  634. break;
  635. case SPAWN_SET_SOGA_SKIN_COLOR:
  636. ((Entity*)target)->SetSogaSkinColor(clr);
  637. break;
  638. case SPAWN_SET_SOGA_HAIR_COLOR1:
  639. ((Entity*)target)->SetSogaHairColor1(clr);
  640. break;
  641. case SPAWN_SET_SOGA_HAIR_COLOR2:
  642. ((Entity*)target)->SetSogaHairColor2(clr);
  643. break;
  644. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  645. ((Entity*)target)->SetSogaHairColor(clr);
  646. break;
  647. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  648. ((Entity*)target)->SetSogaFacialHairColor(clr);
  649. break;
  650. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  651. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  652. break;
  653. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  654. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  655. break;
  656. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  657. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  658. break;
  659. case SPAWN_SET_SOGA_MODEL_COLOR:
  660. ((Entity*)target)->SetSogaModelColor(clr);
  661. break;
  662. case SPAWN_SET_SOGA_EYE_COLOR:
  663. ((Entity*)target)->SetSogaEyeColor(clr);
  664. break;
  665. }
  666. }
  667. safe_delete(skinsep);
  668. }
  669. break;
  670. }
  671. case SPAWN_SET_AAXP_REWARDS: {
  672. target->SetAAXPRewards(atoul(value));
  673. break;
  674. }
  675. case SPAWN_SET_CHEEK_TYPE:{
  676. if(target->IsEntity() && index < 3){
  677. sprintf(tmp, "%i", ((Entity*)target)->features.cheek_type[index]);
  678. sint8 new_value = atoi(value);
  679. ((Entity*)target)->features.cheek_type[index] = new_value;
  680. ((Entity*)target)->info_changed = true;
  681. }
  682. break;
  683. }
  684. case SPAWN_SET_CHIN_TYPE:{
  685. if(target->IsEntity() && index < 3){
  686. sprintf(tmp, "%i", ((Entity*)target)->features.chin_type[index]);
  687. sint8 new_value = atoi(value);
  688. ((Entity*)target)->features.chin_type[index] = new_value;
  689. ((Entity*)target)->info_changed = true;
  690. }
  691. break;
  692. }
  693. case SPAWN_SET_EAR_TYPE:{
  694. if(target->IsEntity() && index < 3){
  695. sprintf(tmp, "%i", ((Entity*)target)->features.ear_type[index]);
  696. sint8 new_value = atoi(value);
  697. ((Entity*)target)->features.ear_type[index] = new_value;
  698. ((Entity*)target)->info_changed = true;
  699. }
  700. break;
  701. }
  702. case SPAWN_SET_EYE_BROW_TYPE:{
  703. if(target->IsEntity() && index < 3){
  704. sprintf(tmp, "%i", ((Entity*)target)->features.eye_brow_type[index]);
  705. sint8 new_value = atoi(value);
  706. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  707. ((Entity*)target)->info_changed = true;
  708. }
  709. break;
  710. }
  711. case SPAWN_SET_EYE_TYPE:{
  712. if(target->IsEntity() && index < 3){
  713. sprintf(tmp, "%i", ((Entity*)target)->features.eye_type[index]);
  714. sint8 new_value = atoi(value);
  715. ((Entity*)target)->features.eye_type[index] = new_value;
  716. ((Entity*)target)->info_changed = true;
  717. }
  718. break;
  719. }
  720. case SPAWN_SET_LIP_TYPE:{
  721. if(target->IsEntity() && index < 3){
  722. sprintf(tmp, "%i", ((Entity*)target)->features.lip_type[index]);
  723. sint8 new_value = atoi(value);
  724. ((Entity*)target)->features.lip_type[index] = new_value;
  725. ((Entity*)target)->info_changed = true;
  726. }
  727. break;
  728. }
  729. case SPAWN_SET_NOSE_TYPE:{
  730. if(target->IsEntity() && index < 3){
  731. sprintf(tmp, "%i", ((Entity*)target)->features.nose_type[index]);
  732. sint8 new_value = atoi(value);
  733. ((Entity*)target)->features.nose_type[index] = new_value;
  734. ((Entity*)target)->info_changed = true;
  735. }
  736. break;
  737. }
  738. case SPAWN_SET_BODY_SIZE:{
  739. if(target->IsEntity()){
  740. sprintf(tmp, "%i", ((Entity*)target)->features.body_size);
  741. int8 new_value = atoul(value);
  742. ((Entity*)target)->features.body_size = new_value;
  743. ((Entity*)target)->info_changed = true;
  744. }
  745. break;
  746. }
  747. case SPAWN_SET_BODY_AGE:{
  748. if(target->IsEntity()){
  749. sprintf(tmp, "%i", ((Entity*)target)->features.body_age);
  750. int8 new_value = atoul(value);
  751. ((Entity*)target)->features.body_age = new_value;
  752. ((Entity*)target)->info_changed = true;
  753. }
  754. break;
  755. }
  756. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  757. if(target->IsEntity() && index < 3){
  758. sprintf(tmp, "%i", ((Entity*)target)->features.soga_cheek_type[index]);
  759. sint8 new_value = atoi(value);
  760. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  761. ((Entity*)target)->info_changed = true;
  762. }
  763. break;
  764. }
  765. case SPAWN_SET_SOGA_CHIN_TYPE:{
  766. if(target->IsEntity() && index < 3){
  767. sprintf(tmp, "%i", ((Entity*)target)->features.soga_chin_type[index]);
  768. sint8 new_value = atoi(value);
  769. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  770. ((Entity*)target)->info_changed = true;
  771. }
  772. break;
  773. }
  774. case SPAWN_SET_SOGA_EAR_TYPE:{
  775. if(target->IsEntity() && index < 3){
  776. sprintf(tmp, "%i", ((Entity*)target)->features.soga_ear_type[index]);
  777. sint8 new_value = atoi(value);
  778. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  779. ((Entity*)target)->info_changed = true;
  780. }
  781. break;
  782. }
  783. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  784. if(target->IsEntity() && index < 3){
  785. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_brow_type[index]);
  786. sint8 new_value = atoi(value);
  787. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  788. ((Entity*)target)->info_changed = true;
  789. }
  790. break;
  791. }
  792. case SPAWN_SET_SOGA_EYE_TYPE:{
  793. if(target->IsEntity() && index < 3){
  794. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_type[index]);
  795. sint8 new_value = atoi(value);
  796. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  797. ((Entity*)target)->info_changed = true;
  798. }
  799. break;
  800. }
  801. case SPAWN_SET_SOGA_LIP_TYPE:{
  802. if(target->IsEntity() && index < 3){
  803. sprintf(tmp, "%i", ((Entity*)target)->features.soga_lip_type[index]);
  804. sint8 new_value = atoi(value);
  805. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  806. ((Entity*)target)->info_changed = true;
  807. }
  808. break;
  809. }
  810. case SPAWN_SET_SOGA_BODY_SIZE:{
  811. if(target->IsEntity()){
  812. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_size);
  813. int8 new_value = atoul(value);
  814. ((Entity*)target)->features.soga_body_size = new_value;
  815. ((Entity*)target)->info_changed = true;
  816. }
  817. break;
  818. }
  819. case SPAWN_SET_SOGA_BODY_AGE:{
  820. if(target->IsEntity()){
  821. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_age);
  822. int8 new_value = atoul(value);
  823. ((Entity*)target)->features.soga_body_age = new_value;
  824. ((Entity*)target)->info_changed = true;
  825. }
  826. break;
  827. }
  828. case SPAWN_SET_ATTACK_TYPE:{
  829. if(target->IsEntity()){
  830. sprintf(tmp, "%u", ((Entity*)target)->GetInfoStruct()->get_attack_type());
  831. int8 new_value = atoul(value);
  832. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  833. }
  834. break;
  835. }
  836. if(temp_value)
  837. *temp_value = string(tmp);
  838. }
  839. }
  840. else{
  841. /**** NOT TEMPORARY ELSE STATEMENT ****/
  842. /**** MUST RE-DEFINE WHAT IS ALREADY IN THE IF TEMPORARY BLOCK HERE ****/
  843. switch(type){
  844. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  845. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  846. break;
  847. }
  848. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  849. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  850. break;
  851. }
  852. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  853. if (target->GetDatabaseID() > 0)
  854. {
  855. char query[256];
  856. snprintf(query, 256, "update spawn set expansion_flag=%u where id=%i", atoul(value), target->GetDatabaseID());
  857. if (database.RunQuery(query, strnlen(query, 256)))
  858. {
  859. if(client)
  860. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  861. }
  862. }
  863. break;
  864. }
  865. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  866. if (target->GetDatabaseID() > 0)
  867. {
  868. char query[256];
  869. snprintf(query, 256, "update spawn set holiday_flag=%u where id=%i", atoul(value), target->GetDatabaseID());
  870. if (database.RunQuery(query, strnlen(query, 256)))
  871. {
  872. if(client)
  873. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  874. }
  875. }
  876. break;
  877. }
  878. case SPAWN_SET_AAXP_REWARDS: {
  879. if (target->GetDatabaseID() > 0)
  880. {
  881. char query[256];
  882. snprintf(query, 256, "update spawn set aaxp_rewards=%u where id=%i", atoul(value), target->GetDatabaseID());
  883. if (database.RunQuery(query, strnlen(query, 256)))
  884. {
  885. if(client)
  886. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  887. }
  888. }
  889. break;
  890. }
  891. case SPAWN_SET_VALUE_NAME:{
  892. target->SetName(value);
  893. if(target->GetZone())
  894. target->GetZone()->SendUpdateTitles(target);
  895. break;
  896. }
  897. case SPAWN_SET_VALUE_SUB_TITLE: {
  898. target->SetSubTitle(value);
  899. if(target->GetZone())
  900. target->GetZone()->SendUpdateTitles(target);
  901. break;
  902. }
  903. case SPAWN_SET_VALUE_X_OFFSET:
  904. {
  905. target->SetXOffset(atof(value));
  906. break;
  907. }
  908. case SPAWN_SET_VALUE_Y_OFFSET:
  909. {
  910. target->SetYOffset(atof(value));
  911. break;
  912. }
  913. case SPAWN_SET_VALUE_Z_OFFSET:
  914. {
  915. target->SetZOffset(atof(value));
  916. break;
  917. }
  918. case SPAWN_SET_VALUE_EXPIRE: {
  919. target->SetExpireTime(val);
  920. break;
  921. }
  922. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  923. target->SetExpireOffsetTime(val);
  924. break;
  925. }
  926. case SPAWN_SET_VALUE_LEVEL:{
  927. target->SetLevel(val, send_update);
  928. break;
  929. }
  930. case SPAWN_SET_VALUE_DIFFICULTY:{
  931. target->SetEncounterLevel(val, send_update);
  932. break;
  933. }
  934. case SPAWN_SET_VALUE_MODEL_TYPE:{
  935. target->SetModelType(val, send_update);
  936. break;
  937. }
  938. case SPAWN_SET_VALUE_CLASS:{
  939. target->SetAdventureClass(val, send_update);
  940. break;
  941. }
  942. case SPAWN_SET_VALUE_GENDER:{
  943. target->SetGender(val, send_update);
  944. break;
  945. }
  946. case SPAWN_SET_VALUE_SHOW_NAME:{
  947. target->SetShowName(val, send_update);
  948. break;
  949. }
  950. case SPAWN_SET_VALUE_ATTACKABLE:{
  951. target->SetAttackable(val, send_update);
  952. break;
  953. }
  954. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  955. target->SetShowLevel(val, send_update);
  956. break;
  957. }
  958. case SPAWN_SET_VALUE_TARGETABLE:{
  959. target->SetTargetable(val, send_update);
  960. break;
  961. }
  962. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  963. target->SetShowCommandIcon(val, send_update);
  964. break;
  965. }
  966. case SPAWN_SET_VALUE_HAND_ICON:{
  967. target->SetShowHandIcon(val, send_update);
  968. break;
  969. }
  970. case SPAWN_SET_VALUE_HAIR_TYPE:{
  971. if(target->IsEntity())
  972. ((Entity*)target)->SetHairType(val, send_update);
  973. break;
  974. }
  975. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  976. if(target->IsEntity())
  977. ((Entity*)target)->SetFacialHairType(val, send_update);
  978. break;
  979. }
  980. case SPAWN_SET_VALUE_WING_TYPE:{
  981. if(target->IsEntity())
  982. ((Entity*)target)->SetWingType(val, send_update);
  983. break;
  984. }
  985. case SPAWN_SET_VALUE_CHEST_TYPE:{
  986. if(target->IsEntity())
  987. ((Entity*)target)->SetChestType(val, send_update);
  988. break;
  989. }
  990. case SPAWN_SET_VALUE_LEGS_TYPE:{
  991. if(target->IsEntity())
  992. ((Entity*)target)->SetLegsType(val, send_update);
  993. break;
  994. }
  995. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  996. if(target->IsEntity())
  997. ((Entity*)target)->SetSogaHairType(val, send_update);
  998. break;
  999. }
  1000. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  1001. if(target->IsEntity())
  1002. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  1003. break;
  1004. }
  1005. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  1006. target->SetSogaModelType(val, send_update);
  1007. break;
  1008. }
  1009. case SPAWN_SET_VALUE_SIZE:{
  1010. target->SetSize(val, send_update);
  1011. break;
  1012. }
  1013. case SPAWN_SET_VALUE_HP:{
  1014. target->SetHP(val, send_update);
  1015. break;
  1016. }
  1017. case SPAWN_SET_VALUE_POWER:{
  1018. target->SetPower(val, send_update);
  1019. break;
  1020. }
  1021. case SPAWN_SET_VALUE_HEROIC:{
  1022. target->SetHeroic(val, send_update);
  1023. break;
  1024. }
  1025. case SPAWN_SET_VALUE_RESPAWN:{
  1026. target->SetRespawnTime(val);
  1027. break;
  1028. }
  1029. case SPAWN_SET_VALUE_X:{
  1030. target->SetX(atof(value), send_update);
  1031. target->SetSpawnOrigX(target->GetX());
  1032. break;
  1033. }
  1034. case SPAWN_SET_VALUE_Y:{
  1035. target->SetY(atof(value), send_update);
  1036. target->SetSpawnOrigY(target->GetY());
  1037. break;
  1038. }
  1039. case SPAWN_SET_VALUE_Z:{
  1040. target->SetZ(atof(value), send_update);
  1041. target->SetSpawnOrigZ(target->GetZ());
  1042. break;
  1043. }
  1044. case SPAWN_SET_VALUE_HEADING:{
  1045. target->SetHeading(atof(value), send_update);
  1046. target->SetSpawnOrigHeading(target->GetHeading());
  1047. break;
  1048. }
  1049. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  1050. ZoneServer* zone = target->GetZone();
  1051. if (!zone && client)
  1052. zone = client->GetCurrentZone();
  1053. if(zone && zone->GetEntityCommandList(val))
  1054. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  1055. target->primary_command_list_id = val;
  1056. break;
  1057. }
  1058. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  1059. ZoneServer* zone = target->GetZone();
  1060. if (!zone && client)
  1061. zone = client->GetCurrentZone();
  1062. if (zone && zone->GetEntityCommandList(val))
  1063. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  1064. target->secondary_command_list_id = val;
  1065. break;
  1066. }
  1067. case SPAWN_SET_VALUE_VISUAL_STATE:{
  1068. target->SetVisualState(val, send_update);
  1069. break;
  1070. }
  1071. case SPAWN_SET_VALUE_ACTION_STATE:{
  1072. target->SetActionState(val, send_update);
  1073. break;
  1074. }
  1075. case SPAWN_SET_VALUE_MOOD_STATE:{
  1076. target->SetMoodState(val, send_update);
  1077. break;
  1078. }
  1079. case SPAWN_SET_VALUE_INITIAL_STATE:{
  1080. target->SetInitialState(val, send_update);
  1081. break;
  1082. }
  1083. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  1084. target->SetActivityStatus(val, send_update);
  1085. break;
  1086. }
  1087. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  1088. target->SetCollisionRadius(val, send_update);
  1089. break;
  1090. }
  1091. case SPAWN_SET_VALUE_FACTION:{
  1092. ZoneServer* zone = target->GetZone();
  1093. if (!zone && client)
  1094. zone = client->GetCurrentZone();
  1095. target->faction_id = val;
  1096. if(zone)
  1097. {
  1098. zone->RemoveDeadEnemyList(target);
  1099. if(target->IsNPC())
  1100. zone->AddEnemyList((NPC*)target);
  1101. }
  1102. break;
  1103. }
  1104. case SPAWN_SET_VALUE_DEVICE_ID:{
  1105. if (target->IsObject())
  1106. ((Object*)target)->SetDeviceID(val);
  1107. break;
  1108. }
  1109. case SPAWN_SET_VALUE_PITCH: {
  1110. target->SetPitch(atof(value), send_update);
  1111. target->SetSpawnOrigPitch(atof(value));
  1112. break;
  1113. }
  1114. case SPAWN_SET_VALUE_ROLL: {
  1115. target->SetRoll(atof(value), send_update);
  1116. target->SetSpawnOrigRoll(atof(value));
  1117. break;
  1118. }
  1119. case SPAWN_SET_VALUE_HIDE_HOOD: {
  1120. target->SetHideHood(val);
  1121. break;
  1122. }
  1123. case SPAWN_SET_VALUE_EMOTE_STATE: {
  1124. target->SetEmoteState(val);
  1125. break;
  1126. }
  1127. case SPAWN_SET_VALUE_ICON: {
  1128. target->SetIcon(val);
  1129. break;
  1130. }
  1131. case SPAWN_SET_VALUE_PREFIX: {
  1132. target->SetPrefixTitle(value);
  1133. if(target->GetZone())
  1134. target->GetZone()->SendUpdateTitles(target);
  1135. break;
  1136. }
  1137. case SPAWN_SET_VALUE_SUFFIX: {
  1138. target->SetSuffixTitle(value);
  1139. if(target->GetZone())
  1140. target->GetZone()->SendUpdateTitles(target);
  1141. break;
  1142. }
  1143. case SPAWN_SET_VALUE_LASTNAME: {
  1144. target->SetLastName(value);
  1145. if(target->GetZone())
  1146. target->GetZone()->SendUpdateTitles(target);
  1147. break;
  1148. }
  1149. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  1150. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1151. if(client){
  1152. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1153. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  1154. }
  1155. return false;
  1156. }
  1157. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  1158. return false;
  1159. else{
  1160. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  1161. target->SetSpawnScript(value);
  1162. }
  1163. break;
  1164. }
  1165. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  1166. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1167. if(client){
  1168. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1169. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  1170. }
  1171. return false;
  1172. }
  1173. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  1174. return false;
  1175. else{
  1176. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  1177. target->SetSpawnScript(value);
  1178. }
  1179. break;
  1180. }
  1181. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  1182. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1183. if(client){
  1184. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1185. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  1186. }
  1187. return false;
  1188. }
  1189. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  1190. return false;
  1191. else
  1192. target->SetSpawnScript(value);
  1193. break;
  1194. }
  1195. case SPAWN_SET_SKIN_COLOR:
  1196. case SPAWN_SET_HAIR_COLOR1:
  1197. case SPAWN_SET_HAIR_COLOR2:
  1198. case SPAWN_SET_HAIR_TYPE_COLOR:
  1199. case SPAWN_SET_HAIR_FACE_COLOR:
  1200. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1201. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1202. case SPAWN_SET_HAIR_HIGHLIGHT:
  1203. case SPAWN_SET_MODEL_COLOR:
  1204. case SPAWN_SET_EYE_COLOR:
  1205. case SPAWN_SET_SOGA_SKIN_COLOR:
  1206. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1207. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1208. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1209. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1210. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1211. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1212. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1213. case SPAWN_SET_SOGA_MODEL_COLOR:
  1214. case SPAWN_SET_SOGA_EYE_COLOR: {
  1215. if (target->IsNPC())
  1216. {
  1217. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  1218. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  1219. {
  1220. EQ2_Color clr;
  1221. clr.red = atoul(skinsep->arg[0]);
  1222. clr.green = atoul(skinsep->arg[1]);
  1223. clr.blue = atoul(skinsep->arg[2]);
  1224. Query replaceSkinQuery;
  1225. string fieldName("");
  1226. switch(type)
  1227. {
  1228. case SPAWN_SET_SKIN_COLOR:
  1229. ((Entity*)target)->SetSkinColor(clr);
  1230. fieldName.append("skin_color");
  1231. break;
  1232. case SPAWN_SET_HAIR_COLOR1:
  1233. ((Entity*)target)->SetHairColor1(clr);
  1234. fieldName.append("hair_color1");
  1235. break;
  1236. case SPAWN_SET_HAIR_COLOR2:
  1237. ((Entity*)target)->SetHairColor2(clr);
  1238. fieldName.append("hair_color2");
  1239. break;
  1240. case SPAWN_SET_HAIR_TYPE_COLOR:
  1241. ((Entity*)target)->SetHairColor(clr);
  1242. fieldName.append("hair_type_color");
  1243. break;
  1244. case SPAWN_SET_HAIR_FACE_COLOR:
  1245. ((Entity*)target)->SetFacialHairColor(clr);
  1246. fieldName.append("hair_face_color");
  1247. break;
  1248. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1249. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  1250. fieldName.append("hair_type_highlight_color");
  1251. break;
  1252. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1253. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  1254. fieldName.append("hair_face_highlight_color");
  1255. break;
  1256. case SPAWN_SET_HAIR_HIGHLIGHT:
  1257. ((Entity*)target)->SetHairHighlightColor(clr);
  1258. fieldName.append("hair_highlight");
  1259. break;
  1260. case SPAWN_SET_MODEL_COLOR:
  1261. ((Entity*)target)->SetModelColor(clr);
  1262. fieldName.append("model_color");
  1263. break;
  1264. case SPAWN_SET_EYE_COLOR:
  1265. ((Entity*)target)->SetEyeColor(clr);
  1266. fieldName.append("eye_color");
  1267. break;
  1268. case SPAWN_SET_SOGA_SKIN_COLOR:
  1269. ((Entity*)target)->SetSogaSkinColor(clr);
  1270. fieldName.append("soga_skin_color");
  1271. break;
  1272. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1273. ((Entity*)target)->SetSogaHairColor1(clr);
  1274. fieldName.append("soga_hair_color1");
  1275. break;
  1276. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1277. ((Entity*)target)->SetSogaHairColor2(clr);
  1278. fieldName.append("soga_hair_color2");
  1279. break;
  1280. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1281. ((Entity*)target)->SetSogaHairColor(clr);
  1282. fieldName.append("soga_hair_type_color");
  1283. break;
  1284. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1285. ((Entity*)target)->SetSogaFacialHairColor(clr);
  1286. fieldName.append("soga_hair_face_color");
  1287. break;
  1288. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1289. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  1290. fieldName.append("soga_hair_type_highlight_color");
  1291. break;
  1292. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1293. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  1294. fieldName.append("soga_hair_face_highlight_color");
  1295. break;
  1296. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1297. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  1298. fieldName.append("soga_hair_highlight");
  1299. break;
  1300. case SPAWN_SET_SOGA_MODEL_COLOR:
  1301. ((Entity*)target)->SetSogaModelColor(clr);
  1302. fieldName.append("soga_model_color");
  1303. break;
  1304. case SPAWN_SET_SOGA_EYE_COLOR:
  1305. ((Entity*)target)->SetSogaEyeColor(clr);
  1306. fieldName.append("soga_eye_color");
  1307. break;
  1308. }
  1309. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1310. replaceSkinQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into npc_appearance set spawn_id=%u, type='%s', red=%u, green=%u, blue=%u", target->GetDatabaseID(), fieldName.c_str(), clr.red, clr.green, clr.blue);
  1311. }
  1312. safe_delete(skinsep);
  1313. }
  1314. break;
  1315. }
  1316. case SPAWN_SET_CHEEK_TYPE:{
  1317. if(target->IsEntity() && index < 3){
  1318. sint8 new_value = atoi(value);
  1319. ((Entity*)target)->features.cheek_type[index] = new_value;
  1320. UpdateDatabaseAppearance(client, target, "cheek_type", ((Entity*)target)->features.cheek_type[0], ((Entity*)target)->features.cheek_type[1], ((Entity*)target)->features.cheek_type[2]);
  1321. }
  1322. break;
  1323. }
  1324. case SPAWN_SET_CHIN_TYPE:{
  1325. if(target->IsEntity() && index < 3){
  1326. sint8 new_value = atoi(value);
  1327. ((Entity*)target)->features.chin_type[index] = new_value;
  1328. UpdateDatabaseAppearance(client, target, "chin_type", ((Entity*)target)->features.chin_type[0], ((Entity*)target)->features.chin_type[1], ((Entity*)target)->features.chin_type[2]);
  1329. }
  1330. break;
  1331. }
  1332. case SPAWN_SET_EAR_TYPE:{
  1333. if(target->IsEntity() && index < 3){
  1334. sint8 new_value = atoi(value);
  1335. ((Entity*)target)->features.ear_type[index] = new_value;
  1336. UpdateDatabaseAppearance(client, target, "ear_type", ((Entity*)target)->features.ear_type[0], ((Entity*)target)->features.ear_type[1], ((Entity*)target)->features.ear_type[2]);
  1337. }
  1338. break;
  1339. }
  1340. case SPAWN_SET_EYE_BROW_TYPE:{
  1341. if(target->IsEntity() && index < 3){
  1342. sint8 new_value = atoi(value);
  1343. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  1344. UpdateDatabaseAppearance(client, target, "eye_brow_type", ((Entity*)target)->features.eye_brow_type[0], ((Entity*)target)->features.eye_brow_type[1], ((Entity*)target)->features.eye_brow_type[2]);
  1345. }
  1346. break;
  1347. }
  1348. case SPAWN_SET_EYE_TYPE:{
  1349. if(target->IsEntity() && index < 3){
  1350. sint8 new_value = atoi(value);
  1351. ((Entity*)target)->features.eye_type[index] = new_value;
  1352. UpdateDatabaseAppearance(client, target, "eye_type", ((Entity*)target)->features.eye_type[0], ((Entity*)target)->features.eye_type[1], ((Entity*)target)->features.eye_type[2]);
  1353. }
  1354. break;
  1355. }
  1356. case SPAWN_SET_LIP_TYPE:{
  1357. if(target->IsEntity() && index < 3){
  1358. sint8 new_value = atoi(value);
  1359. ((Entity*)target)->features.lip_type[index] = new_value;
  1360. UpdateDatabaseAppearance(client, target, "lip_type", ((Entity*)target)->features.lip_type[0], ((Entity*)target)->features.lip_type[1], ((Entity*)target)->features.lip_type[2]);
  1361. }
  1362. break;
  1363. }
  1364. case SPAWN_SET_NOSE_TYPE:{
  1365. if(target->IsEntity() && index < 3){
  1366. sint8 new_value = atoi(value);
  1367. ((Entity*)target)->features.nose_type[index] = new_value;
  1368. UpdateDatabaseAppearance(client, target, "nose_type", ((Entity*)target)->features.nose_type[0], ((Entity*)target)->features.nose_type[1], ((Entity*)target)->features.nose_type[2]);
  1369. }
  1370. break;
  1371. }
  1372. case SPAWN_SET_BODY_SIZE:{
  1373. if(target->IsEntity()){
  1374. int8 new_value = atoul(value);
  1375. ((Entity*)target)->features.body_size = new_value;
  1376. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1377. }
  1378. break;
  1379. }
  1380. case SPAWN_SET_BODY_AGE:{
  1381. if(target->IsEntity()){
  1382. int8 new_value = atoul(value);
  1383. ((Entity*)target)->features.body_age = new_value;
  1384. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1385. }
  1386. break;
  1387. }
  1388. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  1389. if(target->IsEntity() && index < 3){
  1390. sint8 new_value = atoi(value);
  1391. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  1392. UpdateDatabaseAppearance(client, target, "soga_cheek_type", ((Entity*)target)->features.soga_cheek_type[0], ((Entity*)target)->features.soga_cheek_type[1], ((Entity*)target)->features.soga_cheek_type[2]);
  1393. }
  1394. break;
  1395. }
  1396. case SPAWN_SET_SOGA_CHIN_TYPE:{
  1397. if(target->IsEntity() && index < 3){
  1398. sint8 new_value = atoi(value);
  1399. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  1400. UpdateDatabaseAppearance(client, target, "soga_chin_type", ((Entity*)target)->features.soga_chin_type[0], ((Entity*)target)->features.soga_chin_type[1], ((Entity*)target)->features.soga_chin_type[2]);
  1401. }
  1402. break;
  1403. }
  1404. case SPAWN_SET_SOGA_EAR_TYPE:{
  1405. if(target->IsEntity() && index < 3){
  1406. sint8 new_value = atoi(value);
  1407. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  1408. UpdateDatabaseAppearance(client, target, "soga_ear_type", ((Entity*)target)->features.soga_ear_type[0], ((Entity*)target)->features.soga_ear_type[1], ((Entity*)target)->features.soga_ear_type[2]);
  1409. }
  1410. break;
  1411. }
  1412. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  1413. if(target->IsEntity() && index < 3){
  1414. sint8 new_value = atoi(value);
  1415. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  1416. UpdateDatabaseAppearance(client, target, "soga_eye_brow_type", ((Entity*)target)->features.soga_eye_brow_type[0], ((Entity*)target)->features.soga_eye_brow_type[1], ((Entity*)target)->features.soga_eye_brow_type[2]);
  1417. }
  1418. break;
  1419. }
  1420. case SPAWN_SET_SOGA_EYE_TYPE:{
  1421. if(target->IsEntity() && index < 3){
  1422. sint8 new_value = atoi(value);
  1423. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  1424. UpdateDatabaseAppearance(client, target, "soga_eye_type", ((Entity*)target)->features.soga_eye_type[0], ((Entity*)target)->features.soga_eye_type[1], ((Entity*)target)->features.soga_eye_type[2]);
  1425. }
  1426. break;
  1427. }
  1428. case SPAWN_SET_SOGA_LIP_TYPE:{
  1429. if(target->IsEntity() && index < 3){
  1430. sint8 new_value = atoi(value);
  1431. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  1432. UpdateDatabaseAppearance(client, target, "soga_lip_type", ((Entity*)target)->features.soga_lip_type[0], ((Entity*)target)->features.soga_lip_type[1], ((Entity*)target)->features.soga_lip_type[2]);
  1433. }
  1434. break;
  1435. }
  1436. case SPAWN_SET_SOGA_NOSE_TYPE:{
  1437. if(target->IsEntity() && index < 3){
  1438. sint8 new_value = atoi(value);
  1439. ((Entity*)target)->features.soga_nose_type[index] = new_value;
  1440. UpdateDatabaseAppearance(client, target, "soga_nose_type", ((Entity*)target)->features.soga_nose_type[0], ((Entity*)target)->features.soga_nose_type[1], ((Entity*)target)->features.soga_nose_type[2]);
  1441. }
  1442. break;
  1443. }
  1444. case SPAWN_SET_SOGA_BODY_SIZE:{
  1445. if(target->IsEntity()){
  1446. int8 new_value = atoul(value);
  1447. ((Entity*)target)->features.body_size = new_value;
  1448. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1449. }
  1450. break;
  1451. }
  1452. case SPAWN_SET_SOGA_BODY_AGE:{
  1453. if(target->IsEntity()){
  1454. int8 new_value = atoul(value);
  1455. ((Entity*)target)->features.body_age = new_value;
  1456. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1457. }
  1458. break;
  1459. }
  1460. case SPAWN_SET_ATTACK_TYPE:{
  1461. if(target->IsEntity()){
  1462. int8 new_value = atoul(value);
  1463. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  1464. if(target->IsNPC()) {
  1465. if(target->GetDatabaseID()) {
  1466. Query spawnNPCQuery;
  1467. spawnNPCQuery.AddQueryAsync(0, &database, Q_INSERT, "update spawn_npcs set attack_type=%u where id=%u", new_value, target->GetDatabaseID());
  1468. } else if(client) {
  1469. client->Message(CHANNEL_COLOR_RED, "Invalid spawn to update the database (NPC only) or no database id for the NPC present.");
  1470. }
  1471. }
  1472. }
  1473. break;
  1474. }
  1475. }
  1476. }
  1477. return true;
  1478. }
  1479. void Commands::UpdateDatabaseAppearance(Client* client, Spawn* target, string fieldName, sint8 r, sint8 g, sint8 b)
  1480. {
  1481. Query replaceQuery;
  1482. if(target->IsBot())
  1483. {
  1484. Bot* bot = (Bot*)target;
  1485. if(bot->BotID)
  1486. database.SaveBotFloats(bot->BotID, fieldName.c_str(), r, g, b);
  1487. }
  1488. else if(target->IsPlayer())
  1489. {
  1490. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from char_colors where char_id=%u and type='%s'", ((Player*)target)->GetCharacterID(), fieldName.c_str());
  1491. replaceQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into char_colors set char_id=%u, type='%s', red=%i, green=%i, blue=%i", ((Player*)target)->GetCharacterID(), fieldName.c_str(), r, g, b);
  1492. }
  1493. else
  1494. {
  1495. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1496. replaceQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into npc_appearance set spawn_id=%u, type='%s', red=%i, green=%i, blue=%i", target->GetDatabaseID(), fieldName.c_str(), r, g, b);
  1497. }
  1498. ((Entity*)target)->changed = true;
  1499. ((Entity*)target)->info_changed = true;
  1500. if(target->GetZone())
  1501. target->GetZone()->AddChangedSpawn(target);
  1502. }
  1503. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  1504. the database fields always and also update the zone in memory if it's running. */
  1505. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  1506. if (client && zone_id > 0 && type > 0 && value) {
  1507. sint32 int_value = 0;
  1508. float float_value = 0;
  1509. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  1510. try {
  1511. float_value = atof(value);
  1512. }
  1513. catch (...) {
  1514. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  1515. return false;
  1516. }
  1517. }
  1518. 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) {
  1519. try {
  1520. int_value = atoi(value);
  1521. }
  1522. catch (...) {
  1523. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  1524. return false;
  1525. }
  1526. }
  1527. switch (type) {
  1528. case ZONE_SET_VALUE_EXPANSION_ID: {
  1529. break;
  1530. }
  1531. case ZONE_SET_VALUE_NAME: {
  1532. if (zone)
  1533. zone->SetZoneName(const_cast<char*>(value));
  1534. database.SaveZoneInfo(zone_id, "name", value);
  1535. break;
  1536. }
  1537. case ZONE_SET_VALUE_FILE: {
  1538. if (zone)
  1539. zone->SetZoneFile(const_cast<char*>(value));
  1540. database.SaveZoneInfo(zone_id, "file", value);
  1541. break;
  1542. }
  1543. case ZONE_SET_VALUE_DESCRIPTION: {
  1544. if (zone)
  1545. zone->SetZoneDescription(const_cast<char*>(value));
  1546. database.SaveZoneInfo(zone_id, "description", value);
  1547. break;
  1548. }
  1549. case ZONE_SET_VALUE_SAFE_X: {
  1550. if (zone)
  1551. zone->SetSafeX(float_value);
  1552. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  1553. break;
  1554. }
  1555. case ZONE_SET_VALUE_SAFE_Y: {
  1556. if (zone)
  1557. zone->SetSafeY(float_value);
  1558. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  1559. break;
  1560. }
  1561. case ZONE_SET_VALUE_SAFE_Z: {
  1562. if (zone)
  1563. zone->SetSafeZ(float_value);
  1564. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  1565. break;
  1566. }
  1567. case ZONE_SET_VALUE_UNDERWORLD: {
  1568. if (zone)
  1569. zone->SetUnderWorld(float_value);
  1570. database.SaveZoneInfo(zone_id, "underworld", float_value);
  1571. break;
  1572. }
  1573. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  1574. break;
  1575. }
  1576. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  1577. break;
  1578. }
  1579. case ZONE_SET_VALUE_ZONE_TYPE: {
  1580. break;
  1581. }
  1582. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  1583. if (zone)
  1584. zone->SetAlwaysLoaded(int_value == 1);
  1585. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  1586. break;
  1587. }
  1588. case ZONE_SET_VALUE_CITY_ZONE: {
  1589. if (zone)
  1590. zone->SetCityZone(int_value == 1);
  1591. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  1592. break;
  1593. }
  1594. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  1595. if (zone)
  1596. zone->SetWeatherAllowed(int_value == 1);
  1597. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  1598. break;
  1599. }
  1600. case ZONE_SET_VALUE_MIN_STATUS: {
  1601. if (zone)
  1602. zone->SetMinimumStatus(int_value);
  1603. database.SaveZoneInfo(zone_id, "min_status", int_value);
  1604. break;
  1605. }
  1606. case ZONE_SET_VALUE_MIN_LEVEL: {
  1607. if (zone)
  1608. zone->SetMinimumLevel(int_value);
  1609. database.SaveZoneInfo(zone_id, "min_level", int_value);
  1610. break;
  1611. }
  1612. case ZONE_SET_VALUE_MAX_LEVEL: {
  1613. if (zone)
  1614. zone->SetMaximumLevel(int_value);
  1615. database.SaveZoneInfo(zone_id, "max_level", int_value);
  1616. break;
  1617. }
  1618. case ZONE_SET_VALUE_START_ZONE: {
  1619. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  1620. break;
  1621. }
  1622. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  1623. if (zone)
  1624. zone->SetInstanceType(int_value);
  1625. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  1626. break;
  1627. }
  1628. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  1629. if (zone)
  1630. zone->SetDefaultReenterTime(int_value);
  1631. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  1632. break;
  1633. }
  1634. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  1635. if (zone)
  1636. zone->SetDefaultResetTime(int_value);
  1637. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  1638. break;
  1639. }
  1640. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1641. if (zone)
  1642. zone->SetDefaultLockoutTime(int_value);
  1643. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1644. break;
  1645. }
  1646. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1647. if (zone)
  1648. zone->SetForceGroupZoneOption(int_value);
  1649. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1650. break;
  1651. }
  1652. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1653. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1654. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1655. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1656. return false;
  1657. }
  1658. else {
  1659. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1660. database.SaveZoneInfo(zone_id, "lua_script", value);
  1661. }
  1662. break;
  1663. }
  1664. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1665. if (zone)
  1666. zone->SetShutdownTimer(int_value);
  1667. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1668. break;
  1669. }
  1670. case ZONE_SET_VALUE_ZONE_MOTD: {
  1671. if (zone)
  1672. zone->SetZoneMOTD(string(value));
  1673. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1674. break;
  1675. }
  1676. default: {
  1677. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1678. return false;
  1679. }
  1680. }
  1681. }
  1682. else {
  1683. if (client)
  1684. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1685. return false;
  1686. }
  1687. return true;
  1688. }
  1689. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1690. if (index >= remote_commands->commands.size()) {
  1691. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1692. return;
  1693. }
  1694. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1695. EQ2_RemoteCommandString* parent_command = 0;
  1696. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1697. Seperator* sep = 0;
  1698. if (command_parms->size > 0) {
  1699. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1700. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1701. parent_command = command;
  1702. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1703. safe_delete(sep);
  1704. if (command_parms->data.length() > (command->command.data.length() + 1))
  1705. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1706. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1707. }
  1708. else
  1709. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1710. }
  1711. int ndx = 0;
  1712. if (command->required_status > client->GetAdminStatus())
  1713. {
  1714. 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());
  1715. safe_delete(sep);
  1716. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1717. return;
  1718. }
  1719. Player* player = client->GetPlayer();
  1720. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1721. switch (command->handler) {
  1722. case COMMAND_RELOAD: {
  1723. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1724. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1725. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1726. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1727. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1728. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1729. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1730. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1731. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1732. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1733. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1734. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1735. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1736. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1737. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1738. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1739. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1740. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1741. break;
  1742. }
  1743. case COMMAND_RELOADSTRUCTS: {
  1744. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1745. world.SetReloadingSubsystem("Structs");
  1746. configReader.ReloadStructs();
  1747. world.RemoveReloadingSubSystem("Structs");
  1748. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1749. break;
  1750. }
  1751. case COMMAND_RELOAD_QUESTS: {
  1752. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1753. world.SetReloadingSubsystem("Quests");
  1754. master_quest_list.Reload();
  1755. client_list.ReloadQuests();
  1756. zone_list.ReloadClientQuests();
  1757. world.RemoveReloadingSubSystem("Quests");
  1758. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1759. break;
  1760. }
  1761. case COMMAND_RELOAD_SPAWNS: {
  1762. client->GetCurrentZone()->ReloadSpawns();
  1763. break;
  1764. }
  1765. case COMMAND_RELOAD_SPELLS: {
  1766. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1767. world.SetReloadingSubsystem("Spells");
  1768. zone_list.DeleteSpellProcess();
  1769. master_spell_list.Reload();
  1770. if (lua_interface)
  1771. lua_interface->ReloadSpells();
  1772. zone_list.LoadSpellProcess();
  1773. world.RemoveReloadingSubSystem("Spells");
  1774. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1775. break;
  1776. }
  1777. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1778. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1779. world.SetReloadingSubsystem("GroundSpawns");
  1780. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1781. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1782. world.RemoveReloadingSubSystem("GroundSpawns");
  1783. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1784. break;
  1785. }
  1786. case COMMAND_RELOAD_ZONESCRIPTS: {
  1787. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1788. world.SetReloadingSubsystem("ZoneScripts");
  1789. world.ResetZoneScripts();
  1790. database.LoadZoneScriptData();
  1791. if (lua_interface)
  1792. lua_interface->DestroyZoneScripts();
  1793. world.RemoveReloadingSubSystem("ZoneScripts");
  1794. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1795. break;
  1796. }
  1797. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1798. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1799. world.SetReloadingSubsystem("EntityCommands");
  1800. client->GetCurrentZone()->ClearEntityCommands();
  1801. database.LoadEntityCommands(client->GetCurrentZone());
  1802. world.RemoveReloadingSubSystem("EntityCommands");
  1803. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1804. break;
  1805. }
  1806. case COMMAND_RELOAD_FACTIONS: {
  1807. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1808. world.SetReloadingSubsystem("Factions");
  1809. master_faction_list.Clear();
  1810. database.LoadFactionList();
  1811. world.RemoveReloadingSubSystem("Factions");
  1812. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1813. break;
  1814. }
  1815. case COMMAND_RELOAD_MAIL: {
  1816. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1817. zone_list.ReloadMail();
  1818. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1819. break;
  1820. }
  1821. case COMMAND_RELOAD_GUILDS: {
  1822. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1823. world.ReloadGuilds();
  1824. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1825. break;
  1826. }
  1827. case COMMAND_RELOAD_LOCATIONS: {
  1828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1829. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1830. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1831. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1832. break;
  1833. }
  1834. case COMMAND_RELOAD_RULES: {
  1835. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1836. database.LoadRuleSets(true);
  1837. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1838. break;
  1839. }
  1840. case COMMAND_RELOAD_TRANSPORTERS: {
  1841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1842. database.LoadTransporters(client->GetCurrentZone());
  1843. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1844. break;
  1845. }
  1846. case COMMAND_RELOAD_STARTABILITIES: {
  1847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1848. world.PurgeStartingLists();
  1849. world.LoadStartingLists();
  1850. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1851. break;
  1852. }
  1853. case COMMAND_READ: {
  1854. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1855. if (strcmp(sep->arg[0], "read") == 0) {
  1856. int32 item_index = atol(sep->arg[1]);
  1857. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1858. if (item) {
  1859. Spawn* spawn = cmdTarget;
  1860. client->SendShowBook(client->GetPlayer(), item->name, item->book_pages);
  1861. break;
  1862. }
  1863. }
  1864. }
  1865. break;
  1866. }
  1867. case COMMAND_USEABILITY:{
  1868. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1869. if (client->GetPlayer()->GetHP() == 0) {
  1870. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1871. }
  1872. else {
  1873. int32 spell_id = atoul(sep->arg[0]);
  1874. int8 spell_tier = 0;
  1875. if (sep->arg[1][0] && sep->IsNumber(1))
  1876. spell_tier = atoi(sep->arg[1]);
  1877. else
  1878. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1879. if (!spell_tier)
  1880. spell_tier = 1;
  1881. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1882. if (spell) {
  1883. 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)
  1884. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1885. else
  1886. {
  1887. if (cmdTarget)
  1888. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1889. else
  1890. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1891. }
  1892. }
  1893. }
  1894. }
  1895. else if (cmdTarget && cmdTarget->IsWidget())
  1896. {
  1897. Widget* widget = (Widget*)cmdTarget;
  1898. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1899. }
  1900. else
  1901. {
  1902. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1903. }
  1904. break;
  1905. }
  1906. case COMMAND_INFO:{
  1907. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1908. if(strcmp(sep->arg[0], "inventory") == 0){
  1909. int32 item_index = atol(sep->arg[1]);
  1910. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1911. if(item){
  1912. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1913. break;
  1914. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1915. //DumpPacket(app);
  1916. client->QueuePacket(app);
  1917. if(item->GetItemScript() && lua_interface)
  1918. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1919. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1920. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  1921. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1922. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  1923. }
  1924. }
  1925. else
  1926. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1927. }
  1928. else if(strcmp(sep->arg[0], "equipment") == 0){
  1929. int32 item_index = atol(sep->arg[1]);
  1930. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1931. if(item){
  1932. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1933. client->QueuePacket(app);
  1934. if(item->GetItemScript() && lua_interface)
  1935. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1936. }
  1937. else
  1938. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1939. }
  1940. else if(strcmp(sep->arg[0], "appearance") == 0){
  1941. int32 item_index = atol(sep->arg[1]);
  1942. Item* item = client->GetPlayer()->GetAppearanceEquipmentList()->GetItem(item_index);
  1943. if(item){
  1944. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1945. client->QueuePacket(app);
  1946. if(item->GetItemScript() && lua_interface)
  1947. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1948. }
  1949. else
  1950. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1951. }
  1952. 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){
  1953. int32 item_id = atoul(sep->arg[1]);
  1954. Item* item = master_item_list.GetItem(item_id);
  1955. if(item){
  1956. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1957. client->QueuePacket(app);
  1958. }
  1959. else
  1960. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1961. }
  1962. else if (strcmp(sep->arg[0], "spell") == 0) {
  1963. sint32 spell_id = atol(sep->arg[1]);
  1964. int8 tier = atoi(sep->arg[3]);
  1965. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1966. if (outapp)
  1967. client->QueuePacket(outapp);
  1968. else
  1969. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1970. }
  1971. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1972. sint32 spell_id = atol(sep->arg[2]);
  1973. int8 group = atoi(sep->arg[1]);
  1974. AltAdvanceData* data = 0;
  1975. SpellBookEntry* spellentry = 0;
  1976. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1977. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1978. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1979. if (outapp)
  1980. client->QueuePacket(outapp);
  1981. else
  1982. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1983. }
  1984. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1985. sint32 spell_id = atol(sep->arg[1]);
  1986. int32 tier = atoi(sep->arg[2]);
  1987. if (tier > 255) {
  1988. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  1989. if (ent)
  1990. tier = ent->tier;
  1991. }
  1992. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  1993. if (outapp)
  1994. client->QueuePacket(outapp);
  1995. else
  1996. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1997. }
  1998. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1999. sint32 recipe_id = atol(sep->arg[1]);
  2000. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  2001. if(outapp)
  2002. client->QueuePacket(outapp);
  2003. else
  2004. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  2005. }
  2006. else if (strcmp(sep->arg[0], "maintained") ==0) {
  2007. int32 slot = atol(sep->arg[1]);
  2008. int32 spell_id = atol(sep->arg[2]);
  2009. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  2010. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2011. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  2012. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  2013. if(outapp)
  2014. client->QueuePacket(outapp);
  2015. else
  2016. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  2017. }
  2018. else if (strcmp(sep->arg[0], "effect") == 0) {
  2019. int32 spell_id = atol(sep->arg[1]);
  2020. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  2021. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2022. int8 type = 0;
  2023. if (client->GetVersion() <= 546)
  2024. type = 1;
  2025. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  2026. if (outapp){
  2027. client->QueuePacket(outapp);
  2028. }
  2029. else
  2030. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  2031. }
  2032. }
  2033. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  2034. Item* item = player->item_list.GetOverflowItem();
  2035. if(item) {
  2036. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2037. client->QueuePacket(app);
  2038. }
  2039. else
  2040. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  2041. }
  2042. else
  2043. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  2044. break;
  2045. }
  2046. case COMMAND_USE_EQUIPPED_ITEM:{
  2047. if (sep && sep->arg[0] && sep->IsNumber(0)){
  2048. int32 slot_id = atoul(sep->arg[0]);
  2049. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  2050. if (item && item->generic_info.usable && item->GetItemScript())
  2051. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  2052. }
  2053. break;
  2054. }
  2055. case COMMAND_USE_ITEM: {
  2056. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2057. int32 item_index = atoul(sep->arg[0]);
  2058. Item* item = player->item_list.GetItemFromIndex(item_index);
  2059. if (item && item->GetItemScript()) {
  2060. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  2061. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  2062. else {
  2063. if (item->details.count > 0) {
  2064. std::string itemName = string(item->name);
  2065. int32 item_id = item->details.item_id;
  2066. sint64 flags = 0;
  2067. if(lua_interface->RunItemScript(item->GetItemScript(), "used", item, player, &flags) && flags >= 0)
  2068. {
  2069. //reobtain item make sure it wasn't removed
  2070. item = player->item_list.GetItemFromIndex(item_index);
  2071. if(!item)
  2072. LogWrite(PLAYER__WARNING, 0, "Command", "%s: Item %s (%i) was used, however after the item looks to be removed.", client->GetPlayer()->GetName(), itemName.c_str(), item_id);
  2073. else if(!item->generic_info.display_charges && item->generic_info.max_charges == 1) {
  2074. client->Message(CHANNEL_NARRATIVE, "%s is out of charges. It has been removed.", item->name.c_str());
  2075. client->RemoveItem(item, 1); // end of a set of charges OR an item that uses a stack count of actual item quantity
  2076. }
  2077. else
  2078. {
  2079. item->details.count--; // charges
  2080. item->save_needed = true;
  2081. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  2082. if(!item->details.count) {
  2083. client->Message(CHANNEL_NARRATIVE, "%s is out of charges. It has been removed.", item->name.c_str());
  2084. client->RemoveItem(item, 1); // end of a set of charges OR an item that uses a stack count of actual item quantity
  2085. }
  2086. }
  2087. }
  2088. else
  2089. LogWrite(PLAYER__WARNING, 0, "Command", "%s: Item %s (%i) was used, after it returned %i, bypassing any removal/update of items.", client->GetPlayer()->GetName(), itemName.c_str(), item_id, flags);
  2090. }
  2091. else
  2092. {
  2093. //reobtain item make sure it wasn't removed
  2094. item = player->item_list.GetItemFromIndex(item_index);
  2095. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is out of charges.");
  2096. if(item) {
  2097. LogWrite(PLAYER__ERROR, 0, "Command", "%s: Item %s (%i) attempted to be used, however details.count is 0.", client->GetPlayer()->GetName(), item->name.c_str(), item->details.item_id);
  2098. }
  2099. }
  2100. }
  2101. }
  2102. }
  2103. break;
  2104. }
  2105. case COMMAND_SCRIBE_SCROLL_ITEM: {
  2106. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2107. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  2108. if (item) {
  2109. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  2110. if(item->generic_info.item_type == 6) {
  2111. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  2112. int8 old_slot = 0;
  2113. if (spell) {
  2114. int16 tier_up = player->GetTierUp(spell->GetSpellTier());
  2115. if (rule_manager.GetGlobalRule(R_Spells, RequirePreviousTierScribe)->GetInt8() && !player->HasSpell(spell->GetSpellID(), tier_up, false, true))
  2116. client->SimpleMessage(CHANNEL_COLOR_RED, "You have not scribed the required previous version of this ability.");
  2117. else if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  2118. old_slot = player->GetSpellSlot(spell->GetSpellID());
  2119. player->RemoveSpellBookEntry(spell->GetSpellID());
  2120. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  2121. player->UnlockSpell(spell);
  2122. client->SendSpellUpdate(spell);
  2123. database.DeleteItem(client->GetCharacterID(), item, 0);
  2124. player->item_list.RemoveItem(item, true);
  2125. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  2126. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  2127. // force purge client cache and display updated spell for hover over
  2128. EQ2Packet* app = spell->SerializeSpell(client, false, false);
  2129. client->QueuePacket(app);
  2130. }
  2131. }
  2132. else
  2133. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  2134. }
  2135. else if(item->generic_info.item_type == 7){
  2136. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  2137. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  2138. // if valid recipe book and the player doesn't have it
  2139. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  2140. client->Message(CHANNEL_NARRATIVE, "Your tradeskill level is not high enough to scribe this book.");
  2141. safe_delete(recipe_book);
  2142. }
  2143. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  2144. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  2145. // Add recipe book to the players list
  2146. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  2147. // Get a list of all recipes this book contains
  2148. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  2149. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  2150. // Create the packet to send to update the players recipe list
  2151. PacketStruct* packet = 0;
  2152. if (client->GetRecipeListSent()) {
  2153. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  2154. if (packet)
  2155. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  2156. }
  2157. // loop through the list
  2158. vector<Recipe*>::iterator itr;
  2159. int16 i = 0;
  2160. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  2161. // check to see if the player already has this recipe some how
  2162. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  2163. // Player doesn't already have this recipe so lets add it
  2164. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  2165. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  2166. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  2167. client->Message(CHANNEL_NARRATIVE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  2168. if (packet && client->GetRecipeListSent()) {
  2169. packet->setArrayDataByName("id", recipe->GetID(), i);
  2170. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  2171. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  2172. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  2173. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  2174. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  2175. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  2176. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  2177. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  2178. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  2179. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  2180. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  2181. i++;
  2182. }
  2183. }
  2184. }
  2185. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  2186. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  2187. database.DeleteItem(client->GetCharacterID(), item, 0);
  2188. client->GetPlayer()->item_list.RemoveItem(item, true);
  2189. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  2190. if (packet && client->GetRecipeListSent())
  2191. client->QueuePacket(packet->serialize());
  2192. safe_delete(packet);
  2193. }
  2194. else {
  2195. if (recipe_book)
  2196. client->Message(CHANNEL_NARRATIVE, "You have already learned all you can from this item.");
  2197. safe_delete(recipe_book);
  2198. }
  2199. }
  2200. }
  2201. else
  2202. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  2203. }
  2204. break;
  2205. }
  2206. case COMMAND_SUMMONITEM: {
  2207. if (sep && sep->IsNumber(0)) {
  2208. int32 item_id = atol(sep->arg[0]);
  2209. int32 quantity = 1;
  2210. if (sep->arg[1] && sep->IsNumber(1))
  2211. quantity = atoi(sep->arg[1]);
  2212. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  2213. client->AddItemToBank(item_id,quantity);
  2214. }
  2215. else {
  2216. client->AddItem(item_id, quantity);
  2217. }
  2218. }
  2219. else {
  2220. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  2221. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  2222. }
  2223. break;
  2224. }
  2225. case COMMAND_COLLECTION_ADDITEM: {
  2226. // takes 2 params: collection_id, slot
  2227. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2228. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  2229. if (item)
  2230. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  2231. else
  2232. 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]));
  2233. }
  2234. else
  2235. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  2236. break;
  2237. }
  2238. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  2239. // takes 1 param: slot
  2240. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  2241. int i = 0;
  2242. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  2243. printf("\t%u: %s\n", i, sep->arg[i]);
  2244. i++;
  2245. }
  2246. break;
  2247. }
  2248. case COMMAND_WAYPOINT: {
  2249. bool success = false;
  2250. client->ClearWaypoint();
  2251. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  2252. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  2253. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2254. }
  2255. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  2256. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  2257. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2258. }
  2259. else {
  2260. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  2261. }
  2262. break;
  2263. }
  2264. case COMMAND_WHO:{
  2265. const char* who = 0;
  2266. if(sep && sep->arg[0]){
  2267. //cout << "Who query: \n";
  2268. who = sep->argplus[0];
  2269. //cout << who << endl;
  2270. }
  2271. zone_list.ProcessWhoQuery(who, client);
  2272. break;
  2273. }
  2274. case COMMAND_SELECT_JUNCTION:{
  2275. 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__);
  2276. int32 choice = 0;
  2277. if(sep && sep->arg[0] && sep->IsNumber(0))
  2278. choice = atoul(sep->arg[0]);
  2279. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  2280. client->HandlePlayerRevive(choice);
  2281. }
  2282. break;
  2283. }
  2284. case COMMAND_SPAWN_MOVE: {
  2285. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  2286. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  2287. if (packet) {
  2288. float unknown2_3 = 0;
  2289. int8 placement_mode = 0;
  2290. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  2291. if (sep && sep->arg[0][0]) {
  2292. if (strcmp(sep->arg[0], "wall") == 0) {
  2293. placement_mode = 2;
  2294. unknown2_3 = 150;
  2295. }
  2296. else if (strcmp(sep->arg[0], "ceiling") == 0)
  2297. placement_mode = 1;
  2298. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  2299. {
  2300. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  2301. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  2302. }
  2303. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  2304. {
  2305. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  2306. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  2307. }
  2308. else if (strcmp(sep->arg[0], "myloc") == 0)
  2309. {
  2310. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  2311. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  2312. safe_delete(packet);
  2313. break;
  2314. }
  2315. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  2316. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  2317. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  2318. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  2319. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  2320. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  2321. safe_delete(packet);
  2322. break;
  2323. }
  2324. }
  2325. packet->setDataByName("placement_mode", placement_mode);
  2326. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  2327. packet->setDataByName("model_type", cmdTarget->GetModelType());
  2328. packet->setDataByName("unknown", 1); //size
  2329. packet->setDataByName("unknown2", 1); //size 2
  2330. packet->setDataByName("unknown2", .5, 1); //size 3
  2331. packet->setDataByName("unknown2", 3, 2);
  2332. packet->setDataByName("unknown2", unknown2_3, 3);
  2333. packet->setDataByName("max_distance", 500);
  2334. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  2335. client->QueuePacket(packet->serialize());
  2336. safe_delete(packet);
  2337. }
  2338. }
  2339. else {
  2340. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  2341. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  2342. }
  2343. break;
  2344. }
  2345. case COMMAND_HAIL:{
  2346. Spawn* spawn = cmdTarget;
  2347. if(spawn && spawn->GetTargetable())
  2348. {
  2349. char tmp[75] = {0};
  2350. sprintf(tmp, "Hail, %s", spawn->GetName());
  2351. bool show_bubble = true;
  2352. if (spawn->IsNPC())
  2353. show_bubble = false;
  2354. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  2355. if(spawn->IsPlayer() == false && spawn->Alive() && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetGlobalRule(R_Spawn, HailDistance)->GetInt32()){
  2356. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  2357. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  2358. else
  2359. {
  2360. bool pauseRunback = false;
  2361. // prime runback as the heading or anything can be altered when hailing succeeds
  2362. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  2363. {
  2364. ((NPC*)spawn)->StartRunback();
  2365. pauseRunback = true;
  2366. }
  2367. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  2368. spawn->PauseMovement(rule_manager.GetGlobalRule(R_Spawn, HailMovementPause)->GetInt32());
  2369. else if(spawn->IsNPC() && pauseRunback)
  2370. ((NPC*)spawn)->ClearRunback();
  2371. }
  2372. }
  2373. }
  2374. else {
  2375. string tmp = "Hail";
  2376. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  2377. }
  2378. break;
  2379. }
  2380. case COMMAND_SAY:{
  2381. if (sep && sep->arg[0][0]) {
  2382. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  2383. if (cmdTarget && !(cmdTarget->IsPlayer()))
  2384. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  2385. }
  2386. else
  2387. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  2388. break;
  2389. }
  2390. case COMMAND_TELL:{
  2391. if(sep && sep->arg[0] && sep->argplus[1]){
  2392. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1]))
  2393. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  2394. }else
  2395. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  2396. break;
  2397. }
  2398. case COMMAND_SHOUT:{
  2399. if(sep && sep->arg[0][0])
  2400. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  2401. else
  2402. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  2403. break;
  2404. }
  2405. case COMMAND_AUCTION:{
  2406. if(sep && sep->arg[0][0])
  2407. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  2408. else
  2409. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  2410. break;
  2411. }
  2412. case COMMAND_OOC:{
  2413. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2414. if(sep && sep->arg[0][0])
  2415. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0]);
  2416. else
  2417. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2418. break;
  2419. }
  2420. case COMMAND_EMOTE:{
  2421. if(sep && sep->arg[0][0])
  2422. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2423. else
  2424. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2425. break;
  2426. }
  2427. case COMMAND_RACE:{
  2428. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2429. if(sep->arg[1][0] && sep->IsNumber(1)){
  2430. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2431. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2432. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2433. client->GetPlayer()->SetCharSheetChanged(true);
  2434. }
  2435. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2436. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2437. //client->QueuePacket(outapp);
  2438. }
  2439. else{
  2440. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2441. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2442. }
  2443. break;
  2444. }
  2445. case COMMAND_BANK_DEPOSIT:{
  2446. if(client->GetBanker() && sep && sep->arg[0]){
  2447. int64 amount = 0;
  2448. string deposit = string(sep->arg[0]);
  2449. amount = atoi64(deposit.c_str());
  2450. client->BankDeposit(amount);
  2451. }
  2452. break;
  2453. }
  2454. case COMMAND_BANK_WITHDRAWAL:{
  2455. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2456. int64 amount = 0;
  2457. string deposit = string(sep->arg[0]);
  2458. amount = atoi64(deposit.c_str());
  2459. client->BankWithdrawal(amount);
  2460. }
  2461. break;
  2462. }
  2463. case COMMAND_BANK_CANCEL:{
  2464. Spawn* banker = cmdTarget;
  2465. client->Bank(banker, true);
  2466. break;
  2467. }
  2468. case COMMAND_BANK:{
  2469. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2470. Spawn* banker = cmdTarget;
  2471. client->Bank(banker);
  2472. break;
  2473. }
  2474. case COMMAND_GUILD_BANK:{
  2475. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2476. //Spawn* banker = client->GetPlayer()->GetTarget();
  2477. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2478. break;
  2479. }
  2480. case COMMAND_START_MAIL: {
  2481. client->SetMailTransaction(cmdTarget);
  2482. client->SendMailList();
  2483. break;
  2484. }
  2485. case COMMAND_CANCEL_MAIL: {
  2486. client->SetMailTransaction(0);
  2487. break;
  2488. }
  2489. case COMMAND_GET_MAIL_MESSAGE: {
  2490. if (sep && sep->arg[0] && sep->IsNumber(0))
  2491. client->DisplayMailMessage(atoul(sep->arg[0]));
  2492. break;
  2493. }
  2494. case COMMAND_ADD_MAIL_PLAT: {
  2495. if (sep && sep->arg[0] && sep->IsNumber(0))
  2496. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2497. break;
  2498. }
  2499. case COMMAND_ADD_MAIL_GOLD: {
  2500. if (sep && sep->arg[0] && sep->IsNumber(0))
  2501. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2502. break;
  2503. }
  2504. case COMMAND_ADD_MAIL_SILVER: {
  2505. if (sep && sep->arg[0] && sep->IsNumber(0))
  2506. client->AddMailCoin(0, atoul(sep->arg[0]));
  2507. break;
  2508. }
  2509. case COMMAND_ADD_MAIL_COPPER: {
  2510. if (sep && sep->arg[0] && sep->IsNumber(0))
  2511. client->AddMailCoin(atoul(sep->arg[0]));
  2512. break;
  2513. }
  2514. case COMMAND_SET_MAIL_ITEM: {
  2515. if(sep && sep->IsNumber(0) && sep->IsNumber(2))
  2516. {
  2517. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2518. if(item)
  2519. {
  2520. int16 quantity = atoul(sep->arg[1]);
  2521. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2522. {
  2523. return;
  2524. }
  2525. if(item->IsBag())
  2526. {
  2527. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2528. if(bag_items && bag_items->size() > 0)
  2529. {
  2530. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2531. safe_delete(bag_items);
  2532. return;
  2533. }
  2534. safe_delete(bag_items);
  2535. }
  2536. Item* itemtoadd = item;
  2537. if(quantity > 0)
  2538. {
  2539. if(quantity > item->details.count)
  2540. return;
  2541. Item* tmpItem = new Item(item);
  2542. tmpItem->details.count = quantity;
  2543. itemtoadd = tmpItem;
  2544. }
  2545. if(client->AddMailItem(itemtoadd))
  2546. {
  2547. client->RemoveItem(item, quantity, true);
  2548. }
  2549. }
  2550. }
  2551. break;
  2552. }
  2553. case COMMAND_REMOVE_MAIL_PLAT: {
  2554. if (sep && sep->arg[0] && sep->IsNumber(0))
  2555. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2556. break;
  2557. }
  2558. case COMMAND_REMOVE_MAIL_GOLD: {
  2559. if (sep && sep->arg[0] && sep->IsNumber(0))
  2560. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2561. break;
  2562. }
  2563. case COMMAND_REMOVE_MAIL_SILVER: {
  2564. if (sep && sep->arg[0] && sep->IsNumber(0))
  2565. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2566. break;
  2567. }
  2568. case COMMAND_REMOVE_MAIL_COPPER: {
  2569. if (sep && sep->arg[0] && sep->IsNumber(0))
  2570. client->RemoveMailCoin(atoul(sep->arg[0]));
  2571. break;
  2572. }
  2573. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2574. if (sep && sep->arg[0] && sep->IsNumber(0))
  2575. client->TakeMailAttachments(atoul(sep->arg[0]));
  2576. break;
  2577. }
  2578. case COMMAND_CANCEL_SEND_MAIL: {
  2579. client->ResetSendMail();
  2580. break;
  2581. }
  2582. case COMMAND_DELETE_MAIL_MESSAGE: {
  2583. if (sep && sep->arg[0] && sep->IsNumber(0))
  2584. client->DeleteMail(atoul(sep->arg[0]), true);
  2585. break;
  2586. }
  2587. case COMMAND_REPORT_SPAM: {
  2588. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2589. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2590. break;
  2591. }
  2592. case COMMAND_KILL:{
  2593. Spawn* dead = 0;
  2594. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2595. dead=client->GetPlayer();
  2596. client->GetPlayer()->SetHP(0);
  2597. client->GetPlayer()->KillSpawn(dead);
  2598. }else{
  2599. dead= cmdTarget;
  2600. if(dead && dead->IsPlayer() == false){
  2601. dead->SetHP(0);
  2602. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2603. client->GetCurrentZone()->RemoveSpawn(dead, true, true, true, true, true);
  2604. else
  2605. client->GetPlayer()->KillSpawn(dead);
  2606. }else{
  2607. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2608. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2609. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2610. }
  2611. }
  2612. break;
  2613. }
  2614. case COMMAND_LEVEL:{
  2615. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2616. int16 new_level = atoi(sep->arg[ndx]);
  2617. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2618. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2619. else {
  2620. if (new_level < 1)
  2621. new_level = 1;
  2622. if (new_level > 255)
  2623. new_level = 255;
  2624. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2625. }
  2626. }else
  2627. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2628. break;
  2629. }
  2630. case COMMAND_SIT: {
  2631. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2632. if(client->GetPlayer()->GetHP() > 0){
  2633. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2634. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2635. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2636. }
  2637. break;
  2638. }
  2639. case COMMAND_STAND: {
  2640. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2641. if(client->GetPlayer()->GetHP() > 0){
  2642. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2643. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2644. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2645. }
  2646. break;
  2647. }
  2648. case COMMAND_CLASS:{
  2649. if(sep && sep->arg[ndx][0]){
  2650. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2651. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2652. }else
  2653. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2654. break;
  2655. }
  2656. case COMMAND_GENDER:{
  2657. if(sep && sep->arg[ndx][0]){
  2658. client->GetPlayer()->GetInfoStruct()->set_gender(atoi(sep->arg[ndx]));
  2659. client->GetPlayer()->SetCharSheetChanged(true);
  2660. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  2661. }else{
  2662. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  2663. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  2664. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  2665. }
  2666. break;
  2667. }
  2668. case COMMAND_FLYMODE:{
  2669. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2670. PrintSep(sep, "COMMAND_FLYMODE");
  2671. int8 val = atoi(sep->arg[0]);
  2672. ClientPacketFunctions::SendFlyMode(client, val);
  2673. }
  2674. else{
  2675. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  2676. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2677. }
  2678. break;
  2679. }
  2680. case COMMAND_LOOT_LIST:{
  2681. Spawn* spawn = cmdTarget;
  2682. if(spawn && spawn->IsEntity()){
  2683. if (sep && sep->arg[0]) {
  2684. if (!spawn->GetDatabaseID())
  2685. {
  2686. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  2687. break;
  2688. }
  2689. else if (!spawn->IsNPC())
  2690. {
  2691. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2692. break;
  2693. }
  2694. bool reloadLoot = false;
  2695. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2696. {
  2697. int32 loottable_id = atoul(sep->arg[1]);
  2698. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2699. {
  2700. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2701. reloadLoot = true;
  2702. }
  2703. else
  2704. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2705. }
  2706. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2707. {
  2708. int32 loottable_id = atoul(sep->arg[1]);
  2709. if (loottable_id > 0)
  2710. {
  2711. database.AddLootTableToSpawn(spawn, loottable_id);
  2712. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2713. reloadLoot = true;
  2714. }
  2715. else
  2716. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2717. }
  2718. else if (!stricmp(sep->arg[0], "clearall"))
  2719. {
  2720. if (database.RemoveSpawnLootTable(spawn, 0))
  2721. {
  2722. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2723. reloadLoot = true;
  2724. }
  2725. else
  2726. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2727. }
  2728. else
  2729. {
  2730. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2731. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2732. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2733. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2734. break;
  2735. }
  2736. if (reloadLoot)
  2737. {
  2738. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2739. if (spawn->IsNPC())
  2740. {
  2741. Entity* ent = (Entity*)spawn;
  2742. ent->SetLootCoins(0);
  2743. ent->ClearLoot();
  2744. spawn->GetZone()->AddLoot((NPC*)spawn);
  2745. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2746. }
  2747. }
  2748. break; // nothing further this is the end of these sub commands
  2749. }
  2750. else
  2751. {
  2752. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()), spawn);
  2753. if (loot_list.size() > 0) {
  2754. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2755. vector<int32>::iterator list_itr;
  2756. LootTable* table = 0;
  2757. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2758. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2759. if (table)
  2760. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2761. }
  2762. }
  2763. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2764. vector<Item*>* items = spawn->GetLootItems();
  2765. if (items) {
  2766. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2767. vector<Item*>::iterator itr;
  2768. Item* item = 0;
  2769. for (itr = items->begin(); itr != items->end(); itr++) {
  2770. item = *itr;
  2771. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2772. }
  2773. }
  2774. else
  2775. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2776. }
  2777. }
  2778. break;
  2779. }
  2780. case COMMAND_LOOT_SETCOIN:{
  2781. Spawn* spawn = cmdTarget;
  2782. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2783. spawn->SetLootCoins(atoul(sep->arg[0]));
  2784. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2785. }
  2786. else
  2787. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2788. break;
  2789. }
  2790. case COMMAND_LOOT_ADDITEM:{
  2791. Spawn* spawn = cmdTarget;
  2792. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2793. int16 charges = 1;
  2794. if(sep->arg[1] && sep->IsNumber(1))
  2795. charges = atoi(sep->arg[1]);
  2796. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2797. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2798. }
  2799. else
  2800. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2801. break;
  2802. }
  2803. case COMMAND_LOOT_REMOVEITEM:{
  2804. Spawn* spawn = cmdTarget;
  2805. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2806. Item* item = spawn->LootItem(atoul(sep->arg[0]));
  2807. safe_delete(item);
  2808. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2809. }
  2810. else
  2811. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2812. break;
  2813. }
  2814. case COMMAND_LOOT_CORPSE:
  2815. case COMMAND_DISARM:
  2816. case COMMAND_LOOT:{
  2817. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2818. {
  2819. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2820. break;
  2821. }
  2822. if(cmdTarget && cmdTarget->IsEntity()){
  2823. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2824. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2825. client->OpenChest(cmdTarget, true);
  2826. else
  2827. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2828. if (!(cmdTarget)->HasLoot()){
  2829. if (((Entity*)cmdTarget)->IsNPC())
  2830. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2831. }
  2832. }
  2833. else
  2834. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2835. }
  2836. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2837. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2838. break;
  2839. }
  2840. case COMMAND_RELOADSPAWNSCRIPTS:{
  2841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2842. if (lua_interface)
  2843. lua_interface->SetLuaSystemReloading(true);
  2844. world.ResetSpawnScripts();
  2845. database.LoadSpawnScriptData();
  2846. if(lua_interface) {
  2847. lua_interface->DestroySpawnScripts();
  2848. lua_interface->SetLuaSystemReloading(false);
  2849. }
  2850. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2851. break;
  2852. }
  2853. case COMMAND_RELOADREGIONSCRIPTS:{
  2854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2855. if(lua_interface) {
  2856. lua_interface->DestroyRegionScripts();
  2857. }
  2858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2859. break;
  2860. }
  2861. case COMMAND_RELOADLUASYSTEM:{
  2862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2863. world.SetReloadingSubsystem("LuaSystem");
  2864. if(lua_interface) {
  2865. lua_interface->SetLuaSystemReloading(true);
  2866. }
  2867. zone_list.DeleteSpellProcess();
  2868. master_spell_list.Reload();
  2869. if (lua_interface)
  2870. lua_interface->ReloadSpells();
  2871. zone_list.LoadSpellProcess();
  2872. if(lua_interface){
  2873. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2874. map<Client*, int32>::iterator itr;
  2875. for(itr = debug_clients.begin(); itr != debug_clients.end(); itr++){
  2876. if(lua_interface)
  2877. lua_interface->UpdateDebugClients(itr->first);
  2878. }
  2879. }
  2880. world.ResetSpawnScripts();
  2881. database.LoadSpawnScriptData();
  2882. world.ResetZoneScripts();
  2883. database.LoadZoneScriptData();
  2884. if(lua_interface) {
  2885. lua_interface->DestroySpawnScripts();
  2886. lua_interface->DestroyRegionScripts();
  2887. lua_interface->DestroyQuests();
  2888. lua_interface->DestroyItemScripts();
  2889. lua_interface->DestroyZoneScripts();
  2890. }
  2891. int32 quest_count = database.LoadQuests();
  2892. int32 spell_count = 0;
  2893. if(lua_interface) {
  2894. spell_count = database.LoadSpellScriptData();
  2895. lua_interface->SetLuaSystemReloading(false);
  2896. }
  2897. world.RemoveReloadingSubSystem("LuaSystem");
  2898. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2899. break;
  2900. }
  2901. case COMMAND_DECLINE_QUEST:{
  2902. int32 quest_id = 0;
  2903. if(sep && sep->arg[0] && sep->IsNumber(0))
  2904. quest_id = atoul(sep->arg[0]);
  2905. if(quest_id > 0){
  2906. Quest* quest = client->GetPendingQuest(quest_id);
  2907. if(quest){
  2908. client->RemovePendingQuest(quest);
  2909. if(lua_interface)
  2910. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2911. safe_delete(quest);
  2912. client->GetCurrentZone()->SendQuestUpdates(client);
  2913. }
  2914. }
  2915. break;
  2916. }
  2917. case COMMAND_DELETE_QUEST:{
  2918. int32 quest_id = 0;
  2919. if(sep && sep->arg[0] && sep->IsNumber(0))
  2920. quest_id = atoul(sep->arg[0]);
  2921. if(quest_id > 0){
  2922. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2923. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2924. if (quest)
  2925. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2926. }
  2927. client->RemovePlayerQuest(quest_id);
  2928. client->GetCurrentZone()->SendQuestUpdates(client);
  2929. }
  2930. break;
  2931. }
  2932. case COMMAND_ACCEPT_QUEST:{
  2933. int32 quest_id = 0;
  2934. if(sep && sep->arg[0] && sep->IsNumber(0))
  2935. quest_id = atoul(sep->arg[0]);
  2936. if(quest_id > 0){
  2937. client->AcceptQuest(quest_id);
  2938. }
  2939. break;
  2940. }
  2941. case COMMAND_NAME:{
  2942. if(sep && sep->arg[ndx][0]){
  2943. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  2944. client->GetPlayer()->SetCharSheetChanged(true);
  2945. }else
  2946. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2947. break;
  2948. }
  2949. case COMMAND_GROUPSAY:{
  2950. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2951. if(sep && sep->arg[0] && gmi)
  2952. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2953. break;
  2954. }
  2955. case COMMAND_GROUPINVITE: {
  2956. Entity* target = 0;
  2957. Client* target_client = 0;
  2958. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2959. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2960. return;
  2961. }
  2962. // name provided with command so it has to be a player, npc not supported here
  2963. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2964. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2965. if (target_client) {
  2966. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2967. target = 0;
  2968. else
  2969. target = target_client->GetPlayer();
  2970. }
  2971. }
  2972. // if name was not provided use the players target, npc or player supported here
  2973. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2974. target = (Entity*)client->GetPlayer()->GetTarget();
  2975. if (target->IsPlayer()) {
  2976. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2977. }
  2978. }
  2979. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2980. if (result == 0) {
  2981. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2982. if (target_client) {
  2983. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2984. if (packet) {
  2985. packet->setDataByName("type", 1);
  2986. packet->setDataByName("name", client->GetPlayer()->GetName());
  2987. packet->setDataByName("unknown2", 1);
  2988. target_client->QueuePacket(packet->serialize());
  2989. safe_delete(packet);
  2990. }
  2991. }
  2992. }
  2993. else if (result == 1)
  2994. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2995. else if (result == 2)
  2996. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2997. else if (result == 3)
  2998. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2999. else if (result == 4)
  3000. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  3001. else if (result == 5)
  3002. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  3003. else if (result == 6)
  3004. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  3005. else
  3006. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  3007. break;
  3008. }
  3009. case COMMAND_GROUPDISBAND: {
  3010. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3011. if (gmi) { // TODO: Leader check
  3012. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  3013. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  3014. }
  3015. break;
  3016. }
  3017. case COMMAND_GROUP_LEAVE: {
  3018. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3019. if (gmi) {
  3020. int32 group_id = gmi->group_id;
  3021. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  3022. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  3023. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  3024. }
  3025. else {
  3026. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  3027. }
  3028. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  3029. }
  3030. break;
  3031. }
  3032. case COMMAND_FRIEND_ADD:{
  3033. string name = "";
  3034. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3035. name = database.GetPlayerName(sep->arg[0]);
  3036. else if(cmdTarget && cmdTarget->IsPlayer())
  3037. name = string(cmdTarget->GetName());
  3038. if(name.length() > 0){
  3039. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3040. if(client->GetPlayer()->IsIgnored(name.c_str())){
  3041. client->GetPlayer()->RemoveIgnore(name.c_str());
  3042. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3043. client->SendChatRelationship(3, name.c_str());
  3044. }
  3045. client->GetPlayer()->AddFriend(name.c_str(), true);
  3046. client->SendChatRelationship(0, name.c_str());
  3047. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  3048. if(zone_list.GetClientByCharName(name))
  3049. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  3050. }
  3051. else
  3052. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  3053. }
  3054. else
  3055. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3056. break;
  3057. }
  3058. case COMMAND_FRIEND_REMOVE:{
  3059. string name = "";
  3060. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3061. name = database.GetPlayerName(sep->arg[0]);
  3062. else if(cmdTarget && cmdTarget->IsPlayer())
  3063. name = string(cmdTarget->GetName());
  3064. if(name.length() > 0){
  3065. client->GetPlayer()->RemoveFriend(name.c_str());
  3066. client->SendChatRelationship(1, name.c_str());
  3067. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3068. }
  3069. else
  3070. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3071. break;
  3072. }
  3073. case COMMAND_FRIENDS:{
  3074. break;
  3075. }
  3076. case COMMAND_IGNORE_ADD:{
  3077. string name = "";
  3078. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3079. name = database.GetPlayerName(sep->arg[0]);
  3080. else if(cmdTarget && cmdTarget->IsPlayer())
  3081. name = string(cmdTarget->GetName());
  3082. if(name.length() > 0){
  3083. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3084. if(client->GetPlayer()->IsFriend(name.c_str())){
  3085. client->GetPlayer()->RemoveFriend(name.c_str());
  3086. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3087. client->SendChatRelationship(1, name.c_str());
  3088. }
  3089. client->GetPlayer()->AddIgnore(name.c_str(), true);
  3090. client->SendChatRelationship(2, name.c_str());
  3091. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  3092. }
  3093. else
  3094. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  3095. }
  3096. else
  3097. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3098. break;
  3099. }
  3100. case COMMAND_IGNORE_REMOVE:{
  3101. string name = "";
  3102. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3103. name = database.GetPlayerName(sep->arg[0]);
  3104. else if(cmdTarget && cmdTarget->IsPlayer())
  3105. name = string(cmdTarget->GetName());
  3106. if(name.length() > 0){
  3107. client->GetPlayer()->RemoveIgnore(name.c_str());
  3108. client->SendChatRelationship(3, name.c_str());
  3109. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3110. }
  3111. break;
  3112. }
  3113. case COMMAND_IGNORES:{
  3114. break;
  3115. }
  3116. case COMMAND_GROUP_KICK:{
  3117. Entity* kicked = 0;
  3118. Client* kicked_client = 0;
  3119. int32 group_id = 0;
  3120. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  3121. return;
  3122. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  3123. if (sep && sep->arg[0]) {
  3124. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  3125. if (kicked_client)
  3126. kicked = kicked_client->GetPlayer();
  3127. }
  3128. else if (cmdTarget && cmdTarget->IsEntity()) {
  3129. kicked = (Entity*)cmdTarget;
  3130. }
  3131. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  3132. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  3133. if (kicked)
  3134. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  3135. if(send_kicked_message)
  3136. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  3137. else
  3138. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  3139. if (kicked_client)
  3140. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  3141. break;
  3142. }
  3143. case COMMAND_GROUP_MAKE_LEADER:{
  3144. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3145. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  3146. return;
  3147. }
  3148. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  3149. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  3150. if (new_leader) {
  3151. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  3152. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  3153. }
  3154. }
  3155. else
  3156. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  3157. }
  3158. else if (cmdTarget && cmdTarget->IsPlayer())
  3159. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  3160. else
  3161. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  3162. break;
  3163. }
  3164. case COMMAND_GROUP_ACCEPT_INVITE: {
  3165. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  3166. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  3167. if (result == 0)
  3168. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  3169. else if (result == 1)
  3170. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  3171. else if (result == 2)
  3172. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  3173. else
  3174. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  3175. }
  3176. break;
  3177. }
  3178. case COMMAND_GROUP_DECLINE_INVITE: {
  3179. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  3180. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  3181. }
  3182. break;
  3183. }
  3184. case COMMAND_SUMMON:{
  3185. char* search_name = 0;
  3186. if(sep && sep->arg[0][0])
  3187. search_name = sep->arg[0];
  3188. if(!search_name && !cmdTarget){
  3189. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  3190. 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.");
  3191. }
  3192. else{
  3193. if(!client->Summon(search_name))
  3194. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3195. }
  3196. break;
  3197. }
  3198. case COMMAND_GOTO:{
  3199. const char* search_name = 0;
  3200. if(sep && sep->arg[0][0])
  3201. search_name = sep->argplus[0];
  3202. if(!search_name && !cmdTarget){
  3203. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  3204. 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.");
  3205. }
  3206. else{
  3207. if(!client->GotoSpawn(search_name))
  3208. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3209. }
  3210. break;
  3211. }
  3212. case COMMAND_MOVE:{
  3213. bool success = false;
  3214. try{
  3215. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  3216. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  3217. if(app){
  3218. client->QueuePacket(app);
  3219. success = true;
  3220. }
  3221. }
  3222. }
  3223. catch(...){}
  3224. if(!success){
  3225. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  3226. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  3227. }
  3228. break;
  3229. }
  3230. case COMMAND_SETTIME:{
  3231. if(sep && sep->arg[0]){
  3232. world.MWorldTime.writelock(__FUNCTION__, __LINE__);
  3233. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  3234. if(sep->arg[1] && sep->IsNumber(1))
  3235. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  3236. if(sep->arg[2] && sep->IsNumber(2))
  3237. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  3238. if(sep->arg[3] && sep->IsNumber(3))
  3239. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  3240. world.MWorldTime.releasewritelock(__FUNCTION__, __LINE__);
  3241. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  3242. }
  3243. else{
  3244. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  3245. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  3246. }
  3247. break;
  3248. }
  3249. case COMMAND_VERSION:{
  3250. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  3251. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  3252. break;
  3253. }
  3254. case COMMAND_ZONE:{
  3255. int32 instanceID = 0;
  3256. string zone;
  3257. int32 zone_id = 0;
  3258. bool listSearch = false;
  3259. bool isInstance = false;
  3260. ZoneServer* zsZone = 0;
  3261. if(sep && sep->arg[0][0])
  3262. {
  3263. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  3264. listSearch = true;
  3265. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  3266. {
  3267. zone_list.SendZoneList(client);
  3268. break;
  3269. }
  3270. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  3271. {
  3272. if(sep->IsNumber(1))
  3273. instanceID = atol(sep->arg[1]);
  3274. }
  3275. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  3276. {
  3277. PrintSep(sep, "ZONE LOCK");
  3278. if(sep->IsNumber(1))
  3279. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  3280. else
  3281. zsZone = zone_list.Get(sep->arg[1], false);
  3282. if( zsZone )
  3283. {
  3284. zsZone->SetZoneLockState(true);
  3285. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3286. }
  3287. else
  3288. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  3289. break;
  3290. }
  3291. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  3292. {
  3293. PrintSep(sep, "ZONE UNLOCK");
  3294. if(sep->IsNumber(1))
  3295. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  3296. else
  3297. zsZone = zone_list.Get(sep->arg[1], false);
  3298. if( zsZone )
  3299. {
  3300. zsZone->SetZoneLockState(false);
  3301. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3302. }
  3303. else
  3304. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  3305. break;
  3306. }
  3307. else
  3308. {
  3309. if(sep->IsNumber(0))
  3310. {
  3311. zone_id = atoul(sep->arg[0]);
  3312. string zonename = database.GetZoneName(zone_id);
  3313. if(zonename.length() > 0)
  3314. zone = zonename;
  3315. }
  3316. else
  3317. zone = sep->arg[0];
  3318. }
  3319. if(instanceID > 0)
  3320. {
  3321. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  3322. if(zsInstance != NULL)
  3323. {
  3324. instanceID = zsInstance->GetInstanceID();
  3325. zone = zsInstance->GetZoneName();
  3326. zone_id = zsInstance->GetZoneID();
  3327. isInstance = true;
  3328. }
  3329. }
  3330. }
  3331. if(!listSearch)
  3332. {
  3333. if(zone.length() == 0)
  3334. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  3335. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  3336. zone_id != client->GetCurrentZone()->GetZoneID())
  3337. {
  3338. const char* zonestr = zone.c_str();
  3339. if(database.VerifyZone(zonestr))
  3340. {
  3341. if(client->CheckZoneAccess(zonestr))
  3342. {
  3343. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  3344. if(isInstance)
  3345. client->Zone(instanceID,true,true,false);
  3346. else
  3347. client->Zone(zonestr);
  3348. }
  3349. }
  3350. else
  3351. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  3352. }
  3353. else
  3354. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  3355. }
  3356. else
  3357. {
  3358. const char* name = 0;
  3359. if(sep && sep->arg[1][0])
  3360. {
  3361. map<int32, string>* zone_names;
  3362. name = sep->argplus[1];
  3363. sint16 status = client->GetAdminStatus();
  3364. if( status > 0 )
  3365. {
  3366. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  3367. zone_names = database.GetZoneList(name, true);
  3368. }
  3369. else
  3370. zone_names = database.GetZoneList(name);
  3371. if(!zone_names)
  3372. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  3373. else
  3374. {
  3375. map<int32, string>::iterator itr;
  3376. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  3377. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  3378. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  3379. safe_delete(zone_names);
  3380. }
  3381. }
  3382. else
  3383. {
  3384. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  3385. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  3386. }
  3387. }
  3388. break;
  3389. }
  3390. case COMMAND_USE: {
  3391. Spawn* target = cmdTarget;
  3392. if (target && target->IsWidget())
  3393. ((Widget*)target)->HandleUse(client, "use");
  3394. break;
  3395. }
  3396. case COMMAND_OPEN: {
  3397. Spawn* target = cmdTarget;
  3398. if (target && target->IsWidget())
  3399. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  3400. break;
  3401. }
  3402. case COMMAND_CASTSPELL: {
  3403. if (sep && sep->arg[0] && sep->IsNumber(0))
  3404. {
  3405. int8 tier = 1;
  3406. if (sep->arg[1] && sep->IsNumber(1))
  3407. tier = atoul(sep->arg[1]);
  3408. int8 self = 1;
  3409. if (sep->arg[1] && sep->IsNumber(2))
  3410. {
  3411. self = atoul(sep->arg[2]);
  3412. if(self != 1 && !cmdTarget->IsEntity())
  3413. {
  3414. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  3415. self = 1;
  3416. }
  3417. }
  3418. int32 spellid = atoul(sep->arg[0]);
  3419. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  3420. if (spell)
  3421. {
  3422. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3423. SpellProcess* spellProcess = 0;
  3424. // Get the current zones spell process
  3425. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3426. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3427. }
  3428. else
  3429. {
  3430. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3431. }
  3432. }
  3433. else if (sep && sep->arg[0])
  3434. {
  3435. database.FindSpell(client, (char*)sep->argplus[0]);
  3436. }
  3437. else
  3438. {
  3439. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3440. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3441. }
  3442. break;
  3443. }
  3444. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3445. if (client->GetVersion() <= 546)
  3446. break;
  3447. if (sep && sep->GetArgNumber() == 4)
  3448. {
  3449. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3450. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3451. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3452. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3453. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  3454. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3455. ClientPacketFunctions::SendSkillSlotMappings(client);
  3456. }
  3457. else
  3458. {
  3459. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3460. }
  3461. break;
  3462. }
  3463. case COMMAND_MOVE_ITEM:
  3464. {
  3465. int32 id = 0;
  3466. if (sep && sep->IsNumber(0))
  3467. id = atoul(sep->arg[0]);
  3468. Spawn* spawn = 0;
  3469. if (id == 0)
  3470. {
  3471. spawn = cmdTarget;
  3472. }
  3473. else
  3474. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3475. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3476. break;
  3477. client->SendMoveObjectMode(spawn, 0);
  3478. break;
  3479. }
  3480. case COMMAND_PICKUP:
  3481. {
  3482. int32 id = 0;
  3483. if (sep && sep->IsNumber(0))
  3484. id = atoul(sep->arg[0]);
  3485. Spawn* spawn = 0;
  3486. if (id == 0)
  3487. {
  3488. spawn = cmdTarget;
  3489. }
  3490. else
  3491. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3492. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3493. break;
  3494. client->AddItem(spawn->GetPickupItemID(), 1);
  3495. Query query;
  3496. 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());
  3497. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3498. client->GetCurrentZone()->RemoveSpawn(spawn, true, true, true, true, true);
  3499. }
  3500. // we had a UI Window displayed, update the house items
  3501. if ( id > 0 )
  3502. client->GetCurrentZone()->SendHouseItems(client);
  3503. break;
  3504. }
  3505. case COMMAND_HOUSE_DEPOSIT:
  3506. {
  3507. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3508. // arg0 = ??? (set to 3)
  3509. // arg1 = coin (in copper)
  3510. // arg2 = status? (not implemented yet)
  3511. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3512. if (ph && sep && sep->IsNumber(1))
  3513. {
  3514. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3515. int32 outValStatus = 0;
  3516. if(sep->IsNumber(2))
  3517. {
  3518. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3519. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3520. outValStatus = 0; // cheat check
  3521. }
  3522. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3523. {
  3524. if(outValStatus)
  3525. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3526. char query[256];
  3527. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3528. if (itr != ph->depositsMap.end())
  3529. {
  3530. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %I64u, last_amount = %I64u, status = status + %u, last_status = %u where house_id = %u and instance_id = %u and name='%s'", Timer::GetUnixTimeStamp(), outValCoin, outValCoin, outValStatus, outValStatus, ph->house_id, ph->instance_id, client->GetPlayer()->GetName());
  3531. }
  3532. else
  3533. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %I64u, status = %u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outValCoin, outValStatus);
  3534. if (database.RunQuery(query, strnlen(query, 256)))
  3535. {
  3536. ph->escrow_coins += outValCoin;
  3537. ph->escrow_status += outValStatus;
  3538. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3539. database.LoadDeposits(ph);
  3540. client->PlaySound("coin_cha_ching");
  3541. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3542. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3543. }
  3544. else
  3545. {
  3546. if(outValCoin)
  3547. client->GetPlayer()->AddCoins(outValCoin);
  3548. if(outValStatus)
  3549. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3550. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3551. }
  3552. }
  3553. }
  3554. break;
  3555. }
  3556. case COMMAND_HOUSE:
  3557. {
  3558. if (sep && sep->IsNumber(0))
  3559. {
  3560. int32 unique_id = atoi(sep->arg[0]);
  3561. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3562. HouseZone* hz = 0;
  3563. if (ph)
  3564. hz = world.GetHouseZone(ph->house_id);
  3565. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3566. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3567. }
  3568. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3569. {
  3570. // inside a house or something? Send the access window
  3571. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3572. HouseZone* hz = 0;
  3573. if ( ph )
  3574. hz = world.GetHouseZone(ph->house_id);
  3575. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3576. client->GetCurrentZone()->SendHouseItems(client);
  3577. }
  3578. break;
  3579. }
  3580. case COMMAND_HOUSE_UI:
  3581. {
  3582. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3583. {
  3584. int32 unique_id = atoi(sep->arg[0]);
  3585. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3586. HouseZone* hz = 0;
  3587. if ( ph )
  3588. hz = world.GetHouseZone(ph->house_id);
  3589. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3590. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  3591. }
  3592. break;
  3593. }
  3594. case COMMAND_PLACE_HOUSE_ITEM: {
  3595. if (sep && sep->IsNumber(0))
  3596. {
  3597. int32 uniqueid = atoi(sep->arg[0]);
  3598. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3599. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3600. if (item && item->IsHouseItem())
  3601. {
  3602. if (!client->HasOwnerOrEditAccess())
  3603. {
  3604. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3605. break;
  3606. }
  3607. else if (!item->generic_info.appearance_id)
  3608. {
  3609. 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);
  3610. break;
  3611. }
  3612. if (client->GetTempPlacementSpawn())
  3613. {
  3614. Spawn* tmp = client->GetTempPlacementSpawn();
  3615. client->GetCurrentZone()->RemoveSpawn(tmp, true, true, true, true, true);
  3616. client->SetTempPlacementSpawn(nullptr);
  3617. }
  3618. Object* obj = new Object();
  3619. Spawn* spawn = (Spawn*)obj;
  3620. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3621. strcpy(spawn->appearance.name, "temp");
  3622. spawn->SetX(client->GetPlayer()->GetX());
  3623. spawn->SetY(client->GetPlayer()->GetY());
  3624. spawn->SetZ(client->GetPlayer()->GetZ());
  3625. spawn->appearance.pos.collision_radius = 32;
  3626. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3627. spawn->SetSpawnOrigX(spawn->GetX());
  3628. spawn->SetSpawnOrigY(spawn->GetY());
  3629. spawn->SetSpawnOrigZ(spawn->GetZ());
  3630. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3631. spawn->appearance.targetable = 1;
  3632. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3633. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3634. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3635. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3636. spawn->SetZone(client->GetCurrentZone());
  3637. client->SetTempPlacementSpawn(spawn);
  3638. client->SetPlacementUniqueItemID(uniqueid);
  3639. client->GetCurrentZone()->AddSpawn(spawn);
  3640. }
  3641. }
  3642. break;
  3643. }
  3644. case COMMAND_GM:
  3645. {
  3646. if (sep && sep->arg[0] && sep->arg[1])
  3647. {
  3648. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3649. if (strcmp(sep->arg[0], "vision") == 0)
  3650. {
  3651. client->GetPlayer()->SetGMVision(onOff);
  3652. #if defined(__GNUC__)
  3653. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3654. #else
  3655. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3656. #endif
  3657. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3658. if (onOff)
  3659. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3660. else
  3661. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3662. }
  3663. else if (strcmp(sep->arg[0], "tag") == 0)
  3664. {
  3665. int32 value = 0;
  3666. int16 tag_icon = 0;
  3667. // groundspawn has special exception -1 argument so it needs to be handled here
  3668. if(sep->arg[2] && sep->arg[3] && ((tag_icon = atoul(sep->arg[3])) > 0) || (strncasecmp(sep->arg[1], "groundspawn", 11) == 0)) {
  3669. value = atoul(sep->arg[2]);
  3670. if(strncasecmp(sep->arg[1], "faction", 7) == 0){
  3671. if(!value) {
  3672. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid faction id.");
  3673. break;
  3674. }
  3675. if(!tag_icon) {
  3676. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3677. break;
  3678. }
  3679. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_FACTION, value, "", tag_icon);
  3680. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3681. client->Message(CHANNEL_COLOR_RED, "Adding faction id %u with tag icon %u.", value, tag_icon);
  3682. }
  3683. else if(strncasecmp(sep->arg[1], "spawngroup", 10) == 0){
  3684. if(value>0) {
  3685. value = 1;
  3686. }
  3687. if(!tag_icon) {
  3688. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3689. break;
  3690. }
  3691. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_SPAWNGROUP, value, "", tag_icon);
  3692. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3693. client->Message(CHANNEL_COLOR_RED, "Adding spawn group tag \"%s\" with tag icon %u.", (value == 1) ? "on" : "off", tag_icon);
  3694. }
  3695. else if(strncasecmp(sep->arg[1], "race", 5) == 0){
  3696. if(!value) {
  3697. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid race id.");
  3698. break;
  3699. }
  3700. if(!tag_icon) {
  3701. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3702. break;
  3703. }
  3704. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_RACE, value, "", tag_icon);
  3705. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3706. client->Message(CHANNEL_COLOR_RED, "Adding race id %u with tag icon %u.", value, tag_icon);
  3707. }
  3708. else if(strncasecmp(sep->arg[1], "groundspawn", 11) == 0){
  3709. // one less argument value field not tag_icon for this one
  3710. if(!value) {
  3711. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3712. break;
  3713. }
  3714. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_GROUNDSPAWN, 1, "", value);
  3715. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3716. client->Message(CHANNEL_COLOR_RED, "Adding groundspawns with tag icon %u.", value);
  3717. }
  3718. }
  3719. else {
  3720. if(strncasecmp(sep->arg[1], "clear", 5) == 0){
  3721. client->GetPlayer()->ClearGMVisualFilters();
  3722. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Tags Cleared!");
  3723. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3724. }
  3725. else {
  3726. client->SimpleMessage(CHANNEL_COLOR_RED, "GM Tagging Missing Arguments:");
  3727. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag [type] [value] [visual_icon_display]");
  3728. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag clear - Clears all GM visual tags");
  3729. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Type Options:");
  3730. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: faction, value: faction id of spawn(s)");
  3731. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: spawngroup, value: 1 to show grouped, 0 to show not grouped");
  3732. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: race, value: race id (either against base race or race id in spawn details)");
  3733. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: groundspawn, value: (not used)");
  3734. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Icon Options:");
  3735. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3736. "1 = skull, 2 = shield half dark blue / half light blue, 3 = purple? star, 4 = yellow sword, 5 = red X, 6 = green flame");
  3737. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3738. "7 = Number \"1\", 8 = Number \"2\", 9 = Number \"3\", 10 = Number \"4\", 11 = Number \"5\", 12 = Number \"6\"");
  3739. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3740. "25 = shield, 26 = green plus, 27 = crossed swords, 28 = bow with arrow in it, 29 = light blue lightning bolt");
  3741. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3742. "30 = bard instrument (hard to see), 31 = writ with shield, 32 = writ with green +, 33 = writ with crossed sword");
  3743. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3744. "34 = writ with bow, 35 = writ with light blue lightning bolt, 36 = same as 30, 37 = party with crossed sword, shield and lightning bolt");
  3745. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3746. "38 = shaking hands green background, 39 = shaking hands dark green background, unlocked keylock");
  3747. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3748. "40 = red aura icon with black shadow of person and big red aura, 41 = green aura icon with black shadow of person big green aura");
  3749. }
  3750. }
  3751. }
  3752. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3753. {
  3754. client->SetRegionDebug(onOff);
  3755. #if defined(__GNUC__)
  3756. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3757. #else
  3758. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3759. #endif
  3760. if (onOff)
  3761. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  3762. else
  3763. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  3764. }
  3765. else if (strcmp(sep->arg[0], "luadebug") == 0)
  3766. {
  3767. client->SetLuaDebugClient(onOff);
  3768. #if defined(__GNUC__)
  3769. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3770. #else
  3771. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  3772. #endif
  3773. if (onOff)
  3774. {
  3775. if (lua_interface)
  3776. lua_interface->UpdateDebugClients(client);
  3777. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3778. }
  3779. else
  3780. {
  3781. if (lua_interface)
  3782. lua_interface->RemoveDebugClients(client);
  3783. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3784. }
  3785. }
  3786. }
  3787. break;
  3788. }
  3789. case COMMAND_ATTACK:
  3790. case COMMAND_AUTO_ATTACK:{
  3791. int8 type = 1;
  3792. Player* player = client->GetPlayer();
  3793. if(!player)
  3794. break;
  3795. bool incombat = player->EngagedInCombat();
  3796. if(sep && sep->arg[0] && sep->IsNumber(0))
  3797. type = atoi(sep->arg[0]);
  3798. if(client->GetPlayer()->GetHP() == 0){
  3799. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  3800. break;
  3801. }
  3802. if(type == 0){
  3803. if(incombat)
  3804. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3805. player->StopCombat(type);
  3806. }
  3807. else {
  3808. if(type == 2){
  3809. player->InCombat(false);
  3810. if(incombat && player->GetRangeAttack()){
  3811. player->StopCombat(type);
  3812. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3813. }
  3814. else{
  3815. player->SetRangeAttack(true);
  3816. player->InCombat(true, true);
  3817. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3818. }
  3819. }
  3820. else {
  3821. player->InCombat(false, true);
  3822. player->SetRangeAttack(false);
  3823. player->InCombat(true);
  3824. if(!incombat)
  3825. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3826. }
  3827. /*else
  3828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  3829. }
  3830. player->SetCharSheetChanged(true);
  3831. break;
  3832. }
  3833. case COMMAND_DEPOP:{
  3834. bool allow_respawns = false;
  3835. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3836. if(atoi(sep->arg[0]) == 1)
  3837. allow_respawns = true;
  3838. }
  3839. client->GetCurrentZone()->Depop(allow_respawns);
  3840. break;
  3841. }
  3842. case COMMAND_REPOP:{
  3843. client->GetCurrentZone()->Depop(false, true);
  3844. break;
  3845. }
  3846. case COMMAND_BUYBACK:{
  3847. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3848. // 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
  3849. int64 id = atoi64(sep->arg[0]);
  3850. // get the first int32, the item id
  3851. //int32 item_id = (int32)id;
  3852. // get the second int32, the unique id
  3853. int32 unique_id = (int32)(id>>32);
  3854. int8 quantity = atoi(sep->arg[1]);
  3855. if(quantity == 255)
  3856. quantity = 1;
  3857. client->BuyBack(unique_id, quantity);
  3858. }
  3859. break;
  3860. }
  3861. case COMMAND_MERCHANT_BUY:{
  3862. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3863. int32 item_id = atoul(sep->arg[0]);
  3864. int8 quantity = atoi(sep->arg[1]);
  3865. client->BuyItem(item_id, quantity);
  3866. }
  3867. else
  3868. Command_SendMerchantWindow(client, sep);
  3869. break;
  3870. }
  3871. case COMMAND_MERCHANT_SELL:{
  3872. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3873. // 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
  3874. int64 id = atoi64(sep->arg[0]);
  3875. // get the first int32, the item id
  3876. int32 item_id = (int32)id;
  3877. // get the second int32, the unique id
  3878. int32 unique_id = (int32)(id>>32);
  3879. int8 quantity = atoi(sep->arg[1]);
  3880. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  3881. client->SellItem(item_id, quantity, unique_id);
  3882. }
  3883. break;
  3884. }
  3885. case COMMAND_MENDER_REPAIR: {
  3886. if (sep && sep->arg[0] && sep->IsNumber(0))
  3887. client->RepairItem(atoul(sep->arg[0]));
  3888. break;
  3889. }
  3890. case COMMAND_MENDER_REPAIR_ALL: {
  3891. client->RepairAllItems();
  3892. break;
  3893. }
  3894. case COMMAND_CANCEL_MERCHANT:{
  3895. client->SetMerchantTransaction(0);
  3896. break;
  3897. }
  3898. case COMMAND_START_MERCHANT:{
  3899. break;
  3900. }
  3901. case COMMAND_INVULNERABLE:{
  3902. sint8 val = -1;
  3903. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3904. val = atoi(sep->arg[0]);
  3905. //devn00b: Fix for linux builds
  3906. #if defined(__GNUC__)
  3907. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  3908. #else
  3909. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3910. #endif
  3911. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3912. client->GetPlayer()->SetInvulnerable(val==1);
  3913. if(client->GetPlayer()->GetInvulnerable())
  3914. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  3915. else
  3916. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  3917. }
  3918. if(val == -1)
  3919. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  3920. break;
  3921. }
  3922. case COMMAND_REPAIR: {
  3923. Spawn* spawn = cmdTarget;
  3924. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  3925. client->SendHailCommand(spawn);
  3926. client->SetMerchantTransaction(spawn);
  3927. client->SendRepairList();
  3928. }
  3929. break;
  3930. }
  3931. case COMMAND_LOTTO: {
  3932. Spawn* spawn = cmdTarget;
  3933. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  3934. client->SetMerchantTransaction(spawn);
  3935. client->ShowLottoWindow();
  3936. }
  3937. break;
  3938. }
  3939. case COMMAND_ACCEPT_REWARD:{
  3940. int32 unknown = 0;
  3941. int32 selectable_item_id = 0;
  3942. //Quest *quest = 0;
  3943. Collection *collection = 0;
  3944. /* no idea what the first argument is for (faction maybe?)
  3945. if the reward has a selectable item reward, it's sent as the second argument
  3946. if neither of these are included in the reward, there is no sep
  3947. 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
  3948. only 1 quest or collection reward may be displayed at a time */
  3949. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3950. unknown = atoul(sep->arg[0]);
  3951. selectable_item_id = atoul(sep->arg[1]);
  3952. }
  3953. //if ((quest = player->GetPendingQuestReward()))
  3954. // client->AcceptQuestRewards(quest, selectable_item_id);
  3955. /* the below needs to go away eventually and be redone */
  3956. int32 item_id = 0;
  3957. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3958. item_id = atoul(sep->arg[0]);
  3959. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3960. if(quest){
  3961. client->AcceptQuestReward(quest, item_id);
  3962. break;
  3963. }
  3964. bool collectedItems = false;
  3965. if (collection = player->GetPendingCollectionReward())
  3966. {
  3967. client->AcceptCollectionRewards(collection, selectable_item_id);
  3968. collectedItems = true;
  3969. }
  3970. else if (client->GetPlayer()->HasPendingItemRewards()) {
  3971. vector<Item*> items = client->GetPlayer()->GetPendingItemRewards();
  3972. if (items.size() > 0) {
  3973. collectedItems = true;
  3974. for (int i = 0; i < items.size(); i++) {
  3975. client->GetPlayer()->AddItem(new Item(items[i]));
  3976. }
  3977. client->GetPlayer()->ClearPendingItemRewards();
  3978. }
  3979. map<int32, Item*> selectable_item = client->GetPlayer()->GetPendingSelectableItemReward(item_id);
  3980. if (selectable_item.size() > 0) {
  3981. collectedItems = true;
  3982. map<int32, Item*>::iterator itr;
  3983. for (itr = selectable_item.begin(); itr != selectable_item.end(); itr++) {
  3984. client->GetPlayer()->AddItem(new Item(itr->second));
  3985. client->GetPlayer()->ClearPendingSelectableItemRewards(itr->first);
  3986. }
  3987. }
  3988. }
  3989. if (collectedItems) {
  3990. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  3991. if (outapp)
  3992. client->QueuePacket(outapp);
  3993. }
  3994. else
  3995. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  3996. break;
  3997. }
  3998. case COMMAND_BUY_FROM_BROKER:{
  3999. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4000. int32 item_id = atoul(sep->arg[0]);
  4001. int16 quantity = atoul(sep->arg[1]);
  4002. Item* item = master_item_list.GetItem(item_id);
  4003. if(item && item->generic_info.max_charges > 1)
  4004. quantity = item->generic_info.max_charges;
  4005. client->AddItem(item_id, quantity);
  4006. }
  4007. break;
  4008. }
  4009. case COMMAND_SEARCH_STORES_PAGE:{
  4010. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4011. int32 page = atoul(sep->arg[0]);
  4012. client->SearchStore(page);
  4013. }
  4014. break;
  4015. }
  4016. case COMMAND_SEARCH_STORES:{
  4017. if(sep && sep->arg[0][0]){
  4018. const char* values = sep->argplus[0];
  4019. if(values){
  4020. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  4021. map<string, string> str_values = TranslateBrokerRequest(values);
  4022. vector<Item*>* items = master_item_list.GetItems(str_values);
  4023. if(items){
  4024. client->SetItemSearch(items);
  4025. client->SearchStore(0);
  4026. }
  4027. }
  4028. }
  4029. break;
  4030. }
  4031. case COMMAND_LUADEBUG:{
  4032. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  4033. client->SetLuaDebugClient(true);
  4034. if(lua_interface)
  4035. lua_interface->UpdateDebugClients(client);
  4036. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4037. }
  4038. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  4039. client->SetLuaDebugClient(false);
  4040. if(lua_interface)
  4041. lua_interface->RemoveDebugClients(client);
  4042. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4043. }
  4044. else{
  4045. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  4046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  4047. }
  4048. break;
  4049. }
  4050. case COMMAND_SPAWN_GROUP:
  4051. {
  4052. Spawn* target = cmdTarget;
  4053. if(target && target->IsPlayer() == false)
  4054. {
  4055. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  4056. {
  4057. if(target->GetSpawnLocationPlacementID() > 0)
  4058. {
  4059. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  4060. {
  4061. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  4062. if(id > 0)
  4063. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  4064. else
  4065. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  4066. target->SetSpawnGroupID(id);
  4067. target->AddSpawnToGroup(target);
  4068. }
  4069. else
  4070. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  4071. }
  4072. else
  4073. 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.");
  4074. }
  4075. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  4076. {
  4077. if(sep->arg[1] && sep->IsNumber(1))
  4078. {
  4079. int32 group_id = atoul(sep->arg[1]);
  4080. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  4081. if(leader)
  4082. {
  4083. leader->AddSpawnToGroup(target);
  4084. target->SetSpawnGroupID(group_id);
  4085. if(database.SpawnGroupAddSpawn(target, group_id))
  4086. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  4087. else
  4088. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  4089. }
  4090. else
  4091. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  4092. }
  4093. else
  4094. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  4095. }
  4096. else if(target->GetSpawnGroupID() == 0)
  4097. {
  4098. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  4099. }
  4100. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  4101. {
  4102. int32 group_id = target->GetSpawnGroupID();
  4103. target->RemoveSpawnFromGroup();
  4104. if(database.SpawnGroupRemoveSpawn(target, group_id))
  4105. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  4106. else
  4107. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  4108. }
  4109. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  4110. {
  4111. int32 group_id = target->GetSpawnGroupID();
  4112. if(sep->arg[1] && sep->IsNumber(1))
  4113. {
  4114. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  4115. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  4116. else
  4117. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  4118. }
  4119. else
  4120. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  4121. }
  4122. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  4123. {
  4124. int32 group_id = target->GetSpawnGroupID();
  4125. if(sep->arg[1] && sep->IsNumber(1))
  4126. {
  4127. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  4128. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  4129. else
  4130. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  4131. }
  4132. else
  4133. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  4134. }
  4135. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  4136. {
  4137. if(sep->arg[1] && sep->IsNumber(1))
  4138. {
  4139. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  4140. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  4141. else
  4142. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  4143. }
  4144. else
  4145. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  4146. }
  4147. else
  4148. {
  4149. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  4150. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  4151. }
  4152. }
  4153. else
  4154. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  4155. break;
  4156. }
  4157. case COMMAND_SPAWN_COMBINE:{
  4158. Spawn* spawn = cmdTarget;
  4159. float radius = 0;
  4160. bool failed = true;
  4161. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  4162. failed = false;
  4163. if(spawn->GetSpawnGroupID() > 0){
  4164. 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.");
  4165. }
  4166. else if(sep->IsNumber(0)){
  4167. radius = atof(sep->arg[0]);
  4168. client->CombineSpawns(radius, spawn);
  4169. }
  4170. else{
  4171. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  4172. client->AddCombineSpawn(spawn);
  4173. }
  4174. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  4175. client->RemoveCombineSpawn(spawn);
  4176. }
  4177. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  4178. const char* name = 0;
  4179. if(sep->arg[1] && sep->arg[1][0])
  4180. name = sep->argplus[1];
  4181. client->SaveCombineSpawns(name);
  4182. }
  4183. else
  4184. failed = true;
  4185. }
  4186. }
  4187. if(failed){
  4188. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  4189. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  4190. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  4191. }
  4192. break;
  4193. }
  4194. case COMMAND_SPAWN_CREATE:{
  4195. Spawn* spawn = 0;
  4196. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4197. spawn = new Object();
  4198. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4199. }
  4200. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4201. spawn = new GroundSpawn();
  4202. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4203. }
  4204. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4205. spawn = new Sign();
  4206. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4207. }
  4208. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4209. spawn = new NPC();
  4210. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4211. spawn->appearance.pos.collision_radius = 32;
  4212. spawn->secondary_command_list_id = 0;
  4213. spawn->primary_command_list_id = 0;
  4214. spawn->appearance.display_name = 1;
  4215. spawn->appearance.show_level = 1;
  4216. spawn->appearance.attackable = 1;
  4217. }
  4218. else{
  4219. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  4220. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  4221. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  4222. break;
  4223. }
  4224. spawn->SetID(Spawn::NextID());
  4225. spawn->SetX(client->GetPlayer()->GetX());
  4226. spawn->SetY(client->GetPlayer()->GetY());
  4227. spawn->SetZ(client->GetPlayer()->GetZ());
  4228. spawn->SetHeading(client->GetPlayer()->GetHeading());
  4229. spawn->SetSpawnOrigX(spawn->GetX());
  4230. spawn->SetSpawnOrigY(spawn->GetY());
  4231. spawn->SetSpawnOrigZ(spawn->GetZ());
  4232. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4233. if(spawn->IsSign())
  4234. {
  4235. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  4236. ((Sign*)spawn)->SetSignDistance(20.0f);
  4237. ((Sign*)spawn)->SetIncludeLocation(1);
  4238. ((Sign*)spawn)->SetIncludeHeading(1);
  4239. ((Sign*)spawn)->SetInitialState(1);
  4240. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  4241. ((Sign*)spawn)->SetActivityStatus(64);
  4242. spawn->appearance.race = 0;
  4243. spawn->SetLevel(0);
  4244. spawn->SetHP(0);
  4245. spawn->SetTotalHP(0);
  4246. spawn->SetPower(0);
  4247. spawn->SetTotalPower(0);
  4248. spawn->SetEncounterLevel(0);
  4249. spawn->SetTargetable(0);
  4250. spawn->SetSogaModelType(0);
  4251. spawn->SetCollisionRadius(19);
  4252. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  4253. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  4254. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  4255. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4256. spawn->appearance.model_type = atoul(sep->arg[1]);
  4257. }
  4258. else
  4259. {
  4260. spawn->appearance.targetable = 1;
  4261. spawn->appearance.race = 255;
  4262. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4263. spawn->SetModelType(atoi(sep->arg[1]));
  4264. spawn->SetAdventureClass(atoi(sep->arg[2]));
  4265. spawn->SetLevel(atoi(sep->arg[3]));
  4266. spawn->SetName(sep->arg[4]);
  4267. if(sep->arg[5][0] && sep->IsNumber(5))
  4268. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  4269. if(sep->arg[6][0] && sep->IsNumber(6))
  4270. spawn->size = atoi(sep->arg[6]);
  4271. if(spawn->GetTotalHP() == 0){
  4272. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  4273. spawn->SetHP(25*spawn->GetLevel() + 1);
  4274. }
  4275. if(spawn->GetTotalPower() == 0){
  4276. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  4277. spawn->SetPower(25*spawn->GetLevel() + 1);
  4278. }
  4279. }
  4280. client->GetCurrentZone()->AddSpawn(spawn);
  4281. break;
  4282. }
  4283. case COMMAND_SPAWN_EQUIPMENT:{
  4284. Spawn* spawn = cmdTarget;
  4285. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  4286. int8 slot = atoi(sep->arg[0]);
  4287. int16 type = atoi(sep->arg[1]);
  4288. int8 red = 0;
  4289. int8 green = 0;
  4290. int8 blue = 0;
  4291. int8 h_red = 0;
  4292. int8 h_green = 0;
  4293. int8 h_blue = 0;
  4294. if(sep->arg[2])
  4295. red = atoi(sep->arg[2]);
  4296. if(sep->arg[3])
  4297. green = atoi(sep->arg[3]);
  4298. if(sep->arg[4])
  4299. blue = atoi(sep->arg[4]);
  4300. if(sep->arg[5])
  4301. h_red = atoi(sep->arg[5]);
  4302. if(sep->arg[6])
  4303. h_green = atoi(sep->arg[6]);
  4304. if(sep->arg[7])
  4305. h_blue = atoi(sep->arg[7]);
  4306. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  4307. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  4308. }
  4309. else{
  4310. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  4311. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  4312. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  4313. }
  4314. break;
  4315. }
  4316. case COMMAND_SPAWN_DETAILS: {
  4317. Spawn* spawn = cmdTarget;
  4318. if (sep && sep->arg[0][0]) {
  4319. if (cmdTarget)
  4320. {
  4321. if (ToLower(string(sep->arg[0])) == "los")
  4322. {
  4323. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  4324. if (hasLOS)
  4325. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  4326. else
  4327. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  4328. break;
  4329. }
  4330. else if (ToLower(string(sep->arg[0])) == "bestz")
  4331. {
  4332. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  4333. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  4334. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  4335. break;
  4336. }
  4337. else if (ToLower(string(sep->arg[0])) == "inwater")
  4338. {
  4339. if (cmdTarget->GetRegionMap() == nullptr)
  4340. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  4341. else
  4342. {
  4343. bool inWater = cmdTarget->InWater();
  4344. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  4345. }
  4346. break;
  4347. }
  4348. else if (ToLower(string(sep->arg[0])) == "inlava")
  4349. {
  4350. if (cmdTarget->GetRegionMap() == nullptr)
  4351. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4352. else
  4353. {
  4354. bool inLava = cmdTarget->InLava();
  4355. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  4356. }
  4357. break;
  4358. }
  4359. else if (ToLower(string(sep->arg[0])) == "regions")
  4360. {
  4361. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  4362. if (cmdTarget->GetRegionMap() == nullptr)
  4363. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4364. else
  4365. {
  4366. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  4367. }
  4368. break;
  4369. }
  4370. else if (ToLower(string(sep->arg[0])) == "behind")
  4371. {
  4372. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  4373. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  4374. break;
  4375. }
  4376. else if (ToLower(string(sep->arg[0])) == "infront")
  4377. {
  4378. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  4379. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  4380. break;
  4381. }
  4382. else if (ToLower(string(sep->arg[0])) == "flank")
  4383. {
  4384. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  4385. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  4386. break;
  4387. }
  4388. }
  4389. if (sep->IsNumber(0))
  4390. {
  4391. float radius = atof(sep->arg[0]);
  4392. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  4393. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  4394. break;
  4395. }
  4396. }
  4397. if (spawn) {
  4398. const char* type = "NPC";
  4399. if (spawn->IsObject())
  4400. type = "Object";
  4401. else if (spawn->IsSign())
  4402. type = "Sign";
  4403. else if (spawn->IsWidget())
  4404. type = "Widget";
  4405. else if (spawn->IsGroundSpawn())
  4406. type = "GroundSpawn";
  4407. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  4408. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  4409. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  4410. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  4411. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  4412. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  4413. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  4414. 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());
  4415. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  4416. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  4417. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  4418. if (spawn->IsEntity()) {
  4419. 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());
  4420. 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());
  4421. }
  4422. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  4423. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  4424. 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());
  4425. 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);
  4426. if (spawn->IsNPC())
  4427. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  4428. if (spawn->IsNPC()){
  4429. client->Message(CHANNEL_COLOR_YELLOW, "Heat Resist/Base: %u/%u",((NPC*)spawn)->GetHeatResistance(), ((NPC*)spawn)->GetHeatResistanceBase());
  4430. client->Message(CHANNEL_COLOR_YELLOW, "Cold Resist/Base: %u/%u",((NPC*)spawn)->GetColdResistance(), ((NPC*)spawn)->GetColdResistanceBase());
  4431. client->Message(CHANNEL_COLOR_YELLOW, "Magic Resist/Base: %u/%u",((NPC*)spawn)->GetMagicResistance(), ((NPC*)spawn)->GetMagicResistanceBase());
  4432. client->Message(CHANNEL_COLOR_YELLOW, "Mental Resist/Base: %u/%u",((NPC*)spawn)->GetMentalResistance(), ((NPC*)spawn)->GetMentalResistanceBase());
  4433. client->Message(CHANNEL_COLOR_YELLOW, "Divine Resist/Base: %u/%u",((NPC*)spawn)->GetDivineResistance(), ((NPC*)spawn)->GetDivineResistanceBase());
  4434. client->Message(CHANNEL_COLOR_YELLOW, "Disease Resist/Base: %u/%u",((NPC*)spawn)->GetDiseaseResistance(), ((NPC*)spawn)->GetDiseaseResistanceBase());
  4435. client->Message(CHANNEL_COLOR_YELLOW, "Poison Resist/Base: %u/%u",((NPC*)spawn)->GetPoisonResistance(), ((NPC*)spawn)->GetPoisonResistanceBase());
  4436. }
  4437. string details;
  4438. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  4439. details += "Type: " + string(type) + "\n";
  4440. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  4441. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  4442. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  4443. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  4444. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  4445. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  4446. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  4447. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  4448. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  4449. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  4450. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  4451. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  4452. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  4453. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  4454. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  4455. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  4456. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  4457. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  4458. char x[16];
  4459. sprintf(x, "%.2f", spawn->GetX());
  4460. char y[16];
  4461. sprintf(y, "%.2f", spawn->GetY());
  4462. char z[16];
  4463. sprintf(z, "%.2f", spawn->GetZ());
  4464. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  4465. string details2;
  4466. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  4467. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  4468. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  4469. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  4470. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  4471. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  4472. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  4473. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  4474. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  4475. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  4476. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  4477. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  4478. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  4479. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  4480. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  4481. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  4482. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  4483. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  4484. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  4485. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  4486. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  4487. string details3;
  4488. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  4489. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  4490. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  4491. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  4492. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  4493. if(spawn->IsEntity())
  4494. {
  4495. Entity* ent = (Entity*)spawn;
  4496. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  4497. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  4498. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  4499. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  4500. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  4501. }
  4502. string details4;
  4503. if (spawn->IsEntity()) {
  4504. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  4505. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4506. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4507. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4508. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4509. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4510. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4511. if (spawn->IsNPC()) {
  4512. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4513. }
  4514. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4515. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4516. }
  4517. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4518. client->SendShowBook(client->GetPlayer(), title, 4, details, details2, details3, details4);
  4519. }
  4520. else {
  4521. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4522. 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.");
  4523. }
  4524. break;
  4525. }
  4526. case COMMAND_SPAWN_TARGET:{
  4527. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4528. int32 spawn_id = atoul(sep->arg[0]);
  4529. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4530. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4531. }
  4532. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4533. float distance = atof(sep->arg[1]);
  4534. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4535. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4536. }
  4537. else{
  4538. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4539. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4540. }
  4541. break;
  4542. }
  4543. case COMMAND_SPAWN_SET:
  4544. {
  4545. Spawn* spawn = cmdTarget;
  4546. sint16 set_type = -1;
  4547. string type_str;
  4548. if (spawn)
  4549. {
  4550. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4551. 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)
  4552. {
  4553. // set the type, which will be 0 if location or list or invalid
  4554. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4555. }
  4556. if(set_type > 0)
  4557. {
  4558. // check if spawn set is NOT a char update, or not location, or isn't a number
  4559. 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)
  4560. {
  4561. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4562. }
  4563. else
  4564. {
  4565. string name = string(spawn->GetName());
  4566. bool customSetSpawn = false;
  4567. if(set_type >= SPAWN_SET_CHEEK_TYPE && set_type <= SPAWN_SET_SOGA_NOSE_TYPE)
  4568. {
  4569. int8 index = sep->IsNumber(2) ? atoul(sep->arg[2]) : 0;
  4570. // override the standard setspawncommand, we pass arguments different!
  4571. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1], true, false, nullptr, index))
  4572. customSetSpawn = true;
  4573. }
  4574. if(customSetSpawn || SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4575. {
  4576. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4577. {
  4578. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4579. }
  4580. else if (set_type == SPAWN_SET_VALUE_NAME)
  4581. {
  4582. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4583. }
  4584. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4585. {
  4586. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4587. }
  4588. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4589. {
  4590. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4591. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  4592. }
  4593. else
  4594. {
  4595. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  4596. }
  4597. switch (set_type)
  4598. {
  4599. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4600. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4601. case SPAWN_SET_VALUE_FACTION:
  4602. case SPAWN_SET_AAXP_REWARDS:
  4603. case SPAWN_SET_CHEEK_TYPE:
  4604. case SPAWN_SET_CHIN_TYPE:
  4605. case SPAWN_SET_EAR_TYPE:
  4606. case SPAWN_SET_EYE_BROW_TYPE:
  4607. case SPAWN_SET_EYE_TYPE:
  4608. case SPAWN_SET_LIP_TYPE:
  4609. case SPAWN_SET_NOSE_TYPE:
  4610. case SPAWN_SET_BODY_SIZE:
  4611. case SPAWN_SET_BODY_AGE:
  4612. case SPAWN_SET_SOGA_CHEEK_TYPE:
  4613. case SPAWN_SET_SOGA_CHIN_TYPE:
  4614. case SPAWN_SET_SOGA_EAR_TYPE:
  4615. case SPAWN_SET_SOGA_EYE_BROW_TYPE:
  4616. case SPAWN_SET_SOGA_EYE_TYPE:
  4617. case SPAWN_SET_SOGA_LIP_TYPE:
  4618. case SPAWN_SET_SOGA_NOSE_TYPE:
  4619. case SPAWN_SET_SOGA_BODY_SIZE:
  4620. case SPAWN_SET_SOGA_BODY_AGE:
  4621. case SPAWN_SET_ATTACK_TYPE:
  4622. {
  4623. // not applicable already ran db command
  4624. break;
  4625. }
  4626. default:
  4627. {
  4628. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4629. break;
  4630. }
  4631. }
  4632. 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))
  4633. {
  4634. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4635. {
  4636. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  4637. }
  4638. else if(spawn->GetSpawnLocationID() > 0)
  4639. {
  4640. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4641. }
  4642. }
  4643. else
  4644. {
  4645. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4646. {
  4647. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  4648. }
  4649. else if(spawn->GetDatabaseID() > 0)
  4650. {
  4651. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4652. }
  4653. }
  4654. }
  4655. }
  4656. }
  4657. else if(set_type == 0)
  4658. {
  4659. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4660. map<string, int8>::iterator itr;
  4661. int i=0;
  4662. string list;
  4663. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4664. {
  4665. if(i==10)
  4666. {
  4667. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4668. i = 0;
  4669. }
  4670. if(i>0)
  4671. {
  4672. list.append(", ").append(itr->first);
  4673. }
  4674. else
  4675. {
  4676. list = itr->first;
  4677. }
  4678. }
  4679. if(list.length() > 0)
  4680. {
  4681. // if 1 or more, display in client.
  4682. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4683. }
  4684. }
  4685. else
  4686. {
  4687. // syntax fail
  4688. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4689. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4690. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4691. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4692. }
  4693. }
  4694. break;
  4695. }
  4696. case COMMAND_SPAWN_REMOVE:{
  4697. Spawn* spawn = cmdTarget;
  4698. if(spawn && !spawn->IsPlayer()){
  4699. if(spawn->GetSpawnLocationID() > 0){
  4700. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4701. client->GetCurrentZone()->RemoveSpawn(spawn, true, false, true, true, true);
  4702. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  4703. }
  4704. else
  4705. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4706. }
  4707. else
  4708. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4709. }
  4710. else{
  4711. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4712. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4713. }
  4714. break;
  4715. }
  4716. case COMMAND_SPAWN_LIST:{
  4717. if(sep && sep->arg[0][0]){
  4718. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4719. vector<string>::iterator itr;
  4720. if(results){
  4721. for(itr=results->begin();itr!=results->end();itr++){
  4722. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4723. }
  4724. safe_delete(results);
  4725. }
  4726. else
  4727. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4728. }
  4729. else{
  4730. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4731. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4732. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4733. }
  4734. break;
  4735. }
  4736. case COMMAND_SPAWN_ADD:{
  4737. Spawn* spawn = cmdTarget;
  4738. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  4739. if(spawn->GetSpawnLocationID() > 0){
  4740. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4741. break;
  4742. }
  4743. if(spawn->GetDatabaseID() == 0){
  4744. if(database.SaveSpawnInfo(spawn)) {
  4745. char spawn_type[32];
  4746. memset(spawn_type, 0, sizeof(spawn_type));
  4747. if (spawn->IsNPC())
  4748. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4749. else if (spawn->IsObject())
  4750. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4751. else if (spawn->IsSign())
  4752. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4753. else if (spawn->IsGroundSpawn())
  4754. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4755. else
  4756. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4757. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4758. }
  4759. else
  4760. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4761. }
  4762. int32 spawn_group_id = 0;
  4763. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4764. spawn_group_id = database.GetNextSpawnLocation();
  4765. else
  4766. spawn_group_id = atol(sep->arg[0]);
  4767. int8 percent = 100;
  4768. if(sep->arg[2] && sep->IsNumber(2))
  4769. percent = atoi(sep->arg[2]);
  4770. spawn->SetSpawnLocationID(spawn_group_id);
  4771. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4772. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4773. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4774. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4775. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4776. else
  4777. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  4778. }
  4779. else{
  4780. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  4781. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  4782. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  4783. }
  4784. break;
  4785. }
  4786. case COMMAND_SPAWN:{
  4787. int32 id = 0;
  4788. Spawn* spawn = 0;
  4789. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4790. id = atol(sep->arg[0]);
  4791. spawn = client->GetCurrentZone()->GetSpawn(id);
  4792. }
  4793. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  4794. id = 0;
  4795. if(!id || !spawn){
  4796. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  4797. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  4798. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  4799. safe_delete(sep);
  4800. return;
  4801. }
  4802. if(sep && sep->arg[1][0]){
  4803. float x = atof(sep->arg[1]);
  4804. spawn->appearance.pos.X = x;
  4805. }
  4806. else
  4807. spawn->SetX(client->GetPlayer()->GetX(), false);
  4808. if(sep && sep->arg[2][0]){
  4809. float y = atof(sep->arg[2]);
  4810. spawn->appearance.pos.Y = y;
  4811. }
  4812. else
  4813. spawn->SetY(client->GetPlayer()->GetY(), false);
  4814. if(sep && sep->arg[3][0]){
  4815. float z = atof(sep->arg[3]);
  4816. spawn->appearance.pos.Z = z;
  4817. }
  4818. else
  4819. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  4820. if(sep && sep->arg[4][0]){
  4821. float heading = atof(sep->arg[4]);
  4822. spawn->SetHeading(heading);
  4823. }
  4824. else
  4825. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  4826. spawn->SetSpawnOrigX(spawn->GetX());
  4827. spawn->SetSpawnOrigY(spawn->GetY());
  4828. spawn->SetSpawnOrigZ(spawn->GetZ());
  4829. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4830. if(sep && sep->arg[5][0])
  4831. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  4832. else
  4833. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4834. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  4835. spawn->SetTotalHP(spawn->GetLevel() * 15);
  4836. spawn->SetHP(spawn->GetTotalHP());
  4837. }
  4838. if(spawn->GetTotalPower() == 0){
  4839. spawn->SetTotalPower(spawn->GetLevel() * 15);
  4840. spawn->SetPower(spawn->GetTotalPower());
  4841. }
  4842. const char* script = world.GetSpawnScript(id);
  4843. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  4844. spawn->SetSpawnScript(string(script));
  4845. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  4846. client->GetCurrentZone()->AddSpawn(spawn);
  4847. if(spawn->IsNPC())
  4848. spawn->GetZone()->AddLoot((NPC*)spawn);
  4849. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  4850. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  4851. break;
  4852. }
  4853. case COMMAND_ADMINFLAG:
  4854. {
  4855. if(sep && sep->arg[0]){
  4856. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  4857. sint16 new_status = atoi(sep->arg[1]);
  4858. if(tmp_status == -10)
  4859. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  4860. else if(tmp_status >= client->GetAdminStatus())
  4861. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  4862. else if (new_status > client->GetAdminStatus())
  4863. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  4864. else{
  4865. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  4866. if (!client2)
  4867. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  4868. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  4869. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  4870. if (client2) {
  4871. client2->SetAdminStatus(new_status);
  4872. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  4873. }
  4874. }
  4875. else
  4876. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  4877. }
  4878. }else{
  4879. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  4880. if(status != client->GetAdminStatus())
  4881. {
  4882. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  4883. client->SetAdminStatus(status);
  4884. }
  4885. else
  4886. {
  4887. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  4888. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  4889. client->Message(CHANNEL_COLOR_YELLOW," Admin User: %i", status);
  4890. }
  4891. }
  4892. break;
  4893. }
  4894. case COMMAND_CANNEDEMOTE:{
  4895. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  4896. break;
  4897. }
  4898. case COMMAND_BROADCAST: {
  4899. if (sep && sep->arg[0])
  4900. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  4901. else
  4902. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  4903. break;
  4904. }
  4905. case COMMAND_ANNOUNCE: {
  4906. if (sep && sep->arg[0])
  4907. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  4908. else
  4909. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  4910. break;
  4911. }
  4912. case COMMAND_RELOAD_ITEMS:{
  4913. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  4914. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  4915. database.ReloadItemList();
  4916. database.LoadMerchantInformation();
  4917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  4918. break;
  4919. }
  4920. case COMMAND_ENABLE_ABILITY_QUE:{
  4921. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  4922. if(app)
  4923. client->QueuePacket(app);
  4924. break;
  4925. }
  4926. case COMMAND_ITEMSEARCH:
  4927. case COMMAND_FROMBROKER:{
  4928. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  4929. if (packet) {
  4930. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  4931. //packet->setDataByName("unknown", 1);
  4932. packet->setDataByName("unknown2", 5, 0);
  4933. packet->setDataByName("unknown2", 20, 1);
  4934. packet->setDataByName("unknown2", 58, 3);
  4935. packet->setDataByName("unknown2", 40, 4);
  4936. client->QueuePacket(packet->serialize());
  4937. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  4938. if (packet2) {
  4939. packet2->setDataByName("char_id", client->GetCharacterID());
  4940. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  4941. safe_delete(packet2);
  4942. }
  4943. safe_delete(packet);
  4944. }
  4945. break;
  4946. }
  4947. case COMMAND_ANIMTEST:{
  4948. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  4949. if(command_packet){
  4950. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  4951. if (cmdTarget)
  4952. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  4953. command_packet->setDataByName ( "spawn_id" , id);
  4954. int animID = 1;
  4955. if(sep && sep->arg[0] && sep->IsNumber(0))
  4956. animID = atoi(sep->arg[0]);
  4957. VisualState* vs = NULL;
  4958. if(animID == 0)
  4959. {
  4960. vs = visual_states.FindVisualState(sep->arg[0]);
  4961. }
  4962. char msg[128];
  4963. sprintf(msg,"Animation Test ID: %i",animID);
  4964. command_packet->setMediumStringByName ( "emote_msg" , msg );
  4965. if(vs != NULL)
  4966. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  4967. else
  4968. command_packet->setDataByName ( "anim_type", animID );
  4969. command_packet->setDataByName ( "unknown0", 0 );
  4970. EQ2Packet* outapp = command_packet->serialize();
  4971. client->QueuePacket(outapp);
  4972. safe_delete(command_packet);
  4973. }
  4974. break;
  4975. }
  4976. case COMMAND_KICK:
  4977. {
  4978. if( sep == 0 || sep->arg[0] == 0)
  4979. {
  4980. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  4981. }
  4982. else
  4983. {
  4984. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  4985. if ( kickClient == client )
  4986. {
  4987. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  4988. break;
  4989. }
  4990. else if(kickClient != NULL)
  4991. {
  4992. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  4993. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  4994. {
  4995. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  4996. break;
  4997. }
  4998. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  4999. kickClient->Disconnect();
  5000. }
  5001. else
  5002. {
  5003. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5004. }
  5005. }
  5006. break;
  5007. }
  5008. case COMMAND_LOCK:
  5009. {
  5010. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  5011. int worldLocked = atoi(sep->arg[0]);
  5012. net.world_locked = worldLocked;
  5013. if ( worldLocked )
  5014. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  5015. else
  5016. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  5017. }
  5018. else
  5019. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  5020. break;
  5021. }
  5022. case COMMAND_BAN:{
  5023. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  5024. {
  5025. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  5026. }
  5027. else
  5028. {
  5029. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  5030. if ( kickClient == client )
  5031. {
  5032. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  5033. break;
  5034. }
  5035. else if(kickClient != NULL)
  5036. {
  5037. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5038. if ( maxStatus > client->GetAdminStatus( ) ||
  5039. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  5040. {
  5041. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5042. break;
  5043. }
  5044. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  5045. int perm = atol(sep->arg[1]);
  5046. if ( perm == 1 )
  5047. database.UpdateAdminStatus(sep->arg[0],-2);
  5048. else
  5049. database.UpdateAdminStatus(sep->arg[0],-1);
  5050. kickClient->Disconnect();
  5051. }
  5052. else
  5053. {
  5054. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5055. }
  5056. }
  5057. break;
  5058. }
  5059. case COMMAND_SET_COMBAT_VOICE:{
  5060. int32 value = 0;
  5061. if(sep && sep->arg[0] && sep->IsNumber(0))
  5062. value = atoi(sep->arg[0]);
  5063. client->GetPlayer()->SetCombatVoice(value);
  5064. break;
  5065. }
  5066. case COMMAND_SET_EMOTE_VOICE:{
  5067. int32 value = 0;
  5068. if(sep && sep->arg[0] && sep->IsNumber(0))
  5069. value = atoi(sep->arg[0]);
  5070. client->GetPlayer()->SetEmoteVoice(value);
  5071. break;
  5072. }
  5073. case COMMAND_GIVEITEM:{
  5074. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  5075. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  5076. if ( itemToClient == NULL )
  5077. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  5078. else
  5079. {
  5080. int32 item_id = atol(sep->arg[1]);
  5081. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  5082. itemToClient->AddItem(item_id);
  5083. }
  5084. }
  5085. else
  5086. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  5087. break;
  5088. }
  5089. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  5090. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  5091. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  5092. case COMMAND_SKILL :
  5093. case COMMAND_SKILL_ADD :
  5094. case COMMAND_SKILL_REMOVE :
  5095. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  5096. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  5097. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  5098. case COMMAND_ENTITYCOMMAND :
  5099. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  5100. case COMMAND_MERCHANT :
  5101. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  5102. case COMMAND_APPEARANCE :
  5103. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  5104. case COMMAND_TRACK : { Command_Track(client); break; }
  5105. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  5106. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  5107. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  5108. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  5109. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  5110. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  5111. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  5112. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  5113. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  5114. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  5115. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  5116. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  5117. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  5118. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  5119. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  5120. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  5121. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  5122. case COMMAND_LOCATION : { Command_Location(client); break; }
  5123. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  5124. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  5125. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  5126. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  5127. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  5128. case COMMAND_GRID : { Command_Grid(client); break; }
  5129. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  5130. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  5131. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  5132. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  5133. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  5134. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  5135. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  5136. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  5137. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  5138. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  5139. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  5140. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  5141. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  5142. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  5143. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  5144. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  5145. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  5146. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  5147. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  5148. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  5149. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  5150. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  5151. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  5152. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  5153. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  5154. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  5155. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  5156. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  5157. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  5158. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  5159. case COMMAND_MOTD : { Command_MOTD(client); break; }
  5160. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  5161. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  5162. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  5163. case COMMAND_TITLE : { Command_Title(client); break; }
  5164. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  5165. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  5166. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  5167. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  5168. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  5169. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  5170. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  5171. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  5172. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  5173. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  5174. case COMMAND_PET : { Command_Pet(client, sep); break; }
  5175. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  5176. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  5177. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  5178. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  5179. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  5180. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  5181. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  5182. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  5183. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  5184. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  5185. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  5186. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  5187. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  5188. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  5189. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  5190. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  5191. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  5192. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  5193. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  5194. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  5195. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  5196. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  5197. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  5198. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  5199. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  5200. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  5201. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  5202. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  5203. //devn00b
  5204. case COMMAND_MOOD : { Command_Mood(client, sep); break;}
  5205. case COMMAND_MODIFY : { Command_Modify(client); break; }
  5206. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  5207. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  5208. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  5209. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  5210. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  5211. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  5212. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  5213. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  5214. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  5215. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  5216. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  5217. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  5218. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  5219. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  5220. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  5221. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  5222. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  5223. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  5224. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  5225. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  5226. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  5227. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5228. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  5229. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  5230. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  5231. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  5232. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  5233. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  5234. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  5235. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  5236. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  5237. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  5238. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  5239. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  5240. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  5241. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  5242. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  5243. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  5244. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  5245. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  5246. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  5247. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  5248. case ADD_AA : { Add_AA(client, sep); break; }
  5249. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  5250. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  5251. case BACK_AA : { Back_AA(client, sep); break; }
  5252. case REMOVE_AA : { Remove_AA(client, sep); break; }
  5253. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  5254. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  5255. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  5256. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  5257. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  5258. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  5259. case COMMAND_CRAFTITEM: {
  5260. Item* item = 0;
  5261. if (sep && sep->IsNumber(0)) {
  5262. int32 item_id = atol(sep->arg[0]);
  5263. int32 quantity = 1;
  5264. if (sep->arg[1] && sep->IsNumber(1))
  5265. quantity = atoi(sep->arg[1]);
  5266. item = new Item(master_item_list.GetItem(item_id));
  5267. if (!item) {
  5268. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  5269. }
  5270. else {
  5271. item->details.count = quantity;
  5272. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  5273. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  5274. bool itemDeleted = false;
  5275. client->AddItem(item, &itemDeleted);
  5276. //Check for crafting quest updates
  5277. int8 update_amt = 0;
  5278. if (!itemDeleted && item->stack_count > 1)
  5279. update_amt = 1;
  5280. else
  5281. update_amt = quantity;
  5282. if(!itemDeleted)
  5283. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  5284. }
  5285. }
  5286. else {
  5287. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  5288. }
  5289. break;
  5290. }
  5291. case COMMAND_UNMENTOR:
  5292. case COMMAND_MENTOR: {
  5293. client->GetPlayer()->MentorTarget();
  5294. break;
  5295. }
  5296. default:
  5297. {
  5298. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  5299. break;
  5300. }
  5301. }
  5302. safe_delete(sep);
  5303. }
  5304. /******************** New COMMAND Handler Functions ********************/
  5305. /*
  5306. Started breaking apart the huge switch() for commands into sepErate
  5307. functions so it is easier to locate the blocks of code by command
  5308. -- JA 2012.03.03
  5309. */
  5310. // sample function header
  5311. /*
  5312. Function:
  5313. Purpose :
  5314. Params :
  5315. Dev :
  5316. Example :
  5317. */
  5318. //void Commands::Command()
  5319. //{
  5320. //}
  5321. /*
  5322. Function: Command_AcceptAdvancement()
  5323. Purpose : Player accepts a new advancement option
  5324. Params : Spell ID
  5325. Dev : Jabantiz
  5326. */
  5327. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  5328. {
  5329. Player *player = client->GetPlayer();
  5330. if (sep && sep->IsSet(0)) {
  5331. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  5332. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  5333. if (!player->HasSpell(trait->spellID, 0, true))
  5334. {
  5335. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5336. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5337. }
  5338. else
  5339. {
  5340. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5341. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  5342. player->RemoveSpellBookEntry(spell->GetSpellID());
  5343. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5344. player->UnlockSpell(spell);
  5345. client->SendSpellUpdate(spell);
  5346. }
  5347. // Spell book update
  5348. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  5349. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  5350. }
  5351. }
  5352. /*
  5353. Function:
  5354. Purpose :
  5355. Params :
  5356. Dev :
  5357. Example :
  5358. */
  5359. void Commands::Command_AFK(Client* client, Seperator* sep)
  5360. {
  5361. Player* player = client->GetPlayer();
  5362. player->toggle_character_flag(CF_AFK);
  5363. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  5364. if (player->get_character_flag(CF_AFK))
  5365. {
  5366. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  5367. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  5368. if (sep && sep->argplus[0])
  5369. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  5370. else
  5371. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  5372. string message = string(player->GetName()) + " is going afk.";
  5373. Spawn* target = player->GetTarget();
  5374. if (target && target != player)
  5375. {
  5376. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  5377. player->GetGender() == 1 ? message += "he" : message += "she";
  5378. message += " is going afk.";
  5379. }
  5380. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  5381. }
  5382. /*else
  5383. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  5384. }
  5385. /*
  5386. Function: Command_Appearance()
  5387. Purpose : Handles /appearance commands
  5388. Params : list
  5389. Dev : Scatman
  5390. Example : /appearance list
  5391. */
  5392. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  5393. {
  5394. if( handler == COMMAND_APPEARANCE )
  5395. {
  5396. // /appearance command by itself shows help (to be extended)
  5397. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5398. return;
  5399. }
  5400. else if( handler == COMMAND_APPEARANCE_LIST )
  5401. {
  5402. // /appearance list command expects "name" param
  5403. if (sep && sep->arg[0])
  5404. {
  5405. const char* appearance_name = sep->argplus[0];
  5406. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  5407. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  5408. if (appearances)
  5409. {
  5410. vector<int16>::iterator itr;
  5411. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  5412. {
  5413. int16 id = *itr;
  5414. string name = database.GetAppearanceName(id);
  5415. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  5416. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  5417. }
  5418. safe_delete(appearances);
  5419. }
  5420. }
  5421. else // no param
  5422. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5423. }
  5424. }
  5425. /*
  5426. Function: Command_Claim()
  5427. Purpose :
  5428. Params :
  5429. Dev :
  5430. Example :
  5431. */
  5432. void Commands::Command_Claim(Client* client, Seperator* sep)
  5433. {
  5434. if (sep && sep->arg[0] && sep->IsNumber(0))
  5435. {
  5436. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5437. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  5438. }
  5439. else
  5440. client->ShowClaimWindow();
  5441. }
  5442. /*
  5443. Function: Command_ClearAllQueued()
  5444. Purpose :
  5445. Params :
  5446. Dev :
  5447. Example :
  5448. */
  5449. void Commands::Command_ClearAllQueued(Client* client)
  5450. {
  5451. ZoneServer* zone = client->GetPlayer()->GetZone();
  5452. if (zone && zone->GetSpellProcess())
  5453. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  5454. }
  5455. /*
  5456. Function: Command_CancelMaintained()
  5457. Purpose : Cancels maintained spells
  5458. Params : Maintained Spell Index
  5459. Dev : Zcoretri
  5460. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  5461. */
  5462. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  5463. {
  5464. if (sep && sep->arg[0] && sep->IsNumber(0))
  5465. {
  5466. int32 spell_index = atoul(sep->arg[0]);
  5467. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  5468. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  5469. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  5470. // just not spelleffects/dets - Foof
  5471. //{
  5472. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled", false, true))
  5473. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  5474. // }
  5475. //else
  5476. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  5477. }
  5478. }
  5479. /*
  5480. Function: Command_Create()
  5481. Purpose : Handler for starting Tradeskilling table
  5482. Params :
  5483. Dev : Zcoretri
  5484. Example :
  5485. */
  5486. void Commands::Command_Create(Client* client, Seperator* sep)
  5487. {
  5488. PrintSep(sep, "COMMAND_CREATE");
  5489. client->SendRecipeList();
  5490. client->ShowRecipeBook();
  5491. }
  5492. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  5493. {
  5494. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  5495. if (sep && sep->arg[0] && sep->IsNumber(0))
  5496. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  5497. }
  5498. /*
  5499. Function: Command_Distance()
  5500. Purpose : Displays distance from targeted spawn
  5501. Params :
  5502. Dev : Scatman
  5503. Example : /distance
  5504. */
  5505. void Commands::Command_Distance(Client* client)
  5506. {
  5507. Spawn* target = client->GetPlayer()->GetTarget();
  5508. if (target)
  5509. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  5510. else
  5511. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  5512. }
  5513. /*
  5514. Function: Command_Duel()
  5515. Purpose : Handle the /duel commands - not yet implemented
  5516. Params : unknown
  5517. Dev :
  5518. Example :
  5519. */
  5520. void Commands::Command_Duel(Client* client, Seperator* sep)
  5521. {
  5522. PrintSep(sep, "COMMAND_DUEL");
  5523. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  5524. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5525. }
  5526. /*
  5527. Function: Command_DuelBet()
  5528. Purpose : Handle the /duel commands - not yet implemented
  5529. Params : unknown
  5530. Dev :
  5531. Example :
  5532. */
  5533. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  5534. {
  5535. PrintSep(sep, "COMMAND_DUELBET");
  5536. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  5537. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5538. }
  5539. /*
  5540. Function: Command_DuelAccept()
  5541. Purpose : Handle the /duel commands - not yet implemented
  5542. Params : unknown
  5543. Dev :
  5544. Example :
  5545. */
  5546. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5547. {
  5548. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5549. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5550. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5551. }
  5552. /*
  5553. Function: Command_DuelDecline()
  5554. Purpose : Handle the /duel commands - not yet implemented
  5555. Params : unknown
  5556. Dev :
  5557. Example :
  5558. */
  5559. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5560. {
  5561. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5562. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5563. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5564. }
  5565. /*
  5566. Function: Command_DuelSurrender()
  5567. Purpose : Handle the /duel commands - not yet implemented
  5568. Params : unknown
  5569. Dev :
  5570. Example :
  5571. */
  5572. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5573. {
  5574. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5575. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5576. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5577. // JA, just messin around ;)
  5578. char surrender[64];
  5579. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5580. zone_list.HandleGlobalAnnouncement(surrender);
  5581. }
  5582. /*
  5583. Function: Command_DuelToggle()
  5584. Purpose : Handle the /duel commands - not yet implemented
  5585. Params : unknown
  5586. Dev :
  5587. Example :
  5588. */
  5589. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5590. {
  5591. PrintSep(sep, "COMMAND_DUEL");
  5592. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5593. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5594. }
  5595. /*
  5596. Function:
  5597. Purpose :
  5598. Params :
  5599. Dev :
  5600. Example :
  5601. */
  5602. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5603. {
  5604. if( handler == COMMAND_ENTITYCOMMAND )
  5605. {
  5606. // /entitycommand command by itself shows help (to be extended)
  5607. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5608. return;
  5609. }
  5610. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5611. {
  5612. // /entitycommand list command expects "name" param
  5613. if (sep && sep->arg[0])
  5614. {
  5615. const char* entity_command_name = sep->argplus[0];
  5616. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5617. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5618. map<int32, vector<EntityCommand*>*>::iterator itr;
  5619. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5620. {
  5621. vector<EntityCommand*>* entity_command_list = itr->second;
  5622. vector<EntityCommand*>::iterator itr2;
  5623. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5624. {
  5625. EntityCommand* entity_command = *itr2;
  5626. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5627. 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);
  5628. }
  5629. }
  5630. }
  5631. else // no command name
  5632. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5633. }
  5634. }
  5635. /*
  5636. Function: Command_Follow()
  5637. Purpose : Handle the /follow command - not yet implemented
  5638. Params :
  5639. Dev :
  5640. Example :
  5641. */
  5642. void Commands::Command_Follow(Client* client, Seperator* sep)
  5643. {
  5644. PrintSep(sep, "COMMAND_FOLLOW");
  5645. // flag to toggle if the players target is in the players group
  5646. bool targetInGroup = false;
  5647. // get a pointer to the players group
  5648. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5649. // If the player has a group and has a target
  5650. if (gmi && client->GetPlayer()->GetTarget()) {
  5651. deque<GroupMemberInfo*>::iterator itr;
  5652. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5653. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5654. if (group)
  5655. {
  5656. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5657. deque<GroupMemberInfo*>* members = group->GetMembers();
  5658. // Loop through the group members
  5659. for (itr = members->begin(); itr != members->end(); itr++) {
  5660. // If a group member matches a target
  5661. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  5662. // toggle the flag and break the loop
  5663. targetInGroup = true;
  5664. break;
  5665. }
  5666. }
  5667. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5668. }
  5669. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5670. }
  5671. if (targetInGroup) {
  5672. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5673. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5674. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5675. client->GetPlayer()->info_changed = true;
  5676. client->GetPlayer()->changed = true;
  5677. }
  5678. else
  5679. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5680. }
  5681. /*
  5682. Function: Command_StopFollow()
  5683. Purpose : Handle the /stop_follow command - not yet implemented
  5684. Params :
  5685. Dev :
  5686. Example :
  5687. */
  5688. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5689. {
  5690. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5691. if (client->GetPlayer()->GetFollowTarget()) {
  5692. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5693. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5694. client->GetPlayer()->SetFollowTarget(0);
  5695. client->GetPlayer()->info_changed = true;
  5696. client->GetPlayer()->changed = true;
  5697. }
  5698. }
  5699. /*
  5700. Function: Command_Grid()
  5701. Purpose : Show player's current Grid ID
  5702. Params :
  5703. Dev : Scatman
  5704. Example : /grid
  5705. */
  5706. void Commands::Command_Grid(Client* client)
  5707. {
  5708. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  5709. if (client->GetPlayer()->GetMap() != nullptr) {
  5710. auto loc = glm::vec3(client->GetPlayer()->GetX(), client->GetPlayer()->GetZ(), client->GetPlayer()->GetY());
  5711. uint32 GridID = 0;
  5712. float new_z = client->GetPlayer()->GetMap()->FindBestZ(loc, nullptr, &GridID);
  5713. client->Message(CHANNEL_COLOR_YELLOW, "Grid result is %u, at EQ2 Y coordinate %f", GridID, new_z);
  5714. }
  5715. }
  5716. /*
  5717. Function: Command_Guild()
  5718. Purpose : Handler for all UI-related guild commands
  5719. Dev : Scatman
  5720. */
  5721. void Commands::Command_Guild(Client* client, Seperator* sep)
  5722. {
  5723. Guild* guild = client->GetPlayer()->GetGuild();
  5724. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  5725. {
  5726. const char* command = sep->arg[0];
  5727. int32 length = strlen(command);
  5728. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  5729. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  5730. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  5731. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5732. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5733. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5734. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5735. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  5736. guild->KickGuildMember(client, sep->arg[1]);
  5737. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  5738. guild->DemoteGuildMember(client, sep->arg[1]);
  5739. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  5740. guild->PromoteGuildMember(client, sep->arg[1]);
  5741. else if (strncmp(command, "points", length) == 0 && guild)
  5742. {
  5743. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  5744. {
  5745. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5746. {
  5747. float points = atof(sep->arg[2]);
  5748. const char* option = sep->arg[3];
  5749. const char* comment = sep->argplus[4];
  5750. if (strncmp(option, "all", strlen(option)) == 0)
  5751. guild->AddPointsToAll(client, points, comment);
  5752. else if (strncmp(option, "online", strlen(option)) == 0)
  5753. guild->AddPointsToAllOnline(client, points, comment);
  5754. else if (strncmp(option, "group", strlen(option)) == 0)
  5755. guild->AddPointsToGroup(client, points, comment);
  5756. else if (strncmp(option, "raid", strlen(option)) == 0)
  5757. guild->AddPointsToRaid(client, points, comment);
  5758. else
  5759. guild->AddPointsToGuildMember(client, points, option, comment);
  5760. }
  5761. }
  5762. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  5763. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  5764. else
  5765. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  5766. }
  5767. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  5768. guild->SetMOTD(sep->argplus[1]);
  5769. else if (strncmp(command, "recruiting", length) == 0 && guild)
  5770. {
  5771. if (sep->arg[1])
  5772. {
  5773. const char* option = sep->arg[1];
  5774. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  5775. guild->SetRecruitingShortDesc(sep->argplus[2]);
  5776. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  5777. guild->SetRecruitingFullDesc(sep->argplus[2]);
  5778. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5779. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5780. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5781. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  5782. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5783. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  5784. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  5785. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  5786. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  5787. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5788. else
  5789. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5790. }
  5791. else
  5792. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5793. }
  5794. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  5795. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5796. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  5797. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5798. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5799. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5800. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  5801. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  5802. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5803. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5804. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  5805. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  5806. else if (strncmp(command, "invite", length) == 0 && guild)
  5807. {
  5808. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5809. guild->InvitePlayer(client, sep->arg[1]);
  5810. else
  5811. {
  5812. Spawn* target = client->GetPlayer()->GetTarget();
  5813. if (target)
  5814. {
  5815. if (target->IsPlayer())
  5816. guild->InvitePlayer(client, target->GetName());
  5817. else
  5818. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  5819. }
  5820. }
  5821. }
  5822. else if (strncmp(command, "accept", length) == 0)
  5823. {
  5824. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5825. if (pgi && pgi->guild && pgi->invited_by)
  5826. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  5827. client->SetPendingGuildInvite(0);
  5828. }
  5829. else if (strncmp(command, "decline", length) == 0)
  5830. {
  5831. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5832. if (pgi && pgi->guild && pgi->invited_by)
  5833. {
  5834. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  5835. if (client_inviter)
  5836. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  5837. }
  5838. client->SetPendingGuildInvite(0);
  5839. }
  5840. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  5841. {
  5842. const char* guild_name = sep->argplus[1];
  5843. if (!guild_list.GetGuild(guild_name))
  5844. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  5845. else
  5846. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  5847. }
  5848. else if (strncmp(command, "search", length) == 0)
  5849. client->ShowGuildSearchWindow();
  5850. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  5851. {
  5852. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  5853. if (to_guild)
  5854. to_guild->SendGuildRecruitingDetails(client);
  5855. }
  5856. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  5857. {
  5858. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  5859. if (to_guild)
  5860. to_guild->SendGuildRecruitingImages(client);
  5861. }
  5862. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  5863. {
  5864. if (sep->arg[1])
  5865. {
  5866. const char* option = sep->arg[1];
  5867. if (strncmp(option, "toggle", strlen(option)) == 0)
  5868. guild->ToggleGuildRecruiterAdventureClass(client);
  5869. }
  5870. else
  5871. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  5872. }
  5873. else if (strncmp(command, "display_heraldry", length) == 0)
  5874. {
  5875. // JA: not sure this is right...
  5876. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  5877. client->GetPlayer()->SetCharSheetChanged(true);
  5878. }
  5879. else
  5880. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  5881. }
  5882. }
  5883. /*
  5884. Function: Command_GuildCreate()
  5885. Purpose : Display's in-game Guild Creation window
  5886. Dev : Scatman
  5887. */
  5888. void Commands::Command_CreateGuild(Client* client)
  5889. {
  5890. client->SendGuildCreateWindow();
  5891. }
  5892. /*
  5893. Function: Command_SetGuildOfficerNote()
  5894. Purpose :
  5895. Dev : Scatman
  5896. */
  5897. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  5898. {
  5899. if (sep && sep->arg[0] && sep->arg[1])
  5900. {
  5901. Guild* guild = client->GetPlayer()->GetGuild();
  5902. if (guild)
  5903. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  5904. }
  5905. }
  5906. /*
  5907. Function: Command_SetGuildMemberNote()
  5908. Purpose :
  5909. Dev : Scatman
  5910. */
  5911. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  5912. {
  5913. if (sep && sep->arg[0] && sep->arg[1])
  5914. {
  5915. Guild* guild = client->GetPlayer()->GetGuild();
  5916. if (guild)
  5917. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  5918. }
  5919. }
  5920. /*
  5921. Function: Command_GuildSay()
  5922. Purpose :
  5923. Dev : Scatman
  5924. */
  5925. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  5926. {
  5927. Guild* guild = client->GetPlayer()->GetGuild();
  5928. if (guild)
  5929. {
  5930. if (sep && sep->arg[0])
  5931. guild->HandleGuildSay(client, sep->argplus[0]);
  5932. }
  5933. else
  5934. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  5935. }
  5936. /*
  5937. Function: Command_OfficerSay()
  5938. Purpose :
  5939. Dev : Scatman
  5940. */
  5941. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  5942. {
  5943. Guild* guild = client->GetPlayer()->GetGuild();
  5944. if (guild)
  5945. {
  5946. if (sep && sep->arg[0])
  5947. guild->HandleOfficerSay(client, sep->argplus[0]);
  5948. }
  5949. else
  5950. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  5951. }
  5952. /*
  5953. Function: Command_Guilds()
  5954. Purpose : Shows help for /guild command
  5955. Params :
  5956. Dev : Scatman
  5957. Example :
  5958. */
  5959. void Commands::Command_Guilds(Client* client)
  5960. {
  5961. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  5962. }
  5963. /*
  5964. Function: Command_GuildsAdd()
  5965. Purpose : Add's players to a guild
  5966. Params : guild_name|guild_id, player name
  5967. Dev : Scatman
  5968. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  5969. */
  5970. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  5971. {
  5972. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5973. {
  5974. Guild* guild = 0;
  5975. bool found = true;
  5976. if (sep->IsNumber(0))
  5977. {
  5978. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5979. if (!guild)
  5980. {
  5981. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5982. found = false;
  5983. }
  5984. }
  5985. else
  5986. {
  5987. guild = guild_list.GetGuild(sep->arg[0]);
  5988. if (!guild)
  5989. {
  5990. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5991. found = false;
  5992. }
  5993. }
  5994. if (found)
  5995. {
  5996. Client* to_client = 0;
  5997. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5998. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5999. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6000. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6001. if (to_client)
  6002. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  6003. else
  6004. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6005. }
  6006. }
  6007. else
  6008. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  6009. }
  6010. /*
  6011. Function: Command_GuildsCreate()
  6012. Purpose : Creates a guild
  6013. Params : guild_name, player_name (optional)
  6014. Dev : Scatman
  6015. Example : /guilds create [guild name] (player name)
  6016. */
  6017. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  6018. {
  6019. if (sep && sep->arg[0])
  6020. {
  6021. const char* guild_name = sep->arg[0];
  6022. if (!guild_list.GetGuild(guild_name))
  6023. {
  6024. bool ret = false;
  6025. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6026. {
  6027. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6028. if (to_client)
  6029. {
  6030. world.CreateGuild(guild_name, to_client);
  6031. ret = true;
  6032. }
  6033. else
  6034. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  6035. }
  6036. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6037. {
  6038. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6039. if (to_client)
  6040. {
  6041. world.CreateGuild(guild_name, to_client);
  6042. ret = true;
  6043. }
  6044. }
  6045. else
  6046. {
  6047. world.CreateGuild(guild_name);
  6048. ret = true;
  6049. }
  6050. if (ret)
  6051. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  6052. else
  6053. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  6054. }
  6055. else
  6056. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  6057. }
  6058. else
  6059. 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.");
  6060. }
  6061. /*
  6062. Function: Command_GuildsDelete()
  6063. Purpose : Delete's a guild
  6064. Params : guild name
  6065. Dev : Scatman
  6066. Example : /guilds delete Test
  6067. */
  6068. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  6069. {
  6070. if (sep && sep->arg[0])
  6071. {
  6072. Guild* guild = 0;
  6073. bool found = true;
  6074. if (sep->IsNumber(0))
  6075. {
  6076. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6077. if (!guild)
  6078. {
  6079. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6080. found = false;
  6081. }
  6082. }
  6083. else
  6084. {
  6085. guild = guild_list.GetGuild(sep->arg[0]);
  6086. if (!guild)
  6087. {
  6088. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6089. found = false;
  6090. }
  6091. }
  6092. if (found)
  6093. {
  6094. guild->RemoveAllGuildMembers();
  6095. database.DeleteGuild(guild);
  6096. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  6097. guild_list.RemoveGuild(guild, true);
  6098. }
  6099. }
  6100. else
  6101. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  6102. }
  6103. /*
  6104. Function: Command_GuildsList()
  6105. Purpose : Lists current guilds on server
  6106. Params :
  6107. Dev : Scatman
  6108. Example : /guilds list
  6109. */
  6110. void Commands::Command_GuildsList(Client* client)
  6111. {
  6112. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  6113. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  6114. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  6115. if (guilds->size() == 0)
  6116. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  6117. else {
  6118. while (itr.Next()) {
  6119. Guild* guild = itr.second;
  6120. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  6121. }
  6122. }
  6123. }
  6124. /*
  6125. Function: Command_GuildsRemove()
  6126. Purpose : Removes a player from a guild
  6127. Params : guild name|guild id, player name
  6128. Dev : Scatman
  6129. Example : /guilds remove 1 Admin = removes Admin from guild 1
  6130. */
  6131. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  6132. {
  6133. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6134. {
  6135. Guild* guild = 0;
  6136. bool found = true;
  6137. if (sep->IsNumber(0))
  6138. {
  6139. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6140. if (!guild)
  6141. {
  6142. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6143. found = false;
  6144. }
  6145. }
  6146. else
  6147. {
  6148. guild = guild_list.GetGuild(sep->arg[0]);
  6149. if (!guild)
  6150. {
  6151. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6152. found = false;
  6153. }
  6154. }
  6155. if (found)
  6156. {
  6157. Client* to_client = 0;
  6158. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6159. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6160. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6161. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6162. if (to_client)
  6163. {
  6164. Player* to_player = to_client->GetPlayer();
  6165. if (to_player->GetGuild())
  6166. {
  6167. if (to_player->GetGuild() == guild)
  6168. {
  6169. guild->KickGuildMember(client, to_player->GetName());
  6170. }
  6171. else
  6172. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  6173. }
  6174. else
  6175. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  6176. }
  6177. else
  6178. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6179. }
  6180. }
  6181. else
  6182. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  6183. }
  6184. /*
  6185. Function: Command_InspectPlayer()
  6186. Purpose : Handle the Inspect functions
  6187. Params : Client to inspect
  6188. Dev : Scatman
  6189. Example : /inspect Scatman
  6190. */
  6191. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  6192. {
  6193. if (sep && sep->arg[0])
  6194. {
  6195. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  6196. if (inspect_client)
  6197. client->InspectPlayer(inspect_client->GetPlayer());
  6198. }
  6199. else
  6200. {
  6201. Spawn* target = client->GetPlayer()->GetTarget();
  6202. if (target && target->IsPlayer())
  6203. client->InspectPlayer((Player*)target);
  6204. }
  6205. }
  6206. /*
  6207. Function: Command_Inventory()
  6208. Purpose : Handle changes in player inventory
  6209. Params : <TBD>
  6210. Dev : All
  6211. Example : /inventory delete item_id
  6212. */
  6213. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  6214. {
  6215. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  6216. Player* player = client->GetPlayer();
  6217. if(sep && sep->arg[0][0])
  6218. {
  6219. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  6220. if(client->GetPlayer()->GetHP() == 0)
  6221. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  6222. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6223. {
  6224. int16 index = atoi(sep->arg[1]);
  6225. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6226. if(item)
  6227. {
  6228. if(item->details.item_locked)
  6229. {
  6230. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item in use.");
  6231. return;
  6232. }
  6233. if(item->GetItemScript() && lua_interface)
  6234. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  6235. //reobtain item make sure it wasn't removed
  6236. item = player->item_list.GetItemFromIndex(index);
  6237. int32 bag_id = 0;
  6238. if(item){
  6239. bag_id = item->details.inv_slot_id;
  6240. database.DeleteItem(client->GetCharacterID(), item, 0);
  6241. }
  6242. client->GetPlayer()->item_list.DestroyItem(index);
  6243. client->GetPlayer()->UpdateInventory(bag_id);
  6244. }
  6245. }
  6246. 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))
  6247. {
  6248. int16 from_index = atoi(sep->arg[1]);
  6249. sint16 to_slot = atoi(sep->arg[2]);
  6250. sint32 bag_id = atol(sep->arg[3]);
  6251. int8 charges = atoi(sep->arg[4]);
  6252. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  6253. if(!item) {
  6254. client->SimpleMessage(CHANNEL_COLOR_RED, "You have no item.");
  6255. return;
  6256. }
  6257. if(item->details.item_locked)
  6258. {
  6259. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot move the item in use.");
  6260. return;
  6261. }
  6262. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  6263. {
  6264. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  6265. return;
  6266. }
  6267. sint32 old_inventory_id = 0;
  6268. if(item)
  6269. old_inventory_id = item->details.inv_slot_id;
  6270. //autobank
  6271. if (bag_id == -3 && to_slot == -1)
  6272. {
  6273. if (player->HasFreeBankSlot())
  6274. to_slot = player->FindFreeBankSlot();
  6275. else
  6276. {
  6277. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  6278. return;
  6279. }
  6280. }
  6281. //auto inventory
  6282. if (bag_id == 0 && to_slot == -1)
  6283. {
  6284. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6285. {
  6286. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  6287. return;
  6288. }
  6289. }
  6290. bool item_deleted = false;
  6291. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, &item_deleted, client->GetVersion());
  6292. client->QueuePacket(outapp);
  6293. if(item_deleted)
  6294. item = nullptr;
  6295. //removed from bag send update
  6296. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  6297. {
  6298. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  6299. if(outapp)
  6300. client->QueuePacket(outapp);
  6301. }
  6302. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  6303. {
  6304. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  6305. if(outapp)
  6306. client->QueuePacket(outapp);
  6307. }
  6308. }
  6309. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  6310. {
  6311. if(client->GetPlayer()->EngagedInCombat())
  6312. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  6313. else
  6314. {
  6315. int16 index = atoi(sep->arg[1]);
  6316. int8 slot_id = 255;
  6317. int8 unk3 = 0;
  6318. int8 appearance_equip = 0;
  6319. if(sep->arg[2][0] && sep->IsNumber(2))
  6320. slot_id = atoi(sep->arg[2]);
  6321. if(sep->arg[3][0] && sep->IsNumber(3))
  6322. unk3 = atoul(sep->arg[3]);
  6323. if(sep->arg[4][0] && sep->IsNumber(4))
  6324. appearance_equip = atoul(sep->arg[4]);
  6325. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  6326. EQ2Packet* outapp = 0;
  6327. for(int32 i=0;i<packets.size();i++)
  6328. {
  6329. outapp = packets[i];
  6330. if(outapp)
  6331. client->QueuePacket(outapp);
  6332. }
  6333. client->GetPlayer()->ChangePrimaryWeapon();
  6334. client->GetPlayer()->ChangeSecondaryWeapon();
  6335. client->GetPlayer()->ChangeRangedWeapon();
  6336. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6337. client->QueuePacket(characterSheetPackets);
  6338. }
  6339. }
  6340. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6341. {
  6342. if (client->GetPlayer()->EngagedInCombat())
  6343. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  6344. else {
  6345. int16 index = atoi(sep->arg[1]);
  6346. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6347. if (item) {
  6348. if(item->details.item_locked)
  6349. {
  6350. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot unpack the item in use.");
  6351. return;
  6352. }
  6353. // client->GetPlayer()->item_list.DestroyItem(index);
  6354. if (item->item_sets.size() > 0) {
  6355. for (int32 i = 0; i < item->item_sets.size(); i++) {
  6356. ItemSet* set = item->item_sets[i];
  6357. if (set->item_stack_size == 0)
  6358. set->item_stack_size += 1;
  6359. client->AddItem(set->item_id, set->item_stack_size);
  6360. }
  6361. }
  6362. }
  6363. client->RemoveItem(item, 1);
  6364. }
  6365. }
  6366. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  6367. {
  6368. if(client->GetPlayer()->EngagedInCombat())
  6369. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  6370. else
  6371. {
  6372. int16 index = atoi(sep->arg[1]);
  6373. sint32 bag_id = -999;
  6374. int8 to_slot = 255;
  6375. if(sep->arg[3][0])
  6376. {
  6377. if(sep->IsNumber(2))
  6378. bag_id = atol(sep->arg[2]);
  6379. if(sep->IsNumber(3))
  6380. to_slot = atoi(sep->arg[3]);
  6381. }
  6382. sint8 unk4 = 0;
  6383. int8 appearance_equip = 0;
  6384. if(sep->arg[4][0] && sep->IsNumber(4))
  6385. unk4 = atoi(sep->arg[4]);
  6386. if(sep->arg[5][0] && sep->IsNumber(5))
  6387. appearance_equip = atoul(sep->arg[5]);
  6388. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  6389. EQ2Packet* outapp = 0;
  6390. for(int32 i=0;i<packets.size();i++)
  6391. {
  6392. outapp = packets[i];
  6393. if(outapp)
  6394. client->QueuePacket(outapp);
  6395. }
  6396. client->GetPlayer()->ChangePrimaryWeapon();
  6397. client->GetPlayer()->ChangeSecondaryWeapon();
  6398. client->GetPlayer()->ChangeRangedWeapon();
  6399. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6400. client->QueuePacket(characterSheetPackets);
  6401. }
  6402. }
  6403. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6404. {
  6405. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  6406. int16 index1 = atoi(sep->arg[1]);
  6407. int16 index2 = atoi(sep->arg[2]);
  6408. int8 type = 0;
  6409. if(sep->IsNumber(3))
  6410. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  6411. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  6412. if(outapp)
  6413. client->QueuePacket(outapp);
  6414. else
  6415. {
  6416. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  6417. return;
  6418. }
  6419. }
  6420. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6421. {
  6422. sint16 to_slot = atoi(sep->arg[1]);
  6423. sint32 bag_id = atoi(sep->arg[2]);
  6424. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  6425. if (item) {
  6426. //auto inventory
  6427. if (bag_id == 0 && to_slot == -1)
  6428. {
  6429. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6430. {
  6431. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  6432. return;
  6433. }
  6434. // Set the slot for the item
  6435. item->details.inv_slot_id = bag_id;
  6436. item->details.slot_id = to_slot;
  6437. // Flag the item so it gets saved in its new location
  6438. item->save_needed = true;
  6439. // Add the item to its new location
  6440. if(player->item_list.AddItem(item)) {
  6441. // Remove the item from the overflow list
  6442. player->item_list.RemoveOverflowItem(item);
  6443. }
  6444. // Send the inventory update packet
  6445. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6446. return;
  6447. }
  6448. else if (bag_id == -3 && to_slot == -1) {
  6449. // Auto Bank
  6450. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  6451. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  6452. return;
  6453. }
  6454. item->details.inv_slot_id = bag_id;
  6455. item->details.slot_id = to_slot;
  6456. item->save_needed = true;
  6457. if(player->item_list.AddItem(item)) {
  6458. player->item_list.RemoveOverflowItem(item);
  6459. }
  6460. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6461. }
  6462. else if (bag_id == -4) {
  6463. // Shared Bank
  6464. if (!player->item_list.SharedBankAddAllowed(item)) {
  6465. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  6466. return;
  6467. }
  6468. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  6469. if (tmp_item) {
  6470. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6471. return;
  6472. }
  6473. else {
  6474. item->details.inv_slot_id = bag_id;
  6475. item->details.slot_id = to_slot;
  6476. item->save_needed = true;
  6477. if(player->item_list.AddItem(item)) {
  6478. player->item_list.RemoveOverflowItem(item);
  6479. }
  6480. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6481. return;
  6482. }
  6483. }
  6484. else {
  6485. // Try to get an item from the given bag id and slot id
  6486. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  6487. // Check to see if we got an item, if we do send an error,
  6488. // if we don't put the overflow item into this slot
  6489. if (tmp_item) {
  6490. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6491. }
  6492. else {
  6493. item->details.inv_slot_id = bag_id;
  6494. item->details.slot_id = to_slot;
  6495. item->save_needed = true;
  6496. if(player->item_list.AddItem(item)) {
  6497. player->item_list.RemoveOverflowItem(item);
  6498. }
  6499. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6500. return;
  6501. }
  6502. }
  6503. }
  6504. }
  6505. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6506. {
  6507. sint64 data = strtoull(sep->arg[1], NULL, 0);
  6508. int32 character_item_id = (int32) (data >> 32);
  6509. int32 item_id = (int32) (data & 0xffffffffL);
  6510. int8 sale_setting = atoi(sep->arg[2]);
  6511. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  6512. if(item)
  6513. {
  6514. item->no_sale = sale_setting;
  6515. item->save_needed = true;
  6516. client->SendSellMerchantList();
  6517. }
  6518. }
  6519. }
  6520. else
  6521. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  6522. }
  6523. /*
  6524. Function: Command_IRC()
  6525. Purpose : Handle the IRC functions
  6526. Params : IRC Commands
  6527. Dev : Scatman
  6528. Example : /irc say #Channel Hello World!
  6529. */
  6530. void Commands::Command_IRC(Client* client, Seperator* sep)
  6531. {
  6532. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  6533. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  6534. return;
  6535. }
  6536. if (sep && sep->arg[0][0]) {
  6537. if (strcasecmp(sep->arg[0], "say") == 0) {
  6538. if (sep->arg[1][0] && sep->arg[2][0]) {
  6539. if (sep->IsNumber(sep->arg[1]))
  6540. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  6541. else
  6542. irc.Say(client, sep->arg[1], sep->argplus[2]);
  6543. }
  6544. else
  6545. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  6546. }
  6547. else if (strcasecmp(sep->arg[0], "join") == 0) {
  6548. if (sep->arg[1][0])
  6549. irc.JoinChannel(client, sep->arg[1]);
  6550. else
  6551. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  6552. }
  6553. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  6554. if (sep->arg[1][0])
  6555. irc.LeaveChannel(client, sep->arg[1]);
  6556. else
  6557. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  6558. }
  6559. else if (strcasecmp(sep->arg[0], "list") == 0)
  6560. irc.ListChannels(client);
  6561. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  6562. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  6563. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  6564. else
  6565. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  6566. }
  6567. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  6568. irc.DisconnectFromServer(client);
  6569. else
  6570. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  6571. }
  6572. else
  6573. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  6574. }
  6575. /*
  6576. Function: Command_Languages()
  6577. Purpose : Show's languages the player knows
  6578. Params :
  6579. Dev : Zcoretri
  6580. Example :
  6581. */
  6582. void Commands::Command_Languages(Client* client, Seperator* sep)
  6583. {
  6584. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6585. list<Language*>::iterator itr;
  6586. Language* language;
  6587. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6588. for(itr = languages->begin(); itr != languages->end(); itr++)
  6589. {
  6590. language = *itr;
  6591. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6592. }
  6593. }
  6594. /*
  6595. Function: Command_SetLanguage()
  6596. Purpose : Handles language commands
  6597. Params : Language ID
  6598. Dev : Zcoretri
  6599. Example :
  6600. */
  6601. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6602. {
  6603. Player* player = client->GetPlayer();
  6604. if (sep && sep->arg[0])
  6605. {
  6606. if(!sep->IsNumber(0))
  6607. {
  6608. //String passed in
  6609. const char* value = sep->arg[0];
  6610. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6611. {
  6612. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6613. client->SendLanguagesUpdate(0);
  6614. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6615. }
  6616. else
  6617. {
  6618. if(player->HasLanguage(value))
  6619. {
  6620. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6621. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6622. client->SendLanguagesUpdate(language->GetID());
  6623. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6624. }
  6625. else
  6626. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6627. }
  6628. }
  6629. else
  6630. {
  6631. //Number passed in
  6632. int32 id = atoul(sep->arg[0]);
  6633. if(player->HasLanguage(id))
  6634. {
  6635. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6636. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6637. client->SendLanguagesUpdate(id);
  6638. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6639. }
  6640. else
  6641. {
  6642. Language* language = master_languages_list.GetLanguage(id);
  6643. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6644. }
  6645. }
  6646. }
  6647. else
  6648. {
  6649. //No value was passed in
  6650. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6651. if(id > 0)
  6652. {
  6653. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6654. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6655. }
  6656. else
  6657. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6658. }
  6659. }
  6660. /*
  6661. Function: Command_LastName()
  6662. Purpose : Sets player surname
  6663. Params : Name text
  6664. Dev : theFoof
  6665. Example :
  6666. */
  6667. void Commands::Command_LastName(Client* client, Seperator* sep)
  6668. {
  6669. if (!client)
  6670. return;
  6671. if (sep && sep->arg[0])
  6672. {
  6673. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6674. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6675. return;
  6676. }
  6677. client->RemovePendingLastName();
  6678. uchar* checkname = (uchar*)sep->arg[0];
  6679. bool valid_name = true;
  6680. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6681. if (!alpha_check(checkname[i])) {
  6682. valid_name = false;
  6683. break;
  6684. }
  6685. }
  6686. if (!valid_name) {
  6687. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6688. return;
  6689. }
  6690. string last_name = (string)sep->arg[0];
  6691. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6692. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6693. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6694. client->SetPendingLastName(last_name);
  6695. client->SendLastNameConfirmation();
  6696. }
  6697. else
  6698. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6699. }
  6700. }
  6701. /*
  6702. Function: Command_ConfirmLastName()
  6703. Purpose : Confirms setting of player surname
  6704. Params : Name text
  6705. Dev : theFoof
  6706. Example :
  6707. */
  6708. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6709. {
  6710. if (!client)
  6711. return;
  6712. string* name = client->GetPendingLastName();
  6713. if (name){
  6714. Player* player = client->GetPlayer();
  6715. player->SetLastName(name->c_str(), false);
  6716. client->SendTitleUpdate();
  6717. player->SetCharSheetChanged(true);
  6718. client->RemovePendingLastName();
  6719. }
  6720. }
  6721. /*
  6722. Function: Command_Location()
  6723. Purpose : Display's Help for /location commands
  6724. Params :
  6725. Dev : Scatman
  6726. Example : /location = show's help for command
  6727. */
  6728. void Commands::Command_Location(Client* client)
  6729. {
  6730. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6731. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6732. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6733. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6734. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6735. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6736. }
  6737. /*
  6738. Function: Command_LocationAdd()
  6739. Purpose : Add's a location to an existing location config
  6740. Params : location_id
  6741. Dev : Scatman
  6742. Example : /location add {location_id}
  6743. */
  6744. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6745. {
  6746. if (sep && sep->arg[0] && sep->IsNumber(0))
  6747. {
  6748. int32 location_id = atoul(sep->arg[0]);
  6749. float x = client->GetPlayer()->GetX();
  6750. float y = client->GetPlayer()->GetY();
  6751. float z = client->GetPlayer()->GetZ();
  6752. if (database.AddLocationPoint(location_id, x, y, z))
  6753. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6754. else
  6755. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6756. }
  6757. else
  6758. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6759. }
  6760. /*
  6761. Function: Command_LocationCreate()
  6762. Purpose : Creates a new location config
  6763. Params : location name, 0/1 for include_y (optional)
  6764. Dev : Scatman
  6765. Example : /location create Test 1 = creates a new location named Test with include_y True
  6766. */
  6767. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6768. {
  6769. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6770. {
  6771. const char* name = sep->arg[0];
  6772. bool include_y = false;
  6773. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6774. include_y = true;
  6775. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  6776. if (location_id > 0)
  6777. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6778. else
  6779. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6780. }
  6781. else
  6782. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6783. }
  6784. /*
  6785. Function: Command_LocationDelete()
  6786. Purpose : Delete's a location config and all it's location points
  6787. Params : location_id
  6788. Dev : Scatman
  6789. Example : /location delete {location_id}
  6790. */
  6791. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6792. {
  6793. if (sep && sep->arg[0] && sep->IsNumber(0))
  6794. {
  6795. int32 location_id = atoul(sep->arg[0]);
  6796. if (database.DeleteLocation(location_id))
  6797. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6798. else
  6799. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6800. }
  6801. else
  6802. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6803. }
  6804. /*
  6805. Function: Command_LocationList()
  6806. Purpose : Display's a list of location points
  6807. Params : location_id
  6808. Dev : Scatman
  6809. Example : /location list {location_id}
  6810. */
  6811. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6812. {
  6813. if (sep && sep->arg[0])
  6814. {
  6815. const char* option = sep->arg[0];
  6816. if (strncmp(option, "locations", strlen(option)) == 0)
  6817. database.ListLocations(client);
  6818. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  6819. {
  6820. int32 location_id = atoul(sep->arg[1]);
  6821. database.ListLocationPoints(client, location_id);
  6822. }
  6823. else
  6824. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6825. }
  6826. else
  6827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6828. }
  6829. /*
  6830. Function: Command_LocationRemove()
  6831. Purpose : Removes a single location point from a location config
  6832. Params : location_point_id (gotten from /location list {id})
  6833. Dev : Scatman
  6834. Example : /location remove 1 = will remove location_point_id 1
  6835. */
  6836. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  6837. {
  6838. if (sep && sep->arg[0] && sep->IsNumber(0))
  6839. {
  6840. int32 location_point_id = atoul(sep->arg[0]);
  6841. if (database.DeleteLocationPoint(location_point_id))
  6842. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  6843. else
  6844. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  6845. }
  6846. else
  6847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  6848. }
  6849. /*
  6850. Function: Command_Merchant()
  6851. Purpose : Handles Merchant commands
  6852. Params : list
  6853. Dev : Scatman
  6854. Example : /merchant list
  6855. */
  6856. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  6857. {
  6858. if( handler == COMMAND_MERCHANT )
  6859. {
  6860. // /merchant command by itself shows help (to be extended)
  6861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6862. return;
  6863. }
  6864. else if( handler == COMMAND_MERCHANT_LIST )
  6865. {
  6866. // /merchant list command expects "description" param
  6867. if (sep && sep->arg[0])
  6868. {
  6869. const char* merchant_description = sep->argplus[0];
  6870. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  6871. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  6872. map<int32, MerchantInfo*>::iterator itr;
  6873. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  6874. {
  6875. string description = database.GetMerchantDescription(itr->first);
  6876. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  6877. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  6878. }
  6879. }
  6880. else // no description
  6881. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6882. }
  6883. }
  6884. /*
  6885. Function: Command_Modify()
  6886. Purpose : to replace our other "set" commands
  6887. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  6888. Dev : John Adams
  6889. Example : /modify spell set name "Aegolism III"
  6890. */
  6891. void Commands::Command_Modify(Client* client)
  6892. {
  6893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  6894. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  6895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  6896. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  6897. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  6898. }
  6899. /*
  6900. Function: Command_ModifySpawn()
  6901. Purpose : replace "spawn set" commands
  6902. Params : Action : the action to perform (or special handler)
  6903. : Field : the DB field to change
  6904. : Value : what to set the value to
  6905. : Target : what object to change (my target, or spawn_id)
  6906. Dev : John Adams
  6907. Example : /modify spawn set name "Lady Vox"
  6908. :
  6909. Note : Special Handlers, like "zoneto" for Signs
  6910. : /modify spawn zoneto
  6911. : Will set a sign's zone x/y/z to my current coords
  6912. */
  6913. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  6914. {
  6915. PrintSep(sep, "COMMAND_MODIFY");
  6916. // need at least 2 args for a valid command
  6917. if( sep && sep->arg[1] )
  6918. {
  6919. // JA: just a quick implementation because I need it :)
  6920. if (strcmp(sep->arg[0], "zoneto") == 0)
  6921. {
  6922. if( sep->IsNumber(1) )
  6923. {
  6924. int32 spawn_id = atoul(sep->arg[1]);
  6925. float x_coord = client->GetPlayer()->GetX();
  6926. float y_coord = client->GetPlayer()->GetY();
  6927. float z_coord = client->GetPlayer()->GetZ();
  6928. float h_coord = client->GetPlayer()->GetHeading();
  6929. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  6930. }
  6931. else
  6932. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  6933. }
  6934. }
  6935. else
  6936. Command_Modify(client);
  6937. }
  6938. /*
  6939. Function: Command_ModifyCharacter()
  6940. Purpose : to replace our other "set" commands
  6941. Params : Action : Add, Remove
  6942. : Field : copper, silver, gold, plat
  6943. : Value : min 1, max unlimited
  6944. : Target : Self, Player
  6945. Dev : Cynnar
  6946. Example : /modify character add gold 50
  6947. : /modify character remove silver 25
  6948. */
  6949. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  6950. {
  6951. PrintSep(sep, "COMMAND_MODIFY");
  6952. int64 value = 0;
  6953. Player* player = client->GetPlayer();
  6954. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  6955. player = (Player*)player->GetTarget();
  6956. // need at least 2 args for a valid command
  6957. if( sep && sep->arg[1] )
  6958. {
  6959. if (strcmp(sep->arg[0], "add") == 0)
  6960. {
  6961. if (strcmp(sep->arg[1], "copper") == 0)
  6962. {
  6963. value = atoi64(sep->arg[2]);
  6964. player->AddCoins(value);
  6965. if (client->GetPlayer() == player)
  6966. {
  6967. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  6968. }
  6969. else {
  6970. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  6971. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  6972. }
  6973. }
  6974. else if (strcmp(sep->arg[1], "silver") == 0)
  6975. {
  6976. value = atoi64(sep->arg[2]) * 100;
  6977. player->AddCoins(value);
  6978. if (client->GetPlayer() == player)
  6979. {
  6980. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  6981. }
  6982. else {
  6983. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  6984. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  6985. }
  6986. }
  6987. else if (strcmp(sep->arg[1], "gold") == 0)
  6988. {
  6989. value = atoi64(sep->arg[2]) * 10000;
  6990. player->AddCoins(value);
  6991. if (client->GetPlayer() == player)
  6992. {
  6993. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  6994. }
  6995. else {
  6996. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6997. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6998. }
  6999. }
  7000. else if (strcmp(sep->arg[1], "plat") == 0)
  7001. {
  7002. value = atoi64(sep->arg[2]) * 1000000;
  7003. player->AddCoins(value);
  7004. if (client->GetPlayer() == player)
  7005. {
  7006. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  7007. }
  7008. else {
  7009. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7010. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7011. }
  7012. }
  7013. else
  7014. {
  7015. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7016. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7017. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7018. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  7019. }
  7020. }
  7021. else if (strcmp(sep->arg[0], "remove") == 0)
  7022. {
  7023. if (strcmp(sep->arg[1], "copper") == 0)
  7024. {
  7025. value = atoi64(sep->arg[2]);
  7026. player->RemoveCoins(value);
  7027. if (client->GetPlayer() == player)
  7028. {
  7029. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  7030. }
  7031. else {
  7032. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  7033. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7034. }
  7035. }
  7036. else if (strcmp(sep->arg[1], "silver") == 0)
  7037. {
  7038. value = atoi64(sep->arg[2]) * 100;
  7039. player->RemoveCoins(value);
  7040. if (client->GetPlayer() == player)
  7041. {
  7042. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  7043. }
  7044. else {
  7045. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  7046. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7047. }
  7048. }
  7049. else if (strcmp(sep->arg[1], "gold") == 0)
  7050. {
  7051. value = atoi64(sep->arg[2]) * 10000;
  7052. player->RemoveCoins(value);
  7053. if (client->GetPlayer() == player)
  7054. {
  7055. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  7056. }
  7057. else {
  7058. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  7059. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7060. }
  7061. }
  7062. else if (strcmp(sep->arg[1], "plat") == 0)
  7063. {
  7064. value = atoi64(sep->arg[2]) * 1000000;
  7065. player->RemoveCoins(value);
  7066. if (client->GetPlayer() == player)
  7067. {
  7068. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  7069. }
  7070. else {
  7071. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  7072. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7073. }
  7074. }
  7075. else
  7076. {
  7077. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7078. }
  7079. }
  7080. else if (strcmp(sep->arg[0], "set") == 0) {
  7081. if (strcmp(sep->arg[1], "tslevel") == 0) {
  7082. int8 level = atoi(sep->arg[2]);
  7083. if (level > 0 && level < 256) {
  7084. if (player) {
  7085. if (client->GetPlayer() == player)
  7086. client->ChangeTSLevel(player->GetTSLevel(), level);
  7087. else
  7088. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  7089. }
  7090. }
  7091. else
  7092. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  7093. }
  7094. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  7095. int8 tsclass = atoi(sep->arg[2]);
  7096. player->SetTradeskillClass(tsclass);
  7097. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  7098. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  7099. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  7100. player->SetCharSheetChanged(true);
  7101. }
  7102. }
  7103. }
  7104. else
  7105. {
  7106. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7107. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7108. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7109. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7110. }
  7111. }
  7112. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  7113. {
  7114. PrintSep(sep, "COMMAND_MODIFY");
  7115. // need at least 2 args for a valid command
  7116. if( sep && sep->arg[1] )
  7117. {
  7118. }
  7119. else
  7120. Command_Modify(client);
  7121. }
  7122. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  7123. {
  7124. PrintSep(sep, "COMMAND_MODIFY");
  7125. // need at least 2 args for a valid command
  7126. if( sep && sep->arg[1] )
  7127. {
  7128. }
  7129. else
  7130. Command_Modify(client);
  7131. }
  7132. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  7133. {
  7134. PrintSep(sep, "COMMAND_MODIFY");
  7135. // need at least 2 args for a valid command
  7136. if( sep && sep->arg[1] )
  7137. {
  7138. }
  7139. else
  7140. Command_Modify(client);
  7141. }
  7142. /*
  7143. Function: Command_ModifyQuest()
  7144. Purpose : to list players quest and completed quests
  7145. Params : Action : list, completed
  7146. : Target : Self, Player
  7147. Dev : Cynnar
  7148. Example : /modify quest list
  7149. : /modify quest completed
  7150. */
  7151. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  7152. {
  7153. PrintSep(sep, "COMMAND_MODIFY");
  7154. int64 value = 0;
  7155. Player* player = client->GetPlayer();
  7156. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7157. player = (Player*)player->GetTarget();
  7158. // need at least 2 args for a valid command
  7159. if (sep && sep->arg[1])
  7160. {
  7161. if (strcmp(sep->arg[0], "list") == 0)
  7162. {
  7163. map<int32, Quest*>* quests = player->GetPlayerQuests();
  7164. map<int32, Quest*>::iterator itr;
  7165. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  7166. if (quests->size() == 0)
  7167. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  7168. else
  7169. {
  7170. for (itr = quests->begin(); itr != quests->end(); itr++)
  7171. {
  7172. Quest* quest = itr->second;
  7173. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7174. }
  7175. }
  7176. }
  7177. else if (strcmp(sep->arg[0], "completed") == 0)
  7178. {
  7179. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  7180. map<int32, Quest*>::iterator itr;
  7181. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  7182. if (quests->size() == 0)
  7183. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  7184. else
  7185. {
  7186. for (itr = quests->begin(); itr != quests->end(); itr++)
  7187. {
  7188. Quest* quest = itr->second;
  7189. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7190. }
  7191. }
  7192. }
  7193. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  7194. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  7195. else if (strcmp(sep->arg[0], "remove") == 0)
  7196. {
  7197. int32 quest_id = 0;
  7198. if (sep && sep->arg[1] && sep->IsNumber(1))
  7199. quest_id = atoul(sep->arg[1]);
  7200. if (quest_id > 0)
  7201. {
  7202. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  7203. {
  7204. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7205. if (quest)
  7206. if (client->GetPlayer() == player)
  7207. {
  7208. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  7209. }
  7210. else
  7211. {
  7212. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  7213. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  7214. }
  7215. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  7216. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  7217. }
  7218. client->RemovePlayerQuest(quest_id);
  7219. client->GetCurrentZone()->SendQuestUpdates(client);
  7220. }
  7221. }
  7222. else if (strcmp(sep->arg[0], "advance") == 0)
  7223. {
  7224. int32 quest_id = 0;
  7225. int32 step = 0;
  7226. if (sep && sep->arg[1] && sep->IsNumber(1))
  7227. {
  7228. quest_id = atoul(sep->arg[1]);
  7229. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7230. if (sep && sep->arg[2] && sep->IsNumber(1))
  7231. {
  7232. step = atoul(sep->arg[2]);
  7233. if (quest_id > 0 && step > 0)
  7234. {
  7235. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  7236. {
  7237. if (client)
  7238. {
  7239. client->AddPendingQuestUpdate(quest_id, step);
  7240. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  7241. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  7242. }
  7243. }
  7244. }
  7245. else
  7246. {
  7247. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  7248. }
  7249. }
  7250. else
  7251. {
  7252. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  7253. }
  7254. }
  7255. else
  7256. {
  7257. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  7258. }
  7259. }
  7260. else
  7261. {
  7262. Command_Modify(client);
  7263. }
  7264. }
  7265. else
  7266. {
  7267. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  7268. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  7269. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  7270. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  7271. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  7272. }
  7273. }
  7274. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  7275. {
  7276. PrintSep(sep, "COMMAND_MODIFY");
  7277. // need at least 2 args for a valid command
  7278. if( sep && sep->arg[1] )
  7279. {
  7280. if (strcmp(sep->arg[0], "add") == 0) {
  7281. const char* skill_name = sep->argplus[1];
  7282. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7283. if (skill) {
  7284. Player* player = 0;
  7285. Client* to_client = 0;
  7286. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7287. player = (Player*)client->GetPlayer()->GetTarget();
  7288. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7289. }
  7290. else {
  7291. player = client->GetPlayer();
  7292. to_client = client;
  7293. }
  7294. if (player)
  7295. {
  7296. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7297. {
  7298. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7299. if (to_client == client) {
  7300. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  7301. }
  7302. else {
  7303. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7304. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7305. }
  7306. }
  7307. else
  7308. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  7309. }
  7310. }
  7311. else
  7312. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7313. }
  7314. else if (strcmp(sep->arg[0], "remove") == 0) {
  7315. const char* skill_name = sep->argplus[1];
  7316. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7317. if (skill) {
  7318. Player* player = 0;
  7319. Client* to_client = 0;
  7320. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7321. player = (Player*)client->GetPlayer()->GetTarget();
  7322. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7323. }
  7324. else {
  7325. player = client->GetPlayer();
  7326. to_client = client;
  7327. }
  7328. if (player)
  7329. {
  7330. if (player->GetSkills()->HasSkill(skill->skill_id))
  7331. {
  7332. player->RemoveSkillFromDB(skill, true);
  7333. if (client == to_client) {
  7334. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  7335. }
  7336. else {
  7337. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7338. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7339. }
  7340. }
  7341. else {
  7342. if (client == to_client)
  7343. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  7344. else
  7345. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7346. }
  7347. }
  7348. }
  7349. else
  7350. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7351. }
  7352. else if (strcmp(sep->arg[0], "set") == 0) {
  7353. if (!sep->IsNumber(2)) {
  7354. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  7355. return;
  7356. }
  7357. const char* skill_name = sep->arg[1];
  7358. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7359. if (skill) {
  7360. int16 val = atoi(sep->arg[2]);
  7361. Player* player = 0;
  7362. Client* to_client = 0;
  7363. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7364. player = (Player*)client->GetPlayer()->GetTarget();
  7365. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7366. }
  7367. else {
  7368. player = client->GetPlayer();
  7369. to_client = client;
  7370. }
  7371. if (player)
  7372. {
  7373. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  7374. player->GetSkills()->SetSkill(skill->skill_id, val);
  7375. if (client != to_client)
  7376. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  7377. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  7378. }
  7379. else {
  7380. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  7381. }
  7382. }
  7383. }
  7384. else {
  7385. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7386. }
  7387. }
  7388. else {
  7389. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7390. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7391. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7392. }
  7393. }
  7394. else {
  7395. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7396. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7397. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7398. }
  7399. }
  7400. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  7401. {
  7402. PrintSep(sep, "COMMAND_MODIFY");
  7403. // need at least 2 args for a valid command
  7404. if( sep && sep->arg[1] )
  7405. {
  7406. }
  7407. else
  7408. Command_Modify(client);
  7409. }
  7410. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  7411. {
  7412. PrintSep(sep, "COMMAND_MODIFY");
  7413. // need at least 2 args for a valid command
  7414. if( sep && sep->arg[1] )
  7415. {
  7416. }
  7417. else
  7418. Command_Modify(client);
  7419. }
  7420. /*
  7421. Function: Command_MOTD()
  7422. Purpose : Displays server MOTD
  7423. Params :
  7424. Dev : LethalEncounter
  7425. Example : /motd
  7426. */
  7427. void Commands::Command_MOTD(Client* client)
  7428. {
  7429. if (client)
  7430. ClientPacketFunctions::SendMOTD(client);
  7431. }
  7432. /*
  7433. Function: Command_Pet()
  7434. Purpose : Handle Pet {Command} commands
  7435. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  7436. Dev :
  7437. Example : /pet preserve_master
  7438. */
  7439. void Commands::Command_Pet(Client* client, Seperator* sep)
  7440. {
  7441. PrintSep(sep, "COMMAND_PET");
  7442. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  7443. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7444. if (!sep || !sep->arg[0])
  7445. return; // should have sep->arg[0] filled
  7446. if (strcmp(sep->arg[0], "hide") == 0) {
  7447. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  7448. Entity* pet = client->GetPlayer()->GetDeityPet();
  7449. if (pet) {
  7450. if (pet->IsPrivateSpawn())
  7451. client->GetPlayer()->HideDeityPet(false);
  7452. else
  7453. client->GetPlayer()->HideDeityPet(true);
  7454. }
  7455. pet = client->GetPlayer()->GetCosmeticPet();
  7456. if (pet) {
  7457. if (pet->IsPrivateSpawn())
  7458. client->GetPlayer()->HideCosmeticPet(false);
  7459. else
  7460. client->GetPlayer()->HideCosmeticPet(true);
  7461. }
  7462. return;
  7463. }
  7464. // below is for all combat pets
  7465. if (!client->GetPlayer()->HasPet()) {
  7466. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  7467. return;
  7468. }
  7469. if (strcmp(sep->arg[0], "stay") == 0) {
  7470. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  7471. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  7472. client->GetPlayer()->SetCharSheetChanged(true);
  7473. if (client->GetPlayer()->GetPet())
  7474. client->GetPlayer()->GetPet()->following = false;
  7475. if (client->GetPlayer()->GetCharmedPet())
  7476. client->GetPlayer()->GetCharmedPet()->following = false;
  7477. }
  7478. else if (strcmp(sep->arg[0], "follow") == 0) {
  7479. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  7480. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  7481. client->GetPlayer()->SetCharSheetChanged(true);
  7482. }
  7483. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  7484. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  7485. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  7486. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  7487. }
  7488. else {
  7489. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  7490. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  7491. }
  7492. client->GetPlayer()->SetCharSheetChanged(true);
  7493. }
  7494. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  7495. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  7496. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  7497. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  7498. }
  7499. else {
  7500. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  7501. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  7502. }
  7503. client->GetPlayer()->SetCharSheetChanged(true);
  7504. }
  7505. else if (strcmp(sep->arg[0], "backoff") == 0) {
  7506. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  7507. if (client->GetPlayer()->GetPet())
  7508. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  7509. if (client->GetPlayer()->GetCharmedPet())
  7510. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  7511. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  7512. client->GetPlayer()->SetCharSheetChanged(true);
  7513. }
  7514. else if (strcmp(sep->arg[0], "attack") == 0) {
  7515. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  7516. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  7517. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  7518. if (client->GetPlayer()->GetPet())
  7519. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7520. if (client->GetPlayer()->GetCharmedPet())
  7521. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7522. }
  7523. else
  7524. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  7525. }
  7526. else
  7527. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  7528. }
  7529. else if (strcmp(sep->arg[0], "getlost") == 0) {
  7530. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  7531. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  7532. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  7533. }
  7534. else
  7535. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  7536. }
  7537. /*
  7538. Function: Command_PetName()
  7539. Purpose : Pet your name (???)
  7540. Params :
  7541. Dev :
  7542. Example :
  7543. */
  7544. void Commands::Command_PetName(Client* client, Seperator* sep)
  7545. {
  7546. PrintSep(sep, "COMMAND_PETNAME");
  7547. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  7548. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7549. }
  7550. /*
  7551. Function: Command_NamePet()
  7552. Purpose : Name your pet
  7553. Params :
  7554. Dev :
  7555. Example :
  7556. */
  7557. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7558. {
  7559. PrintSep(sep, "COMMAND_NAME_PET");
  7560. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7561. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7562. }
  7563. /*
  7564. Function: Command_Rename()
  7565. Purpose : Renames existing pet
  7566. Params :
  7567. Dev :
  7568. Example :
  7569. */
  7570. void Commands::Command_Rename(Client* client, Seperator* sep)
  7571. {
  7572. PrintSep(sep, "COMMAND_RENAME");
  7573. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7574. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7575. }
  7576. /*
  7577. Function: Command_ConfirmRename()
  7578. Purpose : Confirms renaming your pet
  7579. Params :
  7580. Dev :
  7581. Example :
  7582. */
  7583. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7584. {
  7585. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7586. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7587. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7588. }
  7589. /*
  7590. Function: Command_PetOptions()
  7591. Purpose : Sets various pet options
  7592. Params :
  7593. Dev :
  7594. Example :
  7595. */
  7596. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7597. {
  7598. PrintSep(sep, "COMMAND_PETOPTIONS");
  7599. Player* player = client->GetPlayer();
  7600. Spawn* target = player->GetTarget();
  7601. if (!target)
  7602. return;
  7603. if (target == player->GetPet())
  7604. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7605. else if (target == player->GetCharmedPet())
  7606. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7607. else if (target == player->GetCosmeticPet())
  7608. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7609. else if (target == player->GetDeityPet())
  7610. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7611. }
  7612. /*
  7613. Function: Command_Random()
  7614. Purpose : Handles /random dice roll in-game
  7615. Params : 1-100
  7616. Dev : Scatman
  7617. Example : /randon 1 100
  7618. */
  7619. void Commands::Command_Random(Client* client, Seperator* sep)
  7620. {
  7621. char message[256] = {0};
  7622. if (sep)
  7623. {
  7624. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7625. 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])));
  7626. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7627. 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])));
  7628. else
  7629. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7630. }
  7631. else
  7632. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7633. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7634. }
  7635. /*
  7636. Function: Command_Randomize()
  7637. Purpose : Sets randomize (appearance) values for NPCs
  7638. Params : Attrib Name
  7639. Dev : Scatman
  7640. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7641. */
  7642. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7643. {
  7644. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7645. if (target)
  7646. {
  7647. if (target->IsNPC())
  7648. {
  7649. if (sep && sep->arg[0] && !sep->IsNumber(0))
  7650. {
  7651. const char* value = sep->arg[0];
  7652. if (strncasecmp(value, "show", strlen(value)) == 0)
  7653. {
  7654. client->DisplayRandomizeFeatures(target->GetRandomize());
  7655. }
  7656. else
  7657. {
  7658. if (sep->arg[1] && sep->IsNumber(1))
  7659. {
  7660. int8 option = atoi(sep->arg[1]);
  7661. if (option == 0 || option == 1)
  7662. {
  7663. int32 feature = 0;
  7664. char feature_text[32] = {0};
  7665. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7666. feature = RANDOMIZE_GENDER;
  7667. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7668. }
  7669. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7670. feature = RANDOMIZE_RACE;
  7671. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7672. }
  7673. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7674. feature = RANDOMIZE_MODEL_TYPE;
  7675. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7676. }
  7677. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7678. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7679. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7680. }
  7681. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7682. feature = RANDOMIZE_HAIR_TYPE;
  7683. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7684. }
  7685. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7686. feature = RANDOMIZE_WING_TYPE;
  7687. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7688. }
  7689. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7690. feature = RANDOMIZE_CHEEK_TYPE;
  7691. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7692. }
  7693. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7694. feature = RANDOMIZE_CHIN_TYPE;
  7695. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7696. }
  7697. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7698. feature = RANDOMIZE_EAR_TYPE;
  7699. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7700. }
  7701. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7702. feature = RANDOMIZE_EYE_BROW_TYPE;
  7703. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7704. }
  7705. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7706. feature = RANDOMIZE_EYE_TYPE;
  7707. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7708. }
  7709. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7710. feature = RANDOMIZE_LIP_TYPE;
  7711. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7712. }
  7713. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7714. feature = RANDOMIZE_NOSE_TYPE;
  7715. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7716. }
  7717. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7718. feature = RANDOMIZE_EYE_COLOR;
  7719. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7720. }
  7721. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7722. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7723. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7724. }
  7725. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7726. feature = RANDOMIZE_HAIR_COLOR1;
  7727. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7728. }
  7729. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7730. feature = RANDOMIZE_HAIR_COLOR2;
  7731. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7732. }
  7733. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7734. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7735. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7736. }
  7737. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7738. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7739. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7740. }
  7741. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7742. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7743. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7744. }
  7745. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7746. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7747. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7748. }
  7749. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7750. feature = RANDOMIZE_SKIN_COLOR;
  7751. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7752. }
  7753. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7754. feature = RANDOMIZE_WING_COLOR1;
  7755. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7756. }
  7757. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7758. feature = RANDOMIZE_WING_COLOR2;
  7759. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7760. }
  7761. else {
  7762. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7763. 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'.");
  7764. }
  7765. if (feature > 0) {
  7766. if (option == 1) {
  7767. if (target->GetRandomize() & feature)
  7768. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  7769. else {
  7770. target->AddRandomize(feature);
  7771. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  7772. database.UpdateRandomize(target->GetDatabaseID(), feature);
  7773. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  7774. }
  7775. }
  7776. else {
  7777. if (target->GetRandomize() & feature) {
  7778. target->AddRandomize(-feature);
  7779. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  7780. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  7781. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  7782. }
  7783. else
  7784. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  7785. }
  7786. }
  7787. }
  7788. else
  7789. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7790. }
  7791. else
  7792. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7793. }
  7794. }
  7795. else {
  7796. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  7797. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  7798. 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'.");
  7799. }
  7800. }
  7801. else
  7802. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  7803. }
  7804. else
  7805. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  7806. }
  7807. /*
  7808. Function: Command_ShowCloak()
  7809. Purpose : Character Settings combo box for Show Cloak
  7810. Params : true/false
  7811. Dev : John Adams
  7812. Example :
  7813. */
  7814. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  7815. {
  7816. Player* player = client->GetPlayer();
  7817. if (sep && sep->arg[0])
  7818. {
  7819. const char* value = sep->arg[0];
  7820. if (strncasecmp(value, "true", strlen(value)) == 0)
  7821. {
  7822. player->set_character_flag(CF_SHOW_CLOAK);
  7823. player->reset_character_flag(CF2_SHOW_RANGED);
  7824. }
  7825. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7826. player->reset_character_flag(CF_SHOW_CLOAK);
  7827. else
  7828. {
  7829. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7830. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7831. }
  7832. }
  7833. }
  7834. /*
  7835. Function: Command_ShowHelm()
  7836. Purpose : Character Settings combo box for Show Helm
  7837. Params : true/false
  7838. Dev : John Adams
  7839. Example :
  7840. */
  7841. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  7842. {
  7843. Player* player = client->GetPlayer();
  7844. if (sep && sep->arg[0])
  7845. {
  7846. const char* value = sep->arg[0];
  7847. if (strncasecmp(value, "true", strlen(value)) == 0)
  7848. {
  7849. player->reset_character_flag(CF_HIDE_HELM);
  7850. player->set_character_flag(CF_HIDE_HOOD);
  7851. }
  7852. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7853. player->set_character_flag(CF_HIDE_HELM);
  7854. else
  7855. {
  7856. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7857. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7858. }
  7859. }
  7860. }
  7861. /*
  7862. Function: Command_ShowHood()
  7863. Purpose : Character Settings combo box for Show Hood
  7864. Params : true/false
  7865. Dev : John Adams
  7866. Example :
  7867. */
  7868. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  7869. {
  7870. Player* player = client->GetPlayer();
  7871. if (sep && sep->arg[0])
  7872. {
  7873. const char* value = sep->arg[0];
  7874. if (strncasecmp(value, "true", strlen(value)) == 0)
  7875. {
  7876. player->reset_character_flag(CF_HIDE_HOOD);
  7877. player->set_character_flag(CF_HIDE_HELM);
  7878. }
  7879. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7880. player->set_character_flag(CF_HIDE_HOOD);
  7881. else
  7882. {
  7883. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7884. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7885. }
  7886. }
  7887. }
  7888. /*
  7889. Function: Command_ShowHoodHelm()
  7890. Purpose : Character Settings combo box for Show Helm or Hood
  7891. Params : true/false
  7892. Dev : John Adams
  7893. Example :
  7894. */
  7895. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  7896. {
  7897. Player* player = client->GetPlayer();
  7898. if (sep && sep->arg[0])
  7899. {
  7900. const char* value = sep->arg[0];
  7901. if (strncasecmp(value, "true", strlen(value)) == 0)
  7902. {
  7903. player->reset_character_flag(CF_HIDE_HOOD);
  7904. player->reset_character_flag(CF_HIDE_HELM);
  7905. }
  7906. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7907. {
  7908. // don't think we ever wind up in here...
  7909. player->set_character_flag(CF_HIDE_HOOD);
  7910. player->set_character_flag(CF_HIDE_HELM);
  7911. }
  7912. else
  7913. {
  7914. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7915. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7916. }
  7917. }
  7918. }
  7919. /*
  7920. Function: Command_ShowRanged()
  7921. Purpose : Character Settings combo box for Show Ranged weapon
  7922. Params : true/false
  7923. Dev : John Adams
  7924. Example :
  7925. */
  7926. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  7927. {
  7928. Player* player = client->GetPlayer();
  7929. if (sep && sep->arg[0])
  7930. {
  7931. const char* value = sep->arg[0];
  7932. if (strncasecmp(value, "true", strlen(value)) == 0)
  7933. {
  7934. player->set_character_flag(CF2_SHOW_RANGED);
  7935. player->reset_character_flag(CF_SHOW_CLOAK);
  7936. }
  7937. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7938. player->reset_character_flag(CF2_SHOW_RANGED);
  7939. else
  7940. {
  7941. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7942. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7943. }
  7944. }
  7945. }
  7946. /*
  7947. Function:
  7948. Purpose :
  7949. Params :
  7950. Dev :
  7951. Example :
  7952. */
  7953. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  7954. {
  7955. Player* player = 0;
  7956. Client* to_client = 0;
  7957. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  7958. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  7959. switch(handler)
  7960. {
  7961. case COMMAND_SKILL:
  7962. {
  7963. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  7964. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  7965. break;
  7966. }
  7967. case COMMAND_SKILL_ADD:
  7968. {
  7969. if (sep && sep->arg[0])
  7970. {
  7971. const char* skill_name = sep->argplus[0];
  7972. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7973. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  7974. {
  7975. player = to_client->GetPlayer();
  7976. if (player)
  7977. {
  7978. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7979. {
  7980. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7981. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7982. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7983. }
  7984. else
  7985. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  7986. }
  7987. }
  7988. else if (skill) // add skill to yourself
  7989. {
  7990. player = client->GetPlayer();
  7991. if (player)
  7992. {
  7993. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7994. {
  7995. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7996. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  7997. }
  7998. else
  7999. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  8000. }
  8001. }
  8002. else
  8003. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8004. }
  8005. else
  8006. {
  8007. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  8008. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8009. }
  8010. break;
  8011. }
  8012. case COMMAND_SKILL_REMOVE:
  8013. {
  8014. if (sep && sep->arg[0])
  8015. {
  8016. const char* skill_name = sep->argplus[0];
  8017. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8018. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  8019. {
  8020. player = to_client->GetPlayer();
  8021. if (player)
  8022. {
  8023. if (player->GetSkills()->HasSkill(skill->skill_id))
  8024. {
  8025. player->RemoveSkillFromDB(skill, true);
  8026. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  8027. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  8028. }
  8029. else
  8030. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  8031. }
  8032. }
  8033. else if(skill) // remove skill from yourself
  8034. {
  8035. Player* player = client->GetPlayer();
  8036. if (player)
  8037. {
  8038. if (player->GetSkills()->HasSkill(skill->skill_id))
  8039. {
  8040. player->RemoveSkillFromDB(skill, true);
  8041. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  8042. }
  8043. else
  8044. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  8045. }
  8046. }
  8047. else
  8048. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8049. }
  8050. else
  8051. {
  8052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  8053. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8054. }
  8055. break;
  8056. }
  8057. case COMMAND_SKILL_LIST:
  8058. {
  8059. if (sep && sep->arg[0])
  8060. {
  8061. const char* skill_name = sep->argplus[0];
  8062. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  8063. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  8064. map<int32, Skill*>::iterator itr;
  8065. if (skills && skills->size() > 0)
  8066. {
  8067. for (itr = skills->begin(); itr != skills->end(); itr++)
  8068. {
  8069. Skill* skill = itr->second;
  8070. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  8071. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  8072. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  8073. }
  8074. }
  8075. }
  8076. else
  8077. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  8078. break;
  8079. }
  8080. }
  8081. }
  8082. /*
  8083. Function: Command_SpawnTemplate()
  8084. Purpose : Create or Use defined Spawn Templates
  8085. Params : create, save, rempve, list
  8086. Dev : John Adams
  8087. Example : /spawn template create "Test"
  8088. */
  8089. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  8090. {
  8091. if (sep == NULL || sep->arg[0] == NULL)
  8092. {
  8093. 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.");
  8094. return;
  8095. }
  8096. // got params, continue
  8097. const char * template_cmd = sep->arg[0];
  8098. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  8099. {
  8100. if (!sep->IsSet(1))
  8101. {
  8102. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  8103. 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.");
  8104. return;
  8105. }
  8106. map<int32, string>* template_names = 0;
  8107. if (sep->IsNumber(1))
  8108. {
  8109. int32 location_id = 0;
  8110. location_id = atoi(sep->arg[1]);
  8111. template_names = database.GetSpawnTemplateListByID(location_id);
  8112. }
  8113. else
  8114. {
  8115. const char* name = 0;
  8116. name = sep->argplus[1];
  8117. template_names = database.GetSpawnTemplateListByName(name);
  8118. }
  8119. if(!template_names)
  8120. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  8121. else
  8122. {
  8123. map<int32, string>::iterator itr;
  8124. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  8125. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  8126. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  8127. safe_delete(template_names);
  8128. }
  8129. }
  8130. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  8131. {
  8132. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8133. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  8134. {
  8135. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  8136. {
  8137. // first, lookup to see if template name already exists
  8138. const char* name = 0;
  8139. name = sep->argplus[1];
  8140. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  8141. if(!template_names)
  8142. {
  8143. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  8144. if( new_template_id > 0 )
  8145. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  8146. else
  8147. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  8148. }
  8149. else
  8150. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  8151. }
  8152. else
  8153. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  8154. }
  8155. else
  8156. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  8157. }
  8158. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  8159. {
  8160. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  8161. {
  8162. int32 template_id = 0;
  8163. template_id = atoi(sep->arg[1]);
  8164. if (database.RemoveSpawnTemplate(template_id))
  8165. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  8166. else
  8167. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  8168. }
  8169. else
  8170. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  8171. }
  8172. // Renamed create to spawn
  8173. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  8174. {
  8175. if (sep && sep->arg[1][0])
  8176. {
  8177. int32 new_location = 0;
  8178. if (sep->IsNumber(1))
  8179. {
  8180. int32 template_id = 0;
  8181. template_id = atoi(sep->arg[1]);
  8182. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  8183. if( new_location > 0 )
  8184. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  8185. else
  8186. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  8187. }
  8188. else
  8189. {
  8190. const char* name = 0;
  8191. name = sep->argplus[1];
  8192. new_location = database.CreateSpawnFromTemplateByName(client, name);
  8193. if( new_location > 0 )
  8194. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  8195. else
  8196. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  8197. }
  8198. }
  8199. else
  8200. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  8201. }
  8202. else
  8203. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  8204. }
  8205. void Commands::Command_Speed(Client* client, Seperator* sep) {
  8206. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  8207. float new_speed = atof(sep->arg[0]);
  8208. if (new_speed > 0.0f)
  8209. {
  8210. client->GetPlayer()->SetSpeed(new_speed, true);
  8211. client->GetPlayer()->SetCharSheetChanged(true);
  8212. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  8213. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  8214. }
  8215. else
  8216. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  8217. }
  8218. else{
  8219. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  8220. }
  8221. }
  8222. /*
  8223. Function: Command_StationMarketPlace()
  8224. Purpose : just trying to eat the console spam for now
  8225. Params :
  8226. Dev : John
  8227. */
  8228. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  8229. {
  8230. PrintSep(sep, "COMMAND_SMP");
  8231. // This will reduce the spam from once every 10 sec to once every 30 sec,
  8232. // can't seem to reduce it any more get rid of it completely...
  8233. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  8234. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  8235. if (packet) {
  8236. packet->setDataByName("account_id", client->GetAccountID());
  8237. packet->setDataByName("character_id", client->GetCharacterID());
  8238. packet->setDataByName("unknown1", 1, 5);
  8239. packet->setDataByName("unknown1", 26, 6);
  8240. packet->setDataByName("unknown2", 0xFFFFFFFF);
  8241. packet->setDataByName("unknown3", 248, 1);
  8242. client->QueuePacket(packet->serialize());
  8243. }
  8244. safe_delete(packet);
  8245. }
  8246. }
  8247. /*
  8248. Function: Command_StopDrinking()
  8249. Purpose : Stops player from auto-consuming drink
  8250. Params :
  8251. Dev : Zcoretri
  8252. Example : /stopdrinking
  8253. */
  8254. void Commands::Command_StopDrinking(Client* client)
  8255. {
  8256. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  8257. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  8258. }
  8259. /*
  8260. Function: Command_StopEating()
  8261. Purpose : Stops player from auto-consuming food
  8262. Params :
  8263. Dev : Zcoretri
  8264. Example : /stopeating
  8265. */
  8266. void Commands::Command_StopEating(Client* client)
  8267. {
  8268. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  8269. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  8270. }
  8271. /*
  8272. Function: Command_Title()
  8273. Purpose : Help for /title command
  8274. Params : n/a
  8275. Dev : Zcoretri
  8276. Example : /title
  8277. */
  8278. void Commands::Command_Title(Client* client)
  8279. {
  8280. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  8281. }
  8282. /*
  8283. Function: Command_TitleList()
  8284. Purpose : List available titles for player
  8285. Params : n/a
  8286. Dev : Zcoretri
  8287. Example : /title list
  8288. */
  8289. void Commands::Command_TitleList(Client* client)
  8290. {
  8291. // must call release read lock before leaving function on GetPlayerTitles
  8292. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  8293. vector<Title*>::iterator itr;
  8294. Title* title;
  8295. sint32 i = 0;
  8296. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  8297. for(itr = titles->begin(); itr != titles->end(); itr++)
  8298. {
  8299. title = *itr;
  8300. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  8301. i++;
  8302. }
  8303. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  8304. }
  8305. /*
  8306. Function: Command_TitleSetPrefix()
  8307. Purpose : Set Prefix title for player
  8308. Params : Title ID
  8309. Dev : Zcoretri
  8310. Example : /title setprefix 1
  8311. */
  8312. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  8313. {
  8314. if (sep && sep->arg[0] && sep->IsNumber(0))
  8315. {
  8316. sint32 index = atoul(sep->arg[0]);
  8317. if(index > -1)
  8318. {
  8319. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8320. if(!title)
  8321. {
  8322. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8323. return;
  8324. }
  8325. else if(!title->GetPrefix())
  8326. {
  8327. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  8328. return;
  8329. }
  8330. }
  8331. else // make sure client doesn't pass some bogus negative index
  8332. index = -1;
  8333. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  8334. client->SendTitleUpdate();
  8335. }
  8336. }
  8337. /*
  8338. Function: Command_TitleSetSuffix()
  8339. Purpose : Set Suffix title for player
  8340. Params : Title ID
  8341. Dev : Zcoretri
  8342. Example : /title setsuffix 1
  8343. */
  8344. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  8345. {
  8346. if (sep && sep->arg[0] && sep->IsNumber(0))
  8347. {
  8348. sint32 index = atoul(sep->arg[0]);
  8349. if(index > -1)
  8350. {
  8351. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8352. if(!title)
  8353. {
  8354. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8355. return;
  8356. }
  8357. else if(title->GetPrefix())
  8358. {
  8359. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  8360. return;
  8361. }
  8362. }
  8363. else // make sure client doesn't pass some bogus negative index
  8364. index = -1;
  8365. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  8366. client->SendTitleUpdate();
  8367. }
  8368. }
  8369. /*
  8370. Function: Command_TitleFix()
  8371. Purpose : Fix title for player (???)
  8372. Params :
  8373. Dev : Zcoretri
  8374. Example :
  8375. */
  8376. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  8377. {
  8378. PrintSep(sep, "COMMAND_TITLE_FIX");
  8379. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  8380. }
  8381. /*
  8382. Function: Command_Toggle_Anonymous()
  8383. Purpose : Toggles player Anonymous
  8384. Params :
  8385. Dev : paulgh
  8386. Example : /anon
  8387. */
  8388. void Commands::Command_Toggle_Anonymous(Client* client)
  8389. {
  8390. Player* player = client->GetPlayer();
  8391. player->toggle_character_flag(CF_ANONYMOUS);
  8392. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  8393. if (player->get_character_flag(CF_ANONYMOUS))
  8394. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  8395. else
  8396. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  8397. }
  8398. /*
  8399. Function: Command_Toggle_AutoConsume()
  8400. Purpose : Toggles player food/drink auto consume
  8401. Params : unknown
  8402. Dev : paulgh
  8403. Example : /set_auto_consume
  8404. */
  8405. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  8406. {
  8407. Player* player = client->GetPlayer();
  8408. if (sep && sep->arg[0])
  8409. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  8410. if (sep && sep->arg[0] && sep->IsNumber(0))
  8411. {
  8412. int8 slot = atoi(sep->arg[0]);
  8413. int8 flag = atoi(sep->arg[1]);
  8414. if (client->GetVersion() <= 283) {
  8415. slot += 4;
  8416. }
  8417. else if (client->GetVersion() <= 546) {
  8418. slot += 2;
  8419. }
  8420. if (slot == EQ2_FOOD_SLOT)
  8421. {
  8422. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  8423. player->SetCharSheetChanged(true);
  8424. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8425. if (flag == 1)
  8426. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  8427. else
  8428. {
  8429. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  8430. return;
  8431. }
  8432. }
  8433. else
  8434. {
  8435. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  8436. player->SetCharSheetChanged(true);
  8437. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8438. if (flag == 1)
  8439. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  8440. else
  8441. {
  8442. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  8443. return;
  8444. }
  8445. }
  8446. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  8447. return;
  8448. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  8449. return;
  8450. Item* item = player->GetEquipmentList()->GetItem(slot);
  8451. if(item)
  8452. client->ConsumeFoodDrink(item, slot);
  8453. }
  8454. }
  8455. /*
  8456. Function: Command_Toggle_BonusXP()
  8457. Purpose : Toggles player Bonus XP
  8458. Params :
  8459. Dev : John Adams
  8460. Example : /disable_char_bonus_exp
  8461. */
  8462. void Commands::Command_Toggle_BonusXP(Client* client)
  8463. {
  8464. Player* player = client->GetPlayer();
  8465. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  8466. player->SetCharSheetChanged(true);
  8467. }
  8468. /*
  8469. Function: Command_Toggle_CombatXP()
  8470. Purpose : Toggles player Adventure XP
  8471. Params :
  8472. Dev : John Adams
  8473. Example : /disable_combat_exp
  8474. */
  8475. void Commands::Command_Toggle_CombatXP(Client* client)
  8476. {
  8477. Player* player = client->GetPlayer();
  8478. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  8479. player->SetCharSheetChanged(true);
  8480. }
  8481. /*
  8482. Function: Command_Toggle_GMHide()
  8483. Purpose : Toggles hiding player GM status
  8484. Params :
  8485. Dev : Scatman
  8486. Example : /gm_hide
  8487. */
  8488. void Commands::Command_Toggle_GMHide(Client* client)
  8489. {
  8490. Player* player = client->GetPlayer();
  8491. player->toggle_character_flag(CF_HIDE_STATUS);
  8492. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  8493. }
  8494. /*
  8495. Function: Command_Toggle_GMVanish()
  8496. Purpose : Toggles hiding GM players from /who searches
  8497. Params :
  8498. Dev : Scatman
  8499. Example : /gm_vanish
  8500. */
  8501. void Commands::Command_Toggle_GMVanish(Client* client)
  8502. {
  8503. Player* player = client->GetPlayer();
  8504. player->toggle_character_flag(CF_GM_HIDDEN);
  8505. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  8506. }
  8507. /*
  8508. Function: Command_Toggle_Illusions()
  8509. Purpose : Toggles player illusion form
  8510. Params : not sure sep is needed, testing
  8511. Dev : paulgh
  8512. Example : /hide_illusions
  8513. */
  8514. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  8515. {
  8516. if (sep && sep->arg[0])
  8517. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  8518. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  8519. }
  8520. /*
  8521. Function: Command_Toggle_LFG()
  8522. Purpose : Toggles player LFG Flag
  8523. Params :
  8524. Dev : paulgh
  8525. Example : /lfg
  8526. */
  8527. void Commands::Command_Toggle_LFG(Client* client)
  8528. {
  8529. Player* player = client->GetPlayer();
  8530. player->toggle_character_flag(CF_LFG);
  8531. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  8532. if (player->get_character_flag(CF_LFG))
  8533. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  8534. else
  8535. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  8536. }
  8537. /*
  8538. Function: Command_Toggle_LFW()
  8539. Purpose : Toggles player LFW Flag
  8540. Params :
  8541. Dev : paulgh
  8542. Example : /lfw
  8543. */
  8544. void Commands::Command_Toggle_LFW(Client* client)
  8545. {
  8546. Player* player = client->GetPlayer();
  8547. player->toggle_character_flag(CF_LFW);
  8548. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8549. if (player->get_character_flag(CF_LFW))
  8550. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8551. else
  8552. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8553. }
  8554. /*
  8555. Function: Command_Toggle_QuestXP()
  8556. Purpose : Toggles player Quest XP
  8557. Params :
  8558. Dev : John Adams
  8559. Example : /disable_quest_exp
  8560. */
  8561. void Commands::Command_Toggle_QuestXP(Client* client)
  8562. {
  8563. Player* player = client->GetPlayer();
  8564. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8565. player->SetCharSheetChanged(true);
  8566. }
  8567. /*
  8568. Function: Command_Toggle_Roleplaying()
  8569. Purpose : Toggles player Roleplaying flag
  8570. Params :
  8571. Dev : paulgh
  8572. Example : /role
  8573. */
  8574. void Commands::Command_Toggle_Roleplaying(Client* client)
  8575. {
  8576. Player* player = client->GetPlayer();
  8577. player->toggle_character_flag(CF_ROLEPLAYING);
  8578. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8579. if (player->get_character_flag(CF_ROLEPLAYING))
  8580. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8581. else
  8582. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8583. }
  8584. void Commands::Command_Toggle_Duels(Client* client)
  8585. {
  8586. Player* player = client->GetPlayer();
  8587. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8588. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8589. }
  8590. void Commands::Command_Toggle_Trades(Client* client)
  8591. {
  8592. Player* player = client->GetPlayer();
  8593. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8594. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8595. }
  8596. void Commands::Command_Toggle_Guilds(Client* client)
  8597. {
  8598. Player* player = client->GetPlayer();
  8599. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8600. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8601. }
  8602. void Commands::Command_Toggle_Groups(Client* client)
  8603. {
  8604. Player* player = client->GetPlayer();
  8605. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8606. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8607. }
  8608. void Commands::Command_Toggle_Raids(Client* client)
  8609. {
  8610. Player* player = client->GetPlayer();
  8611. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8612. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8613. }
  8614. void Commands::Command_Toggle_LON(Client* client)
  8615. {
  8616. Player* player = client->GetPlayer();
  8617. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8618. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8619. }
  8620. void Commands::Command_Toggle_VoiceChat(Client* client)
  8621. {
  8622. Player* player = client->GetPlayer();
  8623. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8624. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8625. }
  8626. /*
  8627. Function: Command_TradeStart()
  8628. Purpose : Starts item/coin trade between players
  8629. Params :
  8630. Dev :
  8631. Example :
  8632. */
  8633. #include "../Trade.h"
  8634. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  8635. {
  8636. PrintSep(sep, "COMMAND_START_TRADE");
  8637. Entity* trader = client->GetPlayer();
  8638. Entity* trader2 = 0;
  8639. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8640. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  8641. if (spawn) {
  8642. if (spawn->IsEntity())
  8643. trader2 = (Entity*)spawn;
  8644. }
  8645. }
  8646. else if (client->GetPlayer()->GetTarget()) {
  8647. if (client->GetPlayer()->GetTarget()->IsEntity())
  8648. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  8649. }
  8650. // can only trade with player or bots
  8651. if (trader && trader2) {
  8652. if (trader == trader2) {
  8653. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  8654. }
  8655. else if (trader2->IsPlayer() || trader2->IsBot()) {
  8656. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  8657. if (trader->trade)
  8658. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  8659. else if (trader2->trade)
  8660. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  8661. else {
  8662. Trade* trade = new Trade(trader, trader2);
  8663. trader->trade = trade;
  8664. trader2->trade = trade;
  8665. }
  8666. }
  8667. else {
  8668. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8669. }
  8670. }
  8671. else
  8672. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8673. }
  8674. /*
  8675. Function: Command_Track()
  8676. Purpose : Starts/Stops Tracking for a player
  8677. Params :
  8678. Dev : Scatman
  8679. Example : /track
  8680. */
  8681. void Commands::Command_Track(Client* client)
  8682. {
  8683. if (!client->GetPlayer()->GetIsTracking())
  8684. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8685. else
  8686. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8687. }
  8688. /*
  8689. Function: Command_TradeAccept()
  8690. Purpose : Accepts item/coin trade between players
  8691. Params :
  8692. Dev :
  8693. Example :
  8694. */
  8695. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8696. {
  8697. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8698. Trade* trade = client->GetPlayer()->trade;
  8699. if (trade) {
  8700. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8701. if (trade_complete)
  8702. safe_delete(trade);
  8703. }
  8704. else
  8705. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8706. }
  8707. /*
  8708. Function: Command_TradeReject()
  8709. Purpose : Rejects item/coin trade between players
  8710. Params :
  8711. Dev :
  8712. Example :
  8713. */
  8714. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8715. {
  8716. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8717. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  8718. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8719. }
  8720. /*
  8721. Function: Command_TradeCancel()
  8722. Purpose : Cancels item/coin trade between players
  8723. Params :
  8724. Dev :
  8725. Example :
  8726. */
  8727. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8728. {
  8729. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8730. Trade* trade = client->GetPlayer()->trade;
  8731. if (trade) {
  8732. trade->CancelTrade(client->GetPlayer());
  8733. safe_delete(trade);
  8734. }
  8735. else
  8736. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8737. }
  8738. /*
  8739. Function: Command_TradeSetCoin()
  8740. Purpose : Sets coin trade between players
  8741. Params :
  8742. Dev :
  8743. Example :
  8744. */
  8745. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8746. {
  8747. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8748. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8749. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8750. }
  8751. /*
  8752. Function: Command_TradeAddCoin()
  8753. Purpose : Adds coin to trade between players
  8754. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8755. Dev :
  8756. Example :
  8757. */
  8758. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  8759. {
  8760. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  8761. Trade* trade = client->GetPlayer()->trade;
  8762. if (trade) {
  8763. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8764. int32 amount = atoi(sep->arg[0]);
  8765. int64 val = 0;
  8766. switch (handler) {
  8767. case COMMAND_ADD_TRADE_COPPER:
  8768. {
  8769. val = amount;
  8770. trade->AddCoinToTrade(client->GetPlayer(), val);
  8771. break;
  8772. }
  8773. case COMMAND_ADD_TRADE_SILVER:
  8774. {
  8775. val = amount * 100;
  8776. trade->AddCoinToTrade(client->GetPlayer(), val);
  8777. break;
  8778. }
  8779. case COMMAND_ADD_TRADE_GOLD:
  8780. {
  8781. val = amount * 10000;
  8782. trade->AddCoinToTrade(client->GetPlayer(), val);
  8783. break;
  8784. }
  8785. case COMMAND_ADD_TRADE_PLAT:
  8786. {
  8787. val = amount * 1000000;
  8788. trade->AddCoinToTrade(client->GetPlayer(), val);
  8789. break;
  8790. }
  8791. default:
  8792. {
  8793. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8794. break;
  8795. }
  8796. }
  8797. }
  8798. else
  8799. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  8800. }
  8801. else
  8802. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8803. }
  8804. /*
  8805. Function: Command_TradeRemoveCoin()
  8806. Purpose : Removes coin from trade between players
  8807. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8808. Dev :
  8809. Example :
  8810. */
  8811. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  8812. {
  8813. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  8814. Trade* trade = client->GetPlayer()->trade;
  8815. if (trade) {
  8816. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8817. int32 amount = atoi(sep->arg[0]);
  8818. int64 val = 0;
  8819. switch (handler) {
  8820. case COMMAND_REMOVE_TRADE_COPPER:
  8821. {
  8822. val = amount;
  8823. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8824. break;
  8825. }
  8826. case COMMAND_REMOVE_TRADE_SILVER:
  8827. {
  8828. val = amount * 100;
  8829. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8830. break;
  8831. }
  8832. case COMMAND_REMOVE_TRADE_GOLD:
  8833. {
  8834. val = amount * 10000;
  8835. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8836. break;
  8837. }
  8838. case COMMAND_REMOVE_TRADE_PLAT:
  8839. {
  8840. val = amount * 1000000;
  8841. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8842. break;
  8843. }
  8844. default:
  8845. {
  8846. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8847. break;
  8848. }
  8849. }
  8850. }
  8851. else
  8852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  8853. }
  8854. else
  8855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8856. }
  8857. /*
  8858. Function: Command_TradeAddItem()
  8859. Purpose : Adds item to trade between players
  8860. Params :
  8861. Dev :
  8862. Example :
  8863. */
  8864. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  8865. {
  8866. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  8867. /*
  8868. arg[0] = item index
  8869. arg[1] = slot
  8870. arg[2] = quantity
  8871. */
  8872. if (!client->GetPlayer()->trade) {
  8873. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  8874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8875. return;
  8876. }
  8877. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  8878. Item* item = 0;
  8879. int32 index = atoi(sep->arg[0]);
  8880. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  8881. if (item) {
  8882. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  8883. if (result == 1)
  8884. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  8885. else if (result == 2)
  8886. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  8887. else if (result == 3)
  8888. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  8889. else if (result == 255)
  8890. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  8891. }
  8892. else {
  8893. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  8894. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  8895. }
  8896. }
  8897. else
  8898. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  8899. }
  8900. /*
  8901. Function: Command_TradeRemoveItem()
  8902. Purpose : Removes item from trade between players
  8903. Params :
  8904. Dev :
  8905. Example :
  8906. */
  8907. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  8908. {
  8909. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  8910. /*
  8911. arg[0] = trade window slot
  8912. */
  8913. Trade* trade = client->GetPlayer()->trade;
  8914. if (trade) {
  8915. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8916. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  8917. }
  8918. else
  8919. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  8920. }
  8921. else
  8922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8923. }
  8924. void Commands::Command_TryOn(Client* client, Seperator* sep)
  8925. {
  8926. Item *item = 0;
  8927. sint32 crc;
  8928. if (sep) {
  8929. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  8930. if (client->GetVersion() < 1096) {
  8931. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  8932. {
  8933. item = master_item_list.GetItem(atoul(sep->arg[1]));
  8934. crc = atol(sep->arg[2]);
  8935. }
  8936. }
  8937. else {
  8938. // From the broker and links in chat
  8939. if (strcmp(sep->arg[0], "crc") == 0) {
  8940. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  8941. item = master_item_list.GetItem(atoul(sep->arg[2]));
  8942. crc = atol(sep->arg[3]);
  8943. }
  8944. }
  8945. // From inventory
  8946. if (strcmp(sep->arg[0], "dbid") == 0) {
  8947. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  8948. item = master_item_list.GetItem(atoul(sep->arg[2]));
  8949. crc = atol(sep->arg[4]);
  8950. }
  8951. }
  8952. }
  8953. if (item)
  8954. client->ShowDressingRoom(item, crc);
  8955. }
  8956. }
  8957. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  8958. const char *channel_name, *password = NULL;
  8959. if (sep == NULL || !sep->IsSet(0)) {
  8960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  8961. return;
  8962. }
  8963. channel_name = sep->arg[0];
  8964. if (sep->IsSet(1))
  8965. password = sep->arg[1];
  8966. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  8967. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  8968. return;
  8969. }
  8970. if (chat.IsInChannel(client, channel_name)) {
  8971. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  8972. return;
  8973. }
  8974. if (chat.HasPassword(channel_name)) {
  8975. if (password == NULL) {
  8976. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  8977. return;
  8978. }
  8979. if (!chat.PasswordMatches(channel_name, password)) {
  8980. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  8981. return;
  8982. }
  8983. }
  8984. if (!chat.JoinChannel(client, channel_name))
  8985. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  8986. }
  8987. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  8988. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  8989. Command_JoinChannel(client, sep);
  8990. }
  8991. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  8992. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  8993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  8994. PrintSep(sep, "tellchannel");
  8995. return;
  8996. }
  8997. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  8998. }
  8999. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  9000. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9001. if (sep->IsSet(0)) {
  9002. if (atoi(sep->arg[0]) == 1) {
  9003. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  9004. if (packet2) {
  9005. packet2->setDataByName("spell_type", 2);
  9006. packet2->setDataByName("spell_id", 8308);
  9007. packet2->setDataByName("spell_name", "Sprint");
  9008. packet2->setDataByName("add_silently", 0);
  9009. packet2->setDataByName("tier", 1);
  9010. packet2->setDataByName("blah1", 1);
  9011. packet2->setDataByName("blah2", 1);
  9012. EQ2Packet* outapp = packet2->serialize();
  9013. DumpPacket(outapp);
  9014. client->QueuePacket(outapp);
  9015. safe_delete(packet2);
  9016. }
  9017. }
  9018. else if (atoi(sep->arg[0]) == 2) {
  9019. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  9020. if (packet2) {
  9021. packet2->setDataByName("guild_name", "Test");
  9022. packet2->setDataByName("guild_motd", "Test MOTD");
  9023. packet2->setDataByName("guild_id", 1234);
  9024. packet2->setDataByName("guild_level", 1);
  9025. packet2->setDataByName("unknown", 2);
  9026. packet2->setDataByName("unknown2", 3);
  9027. packet2->setDataByName("exp_current", 1);
  9028. packet2->setDataByName("exp_to_next_level", 4);
  9029. EQ2Packet* outapp = packet2->serialize();
  9030. DumpPacket(outapp);
  9031. client->QueuePacket(outapp);
  9032. safe_delete(packet2);
  9033. }
  9034. }
  9035. else if (atoi(sep->arg[0]) == 3) {
  9036. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  9037. if (packet2) {
  9038. packet2->setDataByName("guild_id", 1234);
  9039. packet2->setDataByName("character_id", 1);
  9040. packet2->setDataByName("account_id", 2);
  9041. packet2->setDataByName("guild_level", 1);
  9042. packet2->setDataByName("name", "Test");
  9043. packet2->setDataByName("unknown2", 0);
  9044. packet2->setDataByName("unknown3", 1);
  9045. packet2->setDataByName("adventure_class", 6);
  9046. packet2->setDataByName("adventure_level", 7);
  9047. packet2->setDataByName("tradeskill_class", 4);
  9048. packet2->setDataByName("tradeskill_level", 5);
  9049. packet2->setDataByName("rank", 0);
  9050. packet2->setDataByName("member_flags", 2);
  9051. packet2->setDataByName("join_date", 1591112273);
  9052. packet2->setDataByName("guild_status", 2);
  9053. packet2->setDataByName("last_login", 1591132273);
  9054. packet2->setDataByName("recruiter_id", 1);
  9055. packet2->setDataByName("points", 2345);
  9056. packet2->setDataByName("note", "note");
  9057. packet2->setMediumStringByName("officer_note", "O note");
  9058. packet2->setMediumStringByName("zone", "Blah");
  9059. EQ2Packet* outapp = packet2->serialize();
  9060. DumpPacket(outapp);
  9061. client->QueuePacket(outapp);
  9062. safe_delete(packet2);
  9063. }
  9064. }
  9065. else if (atoi(sep->arg[0]) == 5) {
  9066. int16 offset = atoi(sep->arg[1]);
  9067. int32 value1 = atol(sep->arg[2]);
  9068. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  9069. client->QueuePacket(outapp);
  9070. }
  9071. else if (atoi(sep->arg[0]) == 6) {
  9072. Spawn* spawn = client->GetPlayer()->GetTarget();
  9073. if (!spawn)
  9074. spawn = client->GetPlayer();
  9075. else if (spawn->IsEntity())
  9076. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  9077. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  9078. }
  9079. else if (atoi(sep->arg[0]) == 7) {
  9080. int32 id = 0;
  9081. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  9082. if (spawn) {
  9083. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9084. spawn->SetY(client->GetPlayer()->GetY(), false);
  9085. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9086. float heading = client->GetPlayer()->GetHeading() + 180;
  9087. if (heading > 360)
  9088. heading -= 360;
  9089. spawn->SetLevel(5);
  9090. spawn->SetAdventureClass(4);
  9091. spawn->SetHeading(heading, false);
  9092. spawn->SetSpawnOrigX(spawn->GetX());
  9093. spawn->SetSpawnOrigY(spawn->GetY());
  9094. spawn->SetSpawnOrigZ(spawn->GetZ());
  9095. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9096. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9097. spawn->appearance.targetable = 1;
  9098. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9099. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9100. spawn->SetHP(spawn->GetTotalHP());
  9101. }
  9102. if (spawn->GetTotalPower() == 0) {
  9103. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9104. spawn->SetPower(spawn->GetTotalPower());
  9105. }
  9106. int16 offset = atoi(sep->arg[1]);
  9107. int32 value1 = atol(sep->arg[2]);
  9108. sprintf(spawn->appearance.name, "Offset %i", offset);
  9109. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  9110. DumpPacket(ret);
  9111. client->QueuePacket(ret);
  9112. }
  9113. }
  9114. else if (atoi(sep->arg[0]) == 8) {
  9115. int32 id = atoi(sep->arg[1]);
  9116. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  9117. if (spawn) {
  9118. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9119. spawn->SetY(client->GetPlayer()->GetY(), false);
  9120. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9121. float heading = client->GetPlayer()->GetHeading() + 180;
  9122. if (heading > 360)
  9123. heading -= 360;
  9124. spawn->SetLevel(5);
  9125. spawn->SetAdventureClass(4);
  9126. spawn->SetHeading(heading, false);
  9127. spawn->SetSpawnOrigX(spawn->GetX());
  9128. spawn->SetSpawnOrigY(spawn->GetY());
  9129. spawn->SetSpawnOrigZ(spawn->GetZ());
  9130. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9131. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9132. spawn->appearance.targetable = 1;
  9133. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9134. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9135. spawn->SetHP(spawn->GetTotalHP());
  9136. }
  9137. if (spawn->GetTotalPower() == 0) {
  9138. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9139. spawn->SetPower(spawn->GetTotalPower());
  9140. }
  9141. int16 offset = atoi(sep->arg[2]);
  9142. int16 offset2 = atoi(sep->arg[3]);
  9143. int32 value1 = atol(sep->arg[4]);
  9144. int16 offset3 = 0;
  9145. int16 offset4 = 0;
  9146. int32 value2 = 0;
  9147. if (sep->IsSet(7)) {
  9148. offset3 = atoi(sep->arg[5]);
  9149. offset4 = atoi(sep->arg[6]);
  9150. value2 = atol(sep->arg[7]);
  9151. }
  9152. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  9153. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  9154. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  9155. DumpPacket(ret);
  9156. client->QueuePacket(ret);
  9157. }
  9158. }
  9159. else if (atoi(sep->arg[0]) == 9) {
  9160. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  9161. if (packet2) {
  9162. packet2->setArrayLengthByName("location_count", 1);
  9163. packet2->setArrayDataByName("location_ida", 1234);
  9164. packet2->setArrayDataByName("unknown2a", 3);
  9165. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  9166. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  9167. packet2->setArrayDataByName("distance", 134);
  9168. EQ2Packet* app = packet2->serialize();
  9169. if (sep->IsSet(2)) {
  9170. int8 offset = atoi(sep->arg[1]);
  9171. uchar* ptr2 = app->pBuffer;
  9172. ptr2 += offset;
  9173. if (sep->IsNumber(2)) {
  9174. int32 value1 = atol(sep->arg[2]);
  9175. if (value1 > 0xFFFF)
  9176. memcpy(ptr2, (uchar*)&value1, 4);
  9177. else if (value1 > 0xFF)
  9178. memcpy(ptr2, (uchar*)&value1, 2);
  9179. else
  9180. memcpy(ptr2, (uchar*)&value1, 1);
  9181. }
  9182. else {
  9183. int8 len = strlen(sep->arg[2]);
  9184. memcpy(ptr2, (uchar*)&len, 1);
  9185. ptr2 += 1;
  9186. memcpy(ptr2, sep->arg[2], len);
  9187. }
  9188. }
  9189. DumpPacket(app);
  9190. client->QueuePacket(app);
  9191. safe_delete(packet2);
  9192. }
  9193. }
  9194. else if (atoi(sep->arg[0]) == 10) {
  9195. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  9196. if (packet2) {
  9197. packet2->setArrayLengthByName("num_quests", 1);
  9198. packet2->setArrayDataByName("active", 1);
  9199. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  9200. packet2->setArrayDataByName("quest_type", "Hallmark");
  9201. packet2->setArrayDataByName("quest_zone", "Hallmark");
  9202. packet2->setArrayDataByName("journal_updated", 1);
  9203. packet2->setArrayDataByName("quest_id", 524);
  9204. packet2->setArrayDataByName("day", 19);
  9205. packet2->setArrayDataByName("month", 6);
  9206. packet2->setArrayDataByName("year", 20);
  9207. packet2->setArrayDataByName("level", 2);
  9208. packet2->setArrayDataByName("encounter_level", 4);
  9209. packet2->setArrayDataByName("difficulty", 3);
  9210. packet2->setArrayDataByName("visible", 1);
  9211. packet2->setDataByName("visible_quest_id", 524);
  9212. packet2->setDataByName("player_crc", 2900677088);
  9213. packet2->setDataByName("player_name", "LethalEncounter");
  9214. EQ2Packet* app = packet2->serialize();
  9215. if (sep->IsSet(2)) {
  9216. int8 offset = atoi(sep->arg[1]);
  9217. uchar* ptr2 = app->pBuffer;
  9218. ptr2 += offset;
  9219. if (sep->IsNumber(2)) {
  9220. int32 value1 = atol(sep->arg[2]);
  9221. if (value1 > 0xFFFF)
  9222. memcpy(ptr2, (uchar*)&value1, 4);
  9223. else if (value1 > 0xFF)
  9224. memcpy(ptr2, (uchar*)&value1, 2);
  9225. else
  9226. memcpy(ptr2, (uchar*)&value1, 1);
  9227. }
  9228. else {
  9229. int8 len = strlen(sep->arg[2]);
  9230. memcpy(ptr2, (uchar*)&len, 1);
  9231. ptr2 += 1;
  9232. memcpy(ptr2, sep->arg[2], len);
  9233. }
  9234. }
  9235. DumpPacket(app);
  9236. client->QueuePacket(app);
  9237. safe_delete(packet2);
  9238. }
  9239. }
  9240. else if (atoi(sep->arg[0]) == 11) {
  9241. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9242. if (packet2) {
  9243. packet2->setDataByName("quest_id", 524);
  9244. packet2->setDataByName("player_crc", 2900677088);
  9245. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  9246. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  9247. packet2->setDataByName("type", "Hallmark");
  9248. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9249. packet2->setDataByName("day", 19);
  9250. packet2->setDataByName("month", 6);
  9251. packet2->setDataByName("year", 20);
  9252. packet2->setDataByName("level", 1);
  9253. packet2->setDataByName("encounter_level", 1);
  9254. packet2->setDataByName("difficulty", 1);
  9255. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9256. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9257. //packet2->setDataByName("timer_duration", 300);
  9258. //packet2->setDataByName("timer_running", 1);
  9259. packet2->setArrayLengthByName("task_groups_completed", 9);
  9260. packet2->setArrayLengthByName("num_task_groups", 10);
  9261. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  9262. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  9263. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  9264. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  9265. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  9266. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  9267. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  9268. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  9269. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  9270. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  9271. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  9272. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9273. packet2->setSubArrayLengthByName("num_updates", 1);
  9274. packet2->setSubArrayDataByName("update_currentval", 0);
  9275. packet2->setSubArrayDataByName("update_maxval", 1);
  9276. packet2->setSubArrayDataByName("icon", 11);
  9277. */
  9278. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9279. packet2->setDataByName("journal_updated", 1);
  9280. packet2->setDataByName("bullets", 1);
  9281. EQ2Packet* app = packet2->serialize();
  9282. if (sep->IsSet(2)) {
  9283. int16 offset = atoi(sep->arg[1]);
  9284. uchar* ptr2 = app->pBuffer;
  9285. ptr2 += offset;
  9286. if (sep->IsNumber(2)) {
  9287. int32 value1 = atol(sep->arg[2]);
  9288. if (value1 > 0xFFFF)
  9289. memcpy(ptr2, (uchar*)&value1, 4);
  9290. else if (value1 > 0xFF)
  9291. memcpy(ptr2, (uchar*)&value1, 2);
  9292. else
  9293. memcpy(ptr2, (uchar*)&value1, 1);
  9294. }
  9295. else {
  9296. int16 len = strlen(sep->arg[2]);
  9297. memcpy(ptr2, (uchar*)&len, 2);
  9298. ptr2 += 2;
  9299. memcpy(ptr2, sep->arg[2], len);
  9300. }
  9301. }
  9302. DumpPacket(app);
  9303. client->QueuePacket(app);
  9304. safe_delete(packet2);
  9305. }
  9306. }
  9307. else if (atoi(sep->arg[0]) == 12) {
  9308. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9309. if (packet2) {
  9310. packet2->setDataByName("quest_id", 524);
  9311. packet2->setDataByName("player_crc", 2900677088);
  9312. packet2->setDataByName("name", "Archetype Selection");
  9313. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  9314. packet2->setDataByName("type", "Hallmark");
  9315. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9316. packet2->setDataByName("day", 19);
  9317. packet2->setDataByName("month", 6);
  9318. packet2->setDataByName("year", 20);
  9319. packet2->setDataByName("level", 2);
  9320. packet2->setDataByName("encounter_level", 4);
  9321. packet2->setDataByName("difficulty", 3);
  9322. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9323. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9324. packet2->setDataByName("timer_duration", 300);
  9325. packet2->setDataByName("timer_running", 1);
  9326. packet2->setArrayLengthByName("task_groups_completed", 0);
  9327. packet2->setArrayLengthByName("num_task_groups", 1);
  9328. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  9329. packet2->setSubArrayLengthByName("num_tasks", 1);
  9330. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9331. packet2->setSubArrayLengthByName("num_updates", 1);
  9332. packet2->setSubArrayDataByName("update_currentval", 0);
  9333. packet2->setSubArrayDataByName("update_maxval", 1);
  9334. packet2->setSubArrayDataByName("icon", 11);
  9335. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9336. packet2->setDataByName("journal_updated", 1);
  9337. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9338. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9339. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  9340. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9341. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9342. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9343. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9344. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  9345. Item* item = master_item_list.GetItem(152755);
  9346. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9347. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9348. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  9349. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  9350. packet2->setSubstructDataByName("item", "icon", 0xe7);
  9351. packet2->setSubstructDataByName("item", "tier", 4);
  9352. packet2->setSubstructDataByName("item", "flags", 0x60);
  9353. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  9354. packet2->setSubstructDataByName("item", "stat_type", 1);
  9355. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  9356. packet2->setSubstructDataByName("item", "value", 3);
  9357. packet2->setSubstructDataByName("item", "condition", 100);
  9358. packet2->setSubstructDataByName("item", "weight", 1);
  9359. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  9360. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  9361. packet2->setSubstructDataByName("item", "skill_min", 1);
  9362. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  9363. packet2->setSubstructDataByName("item", "adventure_class", 1);
  9364. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  9365. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  9366. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  9367. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  9368. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  9369. packet2->setSubstructDataByName("item", "level", 0x1e);
  9370. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  9371. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  9372. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  9373. //packet2->PrintPacket();
  9374. EQ2Packet* app = packet2->serialize();
  9375. if (sep->IsSet(2)) {
  9376. int16 offset = atoi(sep->arg[1]);
  9377. uchar* ptr2 = app->pBuffer;
  9378. ptr2 += offset;
  9379. if (sep->IsNumber(2)) {
  9380. int32 value1 = atol(sep->arg[2]);
  9381. if (value1 > 0xFFFF)
  9382. memcpy(ptr2, (uchar*)&value1, 4);
  9383. else if (value1 > 0xFF)
  9384. memcpy(ptr2, (uchar*)&value1, 2);
  9385. else
  9386. memcpy(ptr2, (uchar*)&value1, 1);
  9387. }
  9388. else {
  9389. int16 len = strlen(sep->arg[2]);
  9390. memcpy(ptr2, (uchar*)&len, 2);
  9391. ptr2 += 2;
  9392. memcpy(ptr2, sep->arg[2], len);
  9393. }
  9394. }
  9395. DumpPacket(app);
  9396. client->QueuePacket(app);
  9397. safe_delete(packet2);
  9398. }
  9399. }
  9400. else if (atoi(sep->arg[0]) == 13) {
  9401. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  9402. if (packet2 && sep->IsSet(7)) {
  9403. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  9404. char blah[128];
  9405. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  9406. packet2->setDataByName("text", blah);
  9407. packet2->setDataByName("message_type", sep->arg[3]);
  9408. packet2->setDataByName("size", atof(sep->arg[4]));
  9409. packet2->setDataByName("red", atoi(sep->arg[5]));
  9410. packet2->setDataByName("green", atoi(sep->arg[6]));
  9411. packet2->setDataByName("blue", atoi(sep->arg[7]));
  9412. EQ2Packet* app = packet2->serialize();
  9413. DumpPacket(app);
  9414. client->QueuePacket(app);
  9415. safe_delete(packet2);
  9416. }
  9417. }
  9418. else if (atoi(sep->arg[0]) == 14) {
  9419. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  9420. if (packet2 && sep->IsSet(3)) {
  9421. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  9422. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  9423. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  9424. packet2->setDataByName("text", "Welcome to Norrath, the world of EverQuest II. Left click on the help button at any time for more detailed help and information.");
  9425. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  9426. packet2->setArrayLengthByName("num_goals", 1);
  9427. //packet2->setArrayDataByName("goal_text", )
  9428. packet2->setSubArrayLengthByName("num_tasks", 1);
  9429. packet2->setSubArrayDataByName("task_text", "continue");
  9430. packet2->setDataByName("complete_sound", "click");
  9431. packet2->setDataByName("signal", "introduction");
  9432. packet2->setDataByName("voice_key1", 0xcda65173);
  9433. packet2->setDataByName("voice_key2", 0x984bfc6d);
  9434. EQ2Packet* app = packet2->serialize();
  9435. DumpPacket(app);
  9436. client->QueuePacket(app);
  9437. safe_delete(packet2);
  9438. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  9439. packet2->setDataByName("window", "MainHUD.StartMenu");
  9440. packet2->setDataByName("show", 1);
  9441. app = packet2->serialize();
  9442. DumpPacket(app);
  9443. client->QueuePacket(app);
  9444. safe_delete(packet2);
  9445. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  9446. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  9447. packet2->setDataByName("flash_seconds", 10);
  9448. app = packet2->serialize();
  9449. DumpPacket(app);
  9450. client->QueuePacket(app);
  9451. safe_delete(packet2);
  9452. }
  9453. }
  9454. else if (atoi(sep->arg[0]) == 15) {
  9455. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9456. if (packet2) {
  9457. packet2->setArrayLengthByName("loot_count", 1);
  9458. packet2->setArrayDataByName("name", "Test");
  9459. packet2->setArrayDataByName("item_id", 1234);
  9460. packet2->setArrayDataByName("count", 1);
  9461. packet2->setArrayDataByName("icon", 258);
  9462. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  9463. Spawn* spawn = client->GetPlayer()->GetTarget();
  9464. if (spawn)
  9465. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9466. packet2->setDataByName("unknown3", 1);
  9467. packet2->setDataByName("unknown4", 1);
  9468. packet2->setDataByName("unknown5", 60);
  9469. EQ2Packet* app = packet2->serialize();
  9470. DumpPacket(app);
  9471. client->QueuePacket(app);
  9472. safe_delete(packet2);
  9473. }
  9474. }
  9475. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  9476. char blah[32];
  9477. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  9478. client->SimpleMessage(atoi(sep->arg[1]), blah);
  9479. }
  9480. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  9481. if (sep->IsSet(2)) {
  9482. int16 offset = atoi(sep->arg[1]);
  9483. if (sep->IsNumber(2)) {
  9484. int32 value1 = atol(sep->arg[2]);
  9485. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  9486. cout << "Sent" << endl;
  9487. }
  9488. }
  9489. }
  9490. else if (atoi(sep->arg[0]) == 18) {
  9491. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  9492. if (packet2) {
  9493. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9494. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9495. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9496. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9497. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9498. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  9499. Item* item = new Item(master_item_list.GetItem(36212));
  9500. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9501. item->stack_count = 20;
  9502. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9503. safe_delete(item);
  9504. item = new Item(master_item_list.GetItem(36685));
  9505. item->stack_count = 20;
  9506. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9507. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  9508. safe_delete(item);
  9509. item = master_item_list.GetItem(1414);
  9510. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9511. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  9512. item = master_item_list.GetItem(75057);
  9513. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9514. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  9515. EQ2Packet* app = packet2->serialize();
  9516. if (sep->IsSet(2)) {
  9517. int16 offset = atoi(sep->arg[1]);
  9518. uchar* ptr2 = app->pBuffer;
  9519. ptr2 += offset;
  9520. if (sep->IsNumber(2)) {
  9521. int32 value1 = atol(sep->arg[2]);
  9522. if (value1 > 0xFFFF)
  9523. memcpy(ptr2, (uchar*)&value1, 4);
  9524. else if (value1 > 0xFF)
  9525. memcpy(ptr2, (uchar*)&value1, 2);
  9526. else
  9527. memcpy(ptr2, (uchar*)&value1, 1);
  9528. }
  9529. else {
  9530. int16 len = strlen(sep->arg[2]);
  9531. memcpy(ptr2, (uchar*)&len, 2);
  9532. ptr2 += 2;
  9533. memcpy(ptr2, sep->arg[2], len);
  9534. }
  9535. }
  9536. DumpPacket(app);
  9537. client->QueuePacket(app);
  9538. safe_delete(packet2);
  9539. }
  9540. }
  9541. else if (atoi(sep->arg[0]) == 19) {
  9542. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9543. Spawn* spawn = client->GetPlayer()->GetTarget();
  9544. if (packet2 && spawn) {
  9545. Item* item = master_item_list.GetItem(130053);
  9546. packet2->setArrayLengthByName("loot_count", 1);
  9547. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9548. packet2->setArrayDataByName("unknown2", 1);
  9549. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9550. packet2->setDataByName("display", 1);
  9551. packet2->setDataByName("unknown2b", 1);
  9552. packet2->setDataByName("unknown3", 0x3c);
  9553. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9554. packet2->PrintPacket();
  9555. EQ2Packet* app = packet2->serialize();
  9556. if (sep->IsSet(2)) {
  9557. int16 offset = atoi(sep->arg[1]);
  9558. int16 offset2 = 0;
  9559. int32 value1 = 0;
  9560. if (sep->IsSet(3)) {
  9561. offset2 = atoi(sep->arg[2]);
  9562. value1 = atol(sep->arg[3]);
  9563. }
  9564. else
  9565. value1 = atol(sep->arg[2]);
  9566. int16 offset3 = 0;
  9567. int16 offset4 = 0;
  9568. int32 value2 = 0;
  9569. if (sep->IsSet(6)) {
  9570. offset3 = atoi(sep->arg[4]);
  9571. offset4 = atoi(sep->arg[5]);
  9572. value2 = atol(sep->arg[6]);
  9573. }
  9574. offset--;
  9575. if (offset2 > 0 && offset2 >= offset) {
  9576. offset2--;
  9577. uchar* ptr2 = app->pBuffer;
  9578. ptr2 += offset;
  9579. for (int i = offset; i <= offset2; i++) {
  9580. if (value1 > 0xFFFF) {
  9581. memcpy(ptr2, (uchar*)&value1, 4);
  9582. i += 3;
  9583. ptr2 += 3;
  9584. }
  9585. else if (value1 > 0xFF) {
  9586. memcpy(ptr2, (uchar*)&value1, 2);
  9587. i++;
  9588. ptr2++;
  9589. }
  9590. else
  9591. memcpy(ptr2, (uchar*)&value1, 1);
  9592. ptr2++;
  9593. }
  9594. }
  9595. if (offset4 > 0 && offset4 >= offset3) {
  9596. offset3--;
  9597. offset4--;
  9598. uchar* ptr2 = app->pBuffer;
  9599. ptr2 += offset3;
  9600. for (int i = offset3; i <= offset4; i++) {
  9601. if (value2 > 0xFFFF) {
  9602. memcpy(ptr2, (uchar*)&value2, 4);
  9603. i += 3;
  9604. ptr2 += 3;
  9605. }
  9606. else if (value2 > 0xFF) {
  9607. memcpy(ptr2, (uchar*)&value2, 2);
  9608. i++;
  9609. ptr2++;
  9610. }
  9611. else
  9612. memcpy(ptr2, (uchar*)&value2, 1);
  9613. ptr2++;
  9614. }
  9615. }
  9616. }
  9617. DumpPacket(app);
  9618. client->QueuePacket(app);
  9619. safe_delete(packet2);
  9620. }
  9621. }
  9622. else if (atoi(sep->arg[0]) == 21) {
  9623. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9624. if (packet2) {
  9625. packet2->setDataByName("unknown0", 255);
  9626. packet2->setDataByName("reward", "New Quest");
  9627. packet2->setDataByName("title", "Title");
  9628. packet2->setDataByName("description", "description");
  9629. packet2->setDataByName("quest_difficulty", 3);
  9630. packet2->setDataByName("unknown1", 5);
  9631. packet2->setDataByName("level", 3);
  9632. packet2->setDataByName("coin", 150);
  9633. packet2->setDataByName("status_points", 5);
  9634. packet2->setDataByName("exp_bonus", 10);
  9635. packet2->setArrayLengthByName("num_rewards", 1);
  9636. Item* item = new Item(master_item_list.GetItem(36212));
  9637. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9638. item->stack_count = 20;
  9639. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9640. safe_delete(item);
  9641. char accept[35] = { 0 };
  9642. char decline[35] = { 0 };
  9643. sprintf(accept, "q_accept_pending_quest %u", 0);
  9644. sprintf(decline, "q_deny_pending_quest %u", 0);
  9645. packet2->setDataByName("accept_command", accept);
  9646. packet2->setDataByName("decline_command", decline);
  9647. EQ2Packet* app = packet2->serialize();
  9648. if (sep->IsSet(2)) {
  9649. int16 offset = atoi(sep->arg[1]);
  9650. uchar* ptr2 = app->pBuffer;
  9651. ptr2 += offset;
  9652. if (sep->IsNumber(2)) {
  9653. int32 value1 = atol(sep->arg[2]);
  9654. if (value1 > 0xFFFF)
  9655. memcpy(ptr2, (uchar*)&value1, 4);
  9656. else if (value1 > 0xFF)
  9657. memcpy(ptr2, (uchar*)&value1, 2);
  9658. else
  9659. memcpy(ptr2, (uchar*)&value1, 1);
  9660. }
  9661. DumpPacket(app);
  9662. client->QueuePacket(app);
  9663. safe_delete(packet2);
  9664. }
  9665. }
  9666. }
  9667. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9668. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9669. if (packet2) {
  9670. packet2->setDataByName("unknown0", 255);
  9671. packet2->setDataByName("reward", "New Quest");
  9672. packet2->setDataByName("title", "Title");
  9673. packet2->setDataByName("description", "description");
  9674. packet2->setDataByName("quest_difficulty", 3);
  9675. packet2->setDataByName("unknown1", 5);
  9676. packet2->setDataByName("level", 3);
  9677. packet2->setDataByName("coin", 150);
  9678. packet2->setDataByName("status_points", 5);
  9679. packet2->setDataByName("exp_bonus", 10);
  9680. packet2->setArrayLengthByName("num_rewards", 1);
  9681. Item* item = new Item(master_item_list.GetItem(36212));
  9682. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9683. item->stack_count = 20;
  9684. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9685. safe_delete(item);
  9686. char accept[35] = { 0 };
  9687. char decline[35] = { 0 };
  9688. sprintf(accept, "q_accept_pending_quest %u", 0);
  9689. sprintf(decline, "q_deny_pending_quest %u", 0);
  9690. packet2->setDataByName("accept_command", accept);
  9691. packet2->setDataByName("decline_command", decline);
  9692. EQ2Packet* app = packet2->serialize();
  9693. if (sep->IsSet(2)) {
  9694. int16 offset = atoi(sep->arg[1]);
  9695. uchar* ptr2 = app->pBuffer;
  9696. ptr2 += offset;
  9697. if (sep->IsNumber(2)) {
  9698. int32 value1 = atol(sep->arg[2]);
  9699. if (value1 > 0xFFFF)
  9700. memcpy(ptr2, (uchar*)&value1, 4);
  9701. else if (value1 > 0xFF)
  9702. memcpy(ptr2, (uchar*)&value1, 2);
  9703. else
  9704. memcpy(ptr2, (uchar*)&value1, 1);
  9705. }
  9706. else {
  9707. int8 len = strlen(sep->arg[2]);
  9708. memcpy(ptr2, (uchar*)&len, 1);
  9709. ptr2 += 1;
  9710. memcpy(ptr2, sep->arg[2], len);
  9711. }
  9712. }
  9713. DumpPacket(app);
  9714. client->QueuePacket(app);
  9715. safe_delete(packet2);
  9716. }
  9717. }
  9718. else if (atoi(sep->arg[0]) == 23) {
  9719. if (client->GetPlayer()->GetTarget()) {
  9720. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9721. if (packet2) {
  9722. Spawn* target = client->GetPlayer()->GetTarget();
  9723. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9724. Item* item = new Item(master_item_list.GetItem(12565));
  9725. int8 i = 0;
  9726. packet2->setArrayLengthByName("num_items", 1);
  9727. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9728. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9729. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9730. packet2->setArrayDataByName("icon", item->details.icon, i);
  9731. int8 tmp_level = 0;
  9732. if (item->generic_info.adventure_default_level > 0)
  9733. tmp_level = item->generic_info.adventure_default_level;
  9734. else
  9735. tmp_level = item->generic_info.tradeskill_default_level;
  9736. packet2->setArrayDataByName("level", tmp_level, i);
  9737. packet2->setArrayDataByName("tier", item->details.tier, i);
  9738. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9739. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9740. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9741. item_difficulty = ARROW_COLOR_WHITE;
  9742. item_difficulty -= 6;
  9743. if (item_difficulty < 0)
  9744. item_difficulty *= -1;
  9745. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9746. packet2->setArrayDataByName("quantity", 2, i);
  9747. packet2->setArrayDataByName("unknown5", 255, i);
  9748. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9749. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9750. packet2->setDataByName("type", 2);
  9751. EQ2Packet* app = packet2->serialize();
  9752. if (sep->IsSet(2)) {
  9753. int16 offset = atoi(sep->arg[1]);
  9754. uchar* ptr2 = app->pBuffer;
  9755. ptr2 += offset;
  9756. if (sep->IsNumber(2)) {
  9757. int32 value1 = atol(sep->arg[2]);
  9758. if (value1 > 0xFFFF)
  9759. memcpy(ptr2, (uchar*)&value1, 4);
  9760. else if (value1 > 0xFF)
  9761. memcpy(ptr2, (uchar*)&value1, 2);
  9762. else
  9763. memcpy(ptr2, (uchar*)&value1, 1);
  9764. }
  9765. else {
  9766. int8 len = strlen(sep->arg[2]);
  9767. memcpy(ptr2, (uchar*)&len, 1);
  9768. ptr2 += 1;
  9769. memcpy(ptr2, sep->arg[2], len);
  9770. }
  9771. }
  9772. DumpPacket(app);
  9773. client->QueuePacket(app);
  9774. safe_delete(packet2);
  9775. }
  9776. }
  9777. }
  9778. else if (atoi(sep->arg[0]) == 24) {
  9779. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  9780. if (packet2) {
  9781. if (sep->IsSet(2)) {
  9782. packet2->setDataByName("event_name", sep->arg[1]);
  9783. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  9784. EQ2Packet* app = packet2->serialize();
  9785. DumpPacket(app);
  9786. client->QueuePacket(app);
  9787. safe_delete(packet2);
  9788. }
  9789. }
  9790. }
  9791. else if (atoi(sep->arg[0]) == 25) {
  9792. if (sep->IsSet(1)) {
  9793. Widget* new_spawn = new Widget();
  9794. int32 id = atoul(sep->arg[1]);
  9795. new_spawn->SetWidgetID(id);
  9796. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9797. client->QueuePacket(ret);
  9798. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  9799. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  9800. if (packet2) {
  9801. packet2->setDataByName("spawn_index", index);
  9802. packet2->setDataByName("delete", 1);
  9803. EQ2Packet* app = packet2->serialize();
  9804. client->QueuePacket(app);
  9805. safe_delete(packet2);
  9806. }
  9807. }
  9808. }
  9809. else if (atoi(sep->arg[0]) == 26) {
  9810. if (sep->IsSet(4)) {
  9811. Widget* new_spawn = new Widget();
  9812. int32 id = atoul(sep->arg[1]);
  9813. new_spawn->SetWidgetID(id);
  9814. float x = atof(sep->arg[2]);
  9815. float y = atof(sep->arg[3]);
  9816. float z = atof(sep->arg[4]);
  9817. new_spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9818. new_spawn->SetWidgetX(x);
  9819. new_spawn->SetWidgetY(y);
  9820. new_spawn->SetWidgetZ(z);
  9821. new_spawn->SetX(x);
  9822. new_spawn->SetY(y);
  9823. new_spawn->SetZ(z);
  9824. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9825. client->QueuePacket(ret);
  9826. }
  9827. }
  9828. else if (atoi(sep->arg[0]) == 27) {
  9829. Spawn* target = client->GetPlayer()->GetTarget();
  9830. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  9831. if (packet2 && target && sep->IsSet(2)) {
  9832. packet2->setSubstructDataByName("header", "defender", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9833. packet2->setSubstructDataByName("header", "defender_proxy", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9834. packet2->setSubstructDataByName("header", "attacker", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  9835. packet2->setArrayLengthByName("num_dmg", 1);
  9836. packet2->setArrayDataByName("damage_type", atoi(sep->arg[1]));
  9837. packet2->setArrayDataByName("damage", atoi(sep->arg[2]));
  9838. packet2->setDataByName("spell", 1);
  9839. packet2->setDataByName("spell_name", "Testing");
  9840. EQ2Packet* app = packet2->serialize();
  9841. if (sep->IsSet(4)) {
  9842. int16 offset = atoi(sep->arg[3]);
  9843. uchar* ptr2 = app->pBuffer;
  9844. ptr2 += offset;
  9845. if (sep->IsNumber(4)) {
  9846. int32 value1 = atol(sep->arg[4]);
  9847. if (value1 > 0xFFFF)
  9848. memcpy(ptr2, (uchar*)&value1, 4);
  9849. else if (value1 > 0xFF)
  9850. memcpy(ptr2, (uchar*)&value1, 2);
  9851. else
  9852. memcpy(ptr2, (uchar*)&value1, 1);
  9853. }
  9854. else {
  9855. int8 len = strlen(sep->arg[4]);
  9856. memcpy(ptr2, (uchar*)&len, 1);
  9857. ptr2 += 1;
  9858. memcpy(ptr2, sep->arg[4], len);
  9859. }
  9860. }
  9861. if (sep->IsSet(6)) {
  9862. int16 offset = atoi(sep->arg[5]);
  9863. uchar* ptr2 = app->pBuffer;
  9864. ptr2 += offset;
  9865. if (sep->IsNumber(6)) {
  9866. int32 value1 = atol(sep->arg[6]);
  9867. if (value1 > 0xFFFF)
  9868. memcpy(ptr2, (uchar*)&value1, 4);
  9869. else if (value1 > 0xFF)
  9870. memcpy(ptr2, (uchar*)&value1, 2);
  9871. else
  9872. memcpy(ptr2, (uchar*)&value1, 1);
  9873. }
  9874. else {
  9875. int8 len = strlen(sep->arg[6]);
  9876. memcpy(ptr2, (uchar*)&len, 1);
  9877. ptr2 += 1;
  9878. memcpy(ptr2, sep->arg[6], len);
  9879. }
  9880. }
  9881. DumpPacket(app);
  9882. client->QueuePacket(app);
  9883. safe_delete(packet2);
  9884. }
  9885. }
  9886. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  9887. World::newValue = strtoull(sep->arg[1], NULL, 0);
  9888. }
  9889. }
  9890. else {
  9891. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  9892. if (packet2) {
  9893. packet2->setSubstructDataByName("info_header", "show_name", 1);
  9894. packet2->setSubstructDataByName("info_header", "unknown", 7);
  9895. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  9896. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  9897. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  9898. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  9899. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  9900. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  9901. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  9902. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  9903. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  9904. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  9905. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  9906. packet2->setSubstructDataByName("info_header", "packettype", 3);
  9907. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  9908. packet2->setSubstructDataByName("spell_info", "level", 19);
  9909. packet2->setSubstructDataByName("spell_info", "tier", 1);
  9910. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  9911. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  9912. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  9913. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  9914. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  9915. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  9916. packet2->setSubstructDataByName("spell_info", "recast", 280);
  9917. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  9918. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  9919. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  9920. packet2->setSubstructDataByName("spell_info", "quality", 3);
  9921. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  9922. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  9923. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  9924. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  9925. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  9926. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  9927. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  9928. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  9929. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  9930. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  9931. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  9932. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  9933. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  9934. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  9935. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  9936. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  9937. packet2->setArrayDataByName("reagent", "Alcohol");
  9938. packet2->setArrayDataByName("consumed", "123");
  9939. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  9940. packet2->setSubstructDataByName("spell_info", "id", 8308);
  9941. packet2->setSubstructDataByName("spell_info", "icon", 303);
  9942. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  9943. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  9944. packet2->setSubstructDataByName("spell_info", "type", 2);
  9945. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  9946. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  9947. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  9948. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  9949. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  9950. EQ2Packet* outapp = packet2->serialize();
  9951. DumpPacket(outapp);
  9952. client->QueuePacket(outapp);
  9953. safe_delete(packet2);
  9954. }
  9955. }
  9956. return;
  9957. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  9958. if (!p) return;
  9959. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9960. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  9961. //}
  9962. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9963. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  9964. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  9965. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  9966. if (packet) {
  9967. client->QueuePacket(packet->serialize());
  9968. safe_delete(packet);
  9969. }
  9970. }*/
  9971. /*if (client->GetCurrentZone()->Grid != nullptr) {
  9972. int32 numFaces = 0;
  9973. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  9974. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  9975. map<int32, vector<Face*> >::iterator itr;
  9976. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  9977. numFaces += (*itr).second.size();
  9978. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  9979. }*/
  9980. //uchar blah[] = {
  9981. // 1208 - OP_EQUpdateStoreCmd
  9982. // /*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
  9983. // /*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
  9984. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  9985. // /*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
  9986. /*};
  9987. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9988. int8 val = 0;
  9989. int16 pos = 0;
  9990. int idx = 0;
  9991. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  9992. pos = atoi(sep2->arg[idx]);
  9993. val = atoi(sep2->arg[idx+1]);
  9994. memset(blah+pos, val, 1);
  9995. idx+=2;
  9996. }
  9997. DumpPacket(blah, sizeof(blah));
  9998. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  9999. if (client->GetPlayer()->GetTarget()) {
  10000. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  10001. if (packet) {
  10002. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10003. packet->setDataByName("size", 0);
  10004. packet->setDataByName("unknown2", 0);
  10005. EQ2Packet* app = packet->serialize();
  10006. client->QueuePacket(app);
  10007. safe_delete(packet);
  10008. }
  10009. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  10010. if (set_pov) {
  10011. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10012. EQ2Packet* app_pov = set_pov->serialize();
  10013. client->QueuePacket(app_pov);
  10014. safe_delete(set_pov);
  10015. }
  10016. }
  10017. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10018. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  10019. if (packet) {
  10020. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  10021. packet->setDataByName("Type", atoi(sep2->arg[0]));
  10022. else
  10023. packet->setDataByName("Type", 2);
  10024. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  10025. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  10026. else
  10027. packet->setDataByName("race_id", 0);
  10028. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  10029. packet->setDataByName("gender", atoi(sep2->arg[2]));
  10030. else
  10031. packet->setDataByName("gender", 2);
  10032. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  10033. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  10034. else
  10035. packet->setDataByName("unknown", 0, 0);
  10036. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  10037. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  10038. else
  10039. packet->setDataByName("unknown", 0, 1);
  10040. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  10041. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  10042. else
  10043. packet->setDataByName("unknown", 0, 2);
  10044. client->QueuePacket(packet->serialize());
  10045. }
  10046. safe_delete(packet);
  10047. safe_delete(sep2);
  10048. }
  10049. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  10050. const char *channel_name;
  10051. if (sep == NULL || !sep->IsSet(0)) {
  10052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  10053. PrintSep(sep);
  10054. return;
  10055. }
  10056. channel_name = sep->arg[0];
  10057. if (!chat.IsInChannel(client, channel_name))
  10058. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  10059. else if (!chat.LeaveChannel(client, channel_name))
  10060. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  10061. }
  10062. /*
  10063. Function:
  10064. Purpose :
  10065. Params :
  10066. Dev :
  10067. Example :
  10068. */
  10069. void Commands::Command_WeaponStats(Client* client)
  10070. {
  10071. Player* player = client->GetPlayer();
  10072. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10073. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10074. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10075. client->SimpleMessage(0, "Primary:");
  10076. if (primary) {
  10077. client->Message(0, "Name: %s", primary->name.c_str());
  10078. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  10079. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  10080. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  10081. client->Message(0, "Proc Percent: %d%%", 0);
  10082. client->Message(0, "Procs Per Minute: %d", 0);
  10083. }
  10084. else {
  10085. client->SimpleMessage(0, "Name: fist");
  10086. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  10087. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  10088. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  10089. client->Message(0, "Proc Percent: %d%%", 0);
  10090. client->Message(0, "Procs Per Minute: %d", 0);
  10091. }
  10092. client->SimpleMessage(0, " ");
  10093. client->SimpleMessage(0, " ");
  10094. if (secondary) {
  10095. client->SimpleMessage(0, "Secondary:");
  10096. client->Message(0, "Name: %s", secondary->name.c_str());
  10097. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  10098. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  10099. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  10100. client->Message(0, "Proc Percent: %d%%", 0);
  10101. client->Message(0, "Procs Per Minute: %d", 0);
  10102. client->SimpleMessage(0, " ");
  10103. client->SimpleMessage(0, " ");
  10104. }
  10105. client->SimpleMessage(0, "Ranged:");
  10106. if (ranged) {
  10107. client->Message(0, "Name: %s", ranged->name.c_str());
  10108. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  10109. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  10110. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  10111. client->Message(0, "Proc Percent: %d%%", 0);
  10112. client->Message(0, "Procs Per Minute: %d", 0);
  10113. }
  10114. else
  10115. client->SimpleMessage(0, "None");
  10116. }
  10117. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  10118. const char *channel_name;
  10119. if (sep == NULL || !sep->IsSet(0)) {
  10120. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  10121. return;
  10122. }
  10123. channel_name = sep->arg[0];
  10124. if (!chat.ChannelExists(channel_name))
  10125. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  10126. else
  10127. chat.SendChannelUserList(client, channel_name);
  10128. }
  10129. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  10130. {
  10131. ZoneServer* zone = 0;
  10132. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  10133. if (zone_id > 0)
  10134. {
  10135. zone = zone_list.Get(zone_id, false);
  10136. if (zone)
  10137. {
  10138. zone->SetSafeX(client->GetPlayer()->GetX());
  10139. zone->SetSafeY(client->GetPlayer()->GetY());
  10140. zone->SetSafeZ(client->GetPlayer()->GetZ());
  10141. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  10142. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  10143. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  10144. else
  10145. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  10146. }
  10147. }
  10148. }
  10149. /*
  10150. Function:
  10151. Purpose :
  10152. Params :
  10153. Dev :
  10154. Example :
  10155. */
  10156. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  10157. {
  10158. ZoneInfo* zone_info = new ZoneInfo;
  10159. if (sep && sep->arg[0])
  10160. {
  10161. if (sep->IsNumber(0))
  10162. zone_info->id = atoi(sep->arg[0]);
  10163. else
  10164. zone_info->id = database.GetZoneID(sep->arg[0]);
  10165. if (zone_info->id > 0)
  10166. {
  10167. database.LoadZoneInfo(zone_info);
  10168. 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);
  10169. 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);
  10170. 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);
  10171. 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);
  10172. 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);
  10173. 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);
  10174. 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);
  10175. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  10176. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  10177. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  10178. }
  10179. else
  10180. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10181. }
  10182. else
  10183. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  10184. safe_delete(zone_info);
  10185. }
  10186. /*
  10187. Function:
  10188. Purpose :
  10189. Params :
  10190. Dev :
  10191. Example :
  10192. */
  10193. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  10194. {
  10195. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  10196. {
  10197. ZoneServer* zone = 0;
  10198. int32 zone_id = 0;
  10199. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  10200. {
  10201. zone_id = atoi(sep->arg[0]);
  10202. zone = zone_list.Get(atoi(sep->arg[0]), false);
  10203. }
  10204. else
  10205. {
  10206. zone_id = database.GetZoneID(sep->arg[0]);
  10207. if (zone_id > 0)
  10208. zone = zone_list.Get(sep->arg[0], false);
  10209. }
  10210. if (zone_id > 0)
  10211. {
  10212. if (zone_set_values.count(string(sep->arg[1])) > 0)
  10213. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  10214. else
  10215. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  10216. }
  10217. else
  10218. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10219. }
  10220. else
  10221. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  10222. }
  10223. void Commands::Command_Rain(Client* client, Seperator* sep) {
  10224. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10225. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  10226. return;
  10227. }
  10228. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  10229. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  10230. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  10231. }
  10232. void Commands::Command_Wind(Client* client, Seperator* sep) {
  10233. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10234. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  10235. return;
  10236. }
  10237. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  10238. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  10239. }
  10240. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  10241. Spawn* spawn = client->GetPlayer()->GetTarget();
  10242. if(spawn) {
  10243. client->SetMerchantTransaction(spawn);
  10244. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  10245. client->SendHailCommand(spawn);
  10246. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  10247. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  10248. client->SendBuyMerchantList(sell);
  10249. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  10250. client->SendSellMerchantList(sell);
  10251. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  10252. client->SendBuyBackList(sell);
  10253. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10254. if (packet) {
  10255. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  10256. packet->setDataByName("type", 16);
  10257. EQ2Packet* outapp = packet->serialize();
  10258. if (outapp)
  10259. client->QueuePacket(outapp);
  10260. safe_delete(packet);
  10261. }
  10262. }
  10263. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  10264. client->SendRepairList();
  10265. }
  10266. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  10267. }
  10268. void Commands::Command_Weather(Client* client, Seperator* sep)
  10269. {
  10270. //PrintSep(sep, "Weather");
  10271. if( sep && sep->arg[0] )
  10272. {
  10273. ZoneServer* zsZone = client->GetCurrentZone();
  10274. const char* value = sep->arg[0];
  10275. // process single-param commands first
  10276. if( strncasecmp(value, "details", strlen(value)) == 0 )
  10277. {
  10278. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  10279. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  10280. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  10281. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  10282. }
  10283. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  10284. {
  10285. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10286. zsZone->ProcessWeather();
  10287. }
  10288. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  10289. {
  10290. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  10291. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  10292. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  10293. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  10294. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  10295. zsZone->SetWeatherPattern(1);
  10296. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  10297. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  10298. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  10299. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10300. zsZone->ProcessWeather();
  10301. }
  10302. // process commands with params
  10303. if( sep->arg[1] )
  10304. {
  10305. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  10306. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  10307. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  10308. zsZone->SetWeatherType(atoi(sep->arg[1]));
  10309. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  10310. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  10311. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  10312. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  10313. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  10314. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  10315. }
  10316. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  10317. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  10318. zsZone->SetRain(zsZone->GetCurrentWeather());
  10319. }
  10320. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  10321. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  10322. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  10323. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  10324. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10325. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  10326. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10327. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  10328. }
  10329. }
  10330. else
  10331. {
  10332. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  10333. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  10334. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  10335. return;
  10336. }
  10337. }
  10338. void Commands::Command_Select(Client* client, Seperator* sep) {
  10339. if (sep && sep->arg[1]) {
  10340. Spawn* spawn = client->GetPlayer()->GetTarget();
  10341. if (spawn && strlen(sep->arg[1]) > 0)
  10342. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  10343. }
  10344. }
  10345. /*
  10346. Function: Command_ConsumeFood()
  10347. Purpose : Consume Food/Drink and apply mods
  10348. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  10349. Dev : Zcoretri
  10350. Example : /consume_food 22
  10351. */
  10352. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  10353. if (sep && sep->arg[0] && sep->IsNumber(0))
  10354. {
  10355. Player* player = client->GetPlayer();
  10356. int8 slot = atoi(sep->arg[0]);
  10357. Item* item = player->GetEquipmentList()->GetItem(slot);
  10358. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  10359. {
  10360. client->Message(CHANNEL_NARRATIVE, "If you ate anymore you would explode!");
  10361. return;
  10362. }
  10363. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  10364. {
  10365. client->Message(CHANNEL_NARRATIVE, "If you drank anymore you would explode!");
  10366. return;
  10367. }
  10368. client->ConsumeFoodDrink(item, slot);
  10369. }
  10370. }
  10371. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  10372. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10373. if (atoi(sep->arg[0]) == 1) {
  10374. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  10375. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  10376. client->GetPlayer()->SetCharSheetChanged(true);
  10377. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  10378. }
  10379. else {
  10380. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  10381. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  10382. client->GetPlayer()->SetCharSheetChanged(true);
  10383. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  10384. }
  10385. }
  10386. else
  10387. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  10388. }
  10389. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  10390. {
  10391. if(sep)
  10392. {
  10393. string data;
  10394. if(sep->arg[0]){
  10395. data = string(sep->arg[0]);
  10396. }
  10397. for(int i=1;i<sep->GetMaxArgNum();i++){
  10398. if(sep->arg[i])
  10399. data.append(" ").append(sep->arg[i]);
  10400. }
  10401. const char* target_name = 0;
  10402. int32 spawn_id = 0;
  10403. if(client->GetPlayer()->GetTarget())
  10404. {
  10405. target_name = client->GetPlayer()->GetTarget()->GetName();
  10406. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10407. }
  10408. else
  10409. target_name = "N/A";
  10410. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  10411. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  10412. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  10413. else
  10414. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  10415. }
  10416. }
  10417. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  10418. PrintSep(sep, "Command_Attune_Inv");
  10419. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10420. // Get the item index from the first parameter
  10421. int16 index = atoi(sep->arg[0]);
  10422. // Check to see if this is a valid item index for the player, if not exit out of the function
  10423. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  10424. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  10425. return;
  10426. }
  10427. // Get the item
  10428. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  10429. if(item) {
  10430. // Valid item lets check to make sure this item is attunable, if not return out
  10431. if (!item->CheckFlag(ATTUNEABLE)) {
  10432. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  10433. return;
  10434. }
  10435. // Remove the attunable flag
  10436. item->generic_info.item_flags -= ATTUNEABLE;
  10437. // Set the attuned flag
  10438. item->generic_info.item_flags += ATTUNED;
  10439. // Flag this item for saving
  10440. item->save_needed = true;
  10441. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  10442. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  10443. EQ2Packet* outapp = 0;
  10444. for (int32 i=0;i<packets.size();i++) {
  10445. outapp = packets[i];
  10446. if(outapp)
  10447. client->QueuePacket(outapp);
  10448. }
  10449. }
  10450. }
  10451. }
  10452. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  10453. PrintSep(sep, "Command_Reset_Zone_Timer");
  10454. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10455. int32 db_id = atoul(sep->arg[0]);
  10456. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  10457. if (data) {
  10458. // TODO: add a check to timers to ensure it can be reset
  10459. // Delete the character from the instance
  10460. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  10461. data->instance_id = 0;
  10462. // Update the success time and set to 0 so the player can enter it again
  10463. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  10464. data->last_success_timestamp = 0;
  10465. }
  10466. }*/
  10467. }
  10468. void Commands::Command_Player(Client* client, Seperator* sep) {
  10469. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  10470. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  10471. }
  10472. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  10473. // /player coins add 10
  10474. // /player coins add plat 10
  10475. Player* player = client->GetPlayer();
  10476. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  10477. player = (Player*)player->GetTarget();
  10478. if (sep && sep->arg[0] && sep->arg[1]) {
  10479. const char* action = sep->arg[0];
  10480. int64 value = 0;
  10481. if (strncasecmp(action, "add", strlen(action)) == 0) {
  10482. if (sep->IsNumber(1)) {
  10483. value = atoi64(sep->arg[1]);
  10484. player->AddCoins(value);
  10485. if (client->GetPlayer() == player)
  10486. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10487. else {
  10488. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10489. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10490. }
  10491. return;
  10492. }
  10493. else if (sep->arg[2] && sep->IsNumber(2)) {
  10494. const char* type = sep->arg[1];
  10495. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  10496. value = atoi64(sep->arg[2]);
  10497. }
  10498. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  10499. value = atoi64(sep->arg[2]) * 100;
  10500. }
  10501. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  10502. value = atoi64(sep->arg[2]) * 10000;
  10503. }
  10504. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  10505. value = atoi64(sep->arg[2]) * 1000000;
  10506. }
  10507. player->AddCoins(value);
  10508. if (client->GetPlayer() == player)
  10509. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10510. else {
  10511. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10512. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10513. }
  10514. return;
  10515. }
  10516. }
  10517. }
  10518. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  10519. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  10520. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  10521. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  10522. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  10523. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  10524. }
  10525. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  10526. PrintSep(sep, "ACHIEVEMENT_ADD");
  10527. if (sep && sep->IsSet(0)) {
  10528. int32 spell_id = atoul(sep->arg[1]);
  10529. int8 spell_tier = 0;
  10530. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10531. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10532. // addspellbookentry here
  10533. if (spell_tier >= data->maxRank) {
  10534. return;
  10535. }
  10536. if (!spell_tier) {
  10537. spell_tier = 1;
  10538. }
  10539. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10540. {
  10541. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10542. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10543. client->GetPlayer()->UnlockSpell(spell);
  10544. client->SendSpellUpdate(spell);
  10545. }
  10546. else
  10547. {
  10548. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  10549. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10550. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10551. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10552. client->GetPlayer()->UnlockSpell(spell);
  10553. client->SendSpellUpdate(spell);
  10554. }
  10555. // cast spell here
  10556. if (!spell_tier)
  10557. spell_tier = 1;
  10558. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10559. if (spell) {
  10560. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10561. }
  10562. }
  10563. else {
  10564. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10565. }
  10566. master_aa_list.DisplayAA(client, 0, 0);
  10567. }
  10568. void Commands::Command_Editor(Client* client, Seperator* sep) {
  10569. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  10570. if (packet) {
  10571. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  10572. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  10573. char command[255];
  10574. url = "browser " + url;
  10575. int32 spawn_id = 0;
  10576. int32 zone_id = 0;
  10577. string type;
  10578. if (client->GetCurrentZone())
  10579. zone_id = client->GetCurrentZone()->GetZoneID();
  10580. if (client->GetPlayer()->GetTarget()) {
  10581. Spawn* target = client->GetPlayer()->GetTarget();
  10582. if (target->IsWidget())
  10583. type = "widgets";
  10584. else if (target->IsSign())
  10585. type = "signs";
  10586. else if (target->IsObject())
  10587. type = "objects";
  10588. else if (target->IsNPC())
  10589. type = "npcs";
  10590. else if (target->IsGroundSpawn())
  10591. type = "ground";
  10592. else
  10593. type = "spawn";
  10594. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10595. }
  10596. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  10597. packet->setDataByName("accept_command", command);
  10598. }
  10599. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  10600. char command[255];
  10601. url = "browser " + url;
  10602. if (client->GetPlayer()->GetTarget())
  10603. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  10604. packet->setDataByName("accept_command", command);
  10605. }
  10606. else {
  10607. string command = "browser " + url;
  10608. packet->setDataByName("accept_command", command.c_str());
  10609. }
  10610. packet->setDataByName("text", "Open the web editor?");
  10611. packet->setDataByName("accept_text", "Open");
  10612. packet->setDataByName("cancel_text", "Cancel");
  10613. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  10614. packet->setDataByName("unknown2", 50);
  10615. packet->setDataByName("unknown4", 1);
  10616. client->QueuePacket(packet->serialize());
  10617. safe_delete(packet);
  10618. }
  10619. }
  10620. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  10621. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10622. return;
  10623. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10624. if(client->GetCurrentRez()->active)
  10625. client->AcceptResurrection();
  10626. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10627. }
  10628. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  10629. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10630. return;
  10631. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10632. if(client->GetCurrentRez()->active)
  10633. client->GetCurrentRez()->should_delete = true;
  10634. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10635. }
  10636. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  10637. PrintSep(sep, "Switch_AA_Profile");
  10638. if (sep && sep->IsSet(0)) {
  10639. string type = sep->arg[0];
  10640. int8 newtemplate = atoul(sep->arg[1]);
  10641. master_aa_list.DisplayAA(client, newtemplate, 1);
  10642. }
  10643. }
  10644. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  10645. PrintSep(sep, "Get_AA_Xml");
  10646. if (sep && sep->IsSet(0)) {
  10647. string tabnum = sep->arg[0];
  10648. string spellid = sep->arg[1];
  10649. }
  10650. }
  10651. void Commands::Add_AA(Client* client, Seperator* sep) {
  10652. PrintSep(sep, "Add_AA");
  10653. if (sep && sep->IsSet(0)) {
  10654. int32 spell_id = atoul(sep->arg[1]);
  10655. int8 spell_tier = 0;
  10656. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10657. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10658. // addspellbookentry here
  10659. if(!data) {
  10660. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  10661. return;
  10662. }
  10663. if (spell_tier >= data->maxRank) {
  10664. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  10665. return;
  10666. }
  10667. if (!spell_tier) {
  10668. spell_tier = 1;
  10669. }
  10670. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10671. {
  10672. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10673. if(spell)
  10674. {
  10675. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10676. client->GetPlayer()->UnlockSpell(spell);
  10677. client->SendSpellUpdate(spell);
  10678. }
  10679. }
  10680. else
  10681. {
  10682. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10683. if(spell)
  10684. {
  10685. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10686. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10687. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10688. client->GetPlayer()->UnlockSpell(spell);
  10689. client->SendSpellUpdate(spell);
  10690. }
  10691. }
  10692. // cast spell here
  10693. if (!spell_tier)
  10694. spell_tier = 1;
  10695. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10696. if (spell) {
  10697. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10698. }
  10699. }
  10700. else {
  10701. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10702. }
  10703. master_aa_list.DisplayAA(client, 0, 0);
  10704. }
  10705. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  10706. PrintSep(sep, "Commit_AA_Profile");
  10707. if (sep && sep->IsSet(0)) {
  10708. }
  10709. }
  10710. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  10711. PrintSep(sep, "Begin_AA_Profile");
  10712. if (sep && sep->IsSet(0)) {
  10713. master_aa_list.DisplayAA(client, 100, 2);
  10714. }
  10715. }
  10716. void Commands::Back_AA(Client* client, Seperator* sep) {
  10717. if (sep && sep->IsSet(0)) {
  10718. PrintSep(sep, "Back_AA");
  10719. }
  10720. }
  10721. void Commands::Remove_AA(Client* client, Seperator* sep) {
  10722. if (sep && sep->IsSet(0)) {
  10723. PrintSep(sep, "Remove_AA");
  10724. }
  10725. }
  10726. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  10727. MasterAAList master_aa_list;
  10728. PrintSep(sep, "Cancel_AA_Profile");
  10729. master_aa_list.DisplayAA(client, 0, 0);
  10730. }
  10731. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  10732. if (sep && sep->IsSet(0)) {
  10733. PrintSep(sep, "Save_AA_Profile");
  10734. }
  10735. }
  10736. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  10737. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  10738. if (!sep->IsNumber(0)) return;
  10739. int32 request_id = atoul(sep->arg[0]);
  10740. if (!sep->IsNumber(1)) return;
  10741. sint32 item_id = atoi(sep->arg[1]);
  10742. if (client->IsCurrentTransmuteID(request_id)) {
  10743. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  10744. }
  10745. else if (client->IsCurrentTransmuteID(item_id)) {
  10746. if (!sep->IsSet(2)) return;
  10747. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  10748. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  10749. }
  10750. }
  10751. }
  10752. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  10753. if(sep)
  10754. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  10755. }
  10756. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  10757. if(sep && sep->arg[0][0] && sep->arg[1][0])
  10758. {
  10759. char* name = sep->arg[0];
  10760. char* zoneName = sep->arg[1];
  10761. char query[256];
  10762. snprintf(query, 256, "UPDATE characters c, zones z set c.x = z.safe_x, c.y = z.safe_y, c.z = z.safe_z, c.heading = z.safe_heading, c.current_zone_id = z.id where c.name = '%s' and z.name='%s'", name, zoneName);
  10763. if (database.RunQuery(query, strnlen(query, 256)))
  10764. {
  10765. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  10766. }
  10767. else
  10768. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  10769. }
  10770. }
  10771. void Commands::Command_Mood(Client* client, Seperator* sep) {
  10772. Player* player = client->GetPlayer();
  10773. if( sep && sep->arg[0] )
  10774. {
  10775. const char* value = sep->arg[0];
  10776. InfoStruct* info = player->GetInfoStruct();
  10777. int32 cid = client->GetCharacterID();
  10778. char* characterName = database.GetCharacterName(cid);
  10779. char tmp[1024]; // our emote string "xyz appears zyx"
  10780. //char properties vals
  10781. char* pname = "mood";
  10782. char* pval; // mood value
  10783. bool pt; //used to verify return from DB.
  10784. //This should never be seen.
  10785. sprintf(tmp, " ");
  10786. if( strncasecmp(value, "angry", strlen(value)) == 0 )
  10787. {
  10788. sprintf(tmp, "%s appears angry", characterName);
  10789. pval = "11852";
  10790. player->SetMoodState(11852, 1);
  10791. info->set_mood(11852);
  10792. pt = database.insertCharacterProperty(client, pname, pval);
  10793. }
  10794. else if( strncasecmp(value, "afraid", strlen(value)) == 0 )
  10795. {
  10796. sprintf(tmp, "%s appears afraid", characterName);
  10797. pval = "11851";
  10798. player->SetMoodState(11851, 1);
  10799. info->set_mood(11851);
  10800. pt = database.insertCharacterProperty(client, pname, pval);
  10801. }
  10802. else if( strncasecmp(value, "happy", strlen(value)) == 0 )
  10803. {
  10804. sprintf(tmp, "%s appears happy", characterName);
  10805. pval = "11854";
  10806. player->SetMoodState(11854, 1);
  10807. info->set_mood(11854);
  10808. pt = database.insertCharacterProperty(client, pname, pval);
  10809. }
  10810. else if( strncasecmp(value, "sad", strlen(value)) == 0 ) {
  10811. sprintf(tmp, "%s appears sad", characterName);
  10812. pval = "11856";
  10813. player->SetMoodState(11856, 1);
  10814. info->set_mood(11856);
  10815. pt = database.insertCharacterProperty(client, pname, pval);
  10816. }
  10817. else if( strncasecmp(value, "tired", strlen(value)) == 0 )
  10818. {
  10819. sprintf(tmp, "%s appears tired", characterName);
  10820. pval = "11857";
  10821. player->SetMoodState(11857, 1);
  10822. info->set_mood(11857);
  10823. pt = database.insertCharacterProperty(client, pname, pval);
  10824. }
  10825. else if( strncasecmp(value, "none", strlen(value)) == 0 )
  10826. {
  10827. //using 11855 mood_idle for none, I assume thats what its for?
  10828. pval = "11855";
  10829. player->SetMoodState(11855, 1);
  10830. info->set_mood(11855);
  10831. pt = database.insertCharacterProperty(client, pname, pval);
  10832. //return since we have nothing left to do. No emote for none.
  10833. return;
  10834. }else{
  10835. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  10836. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  10837. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  10838. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  10839. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  10840. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  10841. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  10842. return;
  10843. }
  10844. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, tmp);
  10845. return;
  10846. }
  10847. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  10848. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  10849. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  10850. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  10851. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  10852. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  10853. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  10854. return;
  10855. }