Commands.cpp 429 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813
  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 <boost/algorithm/string/predicate.hpp>
  18. #include <boost/algorithm/string.hpp>
  19. #include "Commands.h"
  20. #include "../ClientPacketFunctions.h"
  21. #include "../../common/version.h"
  22. #include "../../common/seperator.h"
  23. #include "../../common/servertalk.h"
  24. #include "../WorldDatabase.h"
  25. #include "../World.h"
  26. #include "../../common/ConfigReader.h"
  27. #include "../VisualStates.h"
  28. #include "../../common/debug.h"
  29. #include "../LuaInterface.h"
  30. #include "../Quests.h"
  31. #include "../client.h"
  32. #include "../NPC.h"
  33. #include "../Guilds/Guild.h"
  34. #include "../SpellProcess.h"
  35. #include "../Tradeskills/Tradeskills.h"
  36. #include "../../common/Log.h"
  37. #include "../../common/MiscFunctions.h"
  38. #include "../Languages.h"
  39. #include "../IRC/IRC.h"
  40. #include "../Traits/Traits.h"
  41. #include "../Chat/Chat.h"
  42. #include "../Rules/Rules.h"
  43. #include "../AltAdvancement/AltAdvancement.h"
  44. #include "../RaceTypes/RaceTypes.h"
  45. #include "../classes.h"
  46. #include "../Transmute.h"
  47. #include "../Bots/Bot.h"
  48. extern WorldDatabase database;
  49. extern MasterSpellList master_spell_list;
  50. extern MasterTraitList master_trait_list;
  51. extern MasterRecipeList master_recipe_list;
  52. extern MasterRecipeBookList master_recipebook_list;
  53. extern World world;
  54. extern ClientList client_list;
  55. extern ConfigReader configReader;
  56. extern VisualStates visual_states;
  57. extern ZoneList zone_list;
  58. extern LuaInterface* lua_interface;
  59. extern MasterQuestList master_quest_list;
  60. extern MasterCollectionList master_collection_list;
  61. extern MasterSkillList master_skill_list;
  62. extern MasterFactionList master_faction_list;
  63. extern GuildList guild_list;
  64. extern MasterLanguagesList master_languages_list;
  65. extern IRC irc;
  66. extern Chat chat;
  67. extern RuleManager rule_manager;
  68. extern MasterAAList master_aa_list;
  69. extern MasterRaceTypeList race_types_list;
  70. extern Classes classes;
  71. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  72. #if defined(__GNUC__)
  73. #define stricmp strcasecmp
  74. #define strnicmp strncasecmp
  75. #endif
  76. EQ2Packet* RemoteCommands::serialize(){
  77. buffer.clear();
  78. vector<EQ2_RemoteCommandString>::iterator command_list;
  79. buffer.append((char*)&num_commands, sizeof(int16));
  80. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  81. AddDataCommand(&(*command_list));
  82. }
  83. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  84. return app;
  85. }
  86. Commands::Commands(){
  87. remote_commands = new RemoteCommands();
  88. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  89. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  90. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  91. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  92. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  93. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  94. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  95. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  96. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  97. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  98. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  99. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  100. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  101. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  102. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  103. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  104. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  105. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  106. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  107. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  108. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  109. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  110. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  111. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  112. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  113. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  114. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  115. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  116. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  117. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  118. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  119. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  120. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  121. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  122. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  123. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  124. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  125. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  126. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  127. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  128. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  129. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  130. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  131. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  132. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  133. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  134. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  135. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  136. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  137. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  138. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  139. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  140. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  141. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  142. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  143. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  144. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  145. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  146. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  147. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  148. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  149. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  150. spawn_set_values["skin_color"] = SPAWN_SET_SKIN_COLOR;
  151. spawn_set_values["aaxp_rewards"] = SPAWN_SET_AAXP_REWARDS;
  152. spawn_set_values["hair_color1"] = SPAWN_SET_HAIR_COLOR1;
  153. spawn_set_values["hair_color2"] = SPAWN_SET_HAIR_COLOR2;
  154. spawn_set_values["hair_type_color"] = SPAWN_SET_HAIR_TYPE_COLOR;
  155. spawn_set_values["hair_face_color"] = SPAWN_SET_HAIR_FACE_COLOR;
  156. spawn_set_values["hair_type_highlight_color"] = SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR;
  157. spawn_set_values["face_hairlight_color"] = SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR;
  158. spawn_set_values["hair_highlight"] = SPAWN_SET_HAIR_HIGHLIGHT;
  159. spawn_set_values["model_color"] = SPAWN_SET_MODEL_COLOR;
  160. spawn_set_values["eye_color"] = SPAWN_SET_EYE_COLOR;
  161. spawn_set_values["soga_skin_color"] = SPAWN_SET_SOGA_SKIN_COLOR;
  162. spawn_set_values["soga_hair_color1"] = SPAWN_SET_SOGA_HAIR_COLOR1;
  163. spawn_set_values["soga_hair_color2"] = SPAWN_SET_SOGA_HAIR_COLOR2;
  164. spawn_set_values["soga_hair_type_color"] = SPAWN_SET_SOGA_HAIR_TYPE_COLOR;
  165. spawn_set_values["soga_hair_face_color"] = SPAWN_SET_SOGA_HAIR_FACE_COLOR;
  166. spawn_set_values["soga_hair_type_highlight_color"] = SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR;
  167. spawn_set_values["soga_face_hairlight_color"] = SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR;
  168. spawn_set_values["soga_hair_highlight"] = SPAWN_SET_SOGA_HAIR_HIGHLIGHT;
  169. spawn_set_values["soga_model_color"] = SPAWN_SET_SOGA_MODEL_COLOR;
  170. spawn_set_values["soga_eye_color"] = SPAWN_SET_SOGA_EYE_COLOR;
  171. spawn_set_values["cheek_type"] = SPAWN_SET_CHEEK_TYPE;
  172. spawn_set_values["chin_type"] = SPAWN_SET_CHIN_TYPE;
  173. spawn_set_values["ear_type"] = SPAWN_SET_EAR_TYPE;
  174. spawn_set_values["eye_brow_type"] = SPAWN_SET_EYE_BROW_TYPE;
  175. spawn_set_values["eye_type"] = SPAWN_SET_EYE_TYPE;
  176. spawn_set_values["lip_type"] = SPAWN_SET_LIP_TYPE;
  177. spawn_set_values["nose_type"] = SPAWN_SET_NOSE_TYPE;
  178. spawn_set_values["body_size"] = SPAWN_SET_BODY_SIZE;
  179. spawn_set_values["body_age"] = SPAWN_SET_BODY_AGE;
  180. spawn_set_values["soga_cheek_type"] = SPAWN_SET_SOGA_CHEEK_TYPE;
  181. spawn_set_values["soga_chin_type"] = SPAWN_SET_SOGA_CHIN_TYPE;
  182. spawn_set_values["soga_ear_type"] = SPAWN_SET_SOGA_EAR_TYPE;
  183. spawn_set_values["soga_eye_brow_type"] = SPAWN_SET_SOGA_EYE_BROW_TYPE;
  184. spawn_set_values["soga_eye_type"] = SPAWN_SET_SOGA_EYE_TYPE;
  185. spawn_set_values["soga_lip_type"] = SPAWN_SET_SOGA_LIP_TYPE;
  186. spawn_set_values["soga_nose_type"] = SPAWN_SET_SOGA_NOSE_TYPE;
  187. spawn_set_values["soga_body_size"] = SPAWN_SET_SOGA_BODY_SIZE;
  188. spawn_set_values["soga_body_age"] = SPAWN_SET_SOGA_BODY_AGE;
  189. spawn_set_values["attack_type"] = SPAWN_SET_ATTACK_TYPE;
  190. spawn_set_values["race_type"] = SPAWN_SET_RACE_TYPE;
  191. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  192. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  193. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  194. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  195. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  196. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  197. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  198. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  199. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  200. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  201. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  202. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  203. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  204. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  205. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  206. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  207. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  208. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  209. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  210. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  211. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  212. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  213. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  214. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  215. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  216. }
  217. Commands::~Commands() {
  218. safe_delete(remote_commands);
  219. }
  220. int32 Commands::GetSpawnSetType(string val){
  221. if(spawn_set_values.count(val) > 0)
  222. return spawn_set_values[val];
  223. return 0xFFFFFFFF;
  224. }
  225. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value, int8 index){
  226. if(!target)
  227. return false;
  228. int32 val = 0;
  229. try{
  230. if(type != SPAWN_SET_VALUE_NAME &&
  231. !(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))
  232. {
  233. switch(type)
  234. {
  235. case SPAWN_SET_SKIN_COLOR:
  236. case SPAWN_SET_HAIR_COLOR1:
  237. case SPAWN_SET_HAIR_COLOR2:
  238. case SPAWN_SET_HAIR_TYPE_COLOR:
  239. case SPAWN_SET_HAIR_FACE_COLOR:
  240. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  241. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  242. case SPAWN_SET_HAIR_HIGHLIGHT:
  243. case SPAWN_SET_EYE_COLOR:
  244. case SPAWN_SET_SOGA_SKIN_COLOR:
  245. case SPAWN_SET_SOGA_HAIR_COLOR1:
  246. case SPAWN_SET_SOGA_HAIR_COLOR2:
  247. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  248. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  249. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  250. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  251. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  252. case SPAWN_SET_SOGA_EYE_COLOR:
  253. case SPAWN_SET_RACE_TYPE:
  254. // ignore these are colors can't pass as a integer value
  255. break;
  256. default:
  257. val = atoul(value);
  258. }
  259. }
  260. }
  261. catch(...){
  262. if(client)
  263. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  264. return false;
  265. }
  266. if(temporary){
  267. char tmp[128] = {0};
  268. switch(type){
  269. case SPAWN_SET_VALUE_NAME:{
  270. sprintf(tmp, "%s", target->GetName());
  271. target->SetName(value);
  272. if(target->GetZone())
  273. target->GetZone()->SendUpdateTitles(target);
  274. break;
  275. }
  276. case SPAWN_SET_VALUE_X_OFFSET:
  277. {
  278. sprintf(tmp, "%f", target->GetXOffset());
  279. target->SetXOffset(float(val));
  280. break;
  281. }
  282. case SPAWN_SET_VALUE_Y_OFFSET:
  283. {
  284. sprintf(tmp, "%f", target->GetYOffset());
  285. target->SetYOffset(float(val));
  286. break;
  287. }
  288. case SPAWN_SET_VALUE_Z_OFFSET:
  289. {
  290. sprintf(tmp, "%f", target->GetZOffset());
  291. target->SetZOffset(float(val));
  292. break;
  293. }
  294. case SPAWN_SET_VALUE_EXPIRE: {
  295. sprintf(tmp, "%u", target->GetExpireTime());
  296. target->SetExpireTime(val);
  297. break;
  298. }
  299. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  300. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  301. target->SetExpireOffsetTime(val);
  302. break;
  303. }
  304. case SPAWN_SET_VALUE_SUB_TITLE: {
  305. sprintf(tmp, "%s", target->GetSubTitle());
  306. target->SetSubTitle(value);
  307. if(target->GetZone())
  308. target->GetZone()->SendUpdateTitles(target);
  309. break;
  310. }
  311. case SPAWN_SET_VALUE_LEVEL:{
  312. sprintf(tmp, "%i", target->GetLevel());
  313. target->SetLevel(val, send_update);
  314. break;
  315. }
  316. case SPAWN_SET_VALUE_DIFFICULTY:{
  317. sprintf(tmp, "%i", target->GetEncounterLevel());
  318. target->SetEncounterLevel(val, send_update);
  319. break;
  320. }
  321. case SPAWN_SET_VALUE_MODEL_TYPE:{
  322. sprintf(tmp, "%i", target->GetModelType());
  323. target->SetModelType(val, send_update);
  324. break;
  325. }
  326. case SPAWN_SET_VALUE_CLASS:{
  327. sprintf(tmp, "%i", target->GetAdventureClass());
  328. target->SetAdventureClass(val, send_update);
  329. break;
  330. }
  331. case SPAWN_SET_VALUE_GENDER:{
  332. sprintf(tmp, "%i", target->GetGender());
  333. target->SetGender(val, send_update);
  334. break;
  335. }
  336. case SPAWN_SET_VALUE_SHOW_NAME:{
  337. sprintf(tmp, "%i", target->GetShowName());
  338. target->SetShowName(val, send_update);
  339. break;
  340. }
  341. case SPAWN_SET_VALUE_ATTACKABLE:{
  342. sprintf(tmp, "%i", target->GetAttackable());
  343. target->SetAttackable(val, send_update);
  344. break;
  345. }
  346. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  347. sprintf(tmp, "%i", target->GetShowLevel());
  348. target->SetShowLevel(val, send_update);
  349. break;
  350. }
  351. case SPAWN_SET_VALUE_TARGETABLE:{
  352. sprintf(tmp, "%i", target->GetTargetable());
  353. target->SetTargetable(val, send_update);
  354. break;
  355. }
  356. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  357. sprintf(tmp, "%i", target->GetShowCommandIcon());
  358. target->SetShowCommandIcon(val, send_update);
  359. break;
  360. }
  361. case SPAWN_SET_VALUE_HAND_ICON:{
  362. sprintf(tmp, "%i", target->GetShowHandIcon());
  363. target->SetShowHandIcon(val, send_update);
  364. break;
  365. }
  366. case SPAWN_SET_VALUE_HAIR_TYPE:{
  367. if(target->IsEntity()){
  368. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  369. ((Entity*)target)->SetHairType(val, send_update);
  370. }
  371. break;
  372. }
  373. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  374. if(target->IsEntity()){
  375. sprintf(tmp, "%i", ((Entity*)target)->GetFacialHairType());
  376. ((Entity*)target)->SetFacialHairType(val, send_update);
  377. }
  378. break;
  379. }
  380. case SPAWN_SET_VALUE_WING_TYPE:{
  381. if(target->IsEntity()){
  382. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  383. ((Entity*)target)->SetWingType(val, send_update);
  384. }
  385. break;
  386. }
  387. case SPAWN_SET_VALUE_CHEST_TYPE:{
  388. if(target->IsEntity()){
  389. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  390. ((Entity*)target)->SetChestType(val, send_update);
  391. }
  392. break;
  393. }
  394. case SPAWN_SET_VALUE_LEGS_TYPE:{
  395. if(target->IsEntity()){
  396. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  397. ((Entity*)target)->SetLegsType(val, send_update);
  398. }
  399. break;
  400. }
  401. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  402. if(target->IsEntity()){
  403. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  404. ((Entity*)target)->SetSogaHairType(val, send_update);
  405. }
  406. break;
  407. }
  408. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  409. if(target->IsEntity()){
  410. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  411. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  412. }
  413. break;
  414. }
  415. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  416. sprintf(tmp, "%i", target->GetSogaModelType());
  417. target->SetSogaModelType(val, send_update);
  418. break;
  419. }
  420. case SPAWN_SET_VALUE_SIZE:{
  421. sprintf(tmp, "%i", target->GetSize());
  422. target->SetSize(val, send_update);
  423. break;
  424. }
  425. case SPAWN_SET_VALUE_HP:{
  426. sprintf(tmp, "%i", target->GetHP());
  427. target->SetHP(val, send_update);
  428. break;
  429. }
  430. case SPAWN_SET_VALUE_POWER:{
  431. sprintf(tmp, "%i", target->GetPower());
  432. target->SetPower(val, send_update);
  433. break;
  434. }
  435. case SPAWN_SET_VALUE_HEROIC:{
  436. sprintf(tmp, "%i", target->GetHeroic());
  437. target->SetHeroic(val, send_update);
  438. break;
  439. }
  440. case SPAWN_SET_VALUE_RESPAWN:{
  441. sprintf(tmp, "%u", target->GetRespawnTime());
  442. target->SetRespawnTime(val);
  443. break;
  444. }
  445. case SPAWN_SET_VALUE_X:{
  446. sprintf(tmp, "%f", target->GetX());
  447. target->SetX(atof(value), send_update);
  448. break;
  449. }
  450. case SPAWN_SET_VALUE_Y:{
  451. sprintf(tmp, "%f", target->GetY());
  452. target->SetY(atof(value), send_update);
  453. break;
  454. }
  455. case SPAWN_SET_VALUE_Z:{
  456. sprintf(tmp, "%f", target->GetZ());
  457. target->SetZ(atof(value), send_update);
  458. break;
  459. }
  460. case SPAWN_SET_VALUE_HEADING:{
  461. sprintf(tmp, "%f", target->GetHeading());
  462. target->SetHeading(atof(value) + 360, send_update);
  463. break;
  464. }
  465. case SPAWN_SET_VALUE_VISUAL_STATE:{
  466. sprintf(tmp, "%i", target->GetVisualState());
  467. target->SetVisualState(val, send_update);
  468. break;
  469. }
  470. case SPAWN_SET_VALUE_ACTION_STATE:{
  471. sprintf(tmp, "%i", target->GetActionState());
  472. target->SetActionState(val, send_update);
  473. break;
  474. }
  475. case SPAWN_SET_VALUE_MOOD_STATE:{
  476. sprintf(tmp, "%i", target->GetMoodState());
  477. target->SetMoodState(val, send_update);
  478. break;
  479. }
  480. case SPAWN_SET_VALUE_INITIAL_STATE:{
  481. sprintf(tmp, "%i", target->GetInitialState());
  482. target->SetInitialState(val, send_update);
  483. break;
  484. }
  485. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  486. sprintf(tmp, "%i", target->GetActivityStatus());
  487. target->SetActivityStatus(val, send_update);
  488. break;
  489. }
  490. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  491. sprintf(tmp, "%i", target->GetCollisionRadius());
  492. target->SetCollisionRadius(val, send_update);
  493. break;
  494. }
  495. case SPAWN_SET_VALUE_DEVICE_ID: {
  496. if (target->IsObject()) {
  497. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  498. ((Object*)target)->SetDeviceID(val);
  499. }
  500. break;
  501. }
  502. case SPAWN_SET_VALUE_PITCH: {
  503. sprintf(tmp, "%f", target->GetPitch());
  504. target->SetPitch(atof(value), send_update);
  505. break;
  506. }
  507. case SPAWN_SET_VALUE_ROLL: {
  508. sprintf(tmp, "%f", target->GetRoll());
  509. target->SetRoll(atof(value), send_update);
  510. break;
  511. }
  512. case SPAWN_SET_VALUE_HIDE_HOOD: {
  513. sprintf(tmp, "%i", target->appearance.hide_hood);
  514. target->SetHideHood(val);
  515. break;
  516. }
  517. case SPAWN_SET_VALUE_EMOTE_STATE: {
  518. sprintf(tmp, "%i", target->appearance.emote_state);
  519. target->SetEmoteState(val);
  520. break;
  521. }
  522. case SPAWN_SET_VALUE_ICON: {
  523. sprintf(tmp, "%i", target->GetIconValue());
  524. target->SetIcon(val);
  525. break;
  526. }
  527. case SPAWN_SET_VALUE_PREFIX: {
  528. sprintf(tmp, "%s", target->GetPrefixTitle());
  529. target->SetPrefixTitle(value);
  530. if(target->GetZone())
  531. target->GetZone()->SendUpdateTitles(target);
  532. break;
  533. }
  534. case SPAWN_SET_VALUE_SUFFIX: {
  535. sprintf(tmp, "%s", target->GetSuffixTitle());
  536. target->SetSuffixTitle(value);
  537. if(target->GetZone())
  538. target->GetZone()->SendUpdateTitles(target);
  539. break;
  540. }
  541. case SPAWN_SET_VALUE_LASTNAME: {
  542. sprintf(tmp, "%s", target->GetLastName());
  543. target->SetLastName(value);
  544. if(target->GetZone())
  545. target->GetZone()->SendUpdateTitles(target);
  546. break;
  547. }
  548. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  549. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  550. // nothing to do must reload spawns
  551. break;
  552. }
  553. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  554. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  555. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  556. break;
  557. }
  558. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  559. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  560. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  561. break;
  562. }
  563. case SPAWN_SET_VALUE_FACTION:{
  564. sprintf(tmp, "%i", target->faction_id);
  565. ZoneServer* zone = target->GetZone();
  566. if (!zone && client)
  567. zone = client->GetCurrentZone();
  568. target->faction_id = atoul(value);
  569. if(zone)
  570. {
  571. zone->RemoveDeadEnemyList(target);
  572. if(target->IsNPC())
  573. zone->AddEnemyList((NPC*)target);
  574. }
  575. break;
  576. }
  577. case SPAWN_SET_SKIN_COLOR:
  578. case SPAWN_SET_HAIR_COLOR1:
  579. case SPAWN_SET_HAIR_COLOR2:
  580. case SPAWN_SET_HAIR_TYPE_COLOR:
  581. case SPAWN_SET_HAIR_FACE_COLOR:
  582. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  583. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  584. case SPAWN_SET_HAIR_HIGHLIGHT:
  585. case SPAWN_SET_MODEL_COLOR:
  586. case SPAWN_SET_EYE_COLOR:
  587. case SPAWN_SET_SOGA_SKIN_COLOR:
  588. case SPAWN_SET_SOGA_HAIR_COLOR1:
  589. case SPAWN_SET_SOGA_HAIR_COLOR2:
  590. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  591. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  592. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  593. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  594. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  595. case SPAWN_SET_SOGA_MODEL_COLOR:
  596. case SPAWN_SET_SOGA_EYE_COLOR:
  597. {
  598. if (target->IsEntity())
  599. {
  600. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  601. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  602. {
  603. EQ2_Color clr;
  604. clr.red = atoul(skinsep->arg[0]);
  605. clr.green = atoul(skinsep->arg[1]);
  606. clr.blue = atoul(skinsep->arg[2]);
  607. switch(type)
  608. {
  609. case SPAWN_SET_SKIN_COLOR:
  610. ((Entity*)target)->SetSkinColor(clr);
  611. break;
  612. case SPAWN_SET_HAIR_COLOR1:
  613. ((Entity*)target)->SetHairColor1(clr);
  614. break;
  615. case SPAWN_SET_HAIR_COLOR2:
  616. ((Entity*)target)->SetHairColor2(clr);
  617. break;
  618. case SPAWN_SET_HAIR_TYPE_COLOR:
  619. ((Entity*)target)->SetHairColor(clr);
  620. break;
  621. case SPAWN_SET_HAIR_FACE_COLOR:
  622. ((Entity*)target)->SetFacialHairColor(clr);
  623. break;
  624. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  625. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  626. break;
  627. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  628. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  629. break;
  630. case SPAWN_SET_HAIR_HIGHLIGHT:
  631. ((Entity*)target)->SetHairHighlightColor(clr);
  632. break;
  633. case SPAWN_SET_MODEL_COLOR:
  634. ((Entity*)target)->SetModelColor(clr);
  635. break;
  636. case SPAWN_SET_EYE_COLOR:
  637. ((Entity*)target)->SetEyeColor(clr);
  638. break;
  639. case SPAWN_SET_SOGA_SKIN_COLOR:
  640. ((Entity*)target)->SetSogaSkinColor(clr);
  641. break;
  642. case SPAWN_SET_SOGA_HAIR_COLOR1:
  643. ((Entity*)target)->SetSogaHairColor1(clr);
  644. break;
  645. case SPAWN_SET_SOGA_HAIR_COLOR2:
  646. ((Entity*)target)->SetSogaHairColor2(clr);
  647. break;
  648. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  649. ((Entity*)target)->SetSogaHairColor(clr);
  650. break;
  651. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  652. ((Entity*)target)->SetSogaFacialHairColor(clr);
  653. break;
  654. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  655. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  656. break;
  657. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  658. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  659. break;
  660. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  661. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  662. break;
  663. case SPAWN_SET_SOGA_MODEL_COLOR:
  664. ((Entity*)target)->SetSogaModelColor(clr);
  665. break;
  666. case SPAWN_SET_SOGA_EYE_COLOR:
  667. ((Entity*)target)->SetSogaEyeColor(clr);
  668. break;
  669. }
  670. }
  671. safe_delete(skinsep);
  672. }
  673. break;
  674. }
  675. case SPAWN_SET_AAXP_REWARDS: {
  676. target->SetAAXPRewards(atoul(value));
  677. break;
  678. }
  679. case SPAWN_SET_CHEEK_TYPE:{
  680. if(target->IsEntity() && index < 3){
  681. sprintf(tmp, "%i", ((Entity*)target)->features.cheek_type[index]);
  682. sint8 new_value = atoi(value);
  683. ((Entity*)target)->features.cheek_type[index] = new_value;
  684. ((Entity*)target)->info_changed = true;
  685. }
  686. break;
  687. }
  688. case SPAWN_SET_CHIN_TYPE:{
  689. if(target->IsEntity() && index < 3){
  690. sprintf(tmp, "%i", ((Entity*)target)->features.chin_type[index]);
  691. sint8 new_value = atoi(value);
  692. ((Entity*)target)->features.chin_type[index] = new_value;
  693. ((Entity*)target)->info_changed = true;
  694. }
  695. break;
  696. }
  697. case SPAWN_SET_EAR_TYPE:{
  698. if(target->IsEntity() && index < 3){
  699. sprintf(tmp, "%i", ((Entity*)target)->features.ear_type[index]);
  700. sint8 new_value = atoi(value);
  701. ((Entity*)target)->features.ear_type[index] = new_value;
  702. ((Entity*)target)->info_changed = true;
  703. }
  704. break;
  705. }
  706. case SPAWN_SET_EYE_BROW_TYPE:{
  707. if(target->IsEntity() && index < 3){
  708. sprintf(tmp, "%i", ((Entity*)target)->features.eye_brow_type[index]);
  709. sint8 new_value = atoi(value);
  710. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  711. ((Entity*)target)->info_changed = true;
  712. }
  713. break;
  714. }
  715. case SPAWN_SET_EYE_TYPE:{
  716. if(target->IsEntity() && index < 3){
  717. sprintf(tmp, "%i", ((Entity*)target)->features.eye_type[index]);
  718. sint8 new_value = atoi(value);
  719. ((Entity*)target)->features.eye_type[index] = new_value;
  720. ((Entity*)target)->info_changed = true;
  721. }
  722. break;
  723. }
  724. case SPAWN_SET_LIP_TYPE:{
  725. if(target->IsEntity() && index < 3){
  726. sprintf(tmp, "%i", ((Entity*)target)->features.lip_type[index]);
  727. sint8 new_value = atoi(value);
  728. ((Entity*)target)->features.lip_type[index] = new_value;
  729. ((Entity*)target)->info_changed = true;
  730. }
  731. break;
  732. }
  733. case SPAWN_SET_NOSE_TYPE:{
  734. if(target->IsEntity() && index < 3){
  735. sprintf(tmp, "%i", ((Entity*)target)->features.nose_type[index]);
  736. sint8 new_value = atoi(value);
  737. ((Entity*)target)->features.nose_type[index] = new_value;
  738. ((Entity*)target)->info_changed = true;
  739. }
  740. break;
  741. }
  742. case SPAWN_SET_BODY_SIZE:{
  743. if(target->IsEntity()){
  744. sprintf(tmp, "%i", ((Entity*)target)->features.body_size);
  745. int8 new_value = atoul(value);
  746. ((Entity*)target)->features.body_size = new_value;
  747. ((Entity*)target)->info_changed = true;
  748. }
  749. break;
  750. }
  751. case SPAWN_SET_BODY_AGE:{
  752. if(target->IsEntity()){
  753. sprintf(tmp, "%i", ((Entity*)target)->features.body_age);
  754. int8 new_value = atoul(value);
  755. ((Entity*)target)->features.body_age = new_value;
  756. ((Entity*)target)->info_changed = true;
  757. }
  758. break;
  759. }
  760. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  761. if(target->IsEntity() && index < 3){
  762. sprintf(tmp, "%i", ((Entity*)target)->features.soga_cheek_type[index]);
  763. sint8 new_value = atoi(value);
  764. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  765. ((Entity*)target)->info_changed = true;
  766. }
  767. break;
  768. }
  769. case SPAWN_SET_SOGA_CHIN_TYPE:{
  770. if(target->IsEntity() && index < 3){
  771. sprintf(tmp, "%i", ((Entity*)target)->features.soga_chin_type[index]);
  772. sint8 new_value = atoi(value);
  773. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  774. ((Entity*)target)->info_changed = true;
  775. }
  776. break;
  777. }
  778. case SPAWN_SET_SOGA_EAR_TYPE:{
  779. if(target->IsEntity() && index < 3){
  780. sprintf(tmp, "%i", ((Entity*)target)->features.soga_ear_type[index]);
  781. sint8 new_value = atoi(value);
  782. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  783. ((Entity*)target)->info_changed = true;
  784. }
  785. break;
  786. }
  787. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  788. if(target->IsEntity() && index < 3){
  789. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_brow_type[index]);
  790. sint8 new_value = atoi(value);
  791. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  792. ((Entity*)target)->info_changed = true;
  793. }
  794. break;
  795. }
  796. case SPAWN_SET_SOGA_EYE_TYPE:{
  797. if(target->IsEntity() && index < 3){
  798. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_type[index]);
  799. sint8 new_value = atoi(value);
  800. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  801. ((Entity*)target)->info_changed = true;
  802. }
  803. break;
  804. }
  805. case SPAWN_SET_SOGA_LIP_TYPE:{
  806. if(target->IsEntity() && index < 3){
  807. sprintf(tmp, "%i", ((Entity*)target)->features.soga_lip_type[index]);
  808. sint8 new_value = atoi(value);
  809. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  810. ((Entity*)target)->info_changed = true;
  811. }
  812. break;
  813. }
  814. case SPAWN_SET_SOGA_BODY_SIZE:{
  815. if(target->IsEntity()){
  816. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_size);
  817. int8 new_value = atoul(value);
  818. ((Entity*)target)->features.soga_body_size = new_value;
  819. ((Entity*)target)->info_changed = true;
  820. }
  821. break;
  822. }
  823. case SPAWN_SET_SOGA_BODY_AGE:{
  824. if(target->IsEntity()){
  825. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_age);
  826. int8 new_value = atoul(value);
  827. ((Entity*)target)->features.soga_body_age = new_value;
  828. ((Entity*)target)->info_changed = true;
  829. }
  830. break;
  831. }
  832. case SPAWN_SET_ATTACK_TYPE:{
  833. if(target->IsEntity()){
  834. sprintf(tmp, "%u", ((Entity*)target)->GetInfoStruct()->get_attack_type());
  835. int8 new_value = atoul(value);
  836. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  837. }
  838. break;
  839. }
  840. case SPAWN_SET_RACE_TYPE:{
  841. if(target->GetModelType() > 0){
  842. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  843. if (tmpsep->IsNumber(0))
  844. {
  845. int16 race_type = atoul(value);
  846. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  847. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  848. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  849. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  850. if(client) {
  851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Race type added to memory, however not saved to database.");
  852. }
  853. }
  854. else {
  855. client->SimpleMessage(CHANNEL_COLOR_RED, "Model type already on the race_types_list, use spawn set database to override and update database.");
  856. }
  857. }
  858. safe_delete(tmpsep);
  859. }
  860. break;
  861. }
  862. if(temp_value)
  863. *temp_value = string(tmp);
  864. }
  865. }
  866. else{
  867. /**** NOT TEMPORARY ELSE STATEMENT ****/
  868. /**** MUST RE-DEFINE WHAT IS ALREADY IN THE IF TEMPORARY BLOCK HERE ****/
  869. switch(type){
  870. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  871. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  872. break;
  873. }
  874. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  875. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  876. break;
  877. }
  878. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  879. if (target->GetDatabaseID() > 0)
  880. {
  881. char query[256];
  882. snprintf(query, 256, "update spawn set expansion_flag=%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_HOLIDAY_FLAG: {
  892. if (target->GetDatabaseID() > 0)
  893. {
  894. char query[256];
  895. snprintf(query, 256, "update spawn set holiday_flag=%u where id=%i", atoul(value), target->GetDatabaseID());
  896. if (database.RunQuery(query, strnlen(query, 256)))
  897. {
  898. if(client)
  899. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  900. }
  901. }
  902. break;
  903. }
  904. case SPAWN_SET_AAXP_REWARDS: {
  905. if (target->GetDatabaseID() > 0)
  906. {
  907. char query[256];
  908. snprintf(query, 256, "update spawn set aaxp_rewards=%u where id=%i", atoul(value), target->GetDatabaseID());
  909. if (database.RunQuery(query, strnlen(query, 256)))
  910. {
  911. if(client)
  912. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  913. }
  914. }
  915. break;
  916. }
  917. case SPAWN_SET_VALUE_NAME:{
  918. target->SetName(value);
  919. if(target->GetZone())
  920. target->GetZone()->SendUpdateTitles(target);
  921. break;
  922. }
  923. case SPAWN_SET_VALUE_SUB_TITLE: {
  924. target->SetSubTitle(value);
  925. if(target->GetZone())
  926. target->GetZone()->SendUpdateTitles(target);
  927. break;
  928. }
  929. case SPAWN_SET_VALUE_X_OFFSET:
  930. {
  931. target->SetXOffset(atof(value));
  932. break;
  933. }
  934. case SPAWN_SET_VALUE_Y_OFFSET:
  935. {
  936. target->SetYOffset(atof(value));
  937. break;
  938. }
  939. case SPAWN_SET_VALUE_Z_OFFSET:
  940. {
  941. target->SetZOffset(atof(value));
  942. break;
  943. }
  944. case SPAWN_SET_VALUE_EXPIRE: {
  945. target->SetExpireTime(val);
  946. break;
  947. }
  948. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  949. target->SetExpireOffsetTime(val);
  950. break;
  951. }
  952. case SPAWN_SET_VALUE_LEVEL:{
  953. target->SetLevel(val, send_update);
  954. break;
  955. }
  956. case SPAWN_SET_VALUE_DIFFICULTY:{
  957. target->SetEncounterLevel(val, send_update);
  958. break;
  959. }
  960. case SPAWN_SET_VALUE_MODEL_TYPE:{
  961. target->SetModelType(val, send_update);
  962. break;
  963. }
  964. case SPAWN_SET_VALUE_CLASS:{
  965. target->SetAdventureClass(val, send_update);
  966. break;
  967. }
  968. case SPAWN_SET_VALUE_GENDER:{
  969. target->SetGender(val, send_update);
  970. break;
  971. }
  972. case SPAWN_SET_VALUE_SHOW_NAME:{
  973. target->SetShowName(val, send_update);
  974. break;
  975. }
  976. case SPAWN_SET_VALUE_ATTACKABLE:{
  977. target->SetAttackable(val, send_update);
  978. break;
  979. }
  980. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  981. target->SetShowLevel(val, send_update);
  982. break;
  983. }
  984. case SPAWN_SET_VALUE_TARGETABLE:{
  985. target->SetTargetable(val, send_update);
  986. break;
  987. }
  988. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  989. target->SetShowCommandIcon(val, send_update);
  990. break;
  991. }
  992. case SPAWN_SET_VALUE_HAND_ICON:{
  993. target->SetShowHandIcon(val, send_update);
  994. break;
  995. }
  996. case SPAWN_SET_VALUE_HAIR_TYPE:{
  997. if(target->IsEntity())
  998. ((Entity*)target)->SetHairType(val, send_update);
  999. break;
  1000. }
  1001. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  1002. if(target->IsEntity())
  1003. ((Entity*)target)->SetFacialHairType(val, send_update);
  1004. break;
  1005. }
  1006. case SPAWN_SET_VALUE_WING_TYPE:{
  1007. if(target->IsEntity())
  1008. ((Entity*)target)->SetWingType(val, send_update);
  1009. break;
  1010. }
  1011. case SPAWN_SET_VALUE_CHEST_TYPE:{
  1012. if(target->IsEntity())
  1013. ((Entity*)target)->SetChestType(val, send_update);
  1014. break;
  1015. }
  1016. case SPAWN_SET_VALUE_LEGS_TYPE:{
  1017. if(target->IsEntity())
  1018. ((Entity*)target)->SetLegsType(val, send_update);
  1019. break;
  1020. }
  1021. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  1022. if(target->IsEntity())
  1023. ((Entity*)target)->SetSogaHairType(val, send_update);
  1024. break;
  1025. }
  1026. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  1027. if(target->IsEntity())
  1028. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  1029. break;
  1030. }
  1031. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  1032. target->SetSogaModelType(val, send_update);
  1033. break;
  1034. }
  1035. case SPAWN_SET_VALUE_SIZE:{
  1036. target->SetSize(val, send_update);
  1037. break;
  1038. }
  1039. case SPAWN_SET_VALUE_HP:{
  1040. target->SetHP(val, send_update);
  1041. break;
  1042. }
  1043. case SPAWN_SET_VALUE_POWER:{
  1044. target->SetPower(val, send_update);
  1045. break;
  1046. }
  1047. case SPAWN_SET_VALUE_HEROIC:{
  1048. target->SetHeroic(val, send_update);
  1049. break;
  1050. }
  1051. case SPAWN_SET_VALUE_RESPAWN:{
  1052. target->SetRespawnTime(val);
  1053. break;
  1054. }
  1055. case SPAWN_SET_VALUE_X:{
  1056. target->SetX(atof(value), send_update);
  1057. target->SetSpawnOrigX(target->GetX());
  1058. break;
  1059. }
  1060. case SPAWN_SET_VALUE_Y:{
  1061. target->SetY(atof(value), send_update);
  1062. target->SetSpawnOrigY(target->GetY());
  1063. break;
  1064. }
  1065. case SPAWN_SET_VALUE_Z:{
  1066. target->SetZ(atof(value), send_update);
  1067. target->SetSpawnOrigZ(target->GetZ());
  1068. break;
  1069. }
  1070. case SPAWN_SET_VALUE_HEADING:{
  1071. target->SetHeading(atof(value), send_update);
  1072. target->SetSpawnOrigHeading(target->GetHeading());
  1073. break;
  1074. }
  1075. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  1076. ZoneServer* zone = target->GetZone();
  1077. if (!zone && client)
  1078. zone = client->GetCurrentZone();
  1079. if(zone && zone->GetEntityCommandList(val))
  1080. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  1081. target->primary_command_list_id = val;
  1082. break;
  1083. }
  1084. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  1085. ZoneServer* zone = target->GetZone();
  1086. if (!zone && client)
  1087. zone = client->GetCurrentZone();
  1088. if (zone && zone->GetEntityCommandList(val))
  1089. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  1090. target->secondary_command_list_id = val;
  1091. break;
  1092. }
  1093. case SPAWN_SET_VALUE_VISUAL_STATE:{
  1094. target->SetVisualState(val, send_update);
  1095. break;
  1096. }
  1097. case SPAWN_SET_VALUE_ACTION_STATE:{
  1098. target->SetActionState(val, send_update);
  1099. break;
  1100. }
  1101. case SPAWN_SET_VALUE_MOOD_STATE:{
  1102. target->SetMoodState(val, send_update);
  1103. break;
  1104. }
  1105. case SPAWN_SET_VALUE_INITIAL_STATE:{
  1106. target->SetInitialState(val, send_update);
  1107. break;
  1108. }
  1109. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  1110. target->SetActivityStatus(val, send_update);
  1111. break;
  1112. }
  1113. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  1114. target->SetCollisionRadius(val, send_update);
  1115. break;
  1116. }
  1117. case SPAWN_SET_VALUE_FACTION:{
  1118. ZoneServer* zone = target->GetZone();
  1119. if (!zone && client)
  1120. zone = client->GetCurrentZone();
  1121. target->faction_id = val;
  1122. if(zone)
  1123. {
  1124. zone->RemoveDeadEnemyList(target);
  1125. if(target->IsNPC())
  1126. zone->AddEnemyList((NPC*)target);
  1127. }
  1128. break;
  1129. }
  1130. case SPAWN_SET_VALUE_DEVICE_ID:{
  1131. if (target->IsObject())
  1132. ((Object*)target)->SetDeviceID(val);
  1133. break;
  1134. }
  1135. case SPAWN_SET_VALUE_PITCH: {
  1136. target->SetPitch(atof(value), send_update);
  1137. target->SetSpawnOrigPitch(atof(value));
  1138. break;
  1139. }
  1140. case SPAWN_SET_VALUE_ROLL: {
  1141. target->SetRoll(atof(value), send_update);
  1142. target->SetSpawnOrigRoll(atof(value));
  1143. break;
  1144. }
  1145. case SPAWN_SET_VALUE_HIDE_HOOD: {
  1146. target->SetHideHood(val);
  1147. break;
  1148. }
  1149. case SPAWN_SET_VALUE_EMOTE_STATE: {
  1150. target->SetEmoteState(val);
  1151. break;
  1152. }
  1153. case SPAWN_SET_VALUE_ICON: {
  1154. target->SetIcon(val);
  1155. break;
  1156. }
  1157. case SPAWN_SET_VALUE_PREFIX: {
  1158. target->SetPrefixTitle(value);
  1159. if(target->GetZone())
  1160. target->GetZone()->SendUpdateTitles(target);
  1161. break;
  1162. }
  1163. case SPAWN_SET_VALUE_SUFFIX: {
  1164. target->SetSuffixTitle(value);
  1165. if(target->GetZone())
  1166. target->GetZone()->SendUpdateTitles(target);
  1167. break;
  1168. }
  1169. case SPAWN_SET_VALUE_LASTNAME: {
  1170. target->SetLastName(value);
  1171. if(target->GetZone())
  1172. target->GetZone()->SendUpdateTitles(target);
  1173. break;
  1174. }
  1175. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  1176. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1177. if(client){
  1178. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1179. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  1180. }
  1181. return false;
  1182. }
  1183. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  1184. return false;
  1185. else{
  1186. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  1187. target->SetSpawnScript(value);
  1188. }
  1189. break;
  1190. }
  1191. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  1192. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1193. if(client){
  1194. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1195. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  1196. }
  1197. return false;
  1198. }
  1199. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  1200. return false;
  1201. else{
  1202. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  1203. target->SetSpawnScript(value);
  1204. }
  1205. break;
  1206. }
  1207. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  1208. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1209. if(client){
  1210. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1211. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  1212. }
  1213. return false;
  1214. }
  1215. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  1216. return false;
  1217. else
  1218. target->SetSpawnScript(value);
  1219. break;
  1220. }
  1221. case SPAWN_SET_SKIN_COLOR:
  1222. case SPAWN_SET_HAIR_COLOR1:
  1223. case SPAWN_SET_HAIR_COLOR2:
  1224. case SPAWN_SET_HAIR_TYPE_COLOR:
  1225. case SPAWN_SET_HAIR_FACE_COLOR:
  1226. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1227. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1228. case SPAWN_SET_HAIR_HIGHLIGHT:
  1229. case SPAWN_SET_MODEL_COLOR:
  1230. case SPAWN_SET_EYE_COLOR:
  1231. case SPAWN_SET_SOGA_SKIN_COLOR:
  1232. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1233. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1234. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1235. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1236. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1237. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1238. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1239. case SPAWN_SET_SOGA_MODEL_COLOR:
  1240. case SPAWN_SET_SOGA_EYE_COLOR: {
  1241. if (target->IsNPC())
  1242. {
  1243. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  1244. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  1245. {
  1246. EQ2_Color clr;
  1247. clr.red = atoul(skinsep->arg[0]);
  1248. clr.green = atoul(skinsep->arg[1]);
  1249. clr.blue = atoul(skinsep->arg[2]);
  1250. Query replaceSkinQuery;
  1251. string fieldName("");
  1252. switch(type)
  1253. {
  1254. case SPAWN_SET_SKIN_COLOR:
  1255. ((Entity*)target)->SetSkinColor(clr);
  1256. fieldName.append("skin_color");
  1257. break;
  1258. case SPAWN_SET_HAIR_COLOR1:
  1259. ((Entity*)target)->SetHairColor1(clr);
  1260. fieldName.append("hair_color1");
  1261. break;
  1262. case SPAWN_SET_HAIR_COLOR2:
  1263. ((Entity*)target)->SetHairColor2(clr);
  1264. fieldName.append("hair_color2");
  1265. break;
  1266. case SPAWN_SET_HAIR_TYPE_COLOR:
  1267. ((Entity*)target)->SetHairColor(clr);
  1268. fieldName.append("hair_type_color");
  1269. break;
  1270. case SPAWN_SET_HAIR_FACE_COLOR:
  1271. ((Entity*)target)->SetFacialHairColor(clr);
  1272. fieldName.append("hair_face_color");
  1273. break;
  1274. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1275. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  1276. fieldName.append("hair_type_highlight_color");
  1277. break;
  1278. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1279. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  1280. fieldName.append("hair_face_highlight_color");
  1281. break;
  1282. case SPAWN_SET_HAIR_HIGHLIGHT:
  1283. ((Entity*)target)->SetHairHighlightColor(clr);
  1284. fieldName.append("hair_highlight");
  1285. break;
  1286. case SPAWN_SET_MODEL_COLOR:
  1287. ((Entity*)target)->SetModelColor(clr);
  1288. fieldName.append("model_color");
  1289. break;
  1290. case SPAWN_SET_EYE_COLOR:
  1291. ((Entity*)target)->SetEyeColor(clr);
  1292. fieldName.append("eye_color");
  1293. break;
  1294. case SPAWN_SET_SOGA_SKIN_COLOR:
  1295. ((Entity*)target)->SetSogaSkinColor(clr);
  1296. fieldName.append("soga_skin_color");
  1297. break;
  1298. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1299. ((Entity*)target)->SetSogaHairColor1(clr);
  1300. fieldName.append("soga_hair_color1");
  1301. break;
  1302. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1303. ((Entity*)target)->SetSogaHairColor2(clr);
  1304. fieldName.append("soga_hair_color2");
  1305. break;
  1306. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1307. ((Entity*)target)->SetSogaHairColor(clr);
  1308. fieldName.append("soga_hair_type_color");
  1309. break;
  1310. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1311. ((Entity*)target)->SetSogaFacialHairColor(clr);
  1312. fieldName.append("soga_hair_face_color");
  1313. break;
  1314. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1315. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  1316. fieldName.append("soga_hair_type_highlight_color");
  1317. break;
  1318. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1319. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  1320. fieldName.append("soga_hair_face_highlight_color");
  1321. break;
  1322. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1323. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  1324. fieldName.append("soga_hair_highlight");
  1325. break;
  1326. case SPAWN_SET_SOGA_MODEL_COLOR:
  1327. ((Entity*)target)->SetSogaModelColor(clr);
  1328. fieldName.append("soga_model_color");
  1329. break;
  1330. case SPAWN_SET_SOGA_EYE_COLOR:
  1331. ((Entity*)target)->SetSogaEyeColor(clr);
  1332. fieldName.append("soga_eye_color");
  1333. break;
  1334. }
  1335. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1336. 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);
  1337. }
  1338. safe_delete(skinsep);
  1339. }
  1340. break;
  1341. }
  1342. case SPAWN_SET_CHEEK_TYPE:{
  1343. if(target->IsEntity() && index < 3){
  1344. sint8 new_value = atoi(value);
  1345. ((Entity*)target)->features.cheek_type[index] = new_value;
  1346. UpdateDatabaseAppearance(client, target, "cheek_type", ((Entity*)target)->features.cheek_type[0], ((Entity*)target)->features.cheek_type[1], ((Entity*)target)->features.cheek_type[2]);
  1347. }
  1348. break;
  1349. }
  1350. case SPAWN_SET_CHIN_TYPE:{
  1351. if(target->IsEntity() && index < 3){
  1352. sint8 new_value = atoi(value);
  1353. ((Entity*)target)->features.chin_type[index] = new_value;
  1354. UpdateDatabaseAppearance(client, target, "chin_type", ((Entity*)target)->features.chin_type[0], ((Entity*)target)->features.chin_type[1], ((Entity*)target)->features.chin_type[2]);
  1355. }
  1356. break;
  1357. }
  1358. case SPAWN_SET_EAR_TYPE:{
  1359. if(target->IsEntity() && index < 3){
  1360. sint8 new_value = atoi(value);
  1361. ((Entity*)target)->features.ear_type[index] = new_value;
  1362. UpdateDatabaseAppearance(client, target, "ear_type", ((Entity*)target)->features.ear_type[0], ((Entity*)target)->features.ear_type[1], ((Entity*)target)->features.ear_type[2]);
  1363. }
  1364. break;
  1365. }
  1366. case SPAWN_SET_EYE_BROW_TYPE:{
  1367. if(target->IsEntity() && index < 3){
  1368. sint8 new_value = atoi(value);
  1369. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  1370. 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]);
  1371. }
  1372. break;
  1373. }
  1374. case SPAWN_SET_EYE_TYPE:{
  1375. if(target->IsEntity() && index < 3){
  1376. sint8 new_value = atoi(value);
  1377. ((Entity*)target)->features.eye_type[index] = new_value;
  1378. UpdateDatabaseAppearance(client, target, "eye_type", ((Entity*)target)->features.eye_type[0], ((Entity*)target)->features.eye_type[1], ((Entity*)target)->features.eye_type[2]);
  1379. }
  1380. break;
  1381. }
  1382. case SPAWN_SET_LIP_TYPE:{
  1383. if(target->IsEntity() && index < 3){
  1384. sint8 new_value = atoi(value);
  1385. ((Entity*)target)->features.lip_type[index] = new_value;
  1386. UpdateDatabaseAppearance(client, target, "lip_type", ((Entity*)target)->features.lip_type[0], ((Entity*)target)->features.lip_type[1], ((Entity*)target)->features.lip_type[2]);
  1387. }
  1388. break;
  1389. }
  1390. case SPAWN_SET_NOSE_TYPE:{
  1391. if(target->IsEntity() && index < 3){
  1392. sint8 new_value = atoi(value);
  1393. ((Entity*)target)->features.nose_type[index] = new_value;
  1394. UpdateDatabaseAppearance(client, target, "nose_type", ((Entity*)target)->features.nose_type[0], ((Entity*)target)->features.nose_type[1], ((Entity*)target)->features.nose_type[2]);
  1395. }
  1396. break;
  1397. }
  1398. case SPAWN_SET_BODY_SIZE:{
  1399. if(target->IsEntity()){
  1400. int8 new_value = atoul(value);
  1401. ((Entity*)target)->features.body_size = new_value;
  1402. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1403. }
  1404. break;
  1405. }
  1406. case SPAWN_SET_BODY_AGE:{
  1407. if(target->IsEntity()){
  1408. int8 new_value = atoul(value);
  1409. ((Entity*)target)->features.body_age = new_value;
  1410. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1411. }
  1412. break;
  1413. }
  1414. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  1415. if(target->IsEntity() && index < 3){
  1416. sint8 new_value = atoi(value);
  1417. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  1418. 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]);
  1419. }
  1420. break;
  1421. }
  1422. case SPAWN_SET_SOGA_CHIN_TYPE:{
  1423. if(target->IsEntity() && index < 3){
  1424. sint8 new_value = atoi(value);
  1425. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  1426. 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]);
  1427. }
  1428. break;
  1429. }
  1430. case SPAWN_SET_SOGA_EAR_TYPE:{
  1431. if(target->IsEntity() && index < 3){
  1432. sint8 new_value = atoi(value);
  1433. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  1434. 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]);
  1435. }
  1436. break;
  1437. }
  1438. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  1439. if(target->IsEntity() && index < 3){
  1440. sint8 new_value = atoi(value);
  1441. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  1442. 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]);
  1443. }
  1444. break;
  1445. }
  1446. case SPAWN_SET_SOGA_EYE_TYPE:{
  1447. if(target->IsEntity() && index < 3){
  1448. sint8 new_value = atoi(value);
  1449. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  1450. 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]);
  1451. }
  1452. break;
  1453. }
  1454. case SPAWN_SET_SOGA_LIP_TYPE:{
  1455. if(target->IsEntity() && index < 3){
  1456. sint8 new_value = atoi(value);
  1457. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  1458. 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]);
  1459. }
  1460. break;
  1461. }
  1462. case SPAWN_SET_SOGA_NOSE_TYPE:{
  1463. if(target->IsEntity() && index < 3){
  1464. sint8 new_value = atoi(value);
  1465. ((Entity*)target)->features.soga_nose_type[index] = new_value;
  1466. 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]);
  1467. }
  1468. break;
  1469. }
  1470. case SPAWN_SET_SOGA_BODY_SIZE:{
  1471. if(target->IsEntity()){
  1472. int8 new_value = atoul(value);
  1473. ((Entity*)target)->features.body_size = new_value;
  1474. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1475. }
  1476. break;
  1477. }
  1478. case SPAWN_SET_SOGA_BODY_AGE:{
  1479. if(target->IsEntity()){
  1480. int8 new_value = atoul(value);
  1481. ((Entity*)target)->features.body_age = new_value;
  1482. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1483. }
  1484. break;
  1485. }
  1486. case SPAWN_SET_ATTACK_TYPE:{
  1487. if(target->IsEntity()){
  1488. int8 new_value = atoul(value);
  1489. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  1490. if(target->IsNPC()) {
  1491. if(target->GetDatabaseID()) {
  1492. Query spawnNPCQuery;
  1493. spawnNPCQuery.AddQueryAsync(0, &database, Q_INSERT, "update spawn_npcs set attack_type=%u where id=%u", new_value, target->GetDatabaseID());
  1494. } else if(client) {
  1495. client->Message(CHANNEL_COLOR_RED, "Invalid spawn to update the database (NPC only) or no database id for the NPC present.");
  1496. }
  1497. }
  1498. }
  1499. break;
  1500. }
  1501. case SPAWN_SET_RACE_TYPE:{
  1502. if(target->GetModelType() > 0){
  1503. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  1504. if (tmpsep->IsNumber(0))
  1505. {
  1506. Query typequery;
  1507. int16 race_type = atoul(value);
  1508. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  1509. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  1510. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  1511. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  1512. client->Message(CHANNEL_COLOR_YELLOW, "Model Type %u Race type %u inserted into memory + replaced into database, Model Type: %u set to Race Type: %u, Category: %s, SubCategory: %s, Model Name: %s.", race_type, target->GetModelType(), race_type, category, subcategory, model_name);
  1513. typequery.AddQueryAsync(0, &database, Q_INSERT, "insert into race_types (model_type, race_id, category, subcategory, model_name) values(%u, %u, '%s', '%s', '%s')", target->GetModelType(), race_type, category, subcategory, model_name);
  1514. }
  1515. else {
  1516. client->Message(CHANNEL_COLOR_RED, "Model Type: %u Race type %u overrided in memory + replaced into database, Model Type: %u set to Race Type: %u, Category: %s, SubCategory: %s, Model Name: %s.", race_type, target->GetModelType(), race_type, category, subcategory, model_name);
  1517. race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name, true);
  1518. typequery.AddQueryAsync(0, &database, Q_INSERT, "update race_types set race_id=%u, category='%s', subcategory='%s', model_name='%s' where model_type=%u", race_type, category, subcategory, model_name, target->GetModelType());
  1519. }
  1520. }
  1521. safe_delete(tmpsep);
  1522. }
  1523. break;
  1524. }
  1525. }
  1526. }
  1527. return true;
  1528. }
  1529. void Commands::UpdateDatabaseAppearance(Client* client, Spawn* target, string fieldName, sint8 r, sint8 g, sint8 b)
  1530. {
  1531. Query replaceQuery;
  1532. if(target->IsBot())
  1533. {
  1534. Bot* bot = (Bot*)target;
  1535. if(bot->BotID)
  1536. database.SaveBotFloats(bot->BotID, fieldName.c_str(), r, g, b);
  1537. }
  1538. else if(target->IsPlayer())
  1539. {
  1540. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from char_colors where char_id=%u and type='%s'", ((Player*)target)->GetCharacterID(), fieldName.c_str());
  1541. 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);
  1542. }
  1543. else
  1544. {
  1545. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1546. 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);
  1547. }
  1548. ((Entity*)target)->changed = true;
  1549. ((Entity*)target)->info_changed = true;
  1550. if(target->GetZone())
  1551. target->GetZone()->AddChangedSpawn(target);
  1552. }
  1553. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  1554. the database fields always and also update the zone in memory if it's running. */
  1555. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  1556. if (client && zone_id > 0 && type > 0 && value) {
  1557. sint32 int_value = 0;
  1558. float float_value = 0;
  1559. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  1560. try {
  1561. float_value = atof(value);
  1562. }
  1563. catch (...) {
  1564. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  1565. return false;
  1566. }
  1567. }
  1568. 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) {
  1569. try {
  1570. int_value = atoi(value);
  1571. }
  1572. catch (...) {
  1573. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  1574. return false;
  1575. }
  1576. }
  1577. switch (type) {
  1578. case ZONE_SET_VALUE_EXPANSION_ID: {
  1579. break;
  1580. }
  1581. case ZONE_SET_VALUE_NAME: {
  1582. if (zone)
  1583. zone->SetZoneName(const_cast<char*>(value));
  1584. database.SaveZoneInfo(zone_id, "name", value);
  1585. break;
  1586. }
  1587. case ZONE_SET_VALUE_FILE: {
  1588. if (zone)
  1589. zone->SetZoneFile(const_cast<char*>(value));
  1590. database.SaveZoneInfo(zone_id, "file", value);
  1591. break;
  1592. }
  1593. case ZONE_SET_VALUE_DESCRIPTION: {
  1594. if (zone)
  1595. zone->SetZoneDescription(const_cast<char*>(value));
  1596. database.SaveZoneInfo(zone_id, "description", value);
  1597. break;
  1598. }
  1599. case ZONE_SET_VALUE_SAFE_X: {
  1600. if (zone)
  1601. zone->SetSafeX(float_value);
  1602. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  1603. break;
  1604. }
  1605. case ZONE_SET_VALUE_SAFE_Y: {
  1606. if (zone)
  1607. zone->SetSafeY(float_value);
  1608. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  1609. break;
  1610. }
  1611. case ZONE_SET_VALUE_SAFE_Z: {
  1612. if (zone)
  1613. zone->SetSafeZ(float_value);
  1614. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  1615. break;
  1616. }
  1617. case ZONE_SET_VALUE_UNDERWORLD: {
  1618. if (zone)
  1619. zone->SetUnderWorld(float_value);
  1620. database.SaveZoneInfo(zone_id, "underworld", float_value);
  1621. break;
  1622. }
  1623. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  1624. break;
  1625. }
  1626. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  1627. break;
  1628. }
  1629. case ZONE_SET_VALUE_ZONE_TYPE: {
  1630. break;
  1631. }
  1632. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  1633. if (zone)
  1634. zone->SetAlwaysLoaded(int_value == 1);
  1635. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  1636. break;
  1637. }
  1638. case ZONE_SET_VALUE_CITY_ZONE: {
  1639. if (zone)
  1640. zone->SetCityZone(int_value == 1);
  1641. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  1642. break;
  1643. }
  1644. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  1645. if (zone)
  1646. zone->SetWeatherAllowed(int_value == 1);
  1647. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  1648. break;
  1649. }
  1650. case ZONE_SET_VALUE_MIN_STATUS: {
  1651. if (zone)
  1652. zone->SetMinimumStatus(int_value);
  1653. database.SaveZoneInfo(zone_id, "min_status", int_value);
  1654. break;
  1655. }
  1656. case ZONE_SET_VALUE_MIN_LEVEL: {
  1657. if (zone)
  1658. zone->SetMinimumLevel(int_value);
  1659. database.SaveZoneInfo(zone_id, "min_level", int_value);
  1660. break;
  1661. }
  1662. case ZONE_SET_VALUE_MAX_LEVEL: {
  1663. if (zone)
  1664. zone->SetMaximumLevel(int_value);
  1665. database.SaveZoneInfo(zone_id, "max_level", int_value);
  1666. break;
  1667. }
  1668. case ZONE_SET_VALUE_START_ZONE: {
  1669. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  1670. break;
  1671. }
  1672. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  1673. if (zone)
  1674. zone->SetInstanceType(int_value);
  1675. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  1676. break;
  1677. }
  1678. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  1679. if (zone)
  1680. zone->SetDefaultReenterTime(int_value);
  1681. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  1682. break;
  1683. }
  1684. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  1685. if (zone)
  1686. zone->SetDefaultResetTime(int_value);
  1687. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  1688. break;
  1689. }
  1690. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1691. if (zone)
  1692. zone->SetDefaultLockoutTime(int_value);
  1693. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1694. break;
  1695. }
  1696. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1697. if (zone)
  1698. zone->SetForceGroupZoneOption(int_value);
  1699. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1700. break;
  1701. }
  1702. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1703. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1704. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1705. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1706. return false;
  1707. }
  1708. else {
  1709. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1710. database.SaveZoneInfo(zone_id, "lua_script", value);
  1711. }
  1712. break;
  1713. }
  1714. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1715. if (zone)
  1716. zone->SetShutdownTimer(int_value);
  1717. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1718. break;
  1719. }
  1720. case ZONE_SET_VALUE_ZONE_MOTD: {
  1721. if (zone)
  1722. zone->SetZoneMOTD(string(value));
  1723. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1724. break;
  1725. }
  1726. default: {
  1727. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1728. return false;
  1729. }
  1730. }
  1731. }
  1732. else {
  1733. if (client)
  1734. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1735. return false;
  1736. }
  1737. return true;
  1738. }
  1739. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1740. if (index >= remote_commands->commands.size()) {
  1741. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1742. return;
  1743. }
  1744. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1745. EQ2_RemoteCommandString* parent_command = 0;
  1746. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1747. Seperator* sep = 0;
  1748. if (command_parms->size > 0) {
  1749. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1750. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1751. parent_command = command;
  1752. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1753. safe_delete(sep);
  1754. if (command_parms->data.length() > (command->command.data.length() + 1))
  1755. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1756. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1757. }
  1758. else
  1759. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1760. }
  1761. int ndx = 0;
  1762. if (command->required_status > client->GetAdminStatus())
  1763. {
  1764. 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());
  1765. safe_delete(sep);
  1766. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1767. return;
  1768. }
  1769. Player* player = client->GetPlayer();
  1770. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1771. switch (command->handler) {
  1772. case COMMAND_RELOAD: {
  1773. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1774. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1775. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1776. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1777. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1778. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1779. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1780. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1781. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1782. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1783. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1784. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1785. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1786. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1787. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1788. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1789. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1790. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1791. break;
  1792. }
  1793. case COMMAND_RELOADSTRUCTS: {
  1794. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1795. world.SetReloadingSubsystem("Structs");
  1796. configReader.ReloadStructs();
  1797. world.RemoveReloadingSubSystem("Structs");
  1798. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1799. break;
  1800. }
  1801. case COMMAND_RELOAD_QUESTS: {
  1802. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1803. world.SetReloadingSubsystem("Quests");
  1804. master_quest_list.Reload();
  1805. client_list.ReloadQuests();
  1806. zone_list.ReloadClientQuests();
  1807. world.RemoveReloadingSubSystem("Quests");
  1808. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1809. break;
  1810. }
  1811. case COMMAND_RELOAD_SPAWNS: {
  1812. client->GetCurrentZone()->ReloadSpawns();
  1813. break;
  1814. }
  1815. case COMMAND_RELOAD_SPELLS: {
  1816. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1817. world.SetReloadingSubsystem("Spells");
  1818. zone_list.DeleteSpellProcess();
  1819. master_spell_list.Reload();
  1820. if (lua_interface)
  1821. lua_interface->ReloadSpells();
  1822. zone_list.LoadSpellProcess();
  1823. world.RemoveReloadingSubSystem("Spells");
  1824. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1825. break;
  1826. }
  1827. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1829. world.SetReloadingSubsystem("GroundSpawns");
  1830. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1831. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1832. world.RemoveReloadingSubSystem("GroundSpawns");
  1833. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1834. break;
  1835. }
  1836. case COMMAND_RELOAD_ZONESCRIPTS: {
  1837. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1838. world.SetReloadingSubsystem("ZoneScripts");
  1839. world.ResetZoneScripts();
  1840. database.LoadZoneScriptData();
  1841. if (lua_interface)
  1842. lua_interface->DestroyZoneScripts();
  1843. world.RemoveReloadingSubSystem("ZoneScripts");
  1844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1845. break;
  1846. }
  1847. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1848. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1849. world.SetReloadingSubsystem("EntityCommands");
  1850. client->GetCurrentZone()->ClearEntityCommands();
  1851. database.LoadEntityCommands(client->GetCurrentZone());
  1852. world.RemoveReloadingSubSystem("EntityCommands");
  1853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1854. break;
  1855. }
  1856. case COMMAND_RELOAD_FACTIONS: {
  1857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1858. world.SetReloadingSubsystem("Factions");
  1859. master_faction_list.Clear();
  1860. database.LoadFactionList();
  1861. world.RemoveReloadingSubSystem("Factions");
  1862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1863. break;
  1864. }
  1865. case COMMAND_RELOAD_MAIL: {
  1866. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1867. zone_list.ReloadMail();
  1868. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1869. break;
  1870. }
  1871. case COMMAND_RELOAD_GUILDS: {
  1872. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1873. world.ReloadGuilds();
  1874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1875. break;
  1876. }
  1877. case COMMAND_RELOAD_LOCATIONS: {
  1878. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1879. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1880. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1881. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1882. break;
  1883. }
  1884. case COMMAND_RELOAD_RULES: {
  1885. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1886. database.LoadRuleSets(true);
  1887. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1888. break;
  1889. }
  1890. case COMMAND_RELOAD_TRANSPORTERS: {
  1891. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1892. database.LoadTransporters(client->GetCurrentZone());
  1893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1894. break;
  1895. }
  1896. case COMMAND_RELOAD_STARTABILITIES: {
  1897. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1898. world.PurgeStartingLists();
  1899. world.LoadStartingLists();
  1900. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1901. break;
  1902. }
  1903. case COMMAND_READ: {
  1904. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1905. if (strcmp(sep->arg[0], "read") == 0) {
  1906. int32 item_index = atol(sep->arg[1]);
  1907. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1908. if (item) {
  1909. Spawn* spawn = cmdTarget;
  1910. client->SendShowBook(client->GetPlayer(), item->name, item->book_pages);
  1911. break;
  1912. }
  1913. }
  1914. }
  1915. break;
  1916. }
  1917. case COMMAND_USEABILITY:{
  1918. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1919. if (client->GetPlayer()->GetHP() == 0) {
  1920. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1921. }
  1922. else {
  1923. int32 spell_id = atoul(sep->arg[0]);
  1924. int8 spell_tier = 0;
  1925. if (sep->arg[1][0] && sep->IsNumber(1))
  1926. spell_tier = atoi(sep->arg[1]);
  1927. else
  1928. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1929. if (!spell_tier)
  1930. spell_tier = 1;
  1931. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1932. if (spell) {
  1933. 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)
  1934. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1935. else
  1936. {
  1937. if (cmdTarget)
  1938. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1939. else
  1940. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1941. }
  1942. }
  1943. }
  1944. }
  1945. else if (cmdTarget && cmdTarget->IsWidget())
  1946. {
  1947. Widget* widget = (Widget*)cmdTarget;
  1948. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1949. }
  1950. else
  1951. {
  1952. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1953. }
  1954. break;
  1955. }
  1956. case COMMAND_INFO:{
  1957. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1958. if(strcmp(sep->arg[0], "inventory") == 0){
  1959. int32 item_index = atol(sep->arg[1]);
  1960. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1961. if(item){
  1962. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1963. break;
  1964. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1965. //DumpPacket(app);
  1966. client->QueuePacket(app);
  1967. if(item->GetItemScript() && lua_interface)
  1968. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1969. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1970. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  1971. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1972. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  1973. }
  1974. }
  1975. else
  1976. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1977. }
  1978. else if(strcmp(sep->arg[0], "equipment") == 0){
  1979. int32 item_index = atol(sep->arg[1]);
  1980. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1981. if(item){
  1982. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1983. client->QueuePacket(app);
  1984. if(item->GetItemScript() && lua_interface)
  1985. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1986. }
  1987. else
  1988. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1989. }
  1990. else if(strcmp(sep->arg[0], "appearance") == 0){
  1991. int32 item_index = atol(sep->arg[1]);
  1992. Item* item = client->GetPlayer()->GetAppearanceEquipmentList()->GetItem(item_index);
  1993. if(item){
  1994. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1995. client->QueuePacket(app);
  1996. if(item->GetItemScript() && lua_interface)
  1997. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1998. }
  1999. else
  2000. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  2001. }
  2002. 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){
  2003. int32 item_id = atoul(sep->arg[1]);
  2004. Item* item = master_item_list.GetItem(item_id);
  2005. if(item){
  2006. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2007. client->QueuePacket(app);
  2008. }
  2009. else
  2010. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  2011. }
  2012. else if (strcmp(sep->arg[0], "spell") == 0) {
  2013. sint32 spell_id = atol(sep->arg[1]);
  2014. int8 tier = atoi(sep->arg[3]);
  2015. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  2016. if (outapp)
  2017. client->QueuePacket(outapp);
  2018. else
  2019. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2020. }
  2021. else if (strcmp(sep->arg[0], "achievement") == 0) {
  2022. sint32 spell_id = atol(sep->arg[2]);
  2023. int8 group = atoi(sep->arg[1]);
  2024. AltAdvanceData* data = 0;
  2025. SpellBookEntry* spellentry = 0;
  2026. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2027. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  2028. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  2029. if (outapp)
  2030. client->QueuePacket(outapp);
  2031. else
  2032. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  2033. }
  2034. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  2035. sint32 spell_id = atol(sep->arg[1]);
  2036. int32 tier = atoi(sep->arg[2]);
  2037. if (tier > 255) {
  2038. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  2039. if (ent)
  2040. tier = ent->tier;
  2041. }
  2042. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  2043. if (outapp)
  2044. client->QueuePacket(outapp);
  2045. else
  2046. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2047. }
  2048. else if (strcmp(sep->arg[0], "recipe") == 0) {
  2049. sint32 recipe_id = atol(sep->arg[1]);
  2050. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  2051. if(outapp)
  2052. client->QueuePacket(outapp);
  2053. else
  2054. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  2055. }
  2056. else if (strcmp(sep->arg[0], "maintained") ==0) {
  2057. int32 slot = atol(sep->arg[1]);
  2058. int32 spell_id = atol(sep->arg[2]);
  2059. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  2060. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2061. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  2062. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  2063. if(outapp)
  2064. client->QueuePacket(outapp);
  2065. else
  2066. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  2067. }
  2068. else if (strcmp(sep->arg[0], "effect") == 0) {
  2069. int32 spell_id = atol(sep->arg[1]);
  2070. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  2071. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2072. int8 type = 0;
  2073. if (client->GetVersion() <= 546)
  2074. type = 1;
  2075. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  2076. if (outapp){
  2077. client->QueuePacket(outapp);
  2078. }
  2079. else
  2080. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  2081. }
  2082. }
  2083. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  2084. Item* item = player->item_list.GetOverflowItem();
  2085. if(item) {
  2086. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2087. client->QueuePacket(app);
  2088. }
  2089. else
  2090. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  2091. }
  2092. else
  2093. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  2094. break;
  2095. }
  2096. case COMMAND_USE_EQUIPPED_ITEM:{
  2097. if (sep && sep->arg[0] && sep->IsNumber(0)){
  2098. int32 slot_id = atoul(sep->arg[0]);
  2099. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  2100. if (item && item->generic_info.usable && item->GetItemScript()) {
  2101. if(!item->CheckFlag2(INDESTRUCTABLE) && item->generic_info.condition == 0) {
  2102. client->SimpleMessage(CHANNEL_COLOR_RED, "This item is broken and must be repaired at a mender before it can be used");
  2103. }
  2104. else if (item->CheckFlag(EVIL_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_EVIL) {
  2105. client->Message(0, "%s requires an evil race.", item->name.c_str());
  2106. }
  2107. else if (item->CheckFlag(GOOD_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_GOOD) {
  2108. client->Message(0, "%s requires a good race.", item->name.c_str());
  2109. }
  2110. else {
  2111. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player, player->GetTarget());
  2112. }
  2113. }
  2114. }
  2115. break;
  2116. }
  2117. case COMMAND_USE_ITEM: {
  2118. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2119. int32 item_index = atoul(sep->arg[0]);
  2120. Item* item = player->item_list.GetItemFromIndex(item_index);
  2121. client->UseItem(item, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer());
  2122. }
  2123. break;
  2124. }
  2125. case COMMAND_SCRIBE_SCROLL_ITEM: {
  2126. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2127. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  2128. if (item) {
  2129. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  2130. if(item->generic_info.item_type == 6) {
  2131. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  2132. int8 old_slot = 0;
  2133. if (spell) {
  2134. int16 tier_up = player->GetTierUp(spell->GetSpellTier());
  2135. if (rule_manager.GetGlobalRule(R_Spells, RequirePreviousTierScribe)->GetInt8() && !player->HasSpell(spell->GetSpellID(), tier_up, false, true))
  2136. client->SimpleMessage(CHANNEL_COLOR_RED, "You have not scribed the required previous version of this ability.");
  2137. else if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  2138. old_slot = player->GetSpellSlot(spell->GetSpellID());
  2139. player->RemoveSpellBookEntry(spell->GetSpellID());
  2140. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  2141. player->UnlockSpell(spell);
  2142. client->SendSpellUpdate(spell);
  2143. database.DeleteItem(client->GetCharacterID(), item, 0);
  2144. player->item_list.RemoveItem(item, true);
  2145. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  2146. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  2147. // force purge client cache and display updated spell for hover over
  2148. EQ2Packet* app = spell->SerializeSpell(client, false, false);
  2149. client->QueuePacket(app);
  2150. }
  2151. }
  2152. else
  2153. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  2154. }
  2155. else if(item->generic_info.item_type == 7){
  2156. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  2157. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  2158. // if valid recipe book and the player doesn't have it
  2159. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  2160. client->Message(CHANNEL_NARRATIVE, "Your tradeskill level is not high enough to scribe this book.");
  2161. safe_delete(recipe_book);
  2162. }
  2163. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  2164. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  2165. // Add recipe book to the players list
  2166. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  2167. // Get a list of all recipes this book contains
  2168. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  2169. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  2170. // Create the packet to send to update the players recipe list
  2171. PacketStruct* packet = 0;
  2172. if (client->GetRecipeListSent()) {
  2173. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  2174. if (packet)
  2175. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  2176. }
  2177. // loop through the list
  2178. vector<Recipe*>::iterator itr;
  2179. int16 i = 0;
  2180. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  2181. // check to see if the player already has this recipe some how
  2182. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  2183. // Player doesn't already have this recipe so lets add it
  2184. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  2185. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  2186. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  2187. client->Message(CHANNEL_NARRATIVE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  2188. if (packet && client->GetRecipeListSent()) {
  2189. packet->setArrayDataByName("id", recipe->GetID(), i);
  2190. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  2191. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  2192. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  2193. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  2194. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  2195. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  2196. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  2197. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  2198. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  2199. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  2200. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  2201. i++;
  2202. }
  2203. }
  2204. }
  2205. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  2206. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  2207. database.DeleteItem(client->GetCharacterID(), item, 0);
  2208. client->GetPlayer()->item_list.RemoveItem(item, true);
  2209. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  2210. if (packet && client->GetRecipeListSent())
  2211. client->QueuePacket(packet->serialize());
  2212. safe_delete(packet);
  2213. }
  2214. else {
  2215. if (recipe_book)
  2216. client->Message(CHANNEL_NARRATIVE, "You have already learned all you can from this item.");
  2217. safe_delete(recipe_book);
  2218. }
  2219. }
  2220. }
  2221. else
  2222. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  2223. }
  2224. break;
  2225. }
  2226. case COMMAND_SUMMONITEM: {
  2227. if (sep && sep->IsNumber(0)) {
  2228. int32 item_id = atol(sep->arg[0]);
  2229. int32 quantity = 1;
  2230. if (sep->arg[1] && sep->IsNumber(1))
  2231. quantity = atoi(sep->arg[1]);
  2232. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  2233. client->AddItemToBank(item_id,quantity);
  2234. }
  2235. else {
  2236. client->AddItem(item_id, quantity);
  2237. }
  2238. }
  2239. else {
  2240. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  2241. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  2242. }
  2243. break;
  2244. }
  2245. case COMMAND_COLLECTION_ADDITEM: {
  2246. // takes 2 params: collection_id, slot
  2247. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2248. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  2249. if (item)
  2250. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  2251. else
  2252. 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]));
  2253. }
  2254. else
  2255. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  2256. break;
  2257. }
  2258. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  2259. // takes 1 param: slot
  2260. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  2261. int i = 0;
  2262. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  2263. printf("\t%u: %s\n", i, sep->arg[i]);
  2264. i++;
  2265. }
  2266. break;
  2267. }
  2268. case COMMAND_WAYPOINT: {
  2269. bool success = false;
  2270. client->ClearWaypoint();
  2271. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  2272. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  2273. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2274. }
  2275. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  2276. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  2277. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2278. }
  2279. else {
  2280. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  2281. }
  2282. break;
  2283. }
  2284. case COMMAND_WHO:{
  2285. const char* who = 0;
  2286. if(sep && sep->arg[0]){
  2287. //cout << "Who query: \n";
  2288. who = sep->argplus[0];
  2289. //cout << who << endl;
  2290. }
  2291. zone_list.ProcessWhoQuery(who, client);
  2292. break;
  2293. }
  2294. case COMMAND_SELECT_JUNCTION:{
  2295. 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__);
  2296. int32 choice = 0;
  2297. if(sep && sep->arg[0] && sep->IsNumber(0))
  2298. choice = atoul(sep->arg[0]);
  2299. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  2300. client->HandlePlayerRevive(choice);
  2301. }
  2302. break;
  2303. }
  2304. case COMMAND_SPAWN_MOVE: {
  2305. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  2306. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  2307. if (packet) {
  2308. float unknown2_3 = 0;
  2309. int8 placement_mode = 0;
  2310. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  2311. if (sep && sep->arg[0][0]) {
  2312. if (strcmp(sep->arg[0], "wall") == 0) {
  2313. placement_mode = 2;
  2314. unknown2_3 = 150;
  2315. }
  2316. else if (strcmp(sep->arg[0], "ceiling") == 0)
  2317. placement_mode = 1;
  2318. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  2319. {
  2320. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  2321. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  2322. }
  2323. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  2324. {
  2325. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  2326. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  2327. }
  2328. else if (strcmp(sep->arg[0], "myloc") == 0)
  2329. {
  2330. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  2331. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  2332. safe_delete(packet);
  2333. break;
  2334. }
  2335. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  2336. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  2337. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  2338. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  2339. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  2340. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  2341. safe_delete(packet);
  2342. break;
  2343. }
  2344. }
  2345. packet->setDataByName("placement_mode", placement_mode);
  2346. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  2347. packet->setDataByName("model_type", cmdTarget->GetModelType());
  2348. packet->setDataByName("unknown", 1); //size
  2349. packet->setDataByName("unknown2", 1); //size 2
  2350. packet->setDataByName("unknown2", .5, 1); //size 3
  2351. packet->setDataByName("unknown2", 3, 2);
  2352. packet->setDataByName("unknown2", unknown2_3, 3);
  2353. packet->setDataByName("max_distance", 500);
  2354. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  2355. client->QueuePacket(packet->serialize());
  2356. safe_delete(packet);
  2357. }
  2358. }
  2359. else {
  2360. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  2361. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  2362. }
  2363. break;
  2364. }
  2365. case COMMAND_HAIL:{
  2366. Spawn* spawn = cmdTarget;
  2367. if(spawn && spawn->GetTargetable())
  2368. {
  2369. char tmp[75] = {0};
  2370. sprintf(tmp, "Hail, %s", spawn->GetName());
  2371. bool show_bubble = true;
  2372. if (spawn->IsNPC())
  2373. show_bubble = false;
  2374. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  2375. if(spawn->IsPlayer() == false && spawn->Alive() && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetGlobalRule(R_Spawn, HailDistance)->GetInt32()){
  2376. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  2377. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  2378. else
  2379. {
  2380. bool pauseRunback = false;
  2381. // prime runback as the heading or anything can be altered when hailing succeeds
  2382. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  2383. {
  2384. ((NPC*)spawn)->StartRunback();
  2385. pauseRunback = true;
  2386. }
  2387. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  2388. spawn->PauseMovement(rule_manager.GetGlobalRule(R_Spawn, HailMovementPause)->GetInt32());
  2389. else if(spawn->IsNPC() && pauseRunback)
  2390. ((NPC*)spawn)->ClearRunback();
  2391. }
  2392. }
  2393. }
  2394. else {
  2395. string tmp = "Hail";
  2396. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  2397. }
  2398. break;
  2399. }
  2400. case COMMAND_SAY:{
  2401. if (sep && sep->arg[0][0]) {
  2402. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  2403. if (cmdTarget && !(cmdTarget->IsPlayer()))
  2404. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  2405. }
  2406. else
  2407. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  2408. break;
  2409. }
  2410. case COMMAND_TELL:{
  2411. if(sep && sep->arg[0] && sep->argplus[1]){
  2412. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1]))
  2413. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  2414. }else
  2415. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  2416. break;
  2417. }
  2418. case COMMAND_SHOUT:{
  2419. if(sep && sep->arg[0][0])
  2420. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  2421. else
  2422. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  2423. break;
  2424. }
  2425. case COMMAND_AUCTION:{
  2426. if(sep && sep->arg[0][0])
  2427. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  2428. else
  2429. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  2430. break;
  2431. }
  2432. case COMMAND_OOC:{
  2433. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2434. if(sep && sep->arg[0][0])
  2435. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0]);
  2436. else
  2437. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2438. break;
  2439. }
  2440. case COMMAND_EMOTE:{
  2441. if(sep && sep->arg[0][0])
  2442. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2443. else
  2444. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2445. break;
  2446. }
  2447. case COMMAND_RACE:{
  2448. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2449. if(sep->arg[1][0] && sep->IsNumber(1)){
  2450. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2451. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2452. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2453. client->GetPlayer()->SetCharSheetChanged(true);
  2454. }
  2455. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2456. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2457. //client->QueuePacket(outapp);
  2458. }
  2459. else{
  2460. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2461. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2462. }
  2463. break;
  2464. }
  2465. case COMMAND_BANK_DEPOSIT:{
  2466. if(client->GetBanker() && sep && sep->arg[0]){
  2467. int64 amount = 0;
  2468. string deposit = string(sep->arg[0]);
  2469. amount = atoi64(deposit.c_str());
  2470. client->BankDeposit(amount);
  2471. }
  2472. break;
  2473. }
  2474. case COMMAND_BANK_WITHDRAWAL:{
  2475. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2476. int64 amount = 0;
  2477. string deposit = string(sep->arg[0]);
  2478. amount = atoi64(deposit.c_str());
  2479. client->BankWithdrawal(amount);
  2480. }
  2481. break;
  2482. }
  2483. case COMMAND_BANK_CANCEL:{
  2484. Spawn* banker = cmdTarget;
  2485. client->Bank(banker, true);
  2486. break;
  2487. }
  2488. case COMMAND_BANK:{
  2489. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2490. Spawn* banker = cmdTarget;
  2491. client->Bank(banker);
  2492. break;
  2493. }
  2494. case COMMAND_GUILD_BANK:{
  2495. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2496. //Spawn* banker = client->GetPlayer()->GetTarget();
  2497. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2498. break;
  2499. }
  2500. case COMMAND_START_MAIL: {
  2501. client->SetMailTransaction(cmdTarget);
  2502. client->SendMailList();
  2503. break;
  2504. }
  2505. case COMMAND_CANCEL_MAIL: {
  2506. client->SetMailTransaction(0);
  2507. break;
  2508. }
  2509. case COMMAND_GET_MAIL_MESSAGE: {
  2510. if (sep && sep->arg[0] && sep->IsNumber(0))
  2511. client->DisplayMailMessage(atoul(sep->arg[0]));
  2512. break;
  2513. }
  2514. case COMMAND_ADD_MAIL_PLAT: {
  2515. if (sep && sep->arg[0] && sep->IsNumber(0))
  2516. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2517. break;
  2518. }
  2519. case COMMAND_ADD_MAIL_GOLD: {
  2520. if (sep && sep->arg[0] && sep->IsNumber(0))
  2521. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2522. break;
  2523. }
  2524. case COMMAND_ADD_MAIL_SILVER: {
  2525. if (sep && sep->arg[0] && sep->IsNumber(0))
  2526. client->AddMailCoin(0, atoul(sep->arg[0]));
  2527. break;
  2528. }
  2529. case COMMAND_ADD_MAIL_COPPER: {
  2530. if (sep && sep->arg[0] && sep->IsNumber(0))
  2531. client->AddMailCoin(atoul(sep->arg[0]));
  2532. break;
  2533. }
  2534. case COMMAND_SET_MAIL_ITEM: {
  2535. if(sep && sep->IsNumber(0) && sep->IsNumber(2))
  2536. {
  2537. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2538. if(item)
  2539. {
  2540. int16 quantity = atoul(sep->arg[1]);
  2541. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2542. {
  2543. return;
  2544. }
  2545. if(item->IsBag())
  2546. {
  2547. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2548. if(bag_items && bag_items->size() > 0)
  2549. {
  2550. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2551. safe_delete(bag_items);
  2552. return;
  2553. }
  2554. safe_delete(bag_items);
  2555. }
  2556. Item* itemtoadd = item;
  2557. if(quantity > 0)
  2558. {
  2559. if(quantity > item->details.count)
  2560. return;
  2561. Item* tmpItem = new Item(item);
  2562. tmpItem->details.count = quantity;
  2563. itemtoadd = tmpItem;
  2564. }
  2565. if(client->AddMailItem(itemtoadd))
  2566. {
  2567. client->RemoveItem(item, quantity, true);
  2568. }
  2569. }
  2570. }
  2571. break;
  2572. }
  2573. case COMMAND_REMOVE_MAIL_PLAT: {
  2574. if (sep && sep->arg[0] && sep->IsNumber(0))
  2575. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2576. break;
  2577. }
  2578. case COMMAND_REMOVE_MAIL_GOLD: {
  2579. if (sep && sep->arg[0] && sep->IsNumber(0))
  2580. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2581. break;
  2582. }
  2583. case COMMAND_REMOVE_MAIL_SILVER: {
  2584. if (sep && sep->arg[0] && sep->IsNumber(0))
  2585. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2586. break;
  2587. }
  2588. case COMMAND_REMOVE_MAIL_COPPER: {
  2589. if (sep && sep->arg[0] && sep->IsNumber(0))
  2590. client->RemoveMailCoin(atoul(sep->arg[0]));
  2591. break;
  2592. }
  2593. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2594. if (sep && sep->arg[0] && sep->IsNumber(0))
  2595. client->TakeMailAttachments(atoul(sep->arg[0]));
  2596. break;
  2597. }
  2598. case COMMAND_CANCEL_SEND_MAIL: {
  2599. client->ResetSendMail();
  2600. break;
  2601. }
  2602. case COMMAND_DELETE_MAIL_MESSAGE: {
  2603. if (sep && sep->arg[0] && sep->IsNumber(0))
  2604. client->DeleteMail(atoul(sep->arg[0]), true);
  2605. break;
  2606. }
  2607. case COMMAND_REPORT_SPAM: {
  2608. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2609. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2610. break;
  2611. }
  2612. case COMMAND_KILL:{
  2613. Spawn* dead = 0;
  2614. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2615. dead=client->GetPlayer();
  2616. client->GetPlayer()->SetHP(0);
  2617. client->GetPlayer()->KillSpawn(dead);
  2618. }else{
  2619. dead= cmdTarget;
  2620. if(dead && dead->IsPlayer() == false){
  2621. dead->SetHP(0);
  2622. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2623. client->GetCurrentZone()->RemoveSpawn(dead, true, true, true, true, true);
  2624. else
  2625. client->GetPlayer()->KillSpawn(dead);
  2626. }else{
  2627. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2628. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2629. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2630. }
  2631. }
  2632. break;
  2633. }
  2634. case COMMAND_LEVEL:{
  2635. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2636. int16 new_level = atoi(sep->arg[ndx]);
  2637. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2638. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2639. else {
  2640. if (new_level < 1)
  2641. new_level = 1;
  2642. if (new_level > 255)
  2643. new_level = 255;
  2644. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2645. }
  2646. }else
  2647. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2648. break;
  2649. }
  2650. case COMMAND_SIT: {
  2651. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2652. if(client->GetPlayer()->GetHP() > 0){
  2653. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2654. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2655. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2656. }
  2657. break;
  2658. }
  2659. case COMMAND_STAND: {
  2660. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2661. if(client->GetPlayer()->GetHP() > 0){
  2662. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2663. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2664. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2665. }
  2666. break;
  2667. }
  2668. case COMMAND_CLASS:{
  2669. if(sep && sep->arg[ndx][0]){
  2670. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2671. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2672. }else
  2673. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2674. break;
  2675. }
  2676. case COMMAND_GENDER:{
  2677. if(sep && sep->arg[ndx][0]){
  2678. client->GetPlayer()->GetInfoStruct()->set_gender(atoi(sep->arg[ndx]));
  2679. client->GetPlayer()->SetCharSheetChanged(true);
  2680. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  2681. }else{
  2682. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  2683. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  2684. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  2685. }
  2686. break;
  2687. }
  2688. case COMMAND_FLYMODE:{
  2689. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2690. PrintSep(sep, "COMMAND_FLYMODE");
  2691. int8 val = atoi(sep->arg[0]);
  2692. ClientPacketFunctions::SendFlyMode(client, val);
  2693. }
  2694. else{
  2695. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  2696. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2697. }
  2698. break;
  2699. }
  2700. case COMMAND_LOOT_LIST:{
  2701. Spawn* spawn = cmdTarget;
  2702. if(spawn && spawn->IsEntity()){
  2703. if (sep && sep->arg[0]) {
  2704. if (!spawn->GetDatabaseID())
  2705. {
  2706. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  2707. break;
  2708. }
  2709. else if (!spawn->IsNPC())
  2710. {
  2711. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2712. break;
  2713. }
  2714. bool reloadLoot = false;
  2715. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2716. {
  2717. int32 loottable_id = atoul(sep->arg[1]);
  2718. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2719. {
  2720. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2721. reloadLoot = true;
  2722. }
  2723. else
  2724. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2725. }
  2726. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2727. {
  2728. int32 loottable_id = atoul(sep->arg[1]);
  2729. if (loottable_id > 0)
  2730. {
  2731. database.AddLootTableToSpawn(spawn, loottable_id);
  2732. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2733. reloadLoot = true;
  2734. }
  2735. else
  2736. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2737. }
  2738. else if (!stricmp(sep->arg[0], "clearall"))
  2739. {
  2740. if (database.RemoveSpawnLootTable(spawn, 0))
  2741. {
  2742. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2743. reloadLoot = true;
  2744. }
  2745. else
  2746. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2747. }
  2748. else
  2749. {
  2750. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2751. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2752. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2753. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2754. break;
  2755. }
  2756. if (reloadLoot)
  2757. {
  2758. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2759. if (spawn->IsNPC())
  2760. {
  2761. Entity* ent = (Entity*)spawn;
  2762. ent->SetLootCoins(0);
  2763. ent->ClearLoot();
  2764. spawn->GetZone()->AddLoot((NPC*)spawn);
  2765. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2766. }
  2767. }
  2768. break; // nothing further this is the end of these sub commands
  2769. }
  2770. else
  2771. {
  2772. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()), spawn);
  2773. if (loot_list.size() > 0) {
  2774. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2775. vector<int32>::iterator list_itr;
  2776. LootTable* table = 0;
  2777. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2778. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2779. if (table)
  2780. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2781. }
  2782. }
  2783. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2784. vector<Item*>* items = spawn->GetLootItems();
  2785. if (items) {
  2786. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2787. vector<Item*>::iterator itr;
  2788. Item* item = 0;
  2789. for (itr = items->begin(); itr != items->end(); itr++) {
  2790. item = *itr;
  2791. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2792. }
  2793. }
  2794. else
  2795. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2796. }
  2797. }
  2798. break;
  2799. }
  2800. case COMMAND_LOOT_SETCOIN:{
  2801. Spawn* spawn = cmdTarget;
  2802. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2803. spawn->SetLootCoins(atoul(sep->arg[0]));
  2804. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2805. }
  2806. else
  2807. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2808. break;
  2809. }
  2810. case COMMAND_LOOT_ADDITEM:{
  2811. Spawn* spawn = cmdTarget;
  2812. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2813. int16 charges = 1;
  2814. if(sep->arg[1] && sep->IsNumber(1))
  2815. charges = atoi(sep->arg[1]);
  2816. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2817. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2818. }
  2819. else
  2820. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2821. break;
  2822. }
  2823. case COMMAND_LOOT_REMOVEITEM:{
  2824. Spawn* spawn = cmdTarget;
  2825. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2826. Item* item = spawn->LootItem(atoul(sep->arg[0]));
  2827. safe_delete(item);
  2828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2829. }
  2830. else
  2831. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2832. break;
  2833. }
  2834. case COMMAND_LOOT_CORPSE:
  2835. case COMMAND_DISARM:
  2836. case COMMAND_LOOT:{
  2837. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2838. {
  2839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2840. break;
  2841. }
  2842. if(cmdTarget && cmdTarget->IsEntity()){
  2843. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2844. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2845. client->OpenChest(cmdTarget, true);
  2846. else
  2847. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2848. if (!(cmdTarget)->HasLoot()){
  2849. if (((Entity*)cmdTarget)->IsNPC())
  2850. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2851. }
  2852. }
  2853. else
  2854. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2855. }
  2856. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2858. break;
  2859. }
  2860. case COMMAND_RELOADSPAWNSCRIPTS:{
  2861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2862. if (lua_interface)
  2863. lua_interface->SetLuaSystemReloading(true);
  2864. world.ResetSpawnScripts();
  2865. database.LoadSpawnScriptData();
  2866. if(lua_interface) {
  2867. lua_interface->DestroySpawnScripts();
  2868. lua_interface->SetLuaSystemReloading(false);
  2869. }
  2870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2871. break;
  2872. }
  2873. case COMMAND_RELOADREGIONSCRIPTS:{
  2874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2875. if(lua_interface) {
  2876. lua_interface->DestroyRegionScripts();
  2877. }
  2878. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2879. break;
  2880. }
  2881. case COMMAND_RELOADLUASYSTEM:{
  2882. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2883. world.SetReloadingSubsystem("LuaSystem");
  2884. if(lua_interface) {
  2885. lua_interface->SetLuaSystemReloading(true);
  2886. }
  2887. zone_list.DeleteSpellProcess();
  2888. master_spell_list.Reload();
  2889. if (lua_interface)
  2890. lua_interface->ReloadSpells();
  2891. zone_list.LoadSpellProcess();
  2892. if(lua_interface){
  2893. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2894. map<Client*, int32>::iterator itr;
  2895. for(itr = debug_clients.begin(); itr != debug_clients.end(); itr++){
  2896. if(lua_interface)
  2897. lua_interface->UpdateDebugClients(itr->first);
  2898. }
  2899. }
  2900. world.ResetSpawnScripts();
  2901. database.LoadSpawnScriptData();
  2902. world.ResetZoneScripts();
  2903. database.LoadZoneScriptData();
  2904. if(lua_interface) {
  2905. lua_interface->DestroySpawnScripts();
  2906. lua_interface->DestroyRegionScripts();
  2907. lua_interface->DestroyQuests();
  2908. lua_interface->DestroyItemScripts();
  2909. lua_interface->DestroyZoneScripts();
  2910. }
  2911. int32 quest_count = database.LoadQuests();
  2912. int32 spell_count = 0;
  2913. if(lua_interface) {
  2914. spell_count = database.LoadSpellScriptData();
  2915. lua_interface->SetLuaSystemReloading(false);
  2916. }
  2917. world.RemoveReloadingSubSystem("LuaSystem");
  2918. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2919. break;
  2920. }
  2921. case COMMAND_DECLINE_QUEST:{
  2922. int32 quest_id = 0;
  2923. if(sep && sep->arg[0] && sep->IsNumber(0))
  2924. quest_id = atoul(sep->arg[0]);
  2925. if(quest_id > 0){
  2926. Quest* quest = client->GetPendingQuest(quest_id);
  2927. if(quest){
  2928. client->RemovePendingQuest(quest);
  2929. if(lua_interface)
  2930. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2931. safe_delete(quest);
  2932. client->GetCurrentZone()->SendQuestUpdates(client);
  2933. }
  2934. }
  2935. break;
  2936. }
  2937. case COMMAND_DELETE_QUEST:{
  2938. int32 quest_id = 0;
  2939. if(sep && sep->arg[0] && sep->IsNumber(0))
  2940. quest_id = atoul(sep->arg[0]);
  2941. if(quest_id > 0){
  2942. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2943. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2944. if (quest)
  2945. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2946. }
  2947. client->RemovePlayerQuest(quest_id);
  2948. client->GetCurrentZone()->SendQuestUpdates(client);
  2949. }
  2950. break;
  2951. }
  2952. case COMMAND_ACCEPT_QUEST:{
  2953. int32 quest_id = 0;
  2954. if(sep && sep->arg[0] && sep->IsNumber(0))
  2955. quest_id = atoul(sep->arg[0]);
  2956. if(quest_id > 0){
  2957. client->AcceptQuest(quest_id);
  2958. }
  2959. break;
  2960. }
  2961. case COMMAND_NAME:{
  2962. if(sep && sep->arg[ndx][0]){
  2963. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  2964. client->GetPlayer()->SetCharSheetChanged(true);
  2965. }else
  2966. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2967. break;
  2968. }
  2969. case COMMAND_GROUPSAY:{
  2970. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2971. if(sep && sep->arg[0] && gmi)
  2972. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2973. break;
  2974. }
  2975. case COMMAND_GROUPINVITE: {
  2976. Entity* target = 0;
  2977. Client* target_client = 0;
  2978. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2979. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2980. return;
  2981. }
  2982. // name provided with command so it has to be a player, npc not supported here
  2983. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2984. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2985. if (target_client) {
  2986. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2987. target = 0;
  2988. else
  2989. target = target_client->GetPlayer();
  2990. }
  2991. }
  2992. // if name was not provided use the players target, npc or player supported here
  2993. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2994. target = (Entity*)client->GetPlayer()->GetTarget();
  2995. if (target->IsPlayer()) {
  2996. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2997. }
  2998. }
  2999. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  3000. if (result == 0) {
  3001. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  3002. if (target_client) {
  3003. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  3004. if (packet) {
  3005. packet->setDataByName("type", 1);
  3006. packet->setDataByName("name", client->GetPlayer()->GetName());
  3007. packet->setDataByName("unknown2", 1);
  3008. target_client->QueuePacket(packet->serialize());
  3009. safe_delete(packet);
  3010. }
  3011. }
  3012. }
  3013. else if (result == 1)
  3014. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  3015. else if (result == 2)
  3016. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  3017. else if (result == 3)
  3018. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  3019. else if (result == 4)
  3020. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  3021. else if (result == 5)
  3022. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  3023. else if (result == 6)
  3024. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  3025. else
  3026. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  3027. break;
  3028. }
  3029. case COMMAND_GROUPDISBAND: {
  3030. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3031. if (gmi) { // TODO: Leader check
  3032. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  3033. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  3034. }
  3035. break;
  3036. }
  3037. case COMMAND_GROUP_LEAVE: {
  3038. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3039. if (gmi) {
  3040. int32 group_id = gmi->group_id;
  3041. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  3042. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  3043. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  3044. }
  3045. else {
  3046. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  3047. }
  3048. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  3049. }
  3050. break;
  3051. }
  3052. case COMMAND_FRIEND_ADD:{
  3053. string name = "";
  3054. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3055. name = database.GetPlayerName(sep->arg[0]);
  3056. else if(cmdTarget && cmdTarget->IsPlayer())
  3057. name = string(cmdTarget->GetName());
  3058. if(name.length() > 0){
  3059. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3060. if(client->GetPlayer()->IsIgnored(name.c_str())){
  3061. client->GetPlayer()->RemoveIgnore(name.c_str());
  3062. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3063. client->SendChatRelationship(3, name.c_str());
  3064. }
  3065. client->GetPlayer()->AddFriend(name.c_str(), true);
  3066. client->SendChatRelationship(0, name.c_str());
  3067. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  3068. if(zone_list.GetClientByCharName(name))
  3069. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  3070. }
  3071. else
  3072. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  3073. }
  3074. else
  3075. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3076. break;
  3077. }
  3078. case COMMAND_FRIEND_REMOVE:{
  3079. string name = "";
  3080. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3081. name = database.GetPlayerName(sep->arg[0]);
  3082. else if(cmdTarget && cmdTarget->IsPlayer())
  3083. name = string(cmdTarget->GetName());
  3084. if(name.length() > 0){
  3085. client->GetPlayer()->RemoveFriend(name.c_str());
  3086. client->SendChatRelationship(1, name.c_str());
  3087. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3088. }
  3089. else
  3090. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3091. break;
  3092. }
  3093. case COMMAND_FRIENDS:{
  3094. break;
  3095. }
  3096. case COMMAND_IGNORE_ADD:{
  3097. string name = "";
  3098. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3099. name = database.GetPlayerName(sep->arg[0]);
  3100. else if(cmdTarget && cmdTarget->IsPlayer())
  3101. name = string(cmdTarget->GetName());
  3102. if(name.length() > 0){
  3103. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3104. if(client->GetPlayer()->IsFriend(name.c_str())){
  3105. client->GetPlayer()->RemoveFriend(name.c_str());
  3106. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3107. client->SendChatRelationship(1, name.c_str());
  3108. }
  3109. client->GetPlayer()->AddIgnore(name.c_str(), true);
  3110. client->SendChatRelationship(2, name.c_str());
  3111. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  3112. }
  3113. else
  3114. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  3115. }
  3116. else
  3117. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3118. break;
  3119. }
  3120. case COMMAND_IGNORE_REMOVE:{
  3121. string name = "";
  3122. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3123. name = database.GetPlayerName(sep->arg[0]);
  3124. else if(cmdTarget && cmdTarget->IsPlayer())
  3125. name = string(cmdTarget->GetName());
  3126. if(name.length() > 0){
  3127. client->GetPlayer()->RemoveIgnore(name.c_str());
  3128. client->SendChatRelationship(3, name.c_str());
  3129. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3130. }
  3131. break;
  3132. }
  3133. case COMMAND_IGNORES:{
  3134. break;
  3135. }
  3136. case COMMAND_GROUP_KICK:{
  3137. Entity* kicked = 0;
  3138. Client* kicked_client = 0;
  3139. int32 group_id = 0;
  3140. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  3141. return;
  3142. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  3143. if (sep && sep->arg[0]) {
  3144. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  3145. if (kicked_client)
  3146. kicked = kicked_client->GetPlayer();
  3147. }
  3148. else if (cmdTarget && cmdTarget->IsEntity()) {
  3149. kicked = (Entity*)cmdTarget;
  3150. }
  3151. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  3152. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  3153. if (kicked)
  3154. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  3155. if(send_kicked_message)
  3156. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  3157. else
  3158. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  3159. if (kicked_client)
  3160. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  3161. break;
  3162. }
  3163. case COMMAND_GROUP_MAKE_LEADER:{
  3164. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3165. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  3166. return;
  3167. }
  3168. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  3169. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  3170. if (new_leader) {
  3171. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  3172. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  3173. }
  3174. }
  3175. else
  3176. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  3177. }
  3178. else if (cmdTarget && cmdTarget->IsPlayer())
  3179. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  3180. else
  3181. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  3182. break;
  3183. }
  3184. case COMMAND_GROUP_ACCEPT_INVITE: {
  3185. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  3186. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  3187. if (result == 0)
  3188. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  3189. else if (result == 1)
  3190. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  3191. else if (result == 2)
  3192. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  3193. else
  3194. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  3195. }
  3196. break;
  3197. }
  3198. case COMMAND_GROUP_DECLINE_INVITE: {
  3199. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  3200. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  3201. }
  3202. break;
  3203. }
  3204. case COMMAND_SUMMON:{
  3205. char* search_name = 0;
  3206. if(sep && sep->arg[0][0])
  3207. search_name = sep->arg[0];
  3208. if(!search_name && !cmdTarget){
  3209. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  3210. 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.");
  3211. }
  3212. else{
  3213. if(!client->Summon(search_name))
  3214. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3215. }
  3216. break;
  3217. }
  3218. case COMMAND_GOTO:{
  3219. const char* search_name = 0;
  3220. if(sep && sep->arg[0][0])
  3221. search_name = sep->argplus[0];
  3222. if(!search_name && !cmdTarget){
  3223. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  3224. 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.");
  3225. }
  3226. else{
  3227. if(!client->GotoSpawn(search_name))
  3228. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3229. }
  3230. break;
  3231. }
  3232. case COMMAND_MOVE:{
  3233. bool success = false;
  3234. try{
  3235. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  3236. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  3237. if(app){
  3238. client->QueuePacket(app);
  3239. success = true;
  3240. }
  3241. }
  3242. }
  3243. catch(...){}
  3244. if(!success){
  3245. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  3246. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  3247. }
  3248. break;
  3249. }
  3250. case COMMAND_SETTIME:{
  3251. if(sep && sep->arg[0]){
  3252. world.MWorldTime.writelock(__FUNCTION__, __LINE__);
  3253. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  3254. if(sep->arg[1] && sep->IsNumber(1))
  3255. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  3256. if(sep->arg[2] && sep->IsNumber(2))
  3257. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  3258. if(sep->arg[3] && sep->IsNumber(3))
  3259. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  3260. world.MWorldTime.releasewritelock(__FUNCTION__, __LINE__);
  3261. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  3262. }
  3263. else{
  3264. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  3265. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  3266. }
  3267. break;
  3268. }
  3269. case COMMAND_VERSION:{
  3270. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  3271. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  3272. break;
  3273. }
  3274. case COMMAND_ZONE:{
  3275. int32 instanceID = 0;
  3276. string zone;
  3277. int32 zone_id = 0;
  3278. bool listSearch = false;
  3279. bool isInstance = false;
  3280. ZoneServer* zsZone = 0;
  3281. if(sep && sep->arg[0][0])
  3282. {
  3283. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  3284. listSearch = true;
  3285. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  3286. {
  3287. zone_list.SendZoneList(client);
  3288. break;
  3289. }
  3290. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  3291. {
  3292. if(sep->IsNumber(1))
  3293. instanceID = atol(sep->arg[1]);
  3294. }
  3295. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  3296. {
  3297. PrintSep(sep, "ZONE LOCK");
  3298. if(sep->IsNumber(1))
  3299. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  3300. else
  3301. zsZone = zone_list.Get(sep->arg[1], false);
  3302. if( zsZone )
  3303. {
  3304. zsZone->SetZoneLockState(true);
  3305. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3306. }
  3307. else
  3308. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  3309. break;
  3310. }
  3311. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  3312. {
  3313. PrintSep(sep, "ZONE UNLOCK");
  3314. if(sep->IsNumber(1))
  3315. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  3316. else
  3317. zsZone = zone_list.Get(sep->arg[1], false);
  3318. if( zsZone )
  3319. {
  3320. zsZone->SetZoneLockState(false);
  3321. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3322. }
  3323. else
  3324. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  3325. break;
  3326. }
  3327. else
  3328. {
  3329. if(sep->IsNumber(0))
  3330. {
  3331. zone_id = atoul(sep->arg[0]);
  3332. string zonename = database.GetZoneName(zone_id);
  3333. if(zonename.length() > 0)
  3334. zone = zonename;
  3335. }
  3336. else
  3337. zone = sep->arg[0];
  3338. }
  3339. if(instanceID > 0)
  3340. {
  3341. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  3342. if(zsInstance != NULL)
  3343. {
  3344. instanceID = zsInstance->GetInstanceID();
  3345. zone = zsInstance->GetZoneName();
  3346. zone_id = zsInstance->GetZoneID();
  3347. isInstance = true;
  3348. }
  3349. }
  3350. }
  3351. if(!listSearch)
  3352. {
  3353. if(zone.length() == 0)
  3354. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  3355. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  3356. zone_id != client->GetCurrentZone()->GetZoneID())
  3357. {
  3358. const char* zonestr = zone.c_str();
  3359. if(database.VerifyZone(zonestr))
  3360. {
  3361. if(client->CheckZoneAccess(zonestr))
  3362. {
  3363. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  3364. if(isInstance)
  3365. client->Zone(instanceID,true,true,false);
  3366. else
  3367. client->Zone(zonestr);
  3368. }
  3369. }
  3370. else
  3371. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  3372. }
  3373. else
  3374. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  3375. }
  3376. else
  3377. {
  3378. const char* name = 0;
  3379. if(sep && sep->arg[1][0])
  3380. {
  3381. map<int32, string>* zone_names;
  3382. name = sep->argplus[1];
  3383. sint16 status = client->GetAdminStatus();
  3384. if( status > 0 )
  3385. {
  3386. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  3387. zone_names = database.GetZoneList(name, true);
  3388. }
  3389. else
  3390. zone_names = database.GetZoneList(name);
  3391. if(!zone_names)
  3392. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  3393. else
  3394. {
  3395. map<int32, string>::iterator itr;
  3396. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  3397. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  3398. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  3399. safe_delete(zone_names);
  3400. }
  3401. }
  3402. else
  3403. {
  3404. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  3405. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  3406. }
  3407. }
  3408. break;
  3409. }
  3410. case COMMAND_USE: {
  3411. Spawn* target = cmdTarget;
  3412. if (target && target->IsWidget())
  3413. ((Widget*)target)->HandleUse(client, "use");
  3414. break;
  3415. }
  3416. case COMMAND_OPEN: {
  3417. Spawn* target = cmdTarget;
  3418. if (target && target->IsWidget())
  3419. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  3420. break;
  3421. }
  3422. case COMMAND_CASTSPELL: {
  3423. if (sep && sep->arg[0] && sep->IsNumber(0))
  3424. {
  3425. int8 tier = 1;
  3426. if (sep->arg[1] && sep->IsNumber(1))
  3427. tier = atoul(sep->arg[1]);
  3428. int8 self = 1;
  3429. if (sep->arg[1] && sep->IsNumber(2))
  3430. {
  3431. self = atoul(sep->arg[2]);
  3432. if(self != 1 && !cmdTarget->IsEntity())
  3433. {
  3434. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  3435. self = 1;
  3436. }
  3437. }
  3438. int32 spellid = atoul(sep->arg[0]);
  3439. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  3440. if (spell)
  3441. {
  3442. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3443. SpellProcess* spellProcess = 0;
  3444. // Get the current zones spell process
  3445. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3446. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3447. }
  3448. else
  3449. {
  3450. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3451. }
  3452. }
  3453. else if (sep && sep->arg[0])
  3454. {
  3455. database.FindSpell(client, (char*)sep->argplus[0]);
  3456. }
  3457. else
  3458. {
  3459. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3460. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3461. }
  3462. break;
  3463. }
  3464. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3465. if (client->GetVersion() <= 546)
  3466. break;
  3467. if (sep && sep->GetArgNumber() == 4)
  3468. {
  3469. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3470. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3471. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3472. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3473. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  3474. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3475. ClientPacketFunctions::SendSkillSlotMappings(client);
  3476. }
  3477. else
  3478. {
  3479. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3480. }
  3481. break;
  3482. }
  3483. case COMMAND_MOVE_ITEM:
  3484. {
  3485. int32 id = 0;
  3486. if (sep && sep->IsNumber(0))
  3487. id = atoul(sep->arg[0]);
  3488. Spawn* spawn = 0;
  3489. if (id == 0)
  3490. {
  3491. spawn = cmdTarget;
  3492. }
  3493. else
  3494. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3495. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3496. break;
  3497. client->SendMoveObjectMode(spawn, 0);
  3498. break;
  3499. }
  3500. case COMMAND_PICKUP:
  3501. {
  3502. int32 id = 0;
  3503. if (sep && sep->IsNumber(0))
  3504. id = atoul(sep->arg[0]);
  3505. Spawn* spawn = 0;
  3506. if (id == 0)
  3507. {
  3508. spawn = cmdTarget;
  3509. }
  3510. else
  3511. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3512. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3513. break;
  3514. if(client->AddItem(spawn->GetPickupItemID(), 1)) {
  3515. Query query;
  3516. 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());
  3517. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3518. client->GetCurrentZone()->RemoveSpawn(spawn, true, true, true, true, true);
  3519. }
  3520. // we had a UI Window displayed, update the house items
  3521. if ( id > 0 )
  3522. client->GetCurrentZone()->SendHouseItems(client);
  3523. }
  3524. break;
  3525. }
  3526. case COMMAND_HOUSE_DEPOSIT:
  3527. {
  3528. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3529. // arg0 = ??? (set to 3)
  3530. // arg1 = coin (in copper)
  3531. // arg2 = status? (not implemented yet)
  3532. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3533. if (ph && sep && sep->IsNumber(1))
  3534. {
  3535. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3536. int32 outValStatus = 0;
  3537. if(sep->IsNumber(2))
  3538. {
  3539. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3540. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3541. outValStatus = 0; // cheat check
  3542. }
  3543. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3544. {
  3545. if(outValStatus)
  3546. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3547. char query[256];
  3548. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3549. if (itr != ph->depositsMap.end())
  3550. {
  3551. 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());
  3552. }
  3553. else
  3554. 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);
  3555. if (database.RunQuery(query, strnlen(query, 256)))
  3556. {
  3557. ph->escrow_coins += outValCoin;
  3558. ph->escrow_status += outValStatus;
  3559. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3560. database.LoadDeposits(ph);
  3561. client->PlaySound("coin_cha_ching");
  3562. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3563. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3564. }
  3565. else
  3566. {
  3567. if(outValCoin)
  3568. client->GetPlayer()->AddCoins(outValCoin);
  3569. if(outValStatus)
  3570. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3571. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3572. }
  3573. }
  3574. }
  3575. break;
  3576. }
  3577. case COMMAND_HOUSE:
  3578. {
  3579. if (sep && sep->IsNumber(0))
  3580. {
  3581. int32 unique_id = atoi(sep->arg[0]);
  3582. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3583. HouseZone* hz = 0;
  3584. if (ph)
  3585. hz = world.GetHouseZone(ph->house_id);
  3586. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3587. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3588. }
  3589. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3590. {
  3591. // inside a house or something? Send the access window
  3592. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3593. HouseZone* hz = 0;
  3594. if ( ph )
  3595. hz = world.GetHouseZone(ph->house_id);
  3596. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3597. client->GetCurrentZone()->SendHouseItems(client);
  3598. }
  3599. break;
  3600. }
  3601. case COMMAND_HOUSE_UI:
  3602. {
  3603. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3604. {
  3605. int32 unique_id = atoi(sep->arg[0]);
  3606. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3607. HouseZone* hz = 0;
  3608. if ( ph )
  3609. hz = world.GetHouseZone(ph->house_id);
  3610. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3611. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  3612. }
  3613. break;
  3614. }
  3615. case COMMAND_PLACE_HOUSE_ITEM: {
  3616. if (sep && sep->IsNumber(0))
  3617. {
  3618. int32 uniqueid = atoi(sep->arg[0]);
  3619. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3620. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3621. if (item && item->IsHouseItem())
  3622. {
  3623. if (!client->HasOwnerOrEditAccess())
  3624. {
  3625. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3626. break;
  3627. }
  3628. else if (!item->generic_info.appearance_id)
  3629. {
  3630. 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);
  3631. break;
  3632. }
  3633. if (client->GetTempPlacementSpawn())
  3634. {
  3635. Spawn* tmp = client->GetTempPlacementSpawn();
  3636. client->GetCurrentZone()->RemoveSpawn(tmp, true, true, true, true, true);
  3637. client->SetTempPlacementSpawn(nullptr);
  3638. }
  3639. Object* obj = new Object();
  3640. Spawn* spawn = (Spawn*)obj;
  3641. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3642. strcpy(spawn->appearance.name, "temp");
  3643. spawn->SetX(client->GetPlayer()->GetX());
  3644. spawn->SetY(client->GetPlayer()->GetY());
  3645. spawn->SetZ(client->GetPlayer()->GetZ());
  3646. spawn->appearance.pos.collision_radius = 32;
  3647. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3648. spawn->SetSpawnOrigX(spawn->GetX());
  3649. spawn->SetSpawnOrigY(spawn->GetY());
  3650. spawn->SetSpawnOrigZ(spawn->GetZ());
  3651. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3652. spawn->appearance.targetable = 1;
  3653. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3654. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3655. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3656. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3657. spawn->SetZone(client->GetCurrentZone());
  3658. client->SetTempPlacementSpawn(spawn);
  3659. client->SetPlacementUniqueItemID(uniqueid);
  3660. client->GetCurrentZone()->AddSpawn(spawn);
  3661. }
  3662. }
  3663. break;
  3664. }
  3665. case COMMAND_GM:
  3666. {
  3667. if (sep && sep->arg[0] && sep->arg[1])
  3668. {
  3669. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3670. if (strcmp(sep->arg[0], "vision") == 0)
  3671. {
  3672. client->GetPlayer()->SetGMVision(onOff);
  3673. #if defined(__GNUC__)
  3674. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3675. #else
  3676. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3677. #endif
  3678. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3679. if (onOff)
  3680. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3681. else
  3682. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3683. }
  3684. else if (strcmp(sep->arg[0], "tag") == 0)
  3685. {
  3686. int32 value = 0;
  3687. int16 tag_icon = 0;
  3688. // groundspawn has special exception -1 argument so it needs to be handled here
  3689. if(sep->arg[2] && sep->arg[3] && ((tag_icon = atoul(sep->arg[3])) > 0) || (strncasecmp(sep->arg[1], "groundspawn", 11) == 0)) {
  3690. value = atoul(sep->arg[2]);
  3691. if(strncasecmp(sep->arg[1], "faction", 7) == 0){
  3692. if(!value) {
  3693. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid faction id.");
  3694. break;
  3695. }
  3696. if(!tag_icon) {
  3697. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3698. break;
  3699. }
  3700. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_FACTION, value, "", tag_icon);
  3701. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3702. client->Message(CHANNEL_COLOR_RED, "Adding faction id %u with tag icon %u.", value, tag_icon);
  3703. }
  3704. else if(strncasecmp(sep->arg[1], "spawngroup", 10) == 0){
  3705. if(value>0) {
  3706. value = 1;
  3707. }
  3708. if(!tag_icon) {
  3709. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3710. break;
  3711. }
  3712. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_SPAWNGROUP, value, "", tag_icon);
  3713. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3714. client->Message(CHANNEL_COLOR_RED, "Adding spawn group tag \"%s\" with tag icon %u.", (value == 1) ? "on" : "off", tag_icon);
  3715. }
  3716. else if(strncasecmp(sep->arg[1], "race", 5) == 0){
  3717. if(!value) {
  3718. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid race id.");
  3719. break;
  3720. }
  3721. if(!tag_icon) {
  3722. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3723. break;
  3724. }
  3725. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_RACE, value, "", tag_icon);
  3726. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3727. client->Message(CHANNEL_COLOR_RED, "Adding race id %u with tag icon %u.", value, tag_icon);
  3728. }
  3729. else if(strncasecmp(sep->arg[1], "groundspawn", 11) == 0){
  3730. // one less argument value field not tag_icon for this one
  3731. if(!value) {
  3732. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3733. break;
  3734. }
  3735. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_GROUNDSPAWN, 1, "", value);
  3736. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3737. client->Message(CHANNEL_COLOR_RED, "Adding groundspawns with tag icon %u.", value);
  3738. }
  3739. }
  3740. else {
  3741. if(strncasecmp(sep->arg[1], "clear", 5) == 0){
  3742. client->GetPlayer()->ClearGMVisualFilters();
  3743. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Tags Cleared!");
  3744. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3745. }
  3746. else {
  3747. client->SimpleMessage(CHANNEL_COLOR_RED, "GM Tagging Missing Arguments:");
  3748. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag [type] [value] [visual_icon_display]");
  3749. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag clear - Clears all GM visual tags");
  3750. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Type Options:");
  3751. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: faction, value: faction id of spawn(s)");
  3752. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: spawngroup, value: 1 to show grouped, 0 to show not grouped");
  3753. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: race, value: race id (either against base race or race id in spawn details)");
  3754. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: groundspawn, value: (not used)");
  3755. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Icon Options:");
  3756. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3757. "1 = skull, 2 = shield half dark blue / half light blue, 3 = purple? star, 4 = yellow sword, 5 = red X, 6 = green flame");
  3758. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3759. "7 = Number \"1\", 8 = Number \"2\", 9 = Number \"3\", 10 = Number \"4\", 11 = Number \"5\", 12 = Number \"6\"");
  3760. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3761. "25 = shield, 26 = green plus, 27 = crossed swords, 28 = bow with arrow in it, 29 = light blue lightning bolt");
  3762. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3763. "30 = bard instrument (hard to see), 31 = writ with shield, 32 = writ with green +, 33 = writ with crossed sword");
  3764. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3765. "34 = writ with bow, 35 = writ with light blue lightning bolt, 36 = same as 30, 37 = party with crossed sword, shield and lightning bolt");
  3766. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3767. "38 = shaking hands green background, 39 = shaking hands dark green background, unlocked keylock");
  3768. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3769. "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");
  3770. }
  3771. }
  3772. }
  3773. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3774. {
  3775. client->SetRegionDebug(onOff);
  3776. #if defined(__GNUC__)
  3777. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3778. #else
  3779. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3780. #endif
  3781. if (onOff)
  3782. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  3783. else
  3784. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  3785. }
  3786. else if (strcmp(sep->arg[0], "luadebug") == 0)
  3787. {
  3788. client->SetLuaDebugClient(onOff);
  3789. #if defined(__GNUC__)
  3790. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3791. #else
  3792. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  3793. #endif
  3794. if (onOff)
  3795. {
  3796. if (lua_interface)
  3797. lua_interface->UpdateDebugClients(client);
  3798. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3799. }
  3800. else
  3801. {
  3802. if (lua_interface)
  3803. lua_interface->RemoveDebugClients(client);
  3804. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3805. }
  3806. }
  3807. }
  3808. break;
  3809. }
  3810. case COMMAND_ATTACK:
  3811. case COMMAND_AUTO_ATTACK:{
  3812. int8 type = 1;
  3813. Player* player = client->GetPlayer();
  3814. if(!player)
  3815. break;
  3816. bool incombat = player->EngagedInCombat();
  3817. if(sep && sep->arg[0] && sep->IsNumber(0))
  3818. type = atoi(sep->arg[0]);
  3819. if(client->GetPlayer()->GetHP() == 0){
  3820. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  3821. break;
  3822. }
  3823. if(type == 0){
  3824. if(incombat)
  3825. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3826. player->StopCombat(type);
  3827. }
  3828. else {
  3829. if(type == 2){
  3830. player->InCombat(false);
  3831. if(incombat && player->GetRangeAttack()){
  3832. player->StopCombat(type);
  3833. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3834. }
  3835. else{
  3836. player->SetRangeAttack(true);
  3837. player->InCombat(true, true);
  3838. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3839. }
  3840. }
  3841. else {
  3842. player->InCombat(false, true);
  3843. player->SetRangeAttack(false);
  3844. player->InCombat(true);
  3845. if(!incombat)
  3846. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3847. }
  3848. /*else
  3849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  3850. }
  3851. player->SetCharSheetChanged(true);
  3852. break;
  3853. }
  3854. case COMMAND_DEPOP:{
  3855. bool allow_respawns = false;
  3856. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3857. if(atoi(sep->arg[0]) == 1)
  3858. allow_respawns = true;
  3859. }
  3860. client->GetCurrentZone()->Depop(allow_respawns);
  3861. break;
  3862. }
  3863. case COMMAND_REPOP:{
  3864. client->GetCurrentZone()->Depop(false, true);
  3865. break;
  3866. }
  3867. case COMMAND_BUYBACK:{
  3868. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3869. // 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
  3870. int64 id = atoi64(sep->arg[0]);
  3871. // get the first int32, the item id
  3872. //int32 item_id = (int32)id;
  3873. // get the second int32, the unique id
  3874. int32 unique_id = (int32)(id>>32);
  3875. int8 quantity = atoi(sep->arg[1]);
  3876. if(quantity == 255)
  3877. quantity = 1;
  3878. client->BuyBack(unique_id, quantity);
  3879. }
  3880. break;
  3881. }
  3882. case COMMAND_MERCHANT_BUY:{
  3883. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3884. int32 item_id = atoul(sep->arg[0]);
  3885. int8 quantity = atoi(sep->arg[1]);
  3886. client->BuyItem(item_id, quantity);
  3887. }
  3888. else
  3889. Command_SendMerchantWindow(client, sep);
  3890. break;
  3891. }
  3892. case COMMAND_MERCHANT_SELL:{
  3893. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3894. // 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
  3895. int64 id = atoi64(sep->arg[0]);
  3896. // get the first int32, the item id
  3897. int32 item_id = (int32)id;
  3898. // get the second int32, the unique id
  3899. int32 unique_id = (int32)(id>>32);
  3900. int8 quantity = atoi(sep->arg[1]);
  3901. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  3902. client->SellItem(item_id, quantity, unique_id);
  3903. }
  3904. break;
  3905. }
  3906. case COMMAND_MENDER_REPAIR: {
  3907. if (sep && sep->arg[0] && sep->IsNumber(0))
  3908. client->RepairItem(atoul(sep->arg[0]));
  3909. break;
  3910. }
  3911. case COMMAND_MENDER_REPAIR_ALL: {
  3912. client->RepairAllItems();
  3913. break;
  3914. }
  3915. case COMMAND_CANCEL_MERCHANT:{
  3916. client->SetMerchantTransaction(0);
  3917. break;
  3918. }
  3919. case COMMAND_START_MERCHANT:{
  3920. break;
  3921. }
  3922. case COMMAND_INVULNERABLE:{
  3923. sint8 val = -1;
  3924. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3925. val = atoi(sep->arg[0]);
  3926. //devn00b: Fix for linux builds
  3927. #if defined(__GNUC__)
  3928. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  3929. #else
  3930. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3931. #endif
  3932. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3933. client->GetPlayer()->SetInvulnerable(val==1);
  3934. if(client->GetPlayer()->GetInvulnerable())
  3935. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  3936. else
  3937. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  3938. }
  3939. if(val == -1)
  3940. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  3941. break;
  3942. }
  3943. case COMMAND_REPAIR: {
  3944. Spawn* spawn = cmdTarget;
  3945. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  3946. client->SendHailCommand(spawn);
  3947. client->SetMerchantTransaction(spawn);
  3948. client->SendRepairList();
  3949. }
  3950. break;
  3951. }
  3952. case COMMAND_LOTTO: {
  3953. Spawn* spawn = cmdTarget;
  3954. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  3955. client->SetMerchantTransaction(spawn);
  3956. client->ShowLottoWindow();
  3957. }
  3958. break;
  3959. }
  3960. case COMMAND_ACCEPT_REWARD:{
  3961. int32 unknown = 0;
  3962. int32 selectable_item_id = 0;
  3963. //Quest *quest = 0;
  3964. Collection *collection = 0;
  3965. /* no idea what the first argument is for (faction maybe?)
  3966. if the reward has a selectable item reward, it's sent as the second argument
  3967. if neither of these are included in the reward, there is no sep
  3968. 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
  3969. only 1 quest or collection reward may be displayed at a time */
  3970. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3971. unknown = atoul(sep->arg[0]);
  3972. selectable_item_id = atoul(sep->arg[1]);
  3973. }
  3974. //if ((quest = player->GetPendingQuestReward()))
  3975. // client->AcceptQuestRewards(quest, selectable_item_id);
  3976. /* the below needs to go away eventually and be redone */
  3977. int32 item_id = 0;
  3978. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3979. item_id = atoul(sep->arg[0]);
  3980. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3981. if(quest){
  3982. client->AcceptQuestReward(quest, item_id);
  3983. break;
  3984. }
  3985. bool collectedItems = false;
  3986. if (collection = player->GetPendingCollectionReward())
  3987. {
  3988. client->AcceptCollectionRewards(collection, selectable_item_id);
  3989. collectedItems = true;
  3990. }
  3991. else if (client->GetPlayer()->HasPendingItemRewards()) {
  3992. vector<Item*> items = client->GetPlayer()->GetPendingItemRewards();
  3993. if (items.size() > 0) {
  3994. collectedItems = true;
  3995. for (int i = 0; i < items.size(); i++) {
  3996. client->GetPlayer()->AddItem(new Item(items[i]));
  3997. }
  3998. client->GetPlayer()->ClearPendingItemRewards();
  3999. }
  4000. map<int32, Item*> selectable_item = client->GetPlayer()->GetPendingSelectableItemReward(item_id);
  4001. if (selectable_item.size() > 0) {
  4002. collectedItems = true;
  4003. map<int32, Item*>::iterator itr;
  4004. for (itr = selectable_item.begin(); itr != selectable_item.end(); itr++) {
  4005. client->GetPlayer()->AddItem(new Item(itr->second));
  4006. client->GetPlayer()->ClearPendingSelectableItemRewards(itr->first);
  4007. }
  4008. }
  4009. }
  4010. if (collectedItems) {
  4011. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4012. if (outapp)
  4013. client->QueuePacket(outapp);
  4014. }
  4015. else
  4016. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  4017. break;
  4018. }
  4019. case COMMAND_BUY_FROM_BROKER:{
  4020. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4021. int32 item_id = atoul(sep->arg[0]);
  4022. int16 quantity = atoul(sep->arg[1]);
  4023. Item* item = master_item_list.GetItem(item_id);
  4024. if(item && item->generic_info.max_charges > 1)
  4025. quantity = item->generic_info.max_charges;
  4026. client->AddItem(item_id, quantity, AddItemType::BUY_FROM_BROKER);
  4027. }
  4028. break;
  4029. }
  4030. case COMMAND_SEARCH_STORES_PAGE:{
  4031. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4032. int32 page = atoul(sep->arg[0]);
  4033. client->SearchStore(page);
  4034. }
  4035. break;
  4036. }
  4037. case COMMAND_SEARCH_STORES:{
  4038. if(sep && sep->arg[0][0]){
  4039. const char* values = sep->argplus[0];
  4040. if(values){
  4041. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  4042. map<string, string> str_values = TranslateBrokerRequest(values);
  4043. vector<Item*>* items = master_item_list.GetItems(str_values, client);
  4044. if(items){
  4045. client->SetItemSearch(items);
  4046. client->SearchStore(0);
  4047. }
  4048. }
  4049. }
  4050. break;
  4051. }
  4052. case COMMAND_LUADEBUG:{
  4053. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  4054. client->SetLuaDebugClient(true);
  4055. if(lua_interface)
  4056. lua_interface->UpdateDebugClients(client);
  4057. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4058. }
  4059. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  4060. client->SetLuaDebugClient(false);
  4061. if(lua_interface)
  4062. lua_interface->RemoveDebugClients(client);
  4063. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4064. }
  4065. else{
  4066. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  4067. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  4068. }
  4069. break;
  4070. }
  4071. case COMMAND_SPAWN_GROUP:
  4072. {
  4073. Spawn* target = cmdTarget;
  4074. if(target && target->IsPlayer() == false)
  4075. {
  4076. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  4077. {
  4078. if(target->GetSpawnLocationPlacementID() > 0)
  4079. {
  4080. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  4081. {
  4082. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  4083. if(id > 0)
  4084. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  4085. else
  4086. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  4087. target->SetSpawnGroupID(id);
  4088. target->AddSpawnToGroup(target);
  4089. }
  4090. else
  4091. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  4092. }
  4093. else
  4094. 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.");
  4095. }
  4096. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  4097. {
  4098. if(sep->arg[1] && sep->IsNumber(1))
  4099. {
  4100. int32 group_id = atoul(sep->arg[1]);
  4101. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  4102. if(leader)
  4103. {
  4104. leader->AddSpawnToGroup(target);
  4105. target->SetSpawnGroupID(group_id);
  4106. if(database.SpawnGroupAddSpawn(target, group_id))
  4107. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  4108. else
  4109. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  4110. }
  4111. else
  4112. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  4113. }
  4114. else
  4115. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  4116. }
  4117. else if(target->GetSpawnGroupID() == 0)
  4118. {
  4119. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  4120. }
  4121. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  4122. {
  4123. int32 group_id = target->GetSpawnGroupID();
  4124. target->RemoveSpawnFromGroup();
  4125. if(database.SpawnGroupRemoveSpawn(target, group_id))
  4126. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  4127. else
  4128. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  4129. }
  4130. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  4131. {
  4132. int32 group_id = target->GetSpawnGroupID();
  4133. if(sep->arg[1] && sep->IsNumber(1))
  4134. {
  4135. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  4136. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  4137. else
  4138. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  4139. }
  4140. else
  4141. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  4142. }
  4143. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  4144. {
  4145. int32 group_id = target->GetSpawnGroupID();
  4146. if(sep->arg[1] && sep->IsNumber(1))
  4147. {
  4148. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  4149. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  4150. else
  4151. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  4152. }
  4153. else
  4154. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  4155. }
  4156. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  4157. {
  4158. if(sep->arg[1] && sep->IsNumber(1))
  4159. {
  4160. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  4161. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  4162. else
  4163. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  4164. }
  4165. else
  4166. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  4167. }
  4168. else
  4169. {
  4170. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  4171. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  4172. }
  4173. }
  4174. else
  4175. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  4176. break;
  4177. }
  4178. case COMMAND_SPAWN_COMBINE:{
  4179. Spawn* spawn = cmdTarget;
  4180. float radius = 0;
  4181. bool failed = true;
  4182. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  4183. failed = false;
  4184. if(spawn->GetSpawnGroupID() > 0){
  4185. 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.");
  4186. }
  4187. else if(sep->IsNumber(0)){
  4188. radius = atof(sep->arg[0]);
  4189. client->CombineSpawns(radius, spawn);
  4190. }
  4191. else{
  4192. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  4193. client->AddCombineSpawn(spawn);
  4194. }
  4195. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  4196. client->RemoveCombineSpawn(spawn);
  4197. }
  4198. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  4199. const char* name = 0;
  4200. if(sep->arg[1] && sep->arg[1][0])
  4201. name = sep->argplus[1];
  4202. client->SaveCombineSpawns(name);
  4203. }
  4204. else
  4205. failed = true;
  4206. }
  4207. }
  4208. if(failed){
  4209. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  4210. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  4211. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  4212. }
  4213. break;
  4214. }
  4215. case COMMAND_SPAWN_CREATE:{
  4216. Spawn* spawn = 0;
  4217. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4218. spawn = new Object();
  4219. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4220. }
  4221. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4222. spawn = new GroundSpawn();
  4223. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4224. }
  4225. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4226. spawn = new Sign();
  4227. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4228. }
  4229. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4230. spawn = new NPC();
  4231. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4232. spawn->appearance.pos.collision_radius = 32;
  4233. spawn->secondary_command_list_id = 0;
  4234. spawn->primary_command_list_id = 0;
  4235. spawn->appearance.display_name = 1;
  4236. spawn->appearance.show_level = 1;
  4237. spawn->appearance.attackable = 1;
  4238. }
  4239. else{
  4240. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  4241. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  4242. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  4243. break;
  4244. }
  4245. spawn->SetID(Spawn::NextID());
  4246. spawn->SetX(client->GetPlayer()->GetX());
  4247. spawn->SetY(client->GetPlayer()->GetY());
  4248. spawn->SetZ(client->GetPlayer()->GetZ());
  4249. spawn->SetHeading(client->GetPlayer()->GetHeading());
  4250. spawn->SetSpawnOrigX(spawn->GetX());
  4251. spawn->SetSpawnOrigY(spawn->GetY());
  4252. spawn->SetSpawnOrigZ(spawn->GetZ());
  4253. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4254. if(spawn->IsSign())
  4255. {
  4256. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  4257. ((Sign*)spawn)->SetSignDistance(20.0f);
  4258. ((Sign*)spawn)->SetIncludeLocation(1);
  4259. ((Sign*)spawn)->SetIncludeHeading(1);
  4260. ((Sign*)spawn)->SetInitialState(1);
  4261. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  4262. ((Sign*)spawn)->SetActivityStatus(64);
  4263. spawn->appearance.race = 0;
  4264. spawn->SetLevel(0);
  4265. spawn->SetHP(0);
  4266. spawn->SetTotalHP(0);
  4267. spawn->SetPower(0);
  4268. spawn->SetTotalPower(0);
  4269. spawn->SetEncounterLevel(0);
  4270. spawn->SetTargetable(0);
  4271. spawn->SetSogaModelType(0);
  4272. spawn->SetCollisionRadius(19);
  4273. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  4274. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  4275. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  4276. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4277. spawn->appearance.model_type = atoul(sep->arg[1]);
  4278. }
  4279. else
  4280. {
  4281. spawn->appearance.targetable = 1;
  4282. spawn->appearance.race = 255;
  4283. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4284. spawn->SetModelType(atoi(sep->arg[1]));
  4285. spawn->SetAdventureClass(atoi(sep->arg[2]));
  4286. spawn->SetLevel(atoi(sep->arg[3]));
  4287. spawn->SetName(sep->arg[4]);
  4288. if(sep->arg[5][0] && sep->IsNumber(5))
  4289. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  4290. if(sep->arg[6][0] && sep->IsNumber(6))
  4291. spawn->size = atoi(sep->arg[6]);
  4292. if(spawn->GetTotalHP() == 0){
  4293. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  4294. spawn->SetHP(25*spawn->GetLevel() + 1);
  4295. }
  4296. if(spawn->GetTotalPower() == 0){
  4297. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  4298. spawn->SetPower(25*spawn->GetLevel() + 1);
  4299. }
  4300. }
  4301. client->GetCurrentZone()->AddSpawn(spawn);
  4302. break;
  4303. }
  4304. case COMMAND_SPAWN_EQUIPMENT:{
  4305. Spawn* spawn = cmdTarget;
  4306. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  4307. int8 slot = atoi(sep->arg[0]);
  4308. int16 type = atoi(sep->arg[1]);
  4309. int8 red = 0;
  4310. int8 green = 0;
  4311. int8 blue = 0;
  4312. int8 h_red = 0;
  4313. int8 h_green = 0;
  4314. int8 h_blue = 0;
  4315. if(sep->arg[2])
  4316. red = atoi(sep->arg[2]);
  4317. if(sep->arg[3])
  4318. green = atoi(sep->arg[3]);
  4319. if(sep->arg[4])
  4320. blue = atoi(sep->arg[4]);
  4321. if(sep->arg[5])
  4322. h_red = atoi(sep->arg[5]);
  4323. if(sep->arg[6])
  4324. h_green = atoi(sep->arg[6]);
  4325. if(sep->arg[7])
  4326. h_blue = atoi(sep->arg[7]);
  4327. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  4328. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  4329. }
  4330. else{
  4331. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  4332. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  4333. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  4334. }
  4335. break;
  4336. }
  4337. case COMMAND_SPAWN_DETAILS: {
  4338. Spawn* spawn = cmdTarget;
  4339. if (sep && sep->arg[0][0]) {
  4340. if (cmdTarget)
  4341. {
  4342. if (ToLower(string(sep->arg[0])) == "los")
  4343. {
  4344. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  4345. if (hasLOS)
  4346. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  4347. else
  4348. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  4349. break;
  4350. }
  4351. else if (ToLower(string(sep->arg[0])) == "bestz")
  4352. {
  4353. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  4354. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  4355. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  4356. break;
  4357. }
  4358. else if (ToLower(string(sep->arg[0])) == "inwater")
  4359. {
  4360. if (cmdTarget->GetRegionMap() == nullptr)
  4361. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  4362. else
  4363. {
  4364. bool inWater = cmdTarget->InWater();
  4365. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  4366. }
  4367. break;
  4368. }
  4369. else if (ToLower(string(sep->arg[0])) == "inlava")
  4370. {
  4371. if (cmdTarget->GetRegionMap() == nullptr)
  4372. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4373. else
  4374. {
  4375. bool inLava = cmdTarget->InLava();
  4376. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  4377. }
  4378. break;
  4379. }
  4380. else if (ToLower(string(sep->arg[0])) == "regions")
  4381. {
  4382. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  4383. if (cmdTarget->GetRegionMap() == nullptr)
  4384. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4385. else
  4386. {
  4387. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  4388. }
  4389. break;
  4390. }
  4391. else if (ToLower(string(sep->arg[0])) == "behind")
  4392. {
  4393. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  4394. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  4395. break;
  4396. }
  4397. else if (ToLower(string(sep->arg[0])) == "infront")
  4398. {
  4399. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  4400. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  4401. break;
  4402. }
  4403. else if (ToLower(string(sep->arg[0])) == "flank")
  4404. {
  4405. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  4406. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  4407. break;
  4408. }
  4409. }
  4410. if (sep->IsNumber(0))
  4411. {
  4412. float radius = atof(sep->arg[0]);
  4413. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  4414. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  4415. break;
  4416. }
  4417. }
  4418. if (spawn) {
  4419. const char* type = "NPC";
  4420. if (spawn->IsObject())
  4421. type = "Object";
  4422. else if (spawn->IsSign())
  4423. type = "Sign";
  4424. else if (spawn->IsWidget())
  4425. type = "Widget";
  4426. else if (spawn->IsGroundSpawn())
  4427. type = "GroundSpawn";
  4428. int16 race_type = race_types_list.GetRaceType(spawn->GetModelType());
  4429. int16 race_base_type = race_types_list.GetRaceBaseType(spawn->GetModelType());
  4430. char* category = race_types_list.GetRaceTypeCategory(spawn->GetModelType());
  4431. char* subcategory = race_types_list.GetRaceTypeSubCategory(spawn->GetModelType());
  4432. char* modelname = race_types_list.GetRaceTypeModelName(spawn->GetModelType());
  4433. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  4434. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  4435. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  4436. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  4437. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  4438. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  4439. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  4440. 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());
  4441. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  4442. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  4443. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  4444. if (spawn->IsEntity()) {
  4445. 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());
  4446. 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());
  4447. }
  4448. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i, Race Type: %u, Race Base Type: %u, Race Category: %s (subcategory: %s), Model Name: %s.", spawn->GetModelType(), spawn->GetSogaModelType(), race_type, race_base_type, category, subcategory, modelname);
  4449. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  4450. 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());
  4451. 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);
  4452. if (spawn->IsNPC())
  4453. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  4454. if (spawn->IsNPC()){
  4455. client->Message(CHANNEL_COLOR_YELLOW, "Heat Resist/Base: %u/%u",((NPC*)spawn)->GetHeatResistance(), ((NPC*)spawn)->GetHeatResistanceBase());
  4456. client->Message(CHANNEL_COLOR_YELLOW, "Cold Resist/Base: %u/%u",((NPC*)spawn)->GetColdResistance(), ((NPC*)spawn)->GetColdResistanceBase());
  4457. client->Message(CHANNEL_COLOR_YELLOW, "Magic Resist/Base: %u/%u",((NPC*)spawn)->GetMagicResistance(), ((NPC*)spawn)->GetMagicResistanceBase());
  4458. client->Message(CHANNEL_COLOR_YELLOW, "Mental Resist/Base: %u/%u",((NPC*)spawn)->GetMentalResistance(), ((NPC*)spawn)->GetMentalResistanceBase());
  4459. client->Message(CHANNEL_COLOR_YELLOW, "Divine Resist/Base: %u/%u",((NPC*)spawn)->GetDivineResistance(), ((NPC*)spawn)->GetDivineResistanceBase());
  4460. client->Message(CHANNEL_COLOR_YELLOW, "Disease Resist/Base: %u/%u",((NPC*)spawn)->GetDiseaseResistance(), ((NPC*)spawn)->GetDiseaseResistanceBase());
  4461. client->Message(CHANNEL_COLOR_YELLOW, "Poison Resist/Base: %u/%u",((NPC*)spawn)->GetPoisonResistance(), ((NPC*)spawn)->GetPoisonResistanceBase());
  4462. }
  4463. string details;
  4464. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  4465. details += "Type: " + string(type) + "\n";
  4466. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  4467. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  4468. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  4469. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  4470. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  4471. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  4472. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  4473. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  4474. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  4475. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  4476. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  4477. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  4478. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  4479. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  4480. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  4481. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  4482. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  4483. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  4484. char x[16];
  4485. sprintf(x, "%.2f", spawn->GetX());
  4486. char y[16];
  4487. sprintf(y, "%.2f", spawn->GetY());
  4488. char z[16];
  4489. sprintf(z, "%.2f", spawn->GetZ());
  4490. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  4491. string details2;
  4492. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  4493. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  4494. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  4495. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  4496. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  4497. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  4498. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  4499. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  4500. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  4501. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  4502. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  4503. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  4504. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  4505. details2 += "Race Type: " + to_string(race_type) + "\n";
  4506. details2 += "Race Base Type: " + to_string(race_base_type) + "\n";
  4507. details2 += "Race Category (Sub Category): " + std::string(category) + " (" + std::string(subcategory) + ")\n";
  4508. details2 += "Model Name: " + std::string(modelname) + "\n";
  4509. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  4510. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  4511. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  4512. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  4513. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  4514. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  4515. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  4516. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  4517. string details3;
  4518. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  4519. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  4520. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  4521. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  4522. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  4523. if(spawn->IsEntity())
  4524. {
  4525. Entity* ent = (Entity*)spawn;
  4526. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  4527. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  4528. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  4529. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  4530. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  4531. }
  4532. string details4;
  4533. if (spawn->IsEntity()) {
  4534. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  4535. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4536. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4537. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4538. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4539. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4540. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4541. if (spawn->IsNPC()) {
  4542. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4543. }
  4544. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4545. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4546. }
  4547. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4548. client->SendShowBook(client->GetPlayer(), title, 4, details, details2, details3, details4);
  4549. }
  4550. else {
  4551. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4552. 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.");
  4553. }
  4554. break;
  4555. }
  4556. case COMMAND_SPAWN_TARGET:{
  4557. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4558. int32 spawn_id = atoul(sep->arg[0]);
  4559. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4560. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4561. }
  4562. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4563. float distance = atof(sep->arg[1]);
  4564. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4565. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4566. }
  4567. else{
  4568. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4569. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4570. }
  4571. break;
  4572. }
  4573. case COMMAND_SPAWN_SET:
  4574. {
  4575. Spawn* spawn = cmdTarget;
  4576. sint16 set_type = -1;
  4577. string type_str;
  4578. if (spawn)
  4579. {
  4580. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4581. 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)
  4582. {
  4583. // set the type, which will be 0 if location or list or invalid
  4584. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4585. }
  4586. if(set_type > 0)
  4587. {
  4588. // check if spawn set is NOT a char update, or not location, or isn't a number
  4589. 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)
  4590. {
  4591. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4592. }
  4593. else
  4594. {
  4595. string name = string(spawn->GetName());
  4596. bool customSetSpawn = false;
  4597. if(set_type >= SPAWN_SET_CHEEK_TYPE && set_type <= SPAWN_SET_SOGA_NOSE_TYPE)
  4598. {
  4599. int8 index = sep->IsNumber(2) ? atoul(sep->arg[2]) : 0;
  4600. // override the standard setspawncommand, we pass arguments different!
  4601. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1], true, false, nullptr, index))
  4602. customSetSpawn = true;
  4603. }
  4604. if(customSetSpawn || SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4605. {
  4606. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4607. {
  4608. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4609. }
  4610. else if (set_type == SPAWN_SET_VALUE_NAME)
  4611. {
  4612. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4613. }
  4614. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4615. {
  4616. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4617. }
  4618. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4619. {
  4620. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4621. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  4622. }
  4623. else
  4624. {
  4625. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  4626. }
  4627. switch (set_type)
  4628. {
  4629. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4630. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4631. case SPAWN_SET_VALUE_FACTION:
  4632. case SPAWN_SET_AAXP_REWARDS:
  4633. case SPAWN_SET_CHEEK_TYPE:
  4634. case SPAWN_SET_CHIN_TYPE:
  4635. case SPAWN_SET_EAR_TYPE:
  4636. case SPAWN_SET_EYE_BROW_TYPE:
  4637. case SPAWN_SET_EYE_TYPE:
  4638. case SPAWN_SET_LIP_TYPE:
  4639. case SPAWN_SET_NOSE_TYPE:
  4640. case SPAWN_SET_BODY_SIZE:
  4641. case SPAWN_SET_BODY_AGE:
  4642. case SPAWN_SET_SOGA_CHEEK_TYPE:
  4643. case SPAWN_SET_SOGA_CHIN_TYPE:
  4644. case SPAWN_SET_SOGA_EAR_TYPE:
  4645. case SPAWN_SET_SOGA_EYE_BROW_TYPE:
  4646. case SPAWN_SET_SOGA_EYE_TYPE:
  4647. case SPAWN_SET_SOGA_LIP_TYPE:
  4648. case SPAWN_SET_SOGA_NOSE_TYPE:
  4649. case SPAWN_SET_SOGA_BODY_SIZE:
  4650. case SPAWN_SET_SOGA_BODY_AGE:
  4651. case SPAWN_SET_ATTACK_TYPE:
  4652. case SPAWN_SET_RACE_TYPE:
  4653. {
  4654. // not applicable already ran db command
  4655. break;
  4656. }
  4657. default:
  4658. {
  4659. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4660. break;
  4661. }
  4662. }
  4663. 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))
  4664. {
  4665. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4666. {
  4667. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  4668. }
  4669. else if(spawn->GetSpawnLocationID() > 0)
  4670. {
  4671. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4672. }
  4673. }
  4674. else
  4675. {
  4676. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4677. {
  4678. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  4679. }
  4680. else if(spawn->GetDatabaseID() > 0)
  4681. {
  4682. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4683. }
  4684. }
  4685. }
  4686. }
  4687. }
  4688. else if(set_type == 0)
  4689. {
  4690. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4691. map<string, int8>::iterator itr;
  4692. int i=0;
  4693. string list;
  4694. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4695. {
  4696. if(i==10)
  4697. {
  4698. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4699. i = 0;
  4700. }
  4701. if(i>0)
  4702. {
  4703. list.append(", ").append(itr->first);
  4704. }
  4705. else
  4706. {
  4707. list = itr->first;
  4708. }
  4709. }
  4710. if(list.length() > 0)
  4711. {
  4712. // if 1 or more, display in client.
  4713. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4714. }
  4715. }
  4716. else
  4717. {
  4718. // syntax fail
  4719. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4720. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4721. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4722. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4723. }
  4724. }
  4725. break;
  4726. }
  4727. case COMMAND_SPAWN_REMOVE:{
  4728. Spawn* spawn = cmdTarget;
  4729. if(spawn && !spawn->IsPlayer()){
  4730. if(spawn->GetSpawnLocationID() > 0){
  4731. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4732. client->GetCurrentZone()->RemoveSpawn(spawn, true, false, true, true, true);
  4733. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  4734. }
  4735. else
  4736. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4737. }
  4738. else
  4739. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4740. }
  4741. else{
  4742. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4743. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4744. }
  4745. break;
  4746. }
  4747. case COMMAND_SPAWN_LIST:{
  4748. if(sep && sep->arg[0][0]){
  4749. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4750. vector<string>::iterator itr;
  4751. if(results){
  4752. for(itr=results->begin();itr!=results->end();itr++){
  4753. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4754. }
  4755. safe_delete(results);
  4756. }
  4757. else
  4758. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4759. }
  4760. else{
  4761. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4762. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4763. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4764. }
  4765. break;
  4766. }
  4767. case COMMAND_SPAWN_ADD:{
  4768. Spawn* spawn = cmdTarget;
  4769. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  4770. if(spawn->GetSpawnLocationID() > 0){
  4771. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4772. break;
  4773. }
  4774. if(spawn->GetDatabaseID() == 0){
  4775. if(database.SaveSpawnInfo(spawn)) {
  4776. char spawn_type[32];
  4777. memset(spawn_type, 0, sizeof(spawn_type));
  4778. if (spawn->IsNPC())
  4779. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4780. else if (spawn->IsObject())
  4781. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4782. else if (spawn->IsSign())
  4783. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4784. else if (spawn->IsGroundSpawn())
  4785. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4786. else
  4787. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4788. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4789. }
  4790. else
  4791. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4792. }
  4793. int32 spawn_group_id = 0;
  4794. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4795. spawn_group_id = database.GetNextSpawnLocation();
  4796. else
  4797. spawn_group_id = atol(sep->arg[0]);
  4798. int8 percent = 100;
  4799. if(sep->arg[2] && sep->IsNumber(2))
  4800. percent = atoi(sep->arg[2]);
  4801. spawn->SetSpawnLocationID(spawn_group_id);
  4802. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4803. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4804. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4805. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4806. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4807. else
  4808. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  4809. }
  4810. else{
  4811. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  4812. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  4813. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  4814. }
  4815. break;
  4816. }
  4817. case COMMAND_SPAWN:{
  4818. int32 id = 0;
  4819. Spawn* spawn = 0;
  4820. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4821. id = atol(sep->arg[0]);
  4822. spawn = client->GetCurrentZone()->GetSpawn(id);
  4823. }
  4824. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  4825. id = 0;
  4826. if(!id || !spawn){
  4827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  4828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  4829. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  4830. safe_delete(sep);
  4831. return;
  4832. }
  4833. if(sep && sep->arg[1][0]){
  4834. float x = atof(sep->arg[1]);
  4835. spawn->appearance.pos.X = x;
  4836. }
  4837. else
  4838. spawn->SetX(client->GetPlayer()->GetX(), false);
  4839. if(sep && sep->arg[2][0]){
  4840. float y = atof(sep->arg[2]);
  4841. spawn->appearance.pos.Y = y;
  4842. }
  4843. else
  4844. spawn->SetY(client->GetPlayer()->GetY(), false);
  4845. if(sep && sep->arg[3][0]){
  4846. float z = atof(sep->arg[3]);
  4847. spawn->appearance.pos.Z = z;
  4848. }
  4849. else
  4850. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  4851. if(sep && sep->arg[4][0]){
  4852. float heading = atof(sep->arg[4]);
  4853. spawn->SetHeading(heading);
  4854. }
  4855. else
  4856. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  4857. spawn->SetSpawnOrigX(spawn->GetX());
  4858. spawn->SetSpawnOrigY(spawn->GetY());
  4859. spawn->SetSpawnOrigZ(spawn->GetZ());
  4860. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4861. if(sep && sep->arg[5][0])
  4862. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  4863. else
  4864. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4865. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  4866. spawn->SetTotalHP(spawn->GetLevel() * 15);
  4867. spawn->SetHP(spawn->GetTotalHP());
  4868. }
  4869. if(spawn->GetTotalPower() == 0){
  4870. spawn->SetTotalPower(spawn->GetLevel() * 15);
  4871. spawn->SetPower(spawn->GetTotalPower());
  4872. }
  4873. const char* script = world.GetSpawnScript(id);
  4874. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  4875. spawn->SetSpawnScript(string(script));
  4876. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  4877. client->GetCurrentZone()->AddSpawn(spawn);
  4878. if(spawn->IsNPC())
  4879. spawn->GetZone()->AddLoot((NPC*)spawn);
  4880. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  4881. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  4882. break;
  4883. }
  4884. case COMMAND_ADMINFLAG:
  4885. {
  4886. if(sep && sep->arg[0]){
  4887. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  4888. sint16 new_status = atoi(sep->arg[1]);
  4889. if(tmp_status == -10)
  4890. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  4891. else if(tmp_status >= client->GetAdminStatus())
  4892. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  4893. else if (new_status > client->GetAdminStatus())
  4894. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  4895. else{
  4896. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  4897. if (!client2)
  4898. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  4899. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  4900. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  4901. if (client2) {
  4902. client2->SetAdminStatus(new_status);
  4903. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  4904. }
  4905. }
  4906. else
  4907. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  4908. }
  4909. }else{
  4910. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  4911. if(status != client->GetAdminStatus())
  4912. {
  4913. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  4914. client->SetAdminStatus(status);
  4915. }
  4916. else
  4917. {
  4918. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  4919. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  4920. client->Message(CHANNEL_COLOR_YELLOW," Admin User: %i", status);
  4921. }
  4922. }
  4923. break;
  4924. }
  4925. case COMMAND_CANNEDEMOTE:{
  4926. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  4927. break;
  4928. }
  4929. case COMMAND_BROADCAST: {
  4930. if (sep && sep->arg[0])
  4931. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  4932. else
  4933. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  4934. break;
  4935. }
  4936. case COMMAND_ANNOUNCE: {
  4937. if (sep && sep->arg[0])
  4938. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  4939. else
  4940. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  4941. break;
  4942. }
  4943. case COMMAND_RELOAD_ITEMS:{
  4944. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  4945. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  4946. database.ReloadItemList();
  4947. database.LoadMerchantInformation();
  4948. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  4949. break;
  4950. }
  4951. case COMMAND_ENABLE_ABILITY_QUE:{
  4952. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  4953. if(app)
  4954. client->QueuePacket(app);
  4955. break;
  4956. }
  4957. case COMMAND_ITEMSEARCH:
  4958. case COMMAND_FROMBROKER:{
  4959. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  4960. if (packet) {
  4961. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  4962. //packet->setDataByName("unknown", 1);
  4963. packet->setDataByName("unknown2", 5, 0);
  4964. packet->setDataByName("unknown2", 20, 1);
  4965. packet->setDataByName("unknown2", 58, 3);
  4966. packet->setDataByName("unknown2", 40, 4);
  4967. client->QueuePacket(packet->serialize());
  4968. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  4969. if (packet2) {
  4970. packet2->setDataByName("char_id", client->GetCharacterID());
  4971. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  4972. safe_delete(packet2);
  4973. }
  4974. safe_delete(packet);
  4975. }
  4976. break;
  4977. }
  4978. case COMMAND_ANIMTEST:{
  4979. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  4980. if(command_packet){
  4981. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  4982. if (cmdTarget)
  4983. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  4984. command_packet->setDataByName ( "spawn_id" , id);
  4985. int animID = 1;
  4986. if(sep && sep->arg[0] && sep->IsNumber(0))
  4987. animID = atoi(sep->arg[0]);
  4988. VisualState* vs = NULL;
  4989. if(animID == 0)
  4990. {
  4991. vs = visual_states.FindVisualState(sep->arg[0]);
  4992. }
  4993. char msg[128];
  4994. sprintf(msg,"Animation Test ID: %i",animID);
  4995. command_packet->setMediumStringByName ( "emote_msg" , msg );
  4996. if(vs != NULL)
  4997. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  4998. else
  4999. command_packet->setDataByName ( "anim_type", animID );
  5000. command_packet->setDataByName ( "unknown0", 0 );
  5001. EQ2Packet* outapp = command_packet->serialize();
  5002. client->QueuePacket(outapp);
  5003. safe_delete(command_packet);
  5004. }
  5005. break;
  5006. }
  5007. case COMMAND_KICK:
  5008. {
  5009. if( sep == 0 || sep->arg[0] == 0)
  5010. {
  5011. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  5012. }
  5013. else
  5014. {
  5015. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  5016. if ( kickClient == client )
  5017. {
  5018. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  5019. break;
  5020. }
  5021. else if(kickClient != NULL)
  5022. {
  5023. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5024. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  5025. {
  5026. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5027. break;
  5028. }
  5029. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  5030. kickClient->Disconnect();
  5031. }
  5032. else
  5033. {
  5034. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5035. }
  5036. }
  5037. break;
  5038. }
  5039. case COMMAND_LOCK:
  5040. {
  5041. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  5042. int worldLocked = atoi(sep->arg[0]);
  5043. net.world_locked = worldLocked;
  5044. if ( worldLocked )
  5045. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  5046. else
  5047. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  5048. }
  5049. else
  5050. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  5051. break;
  5052. }
  5053. case COMMAND_BAN:{
  5054. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  5055. {
  5056. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  5057. }
  5058. else
  5059. {
  5060. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  5061. if ( kickClient == client )
  5062. {
  5063. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  5064. break;
  5065. }
  5066. else if(kickClient != NULL)
  5067. {
  5068. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5069. if ( maxStatus > client->GetAdminStatus( ) ||
  5070. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  5071. {
  5072. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5073. break;
  5074. }
  5075. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  5076. int perm = atol(sep->arg[1]);
  5077. if ( perm == 1 )
  5078. database.UpdateAdminStatus(sep->arg[0],-2);
  5079. else
  5080. database.UpdateAdminStatus(sep->arg[0],-1);
  5081. kickClient->Disconnect();
  5082. }
  5083. else
  5084. {
  5085. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5086. }
  5087. }
  5088. break;
  5089. }
  5090. case COMMAND_SET_COMBAT_VOICE:{
  5091. int32 value = 0;
  5092. if(sep && sep->arg[0] && sep->IsNumber(0))
  5093. value = atoi(sep->arg[0]);
  5094. client->GetPlayer()->SetCombatVoice(value);
  5095. break;
  5096. }
  5097. case COMMAND_SET_EMOTE_VOICE:{
  5098. int32 value = 0;
  5099. if(sep && sep->arg[0] && sep->IsNumber(0))
  5100. value = atoi(sep->arg[0]);
  5101. client->GetPlayer()->SetEmoteVoice(value);
  5102. break;
  5103. }
  5104. case COMMAND_GIVEITEM:{
  5105. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  5106. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  5107. if ( itemToClient == NULL )
  5108. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  5109. else
  5110. {
  5111. int32 item_id = atol(sep->arg[1]);
  5112. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  5113. itemToClient->AddItem(item_id);
  5114. }
  5115. }
  5116. else
  5117. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  5118. break;
  5119. }
  5120. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  5121. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  5122. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  5123. case COMMAND_SKILL :
  5124. case COMMAND_SKILL_ADD :
  5125. case COMMAND_SKILL_REMOVE :
  5126. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  5127. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  5128. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  5129. case COMMAND_ENTITYCOMMAND :
  5130. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  5131. case COMMAND_MERCHANT :
  5132. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  5133. case COMMAND_APPEARANCE :
  5134. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  5135. case COMMAND_TRACK : { Command_Track(client); break; }
  5136. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  5137. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  5138. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  5139. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  5140. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  5141. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  5142. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  5143. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  5144. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  5145. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  5146. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  5147. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  5148. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  5149. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  5150. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  5151. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  5152. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  5153. case COMMAND_LOCATION : { Command_Location(client); break; }
  5154. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  5155. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  5156. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  5157. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  5158. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  5159. case COMMAND_GRID : { Command_Grid(client); break; }
  5160. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  5161. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  5162. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  5163. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  5164. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  5165. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  5166. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  5167. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  5168. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  5169. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  5170. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  5171. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  5172. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  5173. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  5174. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  5175. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  5176. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  5177. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  5178. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  5179. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  5180. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  5181. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  5182. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  5183. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  5184. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  5185. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  5186. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  5187. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  5188. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  5189. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  5190. case COMMAND_MOTD : { Command_MOTD(client); break; }
  5191. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  5192. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  5193. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  5194. case COMMAND_TITLE : { Command_Title(client); break; }
  5195. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  5196. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  5197. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  5198. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  5199. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  5200. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  5201. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  5202. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  5203. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  5204. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  5205. case COMMAND_PET : { Command_Pet(client, sep); break; }
  5206. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  5207. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  5208. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  5209. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  5210. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  5211. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  5212. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  5213. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  5214. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  5215. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  5216. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  5217. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  5218. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  5219. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  5220. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  5221. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  5222. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  5223. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  5224. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  5225. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  5226. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  5227. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  5228. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  5229. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  5230. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  5231. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  5232. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  5233. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  5234. //devn00b
  5235. case COMMAND_MOOD : { Command_Mood(client, sep); break;}
  5236. case COMMAND_MODIFY : { Command_Modify(client); break; }
  5237. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  5238. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  5239. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  5240. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  5241. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  5242. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  5243. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  5244. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  5245. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  5246. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  5247. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  5248. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  5249. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  5250. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  5251. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  5252. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  5253. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  5254. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  5255. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  5256. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  5257. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  5258. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5259. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  5260. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  5261. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  5262. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  5263. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  5264. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  5265. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  5266. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  5267. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  5268. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  5269. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  5270. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  5271. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  5272. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  5273. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  5274. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  5275. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  5276. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  5277. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  5278. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  5279. case ADD_AA : { Add_AA(client, sep); break; }
  5280. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  5281. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  5282. case BACK_AA : { Back_AA(client, sep); break; }
  5283. case REMOVE_AA : { Remove_AA(client, sep); break; }
  5284. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  5285. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  5286. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  5287. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  5288. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  5289. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  5290. case COMMAND_CRAFTITEM: {
  5291. Item* item = 0;
  5292. if (sep && sep->IsNumber(0)) {
  5293. int32 item_id = atol(sep->arg[0]);
  5294. int32 quantity = 1;
  5295. if (sep->arg[1] && sep->IsNumber(1))
  5296. quantity = atoi(sep->arg[1]);
  5297. item = new Item(master_item_list.GetItem(item_id));
  5298. if (!item) {
  5299. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  5300. }
  5301. else {
  5302. item->details.count = quantity;
  5303. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  5304. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  5305. bool itemDeleted = false;
  5306. client->AddItem(item, &itemDeleted);
  5307. //Check for crafting quest updates
  5308. int8 update_amt = 0;
  5309. if (!itemDeleted && item->stack_count > 1)
  5310. update_amt = 1;
  5311. else
  5312. update_amt = quantity;
  5313. if(!itemDeleted)
  5314. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  5315. }
  5316. }
  5317. else {
  5318. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  5319. }
  5320. break;
  5321. }
  5322. case COMMAND_UNMENTOR:
  5323. case COMMAND_MENTOR: {
  5324. client->GetPlayer()->MentorTarget();
  5325. break;
  5326. }
  5327. case COMMAND_CANCEL_EFFECT: { Command_CancelEffect(client, sep); break; }
  5328. case COMMAND_CUREPLAYER: { Command_CurePlayer(client, sep); break; }
  5329. default:
  5330. {
  5331. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  5332. break;
  5333. }
  5334. }
  5335. safe_delete(sep);
  5336. }
  5337. /******************** New COMMAND Handler Functions ********************/
  5338. /*
  5339. Started breaking apart the huge switch() for commands into sepErate
  5340. functions so it is easier to locate the blocks of code by command
  5341. -- JA 2012.03.03
  5342. */
  5343. // sample function header
  5344. /*
  5345. Function:
  5346. Purpose :
  5347. Params :
  5348. Dev :
  5349. Example :
  5350. */
  5351. //void Commands::Command()
  5352. //{
  5353. //}
  5354. /*
  5355. Function: Command_AcceptAdvancement()
  5356. Purpose : Player accepts a new advancement option
  5357. Params : Spell ID
  5358. Dev : Jabantiz
  5359. */
  5360. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  5361. {
  5362. Player *player = client->GetPlayer();
  5363. if (sep && sep->IsSet(0)) {
  5364. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  5365. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  5366. if (!player->HasSpell(trait->spellID, 0, true))
  5367. {
  5368. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5369. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5370. }
  5371. else
  5372. {
  5373. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5374. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  5375. player->RemoveSpellBookEntry(spell->GetSpellID());
  5376. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5377. player->UnlockSpell(spell);
  5378. client->SendSpellUpdate(spell);
  5379. }
  5380. // Spell book update
  5381. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  5382. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  5383. }
  5384. }
  5385. /*
  5386. Function:
  5387. Purpose :
  5388. Params :
  5389. Dev :
  5390. Example :
  5391. */
  5392. void Commands::Command_AFK(Client* client, Seperator* sep)
  5393. {
  5394. Player* player = client->GetPlayer();
  5395. player->toggle_character_flag(CF_AFK);
  5396. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  5397. if (player->get_character_flag(CF_AFK))
  5398. {
  5399. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  5400. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  5401. if (sep && sep->argplus[0])
  5402. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  5403. else
  5404. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  5405. string message = string(player->GetName()) + " is going afk.";
  5406. Spawn* target = player->GetTarget();
  5407. if (target && target != player)
  5408. {
  5409. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  5410. player->GetGender() == 1 ? message += "he" : message += "she";
  5411. message += " is going afk.";
  5412. }
  5413. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  5414. }
  5415. /*else
  5416. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  5417. }
  5418. /*
  5419. Function: Command_Appearance()
  5420. Purpose : Handles /appearance commands
  5421. Params : list
  5422. Dev : Scatman
  5423. Example : /appearance list
  5424. */
  5425. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  5426. {
  5427. if( handler == COMMAND_APPEARANCE )
  5428. {
  5429. // /appearance command by itself shows help (to be extended)
  5430. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5431. return;
  5432. }
  5433. else if( handler == COMMAND_APPEARANCE_LIST )
  5434. {
  5435. // /appearance list command expects "name" param
  5436. if (sep && sep->arg[0])
  5437. {
  5438. const char* appearance_name = sep->argplus[0];
  5439. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  5440. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  5441. if (appearances)
  5442. {
  5443. vector<int16>::iterator itr;
  5444. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  5445. {
  5446. int16 id = *itr;
  5447. string name = database.GetAppearanceName(id);
  5448. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  5449. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  5450. }
  5451. safe_delete(appearances);
  5452. }
  5453. }
  5454. else // no param
  5455. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5456. }
  5457. }
  5458. /*
  5459. Function: Command_Claim()
  5460. Purpose :
  5461. Params :
  5462. Dev :
  5463. Example :
  5464. */
  5465. void Commands::Command_Claim(Client* client, Seperator* sep)
  5466. {
  5467. if (sep && sep->arg[0] && sep->IsNumber(0))
  5468. {
  5469. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5470. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  5471. }
  5472. else
  5473. client->ShowClaimWindow();
  5474. }
  5475. /*
  5476. Function: Command_ClearAllQueued()
  5477. Purpose :
  5478. Params :
  5479. Dev :
  5480. Example :
  5481. */
  5482. void Commands::Command_ClearAllQueued(Client* client)
  5483. {
  5484. ZoneServer* zone = client->GetPlayer()->GetZone();
  5485. if (zone && zone->GetSpellProcess())
  5486. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  5487. }
  5488. /*
  5489. Function: Command_CancelMaintained()
  5490. Purpose : Cancels maintained spells
  5491. Params : Maintained Spell Index
  5492. Dev : Zcoretri
  5493. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  5494. */
  5495. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  5496. {
  5497. if (sep && sep->arg[0] && sep->IsNumber(0))
  5498. {
  5499. int32 spell_index = atoul(sep->arg[0]);
  5500. if(spell_index > 29)
  5501. return;
  5502. client->GetPlayer()->MMaintainedSpells.readlock(__FUNCTION__, __LINE__);
  5503. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  5504. client->GetPlayer()->MMaintainedSpells.releasereadlock(__FUNCTION__, __LINE__);
  5505. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled", false, true))
  5506. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  5507. }
  5508. }
  5509. /*
  5510. Function: Command_Create()
  5511. Purpose : Handler for starting Tradeskilling table
  5512. Params :
  5513. Dev : Zcoretri
  5514. Example :
  5515. */
  5516. void Commands::Command_Create(Client* client, Seperator* sep)
  5517. {
  5518. PrintSep(sep, "COMMAND_CREATE");
  5519. client->SendRecipeList();
  5520. client->ShowRecipeBook();
  5521. }
  5522. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  5523. {
  5524. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  5525. if (sep && sep->arg[0] && sep->IsNumber(0))
  5526. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  5527. }
  5528. /*
  5529. Function: Command_Distance()
  5530. Purpose : Displays distance from targeted spawn
  5531. Params :
  5532. Dev : Scatman
  5533. Example : /distance
  5534. */
  5535. void Commands::Command_Distance(Client* client)
  5536. {
  5537. Spawn* target = client->GetPlayer()->GetTarget();
  5538. if (target)
  5539. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  5540. else
  5541. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  5542. }
  5543. /*
  5544. Function: Command_Duel()
  5545. Purpose : Handle the /duel commands - not yet implemented
  5546. Params : unknown
  5547. Dev :
  5548. Example :
  5549. */
  5550. void Commands::Command_Duel(Client* client, Seperator* sep)
  5551. {
  5552. PrintSep(sep, "COMMAND_DUEL");
  5553. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  5554. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5555. }
  5556. /*
  5557. Function: Command_DuelBet()
  5558. Purpose : Handle the /duel commands - not yet implemented
  5559. Params : unknown
  5560. Dev :
  5561. Example :
  5562. */
  5563. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  5564. {
  5565. PrintSep(sep, "COMMAND_DUELBET");
  5566. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  5567. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5568. }
  5569. /*
  5570. Function: Command_DuelAccept()
  5571. Purpose : Handle the /duel commands - not yet implemented
  5572. Params : unknown
  5573. Dev :
  5574. Example :
  5575. */
  5576. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5577. {
  5578. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5579. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5580. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5581. }
  5582. /*
  5583. Function: Command_DuelDecline()
  5584. Purpose : Handle the /duel commands - not yet implemented
  5585. Params : unknown
  5586. Dev :
  5587. Example :
  5588. */
  5589. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5590. {
  5591. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5592. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5593. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5594. }
  5595. /*
  5596. Function: Command_DuelSurrender()
  5597. Purpose : Handle the /duel commands - not yet implemented
  5598. Params : unknown
  5599. Dev :
  5600. Example :
  5601. */
  5602. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5603. {
  5604. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5605. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5606. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5607. // JA, just messin around ;)
  5608. char surrender[64];
  5609. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5610. zone_list.HandleGlobalAnnouncement(surrender);
  5611. }
  5612. /*
  5613. Function: Command_DuelToggle()
  5614. Purpose : Handle the /duel commands - not yet implemented
  5615. Params : unknown
  5616. Dev :
  5617. Example :
  5618. */
  5619. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5620. {
  5621. PrintSep(sep, "COMMAND_DUEL");
  5622. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5623. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5624. }
  5625. /*
  5626. Function:
  5627. Purpose :
  5628. Params :
  5629. Dev :
  5630. Example :
  5631. */
  5632. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5633. {
  5634. if( handler == COMMAND_ENTITYCOMMAND )
  5635. {
  5636. // /entitycommand command by itself shows help (to be extended)
  5637. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5638. return;
  5639. }
  5640. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5641. {
  5642. // /entitycommand list command expects "name" param
  5643. if (sep && sep->arg[0])
  5644. {
  5645. const char* entity_command_name = sep->argplus[0];
  5646. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5647. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5648. map<int32, vector<EntityCommand*>*>::iterator itr;
  5649. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5650. {
  5651. vector<EntityCommand*>* entity_command_list = itr->second;
  5652. vector<EntityCommand*>::iterator itr2;
  5653. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5654. {
  5655. EntityCommand* entity_command = *itr2;
  5656. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5657. 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);
  5658. }
  5659. }
  5660. }
  5661. else // no command name
  5662. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5663. }
  5664. }
  5665. /*
  5666. Function: Command_Follow()
  5667. Purpose : Handle the /follow command - not yet implemented
  5668. Params :
  5669. Dev :
  5670. Example :
  5671. */
  5672. void Commands::Command_Follow(Client* client, Seperator* sep)
  5673. {
  5674. PrintSep(sep, "COMMAND_FOLLOW");
  5675. // flag to toggle if the players target is in the players group
  5676. bool targetInGroup = false;
  5677. // get a pointer to the players group
  5678. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5679. // If the player has a group and has a target
  5680. if (gmi && client->GetPlayer()->GetTarget()) {
  5681. deque<GroupMemberInfo*>::iterator itr;
  5682. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5683. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5684. if (group)
  5685. {
  5686. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5687. deque<GroupMemberInfo*>* members = group->GetMembers();
  5688. // Loop through the group members
  5689. for (itr = members->begin(); itr != members->end(); itr++) {
  5690. // If a group member matches a target
  5691. if ((*itr)->member && (*itr)->member == client->GetPlayer()->GetTarget()) {
  5692. // toggle the flag and break the loop
  5693. targetInGroup = true;
  5694. break;
  5695. }
  5696. }
  5697. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5698. }
  5699. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5700. }
  5701. if (targetInGroup) {
  5702. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5703. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5704. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5705. client->GetPlayer()->info_changed = true;
  5706. client->GetPlayer()->changed = true;
  5707. }
  5708. else
  5709. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5710. }
  5711. /*
  5712. Function: Command_StopFollow()
  5713. Purpose : Handle the /stop_follow command - not yet implemented
  5714. Params :
  5715. Dev :
  5716. Example :
  5717. */
  5718. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5719. {
  5720. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5721. if (client->GetPlayer()->GetFollowTarget()) {
  5722. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5723. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5724. client->GetPlayer()->SetFollowTarget(0);
  5725. client->GetPlayer()->info_changed = true;
  5726. client->GetPlayer()->changed = true;
  5727. }
  5728. }
  5729. /*
  5730. Function: Command_Grid()
  5731. Purpose : Show player's current Grid ID
  5732. Params :
  5733. Dev : Scatman
  5734. Example : /grid
  5735. */
  5736. void Commands::Command_Grid(Client* client)
  5737. {
  5738. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  5739. if (client->GetPlayer()->GetMap() != nullptr) {
  5740. auto loc = glm::vec3(client->GetPlayer()->GetX(), client->GetPlayer()->GetZ(), client->GetPlayer()->GetY());
  5741. uint32 GridID = 0;
  5742. float new_z = client->GetPlayer()->GetMap()->FindBestZ(loc, nullptr, &GridID);
  5743. client->Message(CHANNEL_COLOR_YELLOW, "Grid result is %u, at EQ2 Y coordinate %f", GridID, new_z);
  5744. }
  5745. }
  5746. /*
  5747. Function: Command_Guild()
  5748. Purpose : Handler for all UI-related guild commands
  5749. Dev : Scatman
  5750. */
  5751. void Commands::Command_Guild(Client* client, Seperator* sep)
  5752. {
  5753. Guild* guild = client->GetPlayer()->GetGuild();
  5754. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  5755. {
  5756. const char* command = sep->arg[0];
  5757. int32 length = strlen(command);
  5758. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  5759. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  5760. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  5761. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5762. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5763. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5764. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5765. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  5766. guild->KickGuildMember(client, sep->arg[1]);
  5767. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  5768. guild->DemoteGuildMember(client, sep->arg[1]);
  5769. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  5770. guild->PromoteGuildMember(client, sep->arg[1]);
  5771. else if (strncmp(command, "points", length) == 0 && guild)
  5772. {
  5773. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  5774. {
  5775. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5776. {
  5777. float points = atof(sep->arg[2]);
  5778. const char* option = sep->arg[3];
  5779. const char* comment = sep->argplus[4];
  5780. if (strncmp(option, "all", strlen(option)) == 0)
  5781. guild->AddPointsToAll(client, points, comment);
  5782. else if (strncmp(option, "online", strlen(option)) == 0)
  5783. guild->AddPointsToAllOnline(client, points, comment);
  5784. else if (strncmp(option, "group", strlen(option)) == 0)
  5785. guild->AddPointsToGroup(client, points, comment);
  5786. else if (strncmp(option, "raid", strlen(option)) == 0)
  5787. guild->AddPointsToRaid(client, points, comment);
  5788. else
  5789. guild->AddPointsToGuildMember(client, points, option, comment);
  5790. }
  5791. }
  5792. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  5793. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  5794. else
  5795. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  5796. }
  5797. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  5798. guild->SetMOTD(sep->argplus[1]);
  5799. else if (strncmp(command, "recruiting", length) == 0 && guild)
  5800. {
  5801. if (sep->arg[1])
  5802. {
  5803. const char* option = sep->arg[1];
  5804. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  5805. guild->SetRecruitingShortDesc(sep->argplus[2]);
  5806. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  5807. guild->SetRecruitingFullDesc(sep->argplus[2]);
  5808. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5809. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5810. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5811. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  5812. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5813. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  5814. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  5815. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  5816. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  5817. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5818. else
  5819. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5820. }
  5821. else
  5822. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5823. }
  5824. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  5825. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5826. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  5827. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5828. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5829. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5830. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  5831. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  5832. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5833. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5834. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  5835. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  5836. else if (strncmp(command, "invite", length) == 0 && guild)
  5837. {
  5838. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5839. guild->InvitePlayer(client, sep->arg[1]);
  5840. else
  5841. {
  5842. Spawn* target = client->GetPlayer()->GetTarget();
  5843. if (target)
  5844. {
  5845. if (target->IsPlayer())
  5846. guild->InvitePlayer(client, target->GetName());
  5847. else
  5848. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  5849. }
  5850. }
  5851. }
  5852. else if (strncmp(command, "accept", length) == 0)
  5853. {
  5854. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5855. if (pgi && pgi->guild && pgi->invited_by)
  5856. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  5857. client->SetPendingGuildInvite(0);
  5858. }
  5859. else if (strncmp(command, "decline", length) == 0)
  5860. {
  5861. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5862. if (pgi && pgi->guild && pgi->invited_by)
  5863. {
  5864. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  5865. if (client_inviter)
  5866. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  5867. }
  5868. client->SetPendingGuildInvite(0);
  5869. }
  5870. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  5871. {
  5872. const char* guild_name = sep->argplus[1];
  5873. if (!guild_list.GetGuild(guild_name))
  5874. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  5875. else
  5876. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  5877. }
  5878. else if (strncmp(command, "search", length) == 0)
  5879. client->ShowGuildSearchWindow();
  5880. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  5881. {
  5882. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  5883. if (to_guild)
  5884. to_guild->SendGuildRecruitingDetails(client);
  5885. }
  5886. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  5887. {
  5888. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  5889. if (to_guild)
  5890. to_guild->SendGuildRecruitingImages(client);
  5891. }
  5892. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  5893. {
  5894. if (sep->arg[1])
  5895. {
  5896. const char* option = sep->arg[1];
  5897. if (strncmp(option, "toggle", strlen(option)) == 0)
  5898. guild->ToggleGuildRecruiterAdventureClass(client);
  5899. }
  5900. else
  5901. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  5902. }
  5903. else if (strncmp(command, "display_heraldry", length) == 0)
  5904. {
  5905. // JA: not sure this is right...
  5906. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  5907. client->GetPlayer()->SetCharSheetChanged(true);
  5908. }
  5909. else
  5910. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  5911. }
  5912. }
  5913. /*
  5914. Function: Command_GuildCreate()
  5915. Purpose : Display's in-game Guild Creation window
  5916. Dev : Scatman
  5917. */
  5918. void Commands::Command_CreateGuild(Client* client)
  5919. {
  5920. client->SendGuildCreateWindow();
  5921. }
  5922. /*
  5923. Function: Command_SetGuildOfficerNote()
  5924. Purpose :
  5925. Dev : Scatman
  5926. */
  5927. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  5928. {
  5929. if (sep && sep->arg[0] && sep->arg[1])
  5930. {
  5931. Guild* guild = client->GetPlayer()->GetGuild();
  5932. if (guild)
  5933. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  5934. }
  5935. }
  5936. /*
  5937. Function: Command_SetGuildMemberNote()
  5938. Purpose :
  5939. Dev : Scatman
  5940. */
  5941. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  5942. {
  5943. if (sep && sep->arg[0] && sep->arg[1])
  5944. {
  5945. Guild* guild = client->GetPlayer()->GetGuild();
  5946. if (guild)
  5947. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  5948. }
  5949. }
  5950. /*
  5951. Function: Command_GuildSay()
  5952. Purpose :
  5953. Dev : Scatman
  5954. */
  5955. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  5956. {
  5957. Guild* guild = client->GetPlayer()->GetGuild();
  5958. if (guild)
  5959. {
  5960. if (sep && sep->arg[0])
  5961. guild->HandleGuildSay(client, sep->argplus[0]);
  5962. }
  5963. else
  5964. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  5965. }
  5966. /*
  5967. Function: Command_OfficerSay()
  5968. Purpose :
  5969. Dev : Scatman
  5970. */
  5971. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  5972. {
  5973. Guild* guild = client->GetPlayer()->GetGuild();
  5974. if (guild)
  5975. {
  5976. if (sep && sep->arg[0])
  5977. guild->HandleOfficerSay(client, sep->argplus[0]);
  5978. }
  5979. else
  5980. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  5981. }
  5982. /*
  5983. Function: Command_Guilds()
  5984. Purpose : Shows help for /guild command
  5985. Params :
  5986. Dev : Scatman
  5987. Example :
  5988. */
  5989. void Commands::Command_Guilds(Client* client)
  5990. {
  5991. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  5992. }
  5993. /*
  5994. Function: Command_GuildsAdd()
  5995. Purpose : Add's players to a guild
  5996. Params : guild_name|guild_id, player name
  5997. Dev : Scatman
  5998. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  5999. */
  6000. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  6001. {
  6002. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6003. {
  6004. Guild* guild = 0;
  6005. bool found = true;
  6006. if (sep->IsNumber(0))
  6007. {
  6008. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6009. if (!guild)
  6010. {
  6011. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6012. found = false;
  6013. }
  6014. }
  6015. else
  6016. {
  6017. guild = guild_list.GetGuild(sep->arg[0]);
  6018. if (!guild)
  6019. {
  6020. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6021. found = false;
  6022. }
  6023. }
  6024. if (found)
  6025. {
  6026. Client* to_client = 0;
  6027. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6028. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6029. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6030. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6031. if (to_client)
  6032. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  6033. else
  6034. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6035. }
  6036. }
  6037. else
  6038. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  6039. }
  6040. /*
  6041. Function: Command_GuildsCreate()
  6042. Purpose : Creates a guild
  6043. Params : guild_name, player_name (optional)
  6044. Dev : Scatman
  6045. Example : /guilds create [guild name] (player name)
  6046. */
  6047. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  6048. {
  6049. if (sep && sep->arg[0])
  6050. {
  6051. const char* guild_name = sep->arg[0];
  6052. if (!guild_list.GetGuild(guild_name))
  6053. {
  6054. bool ret = false;
  6055. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6056. {
  6057. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6058. if (to_client)
  6059. {
  6060. world.CreateGuild(guild_name, to_client);
  6061. ret = true;
  6062. }
  6063. else
  6064. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  6065. }
  6066. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6067. {
  6068. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6069. if (to_client)
  6070. {
  6071. world.CreateGuild(guild_name, to_client);
  6072. ret = true;
  6073. }
  6074. }
  6075. else
  6076. {
  6077. world.CreateGuild(guild_name);
  6078. ret = true;
  6079. }
  6080. if (ret)
  6081. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  6082. else
  6083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  6084. }
  6085. else
  6086. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  6087. }
  6088. else
  6089. 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.");
  6090. }
  6091. /*
  6092. Function: Command_GuildsDelete()
  6093. Purpose : Delete's a guild
  6094. Params : guild name
  6095. Dev : Scatman
  6096. Example : /guilds delete Test
  6097. */
  6098. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  6099. {
  6100. if (sep && sep->arg[0])
  6101. {
  6102. Guild* guild = 0;
  6103. bool found = true;
  6104. if (sep->IsNumber(0))
  6105. {
  6106. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6107. if (!guild)
  6108. {
  6109. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6110. found = false;
  6111. }
  6112. }
  6113. else
  6114. {
  6115. guild = guild_list.GetGuild(sep->arg[0]);
  6116. if (!guild)
  6117. {
  6118. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6119. found = false;
  6120. }
  6121. }
  6122. if (found)
  6123. {
  6124. guild->RemoveAllGuildMembers();
  6125. database.DeleteGuild(guild);
  6126. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  6127. guild_list.RemoveGuild(guild, true);
  6128. }
  6129. }
  6130. else
  6131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  6132. }
  6133. /*
  6134. Function: Command_GuildsList()
  6135. Purpose : Lists current guilds on server
  6136. Params :
  6137. Dev : Scatman
  6138. Example : /guilds list
  6139. */
  6140. void Commands::Command_GuildsList(Client* client)
  6141. {
  6142. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  6143. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  6144. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  6145. if (guilds->size() == 0)
  6146. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  6147. else {
  6148. while (itr.Next()) {
  6149. Guild* guild = itr.second;
  6150. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  6151. }
  6152. }
  6153. }
  6154. /*
  6155. Function: Command_GuildsRemove()
  6156. Purpose : Removes a player from a guild
  6157. Params : guild name|guild id, player name
  6158. Dev : Scatman
  6159. Example : /guilds remove 1 Admin = removes Admin from guild 1
  6160. */
  6161. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  6162. {
  6163. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6164. {
  6165. Guild* guild = 0;
  6166. bool found = true;
  6167. if (sep->IsNumber(0))
  6168. {
  6169. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6170. if (!guild)
  6171. {
  6172. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6173. found = false;
  6174. }
  6175. }
  6176. else
  6177. {
  6178. guild = guild_list.GetGuild(sep->arg[0]);
  6179. if (!guild)
  6180. {
  6181. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6182. found = false;
  6183. }
  6184. }
  6185. if (found)
  6186. {
  6187. Client* to_client = 0;
  6188. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6189. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6190. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6191. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6192. if (to_client)
  6193. {
  6194. Player* to_player = to_client->GetPlayer();
  6195. if (to_player->GetGuild())
  6196. {
  6197. if (to_player->GetGuild() == guild)
  6198. {
  6199. guild->KickGuildMember(client, to_player->GetName());
  6200. }
  6201. else
  6202. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  6203. }
  6204. else
  6205. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  6206. }
  6207. else
  6208. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6209. }
  6210. }
  6211. else
  6212. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  6213. }
  6214. /*
  6215. Function: Command_InspectPlayer()
  6216. Purpose : Handle the Inspect functions
  6217. Params : Client to inspect
  6218. Dev : Scatman
  6219. Example : /inspect Scatman
  6220. */
  6221. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  6222. {
  6223. if (sep && sep->arg[0])
  6224. {
  6225. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  6226. if (inspect_client)
  6227. client->InspectPlayer(inspect_client->GetPlayer());
  6228. }
  6229. else
  6230. {
  6231. Spawn* target = client->GetPlayer()->GetTarget();
  6232. if (target && target->IsPlayer())
  6233. client->InspectPlayer((Player*)target);
  6234. }
  6235. }
  6236. /*
  6237. Function: Command_Inventory()
  6238. Purpose : Handle changes in player inventory
  6239. Params : <TBD>
  6240. Dev : All
  6241. Example : /inventory delete item_id
  6242. */
  6243. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  6244. {
  6245. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  6246. Player* player = client->GetPlayer();
  6247. if(sep && sep->arg[0][0])
  6248. {
  6249. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  6250. if(client->GetPlayer()->GetHP() == 0)
  6251. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  6252. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6253. {
  6254. int16 index = atoi(sep->arg[1]);
  6255. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6256. if(item)
  6257. {
  6258. if(item->details.item_locked) {
  6259. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item in use.");
  6260. return;
  6261. }
  6262. else if(item->CheckFlag(NO_DESTROY)) {
  6263. client->SimpleMessage(CHANNEL_COLOR_RED, "You can't destroy this item.");
  6264. return;
  6265. }
  6266. if(item->GetItemScript() && lua_interface)
  6267. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  6268. //reobtain item make sure it wasn't removed
  6269. item = player->item_list.GetItemFromIndex(index);
  6270. int32 bag_id = 0;
  6271. if(item){
  6272. bag_id = item->details.inv_slot_id;
  6273. database.DeleteItem(client->GetCharacterID(), item, 0);
  6274. }
  6275. client->GetPlayer()->item_list.DestroyItem(index);
  6276. client->GetPlayer()->UpdateInventory(bag_id);
  6277. }
  6278. }
  6279. 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))
  6280. {
  6281. int16 from_index = atoi(sep->arg[1]);
  6282. sint16 to_slot = atoi(sep->arg[2]);
  6283. sint32 bag_id = atol(sep->arg[3]);
  6284. int8 charges = atoi(sep->arg[4]);
  6285. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  6286. if(!item) {
  6287. client->SimpleMessage(CHANNEL_COLOR_RED, "You have no item.");
  6288. return;
  6289. }
  6290. if(item->details.item_locked)
  6291. {
  6292. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot move the item in use.");
  6293. return;
  6294. }
  6295. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  6296. {
  6297. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  6298. return;
  6299. }
  6300. sint32 old_inventory_id = 0;
  6301. if(item)
  6302. old_inventory_id = item->details.inv_slot_id;
  6303. //autobank
  6304. if (bag_id == -3 && to_slot == -1)
  6305. {
  6306. if (player->HasFreeBankSlot())
  6307. to_slot = player->FindFreeBankSlot();
  6308. else
  6309. {
  6310. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  6311. return;
  6312. }
  6313. }
  6314. //auto inventory
  6315. if (bag_id == 0 && to_slot == -1)
  6316. {
  6317. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6318. {
  6319. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  6320. return;
  6321. }
  6322. }
  6323. bool item_deleted = false;
  6324. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, &item_deleted, client->GetVersion());
  6325. client->QueuePacket(outapp);
  6326. if(item_deleted)
  6327. item = nullptr;
  6328. //removed from bag send update
  6329. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  6330. {
  6331. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  6332. if(outapp)
  6333. client->QueuePacket(outapp);
  6334. }
  6335. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  6336. {
  6337. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  6338. if(outapp)
  6339. client->QueuePacket(outapp);
  6340. }
  6341. }
  6342. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  6343. {
  6344. if(client->GetPlayer()->EngagedInCombat())
  6345. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  6346. else
  6347. {
  6348. int16 index = atoi(sep->arg[1]);
  6349. int8 slot_id = 255;
  6350. int8 unk3 = 0;
  6351. int8 appearance_equip = 0;
  6352. if(sep->arg[2][0] && sep->IsNumber(2))
  6353. slot_id = atoi(sep->arg[2]);
  6354. if(sep->arg[3][0] && sep->IsNumber(3))
  6355. unk3 = atoul(sep->arg[3]);
  6356. if(sep->arg[4][0] && sep->IsNumber(4))
  6357. appearance_equip = atoul(sep->arg[4]);
  6358. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  6359. EQ2Packet* outapp = 0;
  6360. for(int32 i=0;i<packets.size();i++)
  6361. {
  6362. outapp = packets[i];
  6363. if(outapp)
  6364. client->QueuePacket(outapp);
  6365. }
  6366. client->GetPlayer()->ChangePrimaryWeapon();
  6367. client->GetPlayer()->ChangeSecondaryWeapon();
  6368. client->GetPlayer()->ChangeRangedWeapon();
  6369. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6370. client->QueuePacket(characterSheetPackets);
  6371. }
  6372. }
  6373. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6374. {
  6375. if (client->GetPlayer()->EngagedInCombat())
  6376. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  6377. else {
  6378. int16 index = atoi(sep->arg[1]);
  6379. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6380. if (item) {
  6381. if(item->details.item_locked)
  6382. {
  6383. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot unpack the item in use.");
  6384. return;
  6385. }
  6386. // client->GetPlayer()->item_list.DestroyItem(index);
  6387. if (item->item_sets.size() > 0) {
  6388. for (int32 i = 0; i < item->item_sets.size(); i++) {
  6389. ItemSet* set = item->item_sets[i];
  6390. if (set->item_stack_size == 0)
  6391. set->item_stack_size += 1;
  6392. client->AddItem(set->item_id, set->item_stack_size);
  6393. }
  6394. }
  6395. }
  6396. client->RemoveItem(item, 1);
  6397. }
  6398. }
  6399. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  6400. {
  6401. if(client->GetPlayer()->EngagedInCombat())
  6402. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  6403. else
  6404. {
  6405. int16 index = atoi(sep->arg[1]);
  6406. sint32 bag_id = -999;
  6407. int8 to_slot = 255;
  6408. if(sep->arg[3][0])
  6409. {
  6410. if(sep->IsNumber(2))
  6411. bag_id = atol(sep->arg[2]);
  6412. if(sep->IsNumber(3))
  6413. to_slot = atoi(sep->arg[3]);
  6414. }
  6415. sint8 unk4 = 0;
  6416. int8 appearance_equip = 0;
  6417. if(sep->arg[4][0] && sep->IsNumber(4))
  6418. unk4 = atoi(sep->arg[4]);
  6419. if(sep->arg[5][0] && sep->IsNumber(5))
  6420. appearance_equip = atoul(sep->arg[5]);
  6421. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  6422. EQ2Packet* outapp = 0;
  6423. for(int32 i=0;i<packets.size();i++)
  6424. {
  6425. outapp = packets[i];
  6426. if(outapp)
  6427. client->QueuePacket(outapp);
  6428. }
  6429. client->GetPlayer()->ChangePrimaryWeapon();
  6430. client->GetPlayer()->ChangeSecondaryWeapon();
  6431. client->GetPlayer()->ChangeRangedWeapon();
  6432. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6433. client->QueuePacket(characterSheetPackets);
  6434. }
  6435. }
  6436. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6437. {
  6438. if(client->GetPlayer()->EngagedInCombat()) {
  6439. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not swap items while in combat.");
  6440. }
  6441. else {
  6442. int16 index1 = atoi(sep->arg[1]);
  6443. int16 index2 = atoi(sep->arg[2]);
  6444. int8 type = 0;
  6445. if(sep->IsNumber(3))
  6446. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  6447. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  6448. if(outapp)
  6449. client->QueuePacket(outapp);
  6450. else
  6451. {
  6452. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  6453. return;
  6454. }
  6455. }
  6456. }
  6457. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6458. {
  6459. sint16 to_slot = atoi(sep->arg[1]);
  6460. sint32 bag_id = atoi(sep->arg[2]);
  6461. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  6462. if (item) {
  6463. //auto inventory
  6464. if (bag_id == 0 && to_slot == -1)
  6465. {
  6466. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6467. {
  6468. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  6469. return;
  6470. }
  6471. // Set the slot for the item
  6472. item->details.inv_slot_id = bag_id;
  6473. item->details.slot_id = to_slot;
  6474. // Flag the item so it gets saved in its new location
  6475. item->save_needed = true;
  6476. // Add the item to its new location
  6477. if(player->item_list.AddItem(item)) {
  6478. // Remove the item from the overflow list
  6479. player->item_list.RemoveOverflowItem(item);
  6480. }
  6481. // Send the inventory update packet
  6482. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6483. return;
  6484. }
  6485. else if (bag_id == -3 && to_slot == -1) {
  6486. // Auto Bank
  6487. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  6488. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  6489. return;
  6490. }
  6491. item->details.inv_slot_id = bag_id;
  6492. item->details.slot_id = to_slot;
  6493. item->save_needed = true;
  6494. if(player->item_list.AddItem(item)) {
  6495. player->item_list.RemoveOverflowItem(item);
  6496. }
  6497. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6498. }
  6499. else if (bag_id == -4) {
  6500. // Shared Bank
  6501. if (!player->item_list.SharedBankAddAllowed(item)) {
  6502. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  6503. return;
  6504. }
  6505. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  6506. if (tmp_item) {
  6507. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6508. return;
  6509. }
  6510. else {
  6511. item->details.inv_slot_id = bag_id;
  6512. item->details.slot_id = to_slot;
  6513. item->save_needed = true;
  6514. if(player->item_list.AddItem(item)) {
  6515. player->item_list.RemoveOverflowItem(item);
  6516. }
  6517. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6518. return;
  6519. }
  6520. }
  6521. else {
  6522. // Try to get an item from the given bag id and slot id
  6523. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  6524. // Check to see if we got an item, if we do send an error,
  6525. // if we don't put the overflow item into this slot
  6526. if (tmp_item) {
  6527. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6528. }
  6529. else {
  6530. item->details.inv_slot_id = bag_id;
  6531. item->details.slot_id = to_slot;
  6532. item->save_needed = true;
  6533. if(player->item_list.AddItem(item)) {
  6534. player->item_list.RemoveOverflowItem(item);
  6535. }
  6536. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6537. return;
  6538. }
  6539. }
  6540. }
  6541. }
  6542. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6543. {
  6544. sint64 data = strtoull(sep->arg[1], NULL, 0);
  6545. int32 character_item_id = (int32) (data >> 32);
  6546. int32 item_id = (int32) (data & 0xffffffffL);
  6547. int8 sale_setting = atoi(sep->arg[2]);
  6548. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  6549. if(item)
  6550. {
  6551. item->no_sale = sale_setting;
  6552. item->save_needed = true;
  6553. client->SendSellMerchantList();
  6554. }
  6555. }
  6556. }
  6557. else
  6558. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  6559. }
  6560. /*
  6561. Function: Command_IRC()
  6562. Purpose : Handle the IRC functions
  6563. Params : IRC Commands
  6564. Dev : Scatman
  6565. Example : /irc say #Channel Hello World!
  6566. */
  6567. void Commands::Command_IRC(Client* client, Seperator* sep)
  6568. {
  6569. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  6570. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  6571. return;
  6572. }
  6573. if (sep && sep->arg[0][0]) {
  6574. if (strcasecmp(sep->arg[0], "say") == 0) {
  6575. if (sep->arg[1][0] && sep->arg[2][0]) {
  6576. if (sep->IsNumber(sep->arg[1]))
  6577. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  6578. else
  6579. irc.Say(client, sep->arg[1], sep->argplus[2]);
  6580. }
  6581. else
  6582. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  6583. }
  6584. else if (strcasecmp(sep->arg[0], "join") == 0) {
  6585. if (sep->arg[1][0])
  6586. irc.JoinChannel(client, sep->arg[1]);
  6587. else
  6588. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  6589. }
  6590. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  6591. if (sep->arg[1][0])
  6592. irc.LeaveChannel(client, sep->arg[1]);
  6593. else
  6594. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  6595. }
  6596. else if (strcasecmp(sep->arg[0], "list") == 0)
  6597. irc.ListChannels(client);
  6598. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  6599. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  6600. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  6601. else
  6602. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  6603. }
  6604. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  6605. irc.DisconnectFromServer(client);
  6606. else
  6607. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  6608. }
  6609. else
  6610. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  6611. }
  6612. /*
  6613. Function: Command_Languages()
  6614. Purpose : Show's languages the player knows
  6615. Params :
  6616. Dev : Zcoretri
  6617. Example :
  6618. */
  6619. void Commands::Command_Languages(Client* client, Seperator* sep)
  6620. {
  6621. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6622. list<Language*>::iterator itr;
  6623. Language* language;
  6624. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6625. for(itr = languages->begin(); itr != languages->end(); itr++)
  6626. {
  6627. language = *itr;
  6628. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6629. }
  6630. }
  6631. /*
  6632. Function: Command_SetLanguage()
  6633. Purpose : Handles language commands
  6634. Params : Language ID
  6635. Dev : Zcoretri
  6636. Example :
  6637. */
  6638. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6639. {
  6640. Player* player = client->GetPlayer();
  6641. if (sep && sep->arg[0])
  6642. {
  6643. if(!sep->IsNumber(0))
  6644. {
  6645. //String passed in
  6646. const char* value = sep->arg[0];
  6647. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6648. {
  6649. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6650. client->SendLanguagesUpdate(0);
  6651. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6652. }
  6653. else
  6654. {
  6655. if(player->HasLanguage(value))
  6656. {
  6657. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6658. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6659. client->SendLanguagesUpdate(language->GetID());
  6660. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6661. }
  6662. else
  6663. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6664. }
  6665. }
  6666. else
  6667. {
  6668. //Number passed in
  6669. int32 id = atoul(sep->arg[0]);
  6670. if(player->HasLanguage(id))
  6671. {
  6672. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6673. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6674. client->SendLanguagesUpdate(id);
  6675. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6676. }
  6677. else
  6678. {
  6679. Language* language = master_languages_list.GetLanguage(id);
  6680. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6681. }
  6682. }
  6683. }
  6684. else
  6685. {
  6686. //No value was passed in
  6687. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6688. if(id > 0)
  6689. {
  6690. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6691. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6692. }
  6693. else
  6694. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6695. }
  6696. }
  6697. /*
  6698. Function: Command_LastName()
  6699. Purpose : Sets player surname
  6700. Params : Name text
  6701. Dev : theFoof
  6702. Example :
  6703. */
  6704. void Commands::Command_LastName(Client* client, Seperator* sep)
  6705. {
  6706. if (!client)
  6707. return;
  6708. if (sep && sep->arg[0])
  6709. {
  6710. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6711. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6712. return;
  6713. }
  6714. client->RemovePendingLastName();
  6715. uchar* checkname = (uchar*)sep->arg[0];
  6716. bool valid_name = true;
  6717. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6718. if (!alpha_check(checkname[i])) {
  6719. valid_name = false;
  6720. break;
  6721. }
  6722. }
  6723. if (!valid_name) {
  6724. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6725. return;
  6726. }
  6727. string last_name = (string)sep->arg[0];
  6728. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6729. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6730. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6731. client->SetPendingLastName(last_name);
  6732. client->SendLastNameConfirmation();
  6733. }
  6734. else
  6735. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6736. }
  6737. }
  6738. /*
  6739. Function: Command_ConfirmLastName()
  6740. Purpose : Confirms setting of player surname
  6741. Params : Name text
  6742. Dev : theFoof
  6743. Example :
  6744. */
  6745. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6746. {
  6747. if (!client)
  6748. return;
  6749. string* name = client->GetPendingLastName();
  6750. if (name){
  6751. Player* player = client->GetPlayer();
  6752. player->SetLastName(name->c_str(), false);
  6753. client->SendTitleUpdate();
  6754. player->SetCharSheetChanged(true);
  6755. client->RemovePendingLastName();
  6756. }
  6757. }
  6758. /*
  6759. Function: Command_Location()
  6760. Purpose : Display's Help for /location commands
  6761. Params :
  6762. Dev : Scatman
  6763. Example : /location = show's help for command
  6764. */
  6765. void Commands::Command_Location(Client* client)
  6766. {
  6767. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6768. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6769. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6770. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6771. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6772. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6773. }
  6774. /*
  6775. Function: Command_LocationAdd()
  6776. Purpose : Add's a location to an existing location config
  6777. Params : location_id
  6778. Dev : Scatman
  6779. Example : /location add {location_id}
  6780. */
  6781. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6782. {
  6783. if (sep && sep->arg[0] && sep->IsNumber(0))
  6784. {
  6785. int32 location_id = atoul(sep->arg[0]);
  6786. float x = client->GetPlayer()->GetX();
  6787. float y = client->GetPlayer()->GetY();
  6788. float z = client->GetPlayer()->GetZ();
  6789. if (database.AddLocationPoint(location_id, x, y, z))
  6790. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6791. else
  6792. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6793. }
  6794. else
  6795. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6796. }
  6797. /*
  6798. Function: Command_LocationCreate()
  6799. Purpose : Creates a new location config
  6800. Params : location name, 0/1 for include_y (optional)
  6801. Dev : Scatman
  6802. Example : /location create Test 1 = creates a new location named Test with include_y True
  6803. */
  6804. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6805. {
  6806. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6807. {
  6808. const char* name = sep->arg[0];
  6809. bool include_y = false;
  6810. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6811. include_y = true;
  6812. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  6813. if (location_id > 0)
  6814. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6815. else
  6816. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6817. }
  6818. else
  6819. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6820. }
  6821. /*
  6822. Function: Command_LocationDelete()
  6823. Purpose : Delete's a location config and all it's location points
  6824. Params : location_id
  6825. Dev : Scatman
  6826. Example : /location delete {location_id}
  6827. */
  6828. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6829. {
  6830. if (sep && sep->arg[0] && sep->IsNumber(0))
  6831. {
  6832. int32 location_id = atoul(sep->arg[0]);
  6833. if (database.DeleteLocation(location_id))
  6834. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6835. else
  6836. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6837. }
  6838. else
  6839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6840. }
  6841. /*
  6842. Function: Command_LocationList()
  6843. Purpose : Display's a list of location points
  6844. Params : location_id
  6845. Dev : Scatman
  6846. Example : /location list {location_id}
  6847. */
  6848. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6849. {
  6850. if (sep && sep->arg[0])
  6851. {
  6852. const char* option = sep->arg[0];
  6853. if (strncmp(option, "locations", strlen(option)) == 0)
  6854. database.ListLocations(client);
  6855. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  6856. {
  6857. int32 location_id = atoul(sep->arg[1]);
  6858. database.ListLocationPoints(client, location_id);
  6859. }
  6860. else
  6861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6862. }
  6863. else
  6864. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6865. }
  6866. /*
  6867. Function: Command_LocationRemove()
  6868. Purpose : Removes a single location point from a location config
  6869. Params : location_point_id (gotten from /location list {id})
  6870. Dev : Scatman
  6871. Example : /location remove 1 = will remove location_point_id 1
  6872. */
  6873. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  6874. {
  6875. if (sep && sep->arg[0] && sep->IsNumber(0))
  6876. {
  6877. int32 location_point_id = atoul(sep->arg[0]);
  6878. if (database.DeleteLocationPoint(location_point_id))
  6879. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  6880. else
  6881. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  6882. }
  6883. else
  6884. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  6885. }
  6886. /*
  6887. Function: Command_Merchant()
  6888. Purpose : Handles Merchant commands
  6889. Params : list
  6890. Dev : Scatman
  6891. Example : /merchant list
  6892. */
  6893. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  6894. {
  6895. if( handler == COMMAND_MERCHANT )
  6896. {
  6897. // /merchant command by itself shows help (to be extended)
  6898. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6899. return;
  6900. }
  6901. else if( handler == COMMAND_MERCHANT_LIST )
  6902. {
  6903. // /merchant list command expects "description" param
  6904. if (sep && sep->arg[0])
  6905. {
  6906. const char* merchant_description = sep->argplus[0];
  6907. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  6908. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  6909. map<int32, MerchantInfo*>::iterator itr;
  6910. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  6911. {
  6912. string description = database.GetMerchantDescription(itr->first);
  6913. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  6914. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  6915. }
  6916. }
  6917. else // no description
  6918. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6919. }
  6920. }
  6921. /*
  6922. Function: Command_Modify()
  6923. Purpose : to replace our other "set" commands
  6924. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  6925. Dev : John Adams
  6926. Example : /modify spell set name "Aegolism III"
  6927. */
  6928. void Commands::Command_Modify(Client* client)
  6929. {
  6930. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  6931. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  6932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  6933. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  6934. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  6935. }
  6936. /*
  6937. Function: Command_ModifySpawn()
  6938. Purpose : replace "spawn set" commands
  6939. Params : Action : the action to perform (or special handler)
  6940. : Field : the DB field to change
  6941. : Value : what to set the value to
  6942. : Target : what object to change (my target, or spawn_id)
  6943. Dev : John Adams
  6944. Example : /modify spawn set name "Lady Vox"
  6945. :
  6946. Note : Special Handlers, like "zoneto" for Signs
  6947. : /modify spawn zoneto
  6948. : Will set a sign's zone x/y/z to my current coords
  6949. */
  6950. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  6951. {
  6952. PrintSep(sep, "COMMAND_MODIFY");
  6953. // need at least 2 args for a valid command
  6954. if( sep && sep->arg[1] )
  6955. {
  6956. // JA: just a quick implementation because I need it :)
  6957. if (strcmp(sep->arg[0], "zoneto") == 0)
  6958. {
  6959. if( sep->IsNumber(1) )
  6960. {
  6961. int32 spawn_id = atoul(sep->arg[1]);
  6962. float x_coord = client->GetPlayer()->GetX();
  6963. float y_coord = client->GetPlayer()->GetY();
  6964. float z_coord = client->GetPlayer()->GetZ();
  6965. float h_coord = client->GetPlayer()->GetHeading();
  6966. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  6967. }
  6968. else
  6969. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  6970. }
  6971. }
  6972. else
  6973. Command_Modify(client);
  6974. }
  6975. /*
  6976. Function: Command_ModifyCharacter()
  6977. Purpose : to replace our other "set" commands
  6978. Params : Action : Add, Remove
  6979. : Field : copper, silver, gold, plat
  6980. : Value : min 1, max unlimited
  6981. : Target : Self, Player
  6982. Dev : Cynnar
  6983. Example : /modify character add gold 50
  6984. : /modify character remove silver 25
  6985. */
  6986. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  6987. {
  6988. PrintSep(sep, "COMMAND_MODIFY");
  6989. int64 value = 0;
  6990. Player* player = client->GetPlayer();
  6991. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  6992. player = (Player*)player->GetTarget();
  6993. // need at least 2 args for a valid command
  6994. if( sep && sep->arg[1] )
  6995. {
  6996. if (strcmp(sep->arg[0], "add") == 0)
  6997. {
  6998. if (strcmp(sep->arg[1], "copper") == 0)
  6999. {
  7000. value = atoi64(sep->arg[2]);
  7001. player->AddCoins(value);
  7002. if (client->GetPlayer() == player)
  7003. {
  7004. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  7005. }
  7006. else {
  7007. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7008. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7009. }
  7010. }
  7011. else if (strcmp(sep->arg[1], "silver") == 0)
  7012. {
  7013. value = atoi64(sep->arg[2]) * 100;
  7014. player->AddCoins(value);
  7015. if (client->GetPlayer() == player)
  7016. {
  7017. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  7018. }
  7019. else {
  7020. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  7021. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7022. }
  7023. }
  7024. else if (strcmp(sep->arg[1], "gold") == 0)
  7025. {
  7026. value = atoi64(sep->arg[2]) * 10000;
  7027. player->AddCoins(value);
  7028. if (client->GetPlayer() == player)
  7029. {
  7030. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  7031. }
  7032. else {
  7033. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7034. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7035. }
  7036. }
  7037. else if (strcmp(sep->arg[1], "plat") == 0)
  7038. {
  7039. value = atoi64(sep->arg[2]) * 1000000;
  7040. player->AddCoins(value);
  7041. if (client->GetPlayer() == player)
  7042. {
  7043. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  7044. }
  7045. else {
  7046. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7047. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7048. }
  7049. }
  7050. else
  7051. {
  7052. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7053. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7054. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7055. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  7056. }
  7057. }
  7058. else if (strcmp(sep->arg[0], "remove") == 0)
  7059. {
  7060. if (strcmp(sep->arg[1], "copper") == 0)
  7061. {
  7062. value = atoi64(sep->arg[2]);
  7063. player->RemoveCoins(value);
  7064. if (client->GetPlayer() == player)
  7065. {
  7066. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  7067. }
  7068. else {
  7069. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  7070. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7071. }
  7072. }
  7073. else if (strcmp(sep->arg[1], "silver") == 0)
  7074. {
  7075. value = atoi64(sep->arg[2]) * 100;
  7076. player->RemoveCoins(value);
  7077. if (client->GetPlayer() == player)
  7078. {
  7079. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  7080. }
  7081. else {
  7082. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  7083. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7084. }
  7085. }
  7086. else if (strcmp(sep->arg[1], "gold") == 0)
  7087. {
  7088. value = atoi64(sep->arg[2]) * 10000;
  7089. player->RemoveCoins(value);
  7090. if (client->GetPlayer() == player)
  7091. {
  7092. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  7093. }
  7094. else {
  7095. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  7096. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7097. }
  7098. }
  7099. else if (strcmp(sep->arg[1], "plat") == 0)
  7100. {
  7101. value = atoi64(sep->arg[2]) * 1000000;
  7102. player->RemoveCoins(value);
  7103. if (client->GetPlayer() == player)
  7104. {
  7105. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  7106. }
  7107. else {
  7108. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  7109. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7110. }
  7111. }
  7112. else
  7113. {
  7114. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7115. }
  7116. }
  7117. else if (strcmp(sep->arg[0], "set") == 0) {
  7118. if (strcmp(sep->arg[1], "tslevel") == 0) {
  7119. int8 level = atoi(sep->arg[2]);
  7120. if (level > 0 && level < 256) {
  7121. if (player) {
  7122. if (client->GetPlayer() == player)
  7123. client->ChangeTSLevel(player->GetTSLevel(), level);
  7124. else
  7125. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  7126. }
  7127. }
  7128. else
  7129. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  7130. }
  7131. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  7132. int8 tsclass = atoi(sep->arg[2]);
  7133. player->SetTradeskillClass(tsclass);
  7134. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  7135. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  7136. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  7137. player->SetCharSheetChanged(true);
  7138. }
  7139. }
  7140. }
  7141. else
  7142. {
  7143. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7144. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7145. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7146. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7147. }
  7148. }
  7149. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  7150. {
  7151. PrintSep(sep, "COMMAND_MODIFY");
  7152. // need at least 2 args for a valid command
  7153. if( sep && sep->arg[1] )
  7154. {
  7155. }
  7156. else
  7157. Command_Modify(client);
  7158. }
  7159. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  7160. {
  7161. PrintSep(sep, "COMMAND_MODIFY");
  7162. // need at least 2 args for a valid command
  7163. if( sep && sep->arg[1] )
  7164. {
  7165. }
  7166. else
  7167. Command_Modify(client);
  7168. }
  7169. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  7170. {
  7171. PrintSep(sep, "COMMAND_MODIFY");
  7172. // need at least 2 args for a valid command
  7173. if( sep && sep->arg[1] )
  7174. {
  7175. }
  7176. else
  7177. Command_Modify(client);
  7178. }
  7179. /*
  7180. Function: Command_ModifyQuest()
  7181. Purpose : to list players quest and completed quests
  7182. Params : Action : list, completed
  7183. : Target : Self, Player
  7184. Dev : Cynnar
  7185. Example : /modify quest list
  7186. : /modify quest completed
  7187. */
  7188. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  7189. {
  7190. PrintSep(sep, "COMMAND_MODIFY");
  7191. int64 value = 0;
  7192. Player* player = client->GetPlayer();
  7193. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7194. player = (Player*)player->GetTarget();
  7195. // need at least 2 args for a valid command
  7196. if (sep && sep->arg[1])
  7197. {
  7198. if (strcmp(sep->arg[0], "list") == 0)
  7199. {
  7200. map<int32, Quest*>* quests = player->GetPlayerQuests();
  7201. map<int32, Quest*>::iterator itr;
  7202. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  7203. if (quests->size() == 0)
  7204. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  7205. else
  7206. {
  7207. for (itr = quests->begin(); itr != quests->end(); itr++)
  7208. {
  7209. Quest* quest = itr->second;
  7210. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7211. }
  7212. }
  7213. }
  7214. else if (strcmp(sep->arg[0], "completed") == 0)
  7215. {
  7216. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  7217. map<int32, Quest*>::iterator itr;
  7218. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  7219. if (quests->size() == 0)
  7220. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  7221. else
  7222. {
  7223. for (itr = quests->begin(); itr != quests->end(); itr++)
  7224. {
  7225. Quest* quest = itr->second;
  7226. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7227. }
  7228. }
  7229. }
  7230. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  7231. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  7232. else if (strcmp(sep->arg[0], "remove") == 0)
  7233. {
  7234. int32 quest_id = 0;
  7235. if (sep && sep->arg[1] && sep->IsNumber(1))
  7236. quest_id = atoul(sep->arg[1]);
  7237. if (quest_id > 0)
  7238. {
  7239. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  7240. {
  7241. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7242. if (quest)
  7243. if (client->GetPlayer() == player)
  7244. {
  7245. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  7246. }
  7247. else
  7248. {
  7249. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  7250. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  7251. }
  7252. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  7253. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  7254. }
  7255. client->RemovePlayerQuest(quest_id);
  7256. client->GetCurrentZone()->SendQuestUpdates(client);
  7257. }
  7258. }
  7259. else if (strcmp(sep->arg[0], "advance") == 0)
  7260. {
  7261. int32 quest_id = 0;
  7262. int32 step = 0;
  7263. if (sep && sep->arg[1] && sep->IsNumber(1))
  7264. {
  7265. quest_id = atoul(sep->arg[1]);
  7266. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7267. if (sep && sep->arg[2] && sep->IsNumber(1))
  7268. {
  7269. step = atoul(sep->arg[2]);
  7270. if (quest_id > 0 && step > 0)
  7271. {
  7272. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  7273. {
  7274. if (client)
  7275. {
  7276. client->AddPendingQuestUpdate(quest_id, step);
  7277. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  7278. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  7279. }
  7280. }
  7281. }
  7282. else
  7283. {
  7284. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  7285. }
  7286. }
  7287. else
  7288. {
  7289. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  7290. }
  7291. }
  7292. else
  7293. {
  7294. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  7295. }
  7296. }
  7297. else
  7298. {
  7299. Command_Modify(client);
  7300. }
  7301. }
  7302. else
  7303. {
  7304. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  7305. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  7306. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  7307. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  7308. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  7309. }
  7310. }
  7311. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  7312. {
  7313. PrintSep(sep, "COMMAND_MODIFY");
  7314. // need at least 2 args for a valid command
  7315. if( sep && sep->arg[1] )
  7316. {
  7317. if (strcmp(sep->arg[0], "add") == 0) {
  7318. const char* skill_name = sep->argplus[1];
  7319. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7320. if (skill) {
  7321. Player* player = 0;
  7322. Client* to_client = 0;
  7323. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7324. player = (Player*)client->GetPlayer()->GetTarget();
  7325. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7326. }
  7327. else {
  7328. player = client->GetPlayer();
  7329. to_client = client;
  7330. }
  7331. if (player)
  7332. {
  7333. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7334. {
  7335. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7336. if (to_client == client) {
  7337. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  7338. }
  7339. else {
  7340. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7341. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7342. }
  7343. }
  7344. else
  7345. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  7346. }
  7347. }
  7348. else
  7349. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7350. }
  7351. else if (strcmp(sep->arg[0], "remove") == 0) {
  7352. const char* skill_name = sep->argplus[1];
  7353. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7354. if (skill) {
  7355. Player* player = 0;
  7356. Client* to_client = 0;
  7357. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7358. player = (Player*)client->GetPlayer()->GetTarget();
  7359. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7360. }
  7361. else {
  7362. player = client->GetPlayer();
  7363. to_client = client;
  7364. }
  7365. if (player)
  7366. {
  7367. if (player->GetSkills()->HasSkill(skill->skill_id))
  7368. {
  7369. player->RemoveSkillFromDB(skill, true);
  7370. if (client == to_client) {
  7371. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  7372. }
  7373. else {
  7374. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7375. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7376. }
  7377. }
  7378. else {
  7379. if (client == to_client)
  7380. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  7381. else
  7382. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7383. }
  7384. }
  7385. }
  7386. else
  7387. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7388. }
  7389. else if (strcmp(sep->arg[0], "set") == 0) {
  7390. if (!sep->IsNumber(2)) {
  7391. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  7392. return;
  7393. }
  7394. const char* skill_name = sep->arg[1];
  7395. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7396. if (skill) {
  7397. int16 val = atoi(sep->arg[2]);
  7398. Player* player = 0;
  7399. Client* to_client = 0;
  7400. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7401. player = (Player*)client->GetPlayer()->GetTarget();
  7402. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7403. }
  7404. else {
  7405. player = client->GetPlayer();
  7406. to_client = client;
  7407. }
  7408. if (player)
  7409. {
  7410. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  7411. player->GetSkills()->SetSkill(skill->skill_id, val);
  7412. if (client != to_client)
  7413. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  7414. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  7415. }
  7416. else {
  7417. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  7418. }
  7419. }
  7420. }
  7421. else {
  7422. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7423. }
  7424. }
  7425. else {
  7426. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7427. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7428. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7429. }
  7430. }
  7431. else {
  7432. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7433. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7434. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7435. }
  7436. }
  7437. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  7438. {
  7439. PrintSep(sep, "COMMAND_MODIFY");
  7440. // need at least 2 args for a valid command
  7441. if( sep && sep->arg[1] )
  7442. {
  7443. }
  7444. else
  7445. Command_Modify(client);
  7446. }
  7447. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  7448. {
  7449. PrintSep(sep, "COMMAND_MODIFY");
  7450. // need at least 2 args for a valid command
  7451. if( sep && sep->arg[1] )
  7452. {
  7453. }
  7454. else
  7455. Command_Modify(client);
  7456. }
  7457. /*
  7458. Function: Command_MOTD()
  7459. Purpose : Displays server MOTD
  7460. Params :
  7461. Dev : LethalEncounter
  7462. Example : /motd
  7463. */
  7464. void Commands::Command_MOTD(Client* client)
  7465. {
  7466. if (client)
  7467. ClientPacketFunctions::SendMOTD(client);
  7468. }
  7469. /*
  7470. Function: Command_Pet()
  7471. Purpose : Handle Pet {Command} commands
  7472. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  7473. Dev :
  7474. Example : /pet preserve_master
  7475. */
  7476. void Commands::Command_Pet(Client* client, Seperator* sep)
  7477. {
  7478. PrintSep(sep, "COMMAND_PET");
  7479. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  7480. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7481. if (!sep || !sep->arg[0])
  7482. return; // should have sep->arg[0] filled
  7483. if (strcmp(sep->arg[0], "hide") == 0) {
  7484. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  7485. Entity* pet = client->GetPlayer()->GetDeityPet();
  7486. if (pet) {
  7487. if (pet->IsPrivateSpawn())
  7488. client->GetPlayer()->HideDeityPet(false);
  7489. else
  7490. client->GetPlayer()->HideDeityPet(true);
  7491. }
  7492. pet = client->GetPlayer()->GetCosmeticPet();
  7493. if (pet) {
  7494. if (pet->IsPrivateSpawn())
  7495. client->GetPlayer()->HideCosmeticPet(false);
  7496. else
  7497. client->GetPlayer()->HideCosmeticPet(true);
  7498. }
  7499. return;
  7500. }
  7501. // below is for all combat pets
  7502. if (!client->GetPlayer()->HasPet()) {
  7503. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  7504. return;
  7505. }
  7506. if (strcmp(sep->arg[0], "stay") == 0) {
  7507. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  7508. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  7509. client->GetPlayer()->SetCharSheetChanged(true);
  7510. if (client->GetPlayer()->GetPet())
  7511. client->GetPlayer()->GetPet()->following = false;
  7512. if (client->GetPlayer()->GetCharmedPet())
  7513. client->GetPlayer()->GetCharmedPet()->following = false;
  7514. }
  7515. else if (strcmp(sep->arg[0], "follow") == 0) {
  7516. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  7517. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  7518. client->GetPlayer()->SetCharSheetChanged(true);
  7519. }
  7520. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  7521. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  7522. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  7523. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  7524. }
  7525. else {
  7526. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  7527. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  7528. }
  7529. client->GetPlayer()->SetCharSheetChanged(true);
  7530. }
  7531. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  7532. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  7533. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  7534. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  7535. }
  7536. else {
  7537. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  7538. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  7539. }
  7540. client->GetPlayer()->SetCharSheetChanged(true);
  7541. }
  7542. else if (strcmp(sep->arg[0], "backoff") == 0) {
  7543. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  7544. if (client->GetPlayer()->GetPet())
  7545. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  7546. if (client->GetPlayer()->GetCharmedPet())
  7547. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  7548. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  7549. client->GetPlayer()->SetCharSheetChanged(true);
  7550. }
  7551. else if (strcmp(sep->arg[0], "attack") == 0) {
  7552. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  7553. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  7554. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  7555. if (client->GetPlayer()->GetPet())
  7556. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7557. if (client->GetPlayer()->GetCharmedPet())
  7558. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7559. }
  7560. else
  7561. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  7562. }
  7563. else
  7564. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  7565. }
  7566. else if (strcmp(sep->arg[0], "getlost") == 0) {
  7567. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  7568. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  7569. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  7570. }
  7571. else
  7572. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  7573. }
  7574. /*
  7575. Function: Command_PetName()
  7576. Purpose : Pet your name (???)
  7577. Params :
  7578. Dev :
  7579. Example :
  7580. */
  7581. void Commands::Command_PetName(Client* client, Seperator* sep)
  7582. {
  7583. PrintSep(sep, "COMMAND_PETNAME");
  7584. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  7585. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7586. }
  7587. /*
  7588. Function: Command_NamePet()
  7589. Purpose : Name your pet
  7590. Params :
  7591. Dev :
  7592. Example :
  7593. */
  7594. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7595. {
  7596. PrintSep(sep, "COMMAND_NAME_PET");
  7597. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7598. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7599. }
  7600. /*
  7601. Function: Command_Rename()
  7602. Purpose : Renames existing pet
  7603. Params :
  7604. Dev :
  7605. Example :
  7606. */
  7607. void Commands::Command_Rename(Client* client, Seperator* sep)
  7608. {
  7609. PrintSep(sep, "COMMAND_RENAME");
  7610. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7611. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7612. }
  7613. /*
  7614. Function: Command_ConfirmRename()
  7615. Purpose : Confirms renaming your pet
  7616. Params :
  7617. Dev :
  7618. Example :
  7619. */
  7620. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7621. {
  7622. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7623. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7624. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7625. }
  7626. /*
  7627. Function: Command_PetOptions()
  7628. Purpose : Sets various pet options
  7629. Params :
  7630. Dev :
  7631. Example :
  7632. */
  7633. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7634. {
  7635. PrintSep(sep, "COMMAND_PETOPTIONS");
  7636. Player* player = client->GetPlayer();
  7637. Spawn* target = player->GetTarget();
  7638. if (!target)
  7639. return;
  7640. if (target == player->GetPet())
  7641. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7642. else if (target == player->GetCharmedPet())
  7643. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7644. else if (target == player->GetCosmeticPet())
  7645. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7646. else if (target == player->GetDeityPet())
  7647. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7648. }
  7649. /*
  7650. Function: Command_Random()
  7651. Purpose : Handles /random dice roll in-game
  7652. Params : 1-100
  7653. Dev : Scatman
  7654. Example : /randon 1 100
  7655. */
  7656. void Commands::Command_Random(Client* client, Seperator* sep)
  7657. {
  7658. char message[256] = {0};
  7659. if (sep)
  7660. {
  7661. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7662. 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])));
  7663. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7664. 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])));
  7665. else
  7666. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7667. }
  7668. else
  7669. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7670. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7671. }
  7672. /*
  7673. Function: Command_Randomize()
  7674. Purpose : Sets randomize (appearance) values for NPCs
  7675. Params : Attrib Name
  7676. Dev : Scatman
  7677. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7678. */
  7679. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7680. {
  7681. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7682. if (target)
  7683. {
  7684. if (target->IsNPC())
  7685. {
  7686. if (sep && sep->arg[0] && !sep->IsNumber(0))
  7687. {
  7688. const char* value = sep->arg[0];
  7689. if (strncasecmp(value, "show", strlen(value)) == 0)
  7690. {
  7691. client->DisplayRandomizeFeatures(target->GetRandomize());
  7692. }
  7693. else
  7694. {
  7695. if (sep->arg[1] && sep->IsNumber(1))
  7696. {
  7697. int8 option = atoi(sep->arg[1]);
  7698. if (option == 0 || option == 1)
  7699. {
  7700. int32 feature = 0;
  7701. char feature_text[32] = {0};
  7702. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7703. feature = RANDOMIZE_GENDER;
  7704. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7705. }
  7706. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7707. feature = RANDOMIZE_RACE;
  7708. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7709. }
  7710. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7711. feature = RANDOMIZE_MODEL_TYPE;
  7712. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7713. }
  7714. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7715. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7716. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7717. }
  7718. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7719. feature = RANDOMIZE_HAIR_TYPE;
  7720. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7721. }
  7722. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7723. feature = RANDOMIZE_WING_TYPE;
  7724. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7725. }
  7726. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7727. feature = RANDOMIZE_CHEEK_TYPE;
  7728. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7729. }
  7730. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7731. feature = RANDOMIZE_CHIN_TYPE;
  7732. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7733. }
  7734. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7735. feature = RANDOMIZE_EAR_TYPE;
  7736. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7737. }
  7738. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7739. feature = RANDOMIZE_EYE_BROW_TYPE;
  7740. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7741. }
  7742. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7743. feature = RANDOMIZE_EYE_TYPE;
  7744. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7745. }
  7746. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7747. feature = RANDOMIZE_LIP_TYPE;
  7748. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7749. }
  7750. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7751. feature = RANDOMIZE_NOSE_TYPE;
  7752. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7753. }
  7754. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7755. feature = RANDOMIZE_EYE_COLOR;
  7756. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7757. }
  7758. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7759. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7760. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7761. }
  7762. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7763. feature = RANDOMIZE_HAIR_COLOR1;
  7764. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7765. }
  7766. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7767. feature = RANDOMIZE_HAIR_COLOR2;
  7768. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7769. }
  7770. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7771. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7772. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7773. }
  7774. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7775. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7776. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7777. }
  7778. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7779. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7780. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7781. }
  7782. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7783. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7784. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7785. }
  7786. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7787. feature = RANDOMIZE_SKIN_COLOR;
  7788. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7789. }
  7790. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7791. feature = RANDOMIZE_WING_COLOR1;
  7792. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7793. }
  7794. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7795. feature = RANDOMIZE_WING_COLOR2;
  7796. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7797. }
  7798. else {
  7799. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7800. 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'.");
  7801. }
  7802. if (feature > 0) {
  7803. if (option == 1) {
  7804. if (target->GetRandomize() & feature)
  7805. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  7806. else {
  7807. target->AddRandomize(feature);
  7808. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  7809. database.UpdateRandomize(target->GetDatabaseID(), feature);
  7810. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  7811. }
  7812. }
  7813. else {
  7814. if (target->GetRandomize() & feature) {
  7815. target->AddRandomize(-feature);
  7816. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  7817. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  7818. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  7819. }
  7820. else
  7821. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  7822. }
  7823. }
  7824. }
  7825. else
  7826. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7827. }
  7828. else
  7829. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7830. }
  7831. }
  7832. else {
  7833. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  7834. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  7835. 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'.");
  7836. }
  7837. }
  7838. else
  7839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  7840. }
  7841. else
  7842. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  7843. }
  7844. /*
  7845. Function: Command_ShowCloak()
  7846. Purpose : Character Settings combo box for Show Cloak
  7847. Params : true/false
  7848. Dev : John Adams
  7849. Example :
  7850. */
  7851. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  7852. {
  7853. Player* player = client->GetPlayer();
  7854. if (sep && sep->arg[0])
  7855. {
  7856. const char* value = sep->arg[0];
  7857. if (strncasecmp(value, "true", strlen(value)) == 0)
  7858. {
  7859. player->set_character_flag(CF_SHOW_CLOAK);
  7860. player->reset_character_flag(CF2_SHOW_RANGED);
  7861. }
  7862. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7863. player->reset_character_flag(CF_SHOW_CLOAK);
  7864. else
  7865. {
  7866. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7867. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7868. }
  7869. }
  7870. }
  7871. /*
  7872. Function: Command_ShowHelm()
  7873. Purpose : Character Settings combo box for Show Helm
  7874. Params : true/false
  7875. Dev : John Adams
  7876. Example :
  7877. */
  7878. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  7879. {
  7880. Player* player = client->GetPlayer();
  7881. if (sep && sep->arg[0])
  7882. {
  7883. const char* value = sep->arg[0];
  7884. if (strncasecmp(value, "true", strlen(value)) == 0)
  7885. {
  7886. player->reset_character_flag(CF_HIDE_HELM);
  7887. player->set_character_flag(CF_HIDE_HOOD);
  7888. }
  7889. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7890. player->set_character_flag(CF_HIDE_HELM);
  7891. else
  7892. {
  7893. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7894. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7895. }
  7896. }
  7897. }
  7898. /*
  7899. Function: Command_ShowHood()
  7900. Purpose : Character Settings combo box for Show Hood
  7901. Params : true/false
  7902. Dev : John Adams
  7903. Example :
  7904. */
  7905. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  7906. {
  7907. Player* player = client->GetPlayer();
  7908. if (sep && sep->arg[0])
  7909. {
  7910. const char* value = sep->arg[0];
  7911. if (strncasecmp(value, "true", strlen(value)) == 0)
  7912. {
  7913. player->reset_character_flag(CF_HIDE_HOOD);
  7914. player->set_character_flag(CF_HIDE_HELM);
  7915. }
  7916. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7917. player->set_character_flag(CF_HIDE_HOOD);
  7918. else
  7919. {
  7920. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7921. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7922. }
  7923. }
  7924. }
  7925. /*
  7926. Function: Command_ShowHoodHelm()
  7927. Purpose : Character Settings combo box for Show Helm or Hood
  7928. Params : true/false
  7929. Dev : John Adams
  7930. Example :
  7931. */
  7932. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  7933. {
  7934. Player* player = client->GetPlayer();
  7935. if (sep && sep->arg[0])
  7936. {
  7937. const char* value = sep->arg[0];
  7938. if (strncasecmp(value, "true", strlen(value)) == 0)
  7939. {
  7940. player->reset_character_flag(CF_HIDE_HOOD);
  7941. player->reset_character_flag(CF_HIDE_HELM);
  7942. }
  7943. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7944. {
  7945. // don't think we ever wind up in here...
  7946. player->set_character_flag(CF_HIDE_HOOD);
  7947. player->set_character_flag(CF_HIDE_HELM);
  7948. }
  7949. else
  7950. {
  7951. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7952. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7953. }
  7954. }
  7955. }
  7956. /*
  7957. Function: Command_ShowRanged()
  7958. Purpose : Character Settings combo box for Show Ranged weapon
  7959. Params : true/false
  7960. Dev : John Adams
  7961. Example :
  7962. */
  7963. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  7964. {
  7965. Player* player = client->GetPlayer();
  7966. if (sep && sep->arg[0])
  7967. {
  7968. const char* value = sep->arg[0];
  7969. if (strncasecmp(value, "true", strlen(value)) == 0)
  7970. {
  7971. player->set_character_flag(CF2_SHOW_RANGED);
  7972. player->reset_character_flag(CF_SHOW_CLOAK);
  7973. }
  7974. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7975. player->reset_character_flag(CF2_SHOW_RANGED);
  7976. else
  7977. {
  7978. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7979. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7980. }
  7981. }
  7982. }
  7983. /*
  7984. Function:
  7985. Purpose :
  7986. Params :
  7987. Dev :
  7988. Example :
  7989. */
  7990. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  7991. {
  7992. Player* player = 0;
  7993. Client* to_client = 0;
  7994. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  7995. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  7996. switch(handler)
  7997. {
  7998. case COMMAND_SKILL:
  7999. {
  8000. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  8001. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  8002. break;
  8003. }
  8004. case COMMAND_SKILL_ADD:
  8005. {
  8006. if (sep && sep->arg[0])
  8007. {
  8008. const char* skill_name = sep->argplus[0];
  8009. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8010. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  8011. {
  8012. player = to_client->GetPlayer();
  8013. if (player)
  8014. {
  8015. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8016. {
  8017. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8018. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  8019. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  8020. }
  8021. else
  8022. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  8023. }
  8024. }
  8025. else if (skill) // add skill to yourself
  8026. {
  8027. player = client->GetPlayer();
  8028. if (player)
  8029. {
  8030. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8031. {
  8032. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8033. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  8034. }
  8035. else
  8036. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  8037. }
  8038. }
  8039. else
  8040. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8041. }
  8042. else
  8043. {
  8044. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  8045. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8046. }
  8047. break;
  8048. }
  8049. case COMMAND_SKILL_REMOVE:
  8050. {
  8051. if (sep && sep->arg[0])
  8052. {
  8053. const char* skill_name = sep->argplus[0];
  8054. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8055. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  8056. {
  8057. player = to_client->GetPlayer();
  8058. if (player)
  8059. {
  8060. if (player->GetSkills()->HasSkill(skill->skill_id))
  8061. {
  8062. player->RemoveSkillFromDB(skill, true);
  8063. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  8064. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  8065. }
  8066. else
  8067. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  8068. }
  8069. }
  8070. else if(skill) // remove skill from yourself
  8071. {
  8072. Player* player = client->GetPlayer();
  8073. if (player)
  8074. {
  8075. if (player->GetSkills()->HasSkill(skill->skill_id))
  8076. {
  8077. player->RemoveSkillFromDB(skill, true);
  8078. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  8079. }
  8080. else
  8081. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  8082. }
  8083. }
  8084. else
  8085. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8086. }
  8087. else
  8088. {
  8089. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  8090. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8091. }
  8092. break;
  8093. }
  8094. case COMMAND_SKILL_LIST:
  8095. {
  8096. if (sep && sep->arg[0])
  8097. {
  8098. const char* skill_name = sep->argplus[0];
  8099. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  8100. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  8101. map<int32, Skill*>::iterator itr;
  8102. if (skills && skills->size() > 0)
  8103. {
  8104. for (itr = skills->begin(); itr != skills->end(); itr++)
  8105. {
  8106. Skill* skill = itr->second;
  8107. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  8108. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  8109. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  8110. }
  8111. }
  8112. }
  8113. else
  8114. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  8115. break;
  8116. }
  8117. }
  8118. }
  8119. /*
  8120. Function: Command_SpawnTemplate()
  8121. Purpose : Create or Use defined Spawn Templates
  8122. Params : create, save, rempve, list
  8123. Dev : John Adams
  8124. Example : /spawn template create "Test"
  8125. */
  8126. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  8127. {
  8128. if (sep == NULL || sep->arg[0] == NULL)
  8129. {
  8130. 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.");
  8131. return;
  8132. }
  8133. // got params, continue
  8134. const char * template_cmd = sep->arg[0];
  8135. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  8136. {
  8137. if (!sep->IsSet(1))
  8138. {
  8139. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  8140. 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.");
  8141. return;
  8142. }
  8143. map<int32, string>* template_names = 0;
  8144. if (sep->IsNumber(1))
  8145. {
  8146. int32 location_id = 0;
  8147. location_id = atoi(sep->arg[1]);
  8148. template_names = database.GetSpawnTemplateListByID(location_id);
  8149. }
  8150. else
  8151. {
  8152. const char* name = 0;
  8153. name = sep->argplus[1];
  8154. template_names = database.GetSpawnTemplateListByName(name);
  8155. }
  8156. if(!template_names)
  8157. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  8158. else
  8159. {
  8160. map<int32, string>::iterator itr;
  8161. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  8162. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  8163. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  8164. safe_delete(template_names);
  8165. }
  8166. }
  8167. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  8168. {
  8169. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8170. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  8171. {
  8172. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  8173. {
  8174. // first, lookup to see if template name already exists
  8175. const char* name = 0;
  8176. name = sep->argplus[1];
  8177. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  8178. if(!template_names)
  8179. {
  8180. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  8181. if( new_template_id > 0 )
  8182. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  8183. else
  8184. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  8185. }
  8186. else
  8187. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  8188. }
  8189. else
  8190. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  8191. }
  8192. else
  8193. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  8194. }
  8195. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  8196. {
  8197. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  8198. {
  8199. int32 template_id = 0;
  8200. template_id = atoi(sep->arg[1]);
  8201. if (database.RemoveSpawnTemplate(template_id))
  8202. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  8203. else
  8204. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  8205. }
  8206. else
  8207. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  8208. }
  8209. // Renamed create to spawn
  8210. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  8211. {
  8212. if (sep && sep->arg[1][0])
  8213. {
  8214. int32 new_location = 0;
  8215. if (sep->IsNumber(1))
  8216. {
  8217. int32 template_id = 0;
  8218. template_id = atoi(sep->arg[1]);
  8219. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  8220. if( new_location > 0 )
  8221. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  8222. else
  8223. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  8224. }
  8225. else
  8226. {
  8227. const char* name = 0;
  8228. name = sep->argplus[1];
  8229. new_location = database.CreateSpawnFromTemplateByName(client, name);
  8230. if( new_location > 0 )
  8231. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  8232. else
  8233. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  8234. }
  8235. }
  8236. else
  8237. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  8238. }
  8239. else
  8240. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  8241. }
  8242. void Commands::Command_Speed(Client* client, Seperator* sep) {
  8243. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  8244. float new_speed = atof(sep->arg[0]);
  8245. if (new_speed > 0.0f)
  8246. {
  8247. client->GetPlayer()->SetSpeed(new_speed, true);
  8248. client->GetPlayer()->SetCharSheetChanged(true);
  8249. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  8250. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  8251. }
  8252. else
  8253. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  8254. }
  8255. else{
  8256. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  8257. }
  8258. }
  8259. /*
  8260. Function: Command_StationMarketPlace()
  8261. Purpose : just trying to eat the console spam for now
  8262. Params :
  8263. Dev : John
  8264. */
  8265. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  8266. {
  8267. PrintSep(sep, "COMMAND_SMP");
  8268. // This will reduce the spam from once every 10 sec to once every 30 sec,
  8269. // can't seem to reduce it any more get rid of it completely...
  8270. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  8271. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  8272. if (packet) {
  8273. packet->setDataByName("account_id", client->GetAccountID());
  8274. packet->setDataByName("character_id", client->GetCharacterID());
  8275. packet->setDataByName("unknown1", 1, 5);
  8276. packet->setDataByName("unknown1", 26, 6);
  8277. packet->setDataByName("unknown2", 0xFFFFFFFF);
  8278. packet->setDataByName("unknown3", 248, 1);
  8279. client->QueuePacket(packet->serialize());
  8280. }
  8281. safe_delete(packet);
  8282. }
  8283. }
  8284. /*
  8285. Function: Command_StopDrinking()
  8286. Purpose : Stops player from auto-consuming drink
  8287. Params :
  8288. Dev : Zcoretri
  8289. Example : /stopdrinking
  8290. */
  8291. void Commands::Command_StopDrinking(Client* client)
  8292. {
  8293. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  8294. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  8295. }
  8296. /*
  8297. Function: Command_StopEating()
  8298. Purpose : Stops player from auto-consuming food
  8299. Params :
  8300. Dev : Zcoretri
  8301. Example : /stopeating
  8302. */
  8303. void Commands::Command_StopEating(Client* client)
  8304. {
  8305. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  8306. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  8307. }
  8308. /*
  8309. Function: Command_Title()
  8310. Purpose : Help for /title command
  8311. Params : n/a
  8312. Dev : Zcoretri
  8313. Example : /title
  8314. */
  8315. void Commands::Command_Title(Client* client)
  8316. {
  8317. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  8318. }
  8319. /*
  8320. Function: Command_TitleList()
  8321. Purpose : List available titles for player
  8322. Params : n/a
  8323. Dev : Zcoretri
  8324. Example : /title list
  8325. */
  8326. void Commands::Command_TitleList(Client* client)
  8327. {
  8328. // must call release read lock before leaving function on GetPlayerTitles
  8329. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  8330. vector<Title*>::iterator itr;
  8331. Title* title;
  8332. sint32 i = 0;
  8333. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  8334. for(itr = titles->begin(); itr != titles->end(); itr++)
  8335. {
  8336. title = *itr;
  8337. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  8338. i++;
  8339. }
  8340. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  8341. }
  8342. /*
  8343. Function: Command_TitleSetPrefix()
  8344. Purpose : Set Prefix title for player
  8345. Params : Title ID
  8346. Dev : Zcoretri
  8347. Example : /title setprefix 1
  8348. */
  8349. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  8350. {
  8351. if (sep && sep->arg[0] && sep->IsNumber(0))
  8352. {
  8353. sint32 index = atoul(sep->arg[0]);
  8354. if(index > -1)
  8355. {
  8356. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8357. if(!title)
  8358. {
  8359. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8360. return;
  8361. }
  8362. else if(!title->GetPrefix())
  8363. {
  8364. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  8365. return;
  8366. }
  8367. }
  8368. else // make sure client doesn't pass some bogus negative index
  8369. index = -1;
  8370. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  8371. client->SendTitleUpdate();
  8372. }
  8373. }
  8374. /*
  8375. Function: Command_TitleSetSuffix()
  8376. Purpose : Set Suffix title for player
  8377. Params : Title ID
  8378. Dev : Zcoretri
  8379. Example : /title setsuffix 1
  8380. */
  8381. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  8382. {
  8383. if (sep && sep->arg[0] && sep->IsNumber(0))
  8384. {
  8385. sint32 index = atoul(sep->arg[0]);
  8386. if(index > -1)
  8387. {
  8388. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8389. if(!title)
  8390. {
  8391. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8392. return;
  8393. }
  8394. else if(title->GetPrefix())
  8395. {
  8396. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  8397. return;
  8398. }
  8399. }
  8400. else // make sure client doesn't pass some bogus negative index
  8401. index = -1;
  8402. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  8403. client->SendTitleUpdate();
  8404. }
  8405. }
  8406. /*
  8407. Function: Command_TitleFix()
  8408. Purpose : Fix title for player (???)
  8409. Params :
  8410. Dev : Zcoretri
  8411. Example :
  8412. */
  8413. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  8414. {
  8415. PrintSep(sep, "COMMAND_TITLE_FIX");
  8416. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  8417. }
  8418. /*
  8419. Function: Command_Toggle_Anonymous()
  8420. Purpose : Toggles player Anonymous
  8421. Params :
  8422. Dev : paulgh
  8423. Example : /anon
  8424. */
  8425. void Commands::Command_Toggle_Anonymous(Client* client)
  8426. {
  8427. Player* player = client->GetPlayer();
  8428. player->toggle_character_flag(CF_ANONYMOUS);
  8429. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  8430. if (player->get_character_flag(CF_ANONYMOUS))
  8431. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  8432. else
  8433. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  8434. }
  8435. /*
  8436. Function: Command_Toggle_AutoConsume()
  8437. Purpose : Toggles player food/drink auto consume
  8438. Params : unknown
  8439. Dev : paulgh
  8440. Example : /set_auto_consume
  8441. */
  8442. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  8443. {
  8444. Player* player = client->GetPlayer();
  8445. if (sep && sep->arg[0])
  8446. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  8447. if (sep && sep->arg[0] && sep->IsNumber(0))
  8448. {
  8449. int8 slot = atoi(sep->arg[0]);
  8450. int8 flag = atoi(sep->arg[1]);
  8451. if (client->GetVersion() <= 283) {
  8452. slot += 4;
  8453. }
  8454. else if (client->GetVersion() <= 546) {
  8455. slot += 2;
  8456. }
  8457. if (slot == EQ2_FOOD_SLOT)
  8458. {
  8459. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  8460. player->SetCharSheetChanged(true);
  8461. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8462. if (flag == 1)
  8463. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  8464. else
  8465. {
  8466. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  8467. return;
  8468. }
  8469. }
  8470. else
  8471. {
  8472. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  8473. player->SetCharSheetChanged(true);
  8474. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8475. if (flag == 1)
  8476. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  8477. else
  8478. {
  8479. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  8480. return;
  8481. }
  8482. }
  8483. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  8484. return;
  8485. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  8486. return;
  8487. Item* item = player->GetEquipmentList()->GetItem(slot);
  8488. if(item)
  8489. client->ConsumeFoodDrink(item, slot);
  8490. }
  8491. }
  8492. /*
  8493. Function: Command_Toggle_BonusXP()
  8494. Purpose : Toggles player Bonus XP
  8495. Params :
  8496. Dev : John Adams
  8497. Example : /disable_char_bonus_exp
  8498. */
  8499. void Commands::Command_Toggle_BonusXP(Client* client)
  8500. {
  8501. Player* player = client->GetPlayer();
  8502. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  8503. player->SetCharSheetChanged(true);
  8504. }
  8505. /*
  8506. Function: Command_Toggle_CombatXP()
  8507. Purpose : Toggles player Adventure XP
  8508. Params :
  8509. Dev : John Adams
  8510. Example : /disable_combat_exp
  8511. */
  8512. void Commands::Command_Toggle_CombatXP(Client* client)
  8513. {
  8514. Player* player = client->GetPlayer();
  8515. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  8516. player->SetCharSheetChanged(true);
  8517. }
  8518. /*
  8519. Function: Command_Toggle_GMHide()
  8520. Purpose : Toggles hiding player GM status
  8521. Params :
  8522. Dev : Scatman
  8523. Example : /gm_hide
  8524. */
  8525. void Commands::Command_Toggle_GMHide(Client* client)
  8526. {
  8527. Player* player = client->GetPlayer();
  8528. player->toggle_character_flag(CF_HIDE_STATUS);
  8529. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  8530. }
  8531. /*
  8532. Function: Command_Toggle_GMVanish()
  8533. Purpose : Toggles hiding GM players from /who searches
  8534. Params :
  8535. Dev : Scatman
  8536. Example : /gm_vanish
  8537. */
  8538. void Commands::Command_Toggle_GMVanish(Client* client)
  8539. {
  8540. Player* player = client->GetPlayer();
  8541. player->toggle_character_flag(CF_GM_HIDDEN);
  8542. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  8543. }
  8544. /*
  8545. Function: Command_Toggle_Illusions()
  8546. Purpose : Toggles player illusion form
  8547. Params : not sure sep is needed, testing
  8548. Dev : paulgh
  8549. Example : /hide_illusions
  8550. */
  8551. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  8552. {
  8553. if (sep && sep->arg[0])
  8554. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  8555. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  8556. }
  8557. /*
  8558. Function: Command_Toggle_LFG()
  8559. Purpose : Toggles player LFG Flag
  8560. Params :
  8561. Dev : paulgh
  8562. Example : /lfg
  8563. */
  8564. void Commands::Command_Toggle_LFG(Client* client)
  8565. {
  8566. Player* player = client->GetPlayer();
  8567. player->toggle_character_flag(CF_LFG);
  8568. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  8569. if (player->get_character_flag(CF_LFG))
  8570. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  8571. else
  8572. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  8573. }
  8574. /*
  8575. Function: Command_Toggle_LFW()
  8576. Purpose : Toggles player LFW Flag
  8577. Params :
  8578. Dev : paulgh
  8579. Example : /lfw
  8580. */
  8581. void Commands::Command_Toggle_LFW(Client* client)
  8582. {
  8583. Player* player = client->GetPlayer();
  8584. player->toggle_character_flag(CF_LFW);
  8585. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8586. if (player->get_character_flag(CF_LFW))
  8587. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8588. else
  8589. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8590. }
  8591. /*
  8592. Function: Command_Toggle_QuestXP()
  8593. Purpose : Toggles player Quest XP
  8594. Params :
  8595. Dev : John Adams
  8596. Example : /disable_quest_exp
  8597. */
  8598. void Commands::Command_Toggle_QuestXP(Client* client)
  8599. {
  8600. Player* player = client->GetPlayer();
  8601. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8602. player->SetCharSheetChanged(true);
  8603. }
  8604. /*
  8605. Function: Command_Toggle_Roleplaying()
  8606. Purpose : Toggles player Roleplaying flag
  8607. Params :
  8608. Dev : paulgh
  8609. Example : /role
  8610. */
  8611. void Commands::Command_Toggle_Roleplaying(Client* client)
  8612. {
  8613. Player* player = client->GetPlayer();
  8614. player->toggle_character_flag(CF_ROLEPLAYING);
  8615. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8616. if (player->get_character_flag(CF_ROLEPLAYING))
  8617. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8618. else
  8619. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8620. }
  8621. void Commands::Command_Toggle_Duels(Client* client)
  8622. {
  8623. Player* player = client->GetPlayer();
  8624. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8625. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8626. }
  8627. void Commands::Command_Toggle_Trades(Client* client)
  8628. {
  8629. Player* player = client->GetPlayer();
  8630. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8631. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8632. }
  8633. void Commands::Command_Toggle_Guilds(Client* client)
  8634. {
  8635. Player* player = client->GetPlayer();
  8636. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8637. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8638. }
  8639. void Commands::Command_Toggle_Groups(Client* client)
  8640. {
  8641. Player* player = client->GetPlayer();
  8642. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8643. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8644. }
  8645. void Commands::Command_Toggle_Raids(Client* client)
  8646. {
  8647. Player* player = client->GetPlayer();
  8648. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8649. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8650. }
  8651. void Commands::Command_Toggle_LON(Client* client)
  8652. {
  8653. Player* player = client->GetPlayer();
  8654. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8655. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8656. }
  8657. void Commands::Command_Toggle_VoiceChat(Client* client)
  8658. {
  8659. Player* player = client->GetPlayer();
  8660. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8661. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8662. }
  8663. /*
  8664. Function: Command_TradeStart()
  8665. Purpose : Starts item/coin trade between players
  8666. Params :
  8667. Dev :
  8668. Example :
  8669. */
  8670. #include "../Trade.h"
  8671. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  8672. {
  8673. PrintSep(sep, "COMMAND_START_TRADE");
  8674. Entity* trader = client->GetPlayer();
  8675. Entity* trader2 = 0;
  8676. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8677. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  8678. if (spawn) {
  8679. if (spawn->IsEntity())
  8680. trader2 = (Entity*)spawn;
  8681. }
  8682. }
  8683. else if (client->GetPlayer()->GetTarget()) {
  8684. if (client->GetPlayer()->GetTarget()->IsEntity())
  8685. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  8686. }
  8687. // can only trade with player or bots
  8688. if (trader && trader2) {
  8689. if (trader == trader2) {
  8690. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  8691. }
  8692. else if (trader2->IsPlayer() || trader2->IsBot()) {
  8693. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  8694. if (trader->trade)
  8695. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  8696. else if (trader2->trade)
  8697. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  8698. else {
  8699. Trade* trade = new Trade(trader, trader2);
  8700. trader->trade = trade;
  8701. trader2->trade = trade;
  8702. }
  8703. }
  8704. else {
  8705. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8706. }
  8707. }
  8708. else
  8709. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8710. }
  8711. /*
  8712. Function: Command_Track()
  8713. Purpose : Starts/Stops Tracking for a player
  8714. Params :
  8715. Dev : Scatman
  8716. Example : /track
  8717. */
  8718. void Commands::Command_Track(Client* client)
  8719. {
  8720. if (!client->GetPlayer()->GetIsTracking())
  8721. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8722. else
  8723. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8724. }
  8725. /*
  8726. Function: Command_TradeAccept()
  8727. Purpose : Accepts item/coin trade between players
  8728. Params :
  8729. Dev :
  8730. Example :
  8731. */
  8732. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8733. {
  8734. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8735. Trade* trade = client->GetPlayer()->trade;
  8736. if (trade) {
  8737. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8738. if (trade_complete)
  8739. safe_delete(trade);
  8740. }
  8741. else
  8742. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8743. }
  8744. /*
  8745. Function: Command_TradeReject()
  8746. Purpose : Rejects item/coin trade between players
  8747. Params :
  8748. Dev :
  8749. Example :
  8750. */
  8751. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8752. {
  8753. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8754. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  8755. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8756. }
  8757. /*
  8758. Function: Command_TradeCancel()
  8759. Purpose : Cancels item/coin trade between players
  8760. Params :
  8761. Dev :
  8762. Example :
  8763. */
  8764. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8765. {
  8766. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8767. Trade* trade = client->GetPlayer()->trade;
  8768. if (trade) {
  8769. trade->CancelTrade(client->GetPlayer());
  8770. safe_delete(trade);
  8771. }
  8772. else
  8773. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8774. }
  8775. /*
  8776. Function: Command_TradeSetCoin()
  8777. Purpose : Sets coin trade between players
  8778. Params :
  8779. Dev :
  8780. Example :
  8781. */
  8782. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8783. {
  8784. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8785. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8786. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8787. }
  8788. /*
  8789. Function: Command_TradeAddCoin()
  8790. Purpose : Adds coin to trade between players
  8791. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8792. Dev :
  8793. Example :
  8794. */
  8795. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  8796. {
  8797. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  8798. Trade* trade = client->GetPlayer()->trade;
  8799. if (trade) {
  8800. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8801. int32 amount = atoi(sep->arg[0]);
  8802. int64 val = 0;
  8803. switch (handler) {
  8804. case COMMAND_ADD_TRADE_COPPER:
  8805. {
  8806. val = amount;
  8807. trade->AddCoinToTrade(client->GetPlayer(), val);
  8808. break;
  8809. }
  8810. case COMMAND_ADD_TRADE_SILVER:
  8811. {
  8812. val = amount * 100;
  8813. trade->AddCoinToTrade(client->GetPlayer(), val);
  8814. break;
  8815. }
  8816. case COMMAND_ADD_TRADE_GOLD:
  8817. {
  8818. val = amount * 10000;
  8819. trade->AddCoinToTrade(client->GetPlayer(), val);
  8820. break;
  8821. }
  8822. case COMMAND_ADD_TRADE_PLAT:
  8823. {
  8824. val = amount * 1000000;
  8825. trade->AddCoinToTrade(client->GetPlayer(), val);
  8826. break;
  8827. }
  8828. default:
  8829. {
  8830. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8831. break;
  8832. }
  8833. }
  8834. }
  8835. else
  8836. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  8837. }
  8838. else
  8839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8840. }
  8841. /*
  8842. Function: Command_TradeRemoveCoin()
  8843. Purpose : Removes coin from trade between players
  8844. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8845. Dev :
  8846. Example :
  8847. */
  8848. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  8849. {
  8850. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  8851. Trade* trade = client->GetPlayer()->trade;
  8852. if (trade) {
  8853. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8854. int32 amount = atoi(sep->arg[0]);
  8855. int64 val = 0;
  8856. switch (handler) {
  8857. case COMMAND_REMOVE_TRADE_COPPER:
  8858. {
  8859. val = amount;
  8860. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8861. break;
  8862. }
  8863. case COMMAND_REMOVE_TRADE_SILVER:
  8864. {
  8865. val = amount * 100;
  8866. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8867. break;
  8868. }
  8869. case COMMAND_REMOVE_TRADE_GOLD:
  8870. {
  8871. val = amount * 10000;
  8872. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8873. break;
  8874. }
  8875. case COMMAND_REMOVE_TRADE_PLAT:
  8876. {
  8877. val = amount * 1000000;
  8878. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8879. break;
  8880. }
  8881. default:
  8882. {
  8883. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8884. break;
  8885. }
  8886. }
  8887. }
  8888. else
  8889. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  8890. }
  8891. else
  8892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8893. }
  8894. /*
  8895. Function: Command_TradeAddItem()
  8896. Purpose : Adds item to trade between players
  8897. Params :
  8898. Dev :
  8899. Example :
  8900. */
  8901. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  8902. {
  8903. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  8904. /*
  8905. arg[0] = item index
  8906. arg[1] = slot
  8907. arg[2] = quantity
  8908. */
  8909. if (!client->GetPlayer()->trade) {
  8910. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  8911. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8912. return;
  8913. }
  8914. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  8915. Item* item = 0;
  8916. int32 index = atoi(sep->arg[0]);
  8917. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  8918. if (item) {
  8919. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  8920. if (result == 1)
  8921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  8922. else if (result == 2)
  8923. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  8924. else if (result == 3)
  8925. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  8926. else if (result == 255)
  8927. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  8928. }
  8929. else {
  8930. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  8931. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  8932. }
  8933. }
  8934. else
  8935. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  8936. }
  8937. /*
  8938. Function: Command_TradeRemoveItem()
  8939. Purpose : Removes item from trade between players
  8940. Params :
  8941. Dev :
  8942. Example :
  8943. */
  8944. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  8945. {
  8946. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  8947. /*
  8948. arg[0] = trade window slot
  8949. */
  8950. Trade* trade = client->GetPlayer()->trade;
  8951. if (trade) {
  8952. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8953. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  8954. }
  8955. else
  8956. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  8957. }
  8958. else
  8959. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8960. }
  8961. void Commands::Command_TryOn(Client* client, Seperator* sep)
  8962. {
  8963. Item *item = 0;
  8964. sint32 crc;
  8965. if (sep) {
  8966. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  8967. if (client->GetVersion() < 1096) {
  8968. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  8969. {
  8970. item = master_item_list.GetItem(atoul(sep->arg[1]));
  8971. crc = atol(sep->arg[2]);
  8972. }
  8973. }
  8974. else {
  8975. // From the broker and links in chat
  8976. if (strcmp(sep->arg[0], "crc") == 0) {
  8977. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  8978. item = master_item_list.GetItem(atoul(sep->arg[2]));
  8979. crc = atol(sep->arg[3]);
  8980. }
  8981. }
  8982. // From inventory
  8983. if (strcmp(sep->arg[0], "dbid") == 0) {
  8984. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  8985. item = master_item_list.GetItem(atoul(sep->arg[2]));
  8986. crc = atol(sep->arg[4]);
  8987. }
  8988. }
  8989. }
  8990. if (item)
  8991. client->ShowDressingRoom(item, crc);
  8992. }
  8993. }
  8994. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  8995. const char *channel_name, *password = NULL;
  8996. if (sep == NULL || !sep->IsSet(0)) {
  8997. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  8998. return;
  8999. }
  9000. channel_name = sep->arg[0];
  9001. if (sep->IsSet(1))
  9002. password = sep->arg[1];
  9003. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  9004. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  9005. return;
  9006. }
  9007. if (chat.IsInChannel(client, channel_name)) {
  9008. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  9009. return;
  9010. }
  9011. if (chat.HasPassword(channel_name)) {
  9012. if (password == NULL) {
  9013. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  9014. return;
  9015. }
  9016. if (!chat.PasswordMatches(channel_name, password)) {
  9017. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  9018. return;
  9019. }
  9020. }
  9021. if (!chat.JoinChannel(client, channel_name))
  9022. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  9023. }
  9024. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  9025. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  9026. Command_JoinChannel(client, sep);
  9027. }
  9028. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  9029. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  9030. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  9031. PrintSep(sep, "tellchannel");
  9032. return;
  9033. }
  9034. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  9035. }
  9036. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  9037. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9038. if (sep->IsSet(0)) {
  9039. if (atoi(sep->arg[0]) == 1) {
  9040. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  9041. if (packet2) {
  9042. packet2->setDataByName("spell_type", 2);
  9043. packet2->setDataByName("spell_id", 8308);
  9044. packet2->setDataByName("spell_name", "Sprint");
  9045. packet2->setDataByName("add_silently", 0);
  9046. packet2->setDataByName("tier", 1);
  9047. packet2->setDataByName("blah1", 1);
  9048. packet2->setDataByName("blah2", 1);
  9049. EQ2Packet* outapp = packet2->serialize();
  9050. DumpPacket(outapp);
  9051. client->QueuePacket(outapp);
  9052. safe_delete(packet2);
  9053. }
  9054. }
  9055. else if (atoi(sep->arg[0]) == 2) {
  9056. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  9057. if (packet2) {
  9058. packet2->setDataByName("guild_name", "Test");
  9059. packet2->setDataByName("guild_motd", "Test MOTD");
  9060. packet2->setDataByName("guild_id", 1234);
  9061. packet2->setDataByName("guild_level", 1);
  9062. packet2->setDataByName("unknown", 2);
  9063. packet2->setDataByName("unknown2", 3);
  9064. packet2->setDataByName("exp_current", 1);
  9065. packet2->setDataByName("exp_to_next_level", 4);
  9066. EQ2Packet* outapp = packet2->serialize();
  9067. DumpPacket(outapp);
  9068. client->QueuePacket(outapp);
  9069. safe_delete(packet2);
  9070. }
  9071. }
  9072. else if (atoi(sep->arg[0]) == 3) {
  9073. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  9074. if (packet2) {
  9075. packet2->setDataByName("guild_id", 1234);
  9076. packet2->setDataByName("character_id", 1);
  9077. packet2->setDataByName("account_id", 2);
  9078. packet2->setDataByName("guild_level", 1);
  9079. packet2->setDataByName("name", "Test");
  9080. packet2->setDataByName("unknown2", 0);
  9081. packet2->setDataByName("unknown3", 1);
  9082. packet2->setDataByName("adventure_class", 6);
  9083. packet2->setDataByName("adventure_level", 7);
  9084. packet2->setDataByName("tradeskill_class", 4);
  9085. packet2->setDataByName("tradeskill_level", 5);
  9086. packet2->setDataByName("rank", 0);
  9087. packet2->setDataByName("member_flags", 2);
  9088. packet2->setDataByName("join_date", 1591112273);
  9089. packet2->setDataByName("guild_status", 2);
  9090. packet2->setDataByName("last_login", 1591132273);
  9091. packet2->setDataByName("recruiter_id", 1);
  9092. packet2->setDataByName("points", 2345);
  9093. packet2->setDataByName("note", "note");
  9094. packet2->setMediumStringByName("officer_note", "O note");
  9095. packet2->setMediumStringByName("zone", "Blah");
  9096. EQ2Packet* outapp = packet2->serialize();
  9097. DumpPacket(outapp);
  9098. client->QueuePacket(outapp);
  9099. safe_delete(packet2);
  9100. }
  9101. }
  9102. else if (atoi(sep->arg[0]) == 5) {
  9103. int16 offset = atoi(sep->arg[1]);
  9104. int32 value1 = atol(sep->arg[2]);
  9105. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  9106. client->QueuePacket(outapp);
  9107. }
  9108. else if (atoi(sep->arg[0]) == 6) {
  9109. Spawn* spawn = client->GetPlayer()->GetTarget();
  9110. if (!spawn)
  9111. spawn = client->GetPlayer();
  9112. else if (spawn->IsEntity())
  9113. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  9114. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  9115. }
  9116. else if (atoi(sep->arg[0]) == 7) {
  9117. int32 id = 0;
  9118. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  9119. if (spawn) {
  9120. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9121. spawn->SetY(client->GetPlayer()->GetY(), false);
  9122. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9123. float heading = client->GetPlayer()->GetHeading() + 180;
  9124. if (heading > 360)
  9125. heading -= 360;
  9126. spawn->SetLevel(5);
  9127. spawn->SetAdventureClass(4);
  9128. spawn->SetHeading(heading, false);
  9129. spawn->SetSpawnOrigX(spawn->GetX());
  9130. spawn->SetSpawnOrigY(spawn->GetY());
  9131. spawn->SetSpawnOrigZ(spawn->GetZ());
  9132. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9133. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9134. spawn->appearance.targetable = 1;
  9135. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9136. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9137. spawn->SetHP(spawn->GetTotalHP());
  9138. }
  9139. if (spawn->GetTotalPower() == 0) {
  9140. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9141. spawn->SetPower(spawn->GetTotalPower());
  9142. }
  9143. int16 offset = atoi(sep->arg[1]);
  9144. int32 value1 = atol(sep->arg[2]);
  9145. sprintf(spawn->appearance.name, "Offset %i", offset);
  9146. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  9147. DumpPacket(ret);
  9148. client->QueuePacket(ret);
  9149. }
  9150. }
  9151. else if (atoi(sep->arg[0]) == 8) {
  9152. int32 id = atoi(sep->arg[1]);
  9153. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  9154. if (spawn) {
  9155. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9156. spawn->SetY(client->GetPlayer()->GetY(), false);
  9157. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9158. float heading = client->GetPlayer()->GetHeading() + 180;
  9159. if (heading > 360)
  9160. heading -= 360;
  9161. spawn->SetLevel(5);
  9162. spawn->SetAdventureClass(4);
  9163. spawn->SetHeading(heading, false);
  9164. spawn->SetSpawnOrigX(spawn->GetX());
  9165. spawn->SetSpawnOrigY(spawn->GetY());
  9166. spawn->SetSpawnOrigZ(spawn->GetZ());
  9167. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9168. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9169. spawn->appearance.targetable = 1;
  9170. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9171. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9172. spawn->SetHP(spawn->GetTotalHP());
  9173. }
  9174. if (spawn->GetTotalPower() == 0) {
  9175. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9176. spawn->SetPower(spawn->GetTotalPower());
  9177. }
  9178. int16 offset = atoi(sep->arg[2]);
  9179. int16 offset2 = atoi(sep->arg[3]);
  9180. int32 value1 = atol(sep->arg[4]);
  9181. int16 offset3 = 0;
  9182. int16 offset4 = 0;
  9183. int32 value2 = 0;
  9184. if (sep->IsSet(7)) {
  9185. offset3 = atoi(sep->arg[5]);
  9186. offset4 = atoi(sep->arg[6]);
  9187. value2 = atol(sep->arg[7]);
  9188. }
  9189. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  9190. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  9191. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  9192. DumpPacket(ret);
  9193. client->QueuePacket(ret);
  9194. }
  9195. }
  9196. else if (atoi(sep->arg[0]) == 9) {
  9197. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  9198. if (packet2) {
  9199. packet2->setArrayLengthByName("location_count", 1);
  9200. packet2->setArrayDataByName("location_ida", 1234);
  9201. packet2->setArrayDataByName("unknown2a", 3);
  9202. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  9203. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  9204. packet2->setArrayDataByName("distance", 134);
  9205. EQ2Packet* app = packet2->serialize();
  9206. if (sep->IsSet(2)) {
  9207. int8 offset = atoi(sep->arg[1]);
  9208. uchar* ptr2 = app->pBuffer;
  9209. ptr2 += offset;
  9210. if (sep->IsNumber(2)) {
  9211. int32 value1 = atol(sep->arg[2]);
  9212. if (value1 > 0xFFFF)
  9213. memcpy(ptr2, (uchar*)&value1, 4);
  9214. else if (value1 > 0xFF)
  9215. memcpy(ptr2, (uchar*)&value1, 2);
  9216. else
  9217. memcpy(ptr2, (uchar*)&value1, 1);
  9218. }
  9219. else {
  9220. int8 len = strlen(sep->arg[2]);
  9221. memcpy(ptr2, (uchar*)&len, 1);
  9222. ptr2 += 1;
  9223. memcpy(ptr2, sep->arg[2], len);
  9224. }
  9225. }
  9226. DumpPacket(app);
  9227. client->QueuePacket(app);
  9228. safe_delete(packet2);
  9229. }
  9230. }
  9231. else if (atoi(sep->arg[0]) == 10) {
  9232. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  9233. if (packet2) {
  9234. packet2->setArrayLengthByName("num_quests", 1);
  9235. packet2->setArrayDataByName("active", 1);
  9236. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  9237. packet2->setArrayDataByName("quest_type", "Hallmark");
  9238. packet2->setArrayDataByName("quest_zone", "Hallmark");
  9239. packet2->setArrayDataByName("journal_updated", 1);
  9240. packet2->setArrayDataByName("quest_id", 524);
  9241. packet2->setArrayDataByName("day", 19);
  9242. packet2->setArrayDataByName("month", 6);
  9243. packet2->setArrayDataByName("year", 20);
  9244. packet2->setArrayDataByName("level", 2);
  9245. packet2->setArrayDataByName("encounter_level", 4);
  9246. packet2->setArrayDataByName("difficulty", 3);
  9247. packet2->setArrayDataByName("visible", 1);
  9248. packet2->setDataByName("visible_quest_id", 524);
  9249. packet2->setDataByName("player_crc", 2900677088);
  9250. packet2->setDataByName("player_name", "LethalEncounter");
  9251. EQ2Packet* app = packet2->serialize();
  9252. if (sep->IsSet(2)) {
  9253. int8 offset = atoi(sep->arg[1]);
  9254. uchar* ptr2 = app->pBuffer;
  9255. ptr2 += offset;
  9256. if (sep->IsNumber(2)) {
  9257. int32 value1 = atol(sep->arg[2]);
  9258. if (value1 > 0xFFFF)
  9259. memcpy(ptr2, (uchar*)&value1, 4);
  9260. else if (value1 > 0xFF)
  9261. memcpy(ptr2, (uchar*)&value1, 2);
  9262. else
  9263. memcpy(ptr2, (uchar*)&value1, 1);
  9264. }
  9265. else {
  9266. int8 len = strlen(sep->arg[2]);
  9267. memcpy(ptr2, (uchar*)&len, 1);
  9268. ptr2 += 1;
  9269. memcpy(ptr2, sep->arg[2], len);
  9270. }
  9271. }
  9272. DumpPacket(app);
  9273. client->QueuePacket(app);
  9274. safe_delete(packet2);
  9275. }
  9276. }
  9277. else if (atoi(sep->arg[0]) == 11) {
  9278. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9279. if (packet2) {
  9280. packet2->setDataByName("quest_id", 524);
  9281. packet2->setDataByName("player_crc", 2900677088);
  9282. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  9283. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  9284. packet2->setDataByName("type", "Hallmark");
  9285. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9286. packet2->setDataByName("day", 19);
  9287. packet2->setDataByName("month", 6);
  9288. packet2->setDataByName("year", 20);
  9289. packet2->setDataByName("level", 1);
  9290. packet2->setDataByName("encounter_level", 1);
  9291. packet2->setDataByName("difficulty", 1);
  9292. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9293. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9294. //packet2->setDataByName("timer_duration", 300);
  9295. //packet2->setDataByName("timer_running", 1);
  9296. packet2->setArrayLengthByName("task_groups_completed", 9);
  9297. packet2->setArrayLengthByName("num_task_groups", 10);
  9298. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  9299. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  9300. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  9301. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  9302. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  9303. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  9304. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  9305. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  9306. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  9307. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  9308. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  9309. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9310. packet2->setSubArrayLengthByName("num_updates", 1);
  9311. packet2->setSubArrayDataByName("update_currentval", 0);
  9312. packet2->setSubArrayDataByName("update_maxval", 1);
  9313. packet2->setSubArrayDataByName("icon", 11);
  9314. */
  9315. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9316. packet2->setDataByName("journal_updated", 1);
  9317. packet2->setDataByName("bullets", 1);
  9318. EQ2Packet* app = packet2->serialize();
  9319. if (sep->IsSet(2)) {
  9320. int16 offset = atoi(sep->arg[1]);
  9321. uchar* ptr2 = app->pBuffer;
  9322. ptr2 += offset;
  9323. if (sep->IsNumber(2)) {
  9324. int32 value1 = atol(sep->arg[2]);
  9325. if (value1 > 0xFFFF)
  9326. memcpy(ptr2, (uchar*)&value1, 4);
  9327. else if (value1 > 0xFF)
  9328. memcpy(ptr2, (uchar*)&value1, 2);
  9329. else
  9330. memcpy(ptr2, (uchar*)&value1, 1);
  9331. }
  9332. else {
  9333. int16 len = strlen(sep->arg[2]);
  9334. memcpy(ptr2, (uchar*)&len, 2);
  9335. ptr2 += 2;
  9336. memcpy(ptr2, sep->arg[2], len);
  9337. }
  9338. }
  9339. DumpPacket(app);
  9340. client->QueuePacket(app);
  9341. safe_delete(packet2);
  9342. }
  9343. }
  9344. else if (atoi(sep->arg[0]) == 12) {
  9345. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9346. if (packet2) {
  9347. packet2->setDataByName("quest_id", 524);
  9348. packet2->setDataByName("player_crc", 2900677088);
  9349. packet2->setDataByName("name", "Archetype Selection");
  9350. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  9351. packet2->setDataByName("type", "Hallmark");
  9352. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9353. packet2->setDataByName("day", 19);
  9354. packet2->setDataByName("month", 6);
  9355. packet2->setDataByName("year", 20);
  9356. packet2->setDataByName("level", 2);
  9357. packet2->setDataByName("encounter_level", 4);
  9358. packet2->setDataByName("difficulty", 3);
  9359. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9360. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9361. packet2->setDataByName("timer_duration", 300);
  9362. packet2->setDataByName("timer_running", 1);
  9363. packet2->setArrayLengthByName("task_groups_completed", 0);
  9364. packet2->setArrayLengthByName("num_task_groups", 1);
  9365. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  9366. packet2->setSubArrayLengthByName("num_tasks", 1);
  9367. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9368. packet2->setSubArrayLengthByName("num_updates", 1);
  9369. packet2->setSubArrayDataByName("update_currentval", 0);
  9370. packet2->setSubArrayDataByName("update_maxval", 1);
  9371. packet2->setSubArrayDataByName("icon", 11);
  9372. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9373. packet2->setDataByName("journal_updated", 1);
  9374. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9375. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9376. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  9377. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9378. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9379. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9380. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9381. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  9382. Item* item = master_item_list.GetItem(152755);
  9383. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9384. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9385. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  9386. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  9387. packet2->setSubstructDataByName("item", "icon", 0xe7);
  9388. packet2->setSubstructDataByName("item", "tier", 4);
  9389. packet2->setSubstructDataByName("item", "flags", 0x60);
  9390. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  9391. packet2->setSubstructDataByName("item", "stat_type", 1);
  9392. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  9393. packet2->setSubstructDataByName("item", "value", 3);
  9394. packet2->setSubstructDataByName("item", "condition", 100);
  9395. packet2->setSubstructDataByName("item", "weight", 1);
  9396. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  9397. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  9398. packet2->setSubstructDataByName("item", "skill_min", 1);
  9399. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  9400. packet2->setSubstructDataByName("item", "adventure_class", 1);
  9401. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  9402. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  9403. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  9404. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  9405. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  9406. packet2->setSubstructDataByName("item", "level", 0x1e);
  9407. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  9408. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  9409. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  9410. //packet2->PrintPacket();
  9411. EQ2Packet* app = packet2->serialize();
  9412. if (sep->IsSet(2)) {
  9413. int16 offset = atoi(sep->arg[1]);
  9414. uchar* ptr2 = app->pBuffer;
  9415. ptr2 += offset;
  9416. if (sep->IsNumber(2)) {
  9417. int32 value1 = atol(sep->arg[2]);
  9418. if (value1 > 0xFFFF)
  9419. memcpy(ptr2, (uchar*)&value1, 4);
  9420. else if (value1 > 0xFF)
  9421. memcpy(ptr2, (uchar*)&value1, 2);
  9422. else
  9423. memcpy(ptr2, (uchar*)&value1, 1);
  9424. }
  9425. else {
  9426. int16 len = strlen(sep->arg[2]);
  9427. memcpy(ptr2, (uchar*)&len, 2);
  9428. ptr2 += 2;
  9429. memcpy(ptr2, sep->arg[2], len);
  9430. }
  9431. }
  9432. DumpPacket(app);
  9433. client->QueuePacket(app);
  9434. safe_delete(packet2);
  9435. }
  9436. }
  9437. else if (atoi(sep->arg[0]) == 13) {
  9438. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  9439. if (packet2 && sep->IsSet(7)) {
  9440. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  9441. char blah[128];
  9442. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  9443. packet2->setDataByName("text", blah);
  9444. packet2->setDataByName("message_type", sep->arg[3]);
  9445. packet2->setDataByName("size", atof(sep->arg[4]));
  9446. packet2->setDataByName("red", atoi(sep->arg[5]));
  9447. packet2->setDataByName("green", atoi(sep->arg[6]));
  9448. packet2->setDataByName("blue", atoi(sep->arg[7]));
  9449. EQ2Packet* app = packet2->serialize();
  9450. DumpPacket(app);
  9451. client->QueuePacket(app);
  9452. safe_delete(packet2);
  9453. }
  9454. }
  9455. else if (atoi(sep->arg[0]) == 14) {
  9456. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  9457. if (packet2 && sep->IsSet(3)) {
  9458. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  9459. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  9460. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  9461. 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.");
  9462. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  9463. packet2->setArrayLengthByName("num_goals", 1);
  9464. //packet2->setArrayDataByName("goal_text", )
  9465. packet2->setSubArrayLengthByName("num_tasks", 1);
  9466. packet2->setSubArrayDataByName("task_text", "continue");
  9467. packet2->setDataByName("complete_sound", "click");
  9468. packet2->setDataByName("signal", "introduction");
  9469. packet2->setDataByName("voice_key1", 0xcda65173);
  9470. packet2->setDataByName("voice_key2", 0x984bfc6d);
  9471. EQ2Packet* app = packet2->serialize();
  9472. DumpPacket(app);
  9473. client->QueuePacket(app);
  9474. safe_delete(packet2);
  9475. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  9476. packet2->setDataByName("window", "MainHUD.StartMenu");
  9477. packet2->setDataByName("show", 1);
  9478. app = packet2->serialize();
  9479. DumpPacket(app);
  9480. client->QueuePacket(app);
  9481. safe_delete(packet2);
  9482. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  9483. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  9484. packet2->setDataByName("flash_seconds", 10);
  9485. app = packet2->serialize();
  9486. DumpPacket(app);
  9487. client->QueuePacket(app);
  9488. safe_delete(packet2);
  9489. }
  9490. }
  9491. else if (atoi(sep->arg[0]) == 15) {
  9492. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9493. if (packet2) {
  9494. packet2->setArrayLengthByName("loot_count", 1);
  9495. packet2->setArrayDataByName("name", "Test");
  9496. packet2->setArrayDataByName("item_id", 1234);
  9497. packet2->setArrayDataByName("count", 1);
  9498. packet2->setArrayDataByName("icon", 258);
  9499. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  9500. Spawn* spawn = client->GetPlayer()->GetTarget();
  9501. if (spawn)
  9502. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9503. packet2->setDataByName("unknown3", 1);
  9504. packet2->setDataByName("unknown4", 1);
  9505. packet2->setDataByName("unknown5", 60);
  9506. EQ2Packet* app = packet2->serialize();
  9507. DumpPacket(app);
  9508. client->QueuePacket(app);
  9509. safe_delete(packet2);
  9510. }
  9511. }
  9512. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  9513. char blah[32];
  9514. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  9515. client->SimpleMessage(atoi(sep->arg[1]), blah);
  9516. }
  9517. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  9518. if (sep->IsSet(2)) {
  9519. int16 offset = atoi(sep->arg[1]);
  9520. if (sep->IsNumber(2)) {
  9521. int32 value1 = atol(sep->arg[2]);
  9522. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  9523. cout << "Sent" << endl;
  9524. }
  9525. }
  9526. }
  9527. else if (atoi(sep->arg[0]) == 18) {
  9528. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  9529. if (packet2) {
  9530. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9531. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9532. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9533. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9534. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9535. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  9536. Item* item = new Item(master_item_list.GetItem(36212));
  9537. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9538. item->stack_count = 20;
  9539. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9540. safe_delete(item);
  9541. item = new Item(master_item_list.GetItem(36685));
  9542. item->stack_count = 20;
  9543. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9544. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  9545. safe_delete(item);
  9546. item = master_item_list.GetItem(1414);
  9547. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9548. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  9549. item = master_item_list.GetItem(75057);
  9550. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9551. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  9552. EQ2Packet* app = packet2->serialize();
  9553. if (sep->IsSet(2)) {
  9554. int16 offset = atoi(sep->arg[1]);
  9555. uchar* ptr2 = app->pBuffer;
  9556. ptr2 += offset;
  9557. if (sep->IsNumber(2)) {
  9558. int32 value1 = atol(sep->arg[2]);
  9559. if (value1 > 0xFFFF)
  9560. memcpy(ptr2, (uchar*)&value1, 4);
  9561. else if (value1 > 0xFF)
  9562. memcpy(ptr2, (uchar*)&value1, 2);
  9563. else
  9564. memcpy(ptr2, (uchar*)&value1, 1);
  9565. }
  9566. else {
  9567. int16 len = strlen(sep->arg[2]);
  9568. memcpy(ptr2, (uchar*)&len, 2);
  9569. ptr2 += 2;
  9570. memcpy(ptr2, sep->arg[2], len);
  9571. }
  9572. }
  9573. DumpPacket(app);
  9574. client->QueuePacket(app);
  9575. safe_delete(packet2);
  9576. }
  9577. }
  9578. else if (atoi(sep->arg[0]) == 19) {
  9579. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9580. Spawn* spawn = client->GetPlayer()->GetTarget();
  9581. if (packet2 && spawn) {
  9582. Item* item = master_item_list.GetItem(130053);
  9583. packet2->setArrayLengthByName("loot_count", 1);
  9584. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9585. packet2->setArrayDataByName("unknown2", 1);
  9586. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9587. packet2->setDataByName("display", 1);
  9588. packet2->setDataByName("unknown2b", 1);
  9589. packet2->setDataByName("unknown3", 0x3c);
  9590. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9591. packet2->PrintPacket();
  9592. EQ2Packet* app = packet2->serialize();
  9593. if (sep->IsSet(2)) {
  9594. int16 offset = atoi(sep->arg[1]);
  9595. int16 offset2 = 0;
  9596. int32 value1 = 0;
  9597. if (sep->IsSet(3)) {
  9598. offset2 = atoi(sep->arg[2]);
  9599. value1 = atol(sep->arg[3]);
  9600. }
  9601. else
  9602. value1 = atol(sep->arg[2]);
  9603. int16 offset3 = 0;
  9604. int16 offset4 = 0;
  9605. int32 value2 = 0;
  9606. if (sep->IsSet(6)) {
  9607. offset3 = atoi(sep->arg[4]);
  9608. offset4 = atoi(sep->arg[5]);
  9609. value2 = atol(sep->arg[6]);
  9610. }
  9611. offset--;
  9612. if (offset2 > 0 && offset2 >= offset) {
  9613. offset2--;
  9614. uchar* ptr2 = app->pBuffer;
  9615. ptr2 += offset;
  9616. for (int i = offset; i <= offset2; i++) {
  9617. if (value1 > 0xFFFF) {
  9618. memcpy(ptr2, (uchar*)&value1, 4);
  9619. i += 3;
  9620. ptr2 += 3;
  9621. }
  9622. else if (value1 > 0xFF) {
  9623. memcpy(ptr2, (uchar*)&value1, 2);
  9624. i++;
  9625. ptr2++;
  9626. }
  9627. else
  9628. memcpy(ptr2, (uchar*)&value1, 1);
  9629. ptr2++;
  9630. }
  9631. }
  9632. if (offset4 > 0 && offset4 >= offset3) {
  9633. offset3--;
  9634. offset4--;
  9635. uchar* ptr2 = app->pBuffer;
  9636. ptr2 += offset3;
  9637. for (int i = offset3; i <= offset4; i++) {
  9638. if (value2 > 0xFFFF) {
  9639. memcpy(ptr2, (uchar*)&value2, 4);
  9640. i += 3;
  9641. ptr2 += 3;
  9642. }
  9643. else if (value2 > 0xFF) {
  9644. memcpy(ptr2, (uchar*)&value2, 2);
  9645. i++;
  9646. ptr2++;
  9647. }
  9648. else
  9649. memcpy(ptr2, (uchar*)&value2, 1);
  9650. ptr2++;
  9651. }
  9652. }
  9653. }
  9654. DumpPacket(app);
  9655. client->QueuePacket(app);
  9656. safe_delete(packet2);
  9657. }
  9658. }
  9659. else if (atoi(sep->arg[0]) == 21) {
  9660. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9661. if (packet2) {
  9662. packet2->setDataByName("unknown0", 255);
  9663. packet2->setDataByName("reward", "New Quest");
  9664. packet2->setDataByName("title", "Title");
  9665. packet2->setDataByName("description", "description");
  9666. packet2->setDataByName("quest_difficulty", 3);
  9667. packet2->setDataByName("unknown1", 5);
  9668. packet2->setDataByName("level", 3);
  9669. packet2->setDataByName("coin", 150);
  9670. packet2->setDataByName("status_points", 5);
  9671. packet2->setDataByName("exp_bonus", 10);
  9672. packet2->setArrayLengthByName("num_rewards", 1);
  9673. Item* item = new Item(master_item_list.GetItem(36212));
  9674. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9675. item->stack_count = 20;
  9676. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9677. safe_delete(item);
  9678. char accept[35] = { 0 };
  9679. char decline[35] = { 0 };
  9680. sprintf(accept, "q_accept_pending_quest %u", 0);
  9681. sprintf(decline, "q_deny_pending_quest %u", 0);
  9682. packet2->setDataByName("accept_command", accept);
  9683. packet2->setDataByName("decline_command", decline);
  9684. EQ2Packet* app = packet2->serialize();
  9685. if (sep->IsSet(2)) {
  9686. int16 offset = atoi(sep->arg[1]);
  9687. uchar* ptr2 = app->pBuffer;
  9688. ptr2 += offset;
  9689. if (sep->IsNumber(2)) {
  9690. int32 value1 = atol(sep->arg[2]);
  9691. if (value1 > 0xFFFF)
  9692. memcpy(ptr2, (uchar*)&value1, 4);
  9693. else if (value1 > 0xFF)
  9694. memcpy(ptr2, (uchar*)&value1, 2);
  9695. else
  9696. memcpy(ptr2, (uchar*)&value1, 1);
  9697. }
  9698. DumpPacket(app);
  9699. client->QueuePacket(app);
  9700. safe_delete(packet2);
  9701. }
  9702. }
  9703. }
  9704. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9705. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9706. if (packet2) {
  9707. packet2->setDataByName("unknown0", 255);
  9708. packet2->setDataByName("reward", "New Quest");
  9709. packet2->setDataByName("title", "Title");
  9710. packet2->setDataByName("description", "description");
  9711. packet2->setDataByName("quest_difficulty", 3);
  9712. packet2->setDataByName("unknown1", 5);
  9713. packet2->setDataByName("level", 3);
  9714. packet2->setDataByName("coin", 150);
  9715. packet2->setDataByName("status_points", 5);
  9716. packet2->setDataByName("exp_bonus", 10);
  9717. packet2->setArrayLengthByName("num_rewards", 1);
  9718. Item* item = new Item(master_item_list.GetItem(36212));
  9719. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9720. item->stack_count = 20;
  9721. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9722. safe_delete(item);
  9723. char accept[35] = { 0 };
  9724. char decline[35] = { 0 };
  9725. sprintf(accept, "q_accept_pending_quest %u", 0);
  9726. sprintf(decline, "q_deny_pending_quest %u", 0);
  9727. packet2->setDataByName("accept_command", accept);
  9728. packet2->setDataByName("decline_command", decline);
  9729. EQ2Packet* app = packet2->serialize();
  9730. if (sep->IsSet(2)) {
  9731. int16 offset = atoi(sep->arg[1]);
  9732. uchar* ptr2 = app->pBuffer;
  9733. ptr2 += offset;
  9734. if (sep->IsNumber(2)) {
  9735. int32 value1 = atol(sep->arg[2]);
  9736. if (value1 > 0xFFFF)
  9737. memcpy(ptr2, (uchar*)&value1, 4);
  9738. else if (value1 > 0xFF)
  9739. memcpy(ptr2, (uchar*)&value1, 2);
  9740. else
  9741. memcpy(ptr2, (uchar*)&value1, 1);
  9742. }
  9743. else {
  9744. int8 len = strlen(sep->arg[2]);
  9745. memcpy(ptr2, (uchar*)&len, 1);
  9746. ptr2 += 1;
  9747. memcpy(ptr2, sep->arg[2], len);
  9748. }
  9749. }
  9750. DumpPacket(app);
  9751. client->QueuePacket(app);
  9752. safe_delete(packet2);
  9753. }
  9754. }
  9755. else if (atoi(sep->arg[0]) == 23) {
  9756. if (client->GetPlayer()->GetTarget()) {
  9757. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9758. if (packet2) {
  9759. Spawn* target = client->GetPlayer()->GetTarget();
  9760. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9761. Item* item = new Item(master_item_list.GetItem(12565));
  9762. int8 i = 0;
  9763. packet2->setArrayLengthByName("num_items", 1);
  9764. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9765. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9766. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9767. packet2->setArrayDataByName("icon", item->details.icon, i);
  9768. int8 tmp_level = 0;
  9769. if (item->generic_info.adventure_default_level > 0)
  9770. tmp_level = item->generic_info.adventure_default_level;
  9771. else
  9772. tmp_level = item->generic_info.tradeskill_default_level;
  9773. packet2->setArrayDataByName("level", tmp_level, i);
  9774. packet2->setArrayDataByName("tier", item->details.tier, i);
  9775. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9776. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9777. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9778. item_difficulty = ARROW_COLOR_WHITE;
  9779. item_difficulty -= 6;
  9780. if (item_difficulty < 0)
  9781. item_difficulty *= -1;
  9782. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9783. packet2->setArrayDataByName("quantity", 2, i);
  9784. packet2->setArrayDataByName("unknown5", 255, i);
  9785. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9786. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9787. packet2->setDataByName("type", 2);
  9788. EQ2Packet* app = packet2->serialize();
  9789. if (sep->IsSet(2)) {
  9790. int16 offset = atoi(sep->arg[1]);
  9791. uchar* ptr2 = app->pBuffer;
  9792. ptr2 += offset;
  9793. if (sep->IsNumber(2)) {
  9794. int32 value1 = atol(sep->arg[2]);
  9795. if (value1 > 0xFFFF)
  9796. memcpy(ptr2, (uchar*)&value1, 4);
  9797. else if (value1 > 0xFF)
  9798. memcpy(ptr2, (uchar*)&value1, 2);
  9799. else
  9800. memcpy(ptr2, (uchar*)&value1, 1);
  9801. }
  9802. else {
  9803. int8 len = strlen(sep->arg[2]);
  9804. memcpy(ptr2, (uchar*)&len, 1);
  9805. ptr2 += 1;
  9806. memcpy(ptr2, sep->arg[2], len);
  9807. }
  9808. }
  9809. DumpPacket(app);
  9810. client->QueuePacket(app);
  9811. safe_delete(packet2);
  9812. }
  9813. }
  9814. }
  9815. else if (atoi(sep->arg[0]) == 24) {
  9816. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  9817. if (packet2) {
  9818. if (sep->IsSet(2)) {
  9819. packet2->setDataByName("event_name", sep->arg[1]);
  9820. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  9821. EQ2Packet* app = packet2->serialize();
  9822. DumpPacket(app);
  9823. client->QueuePacket(app);
  9824. safe_delete(packet2);
  9825. }
  9826. }
  9827. }
  9828. else if (atoi(sep->arg[0]) == 25) {
  9829. if (sep->IsSet(1)) {
  9830. Widget* new_spawn = new Widget();
  9831. int32 id = atoul(sep->arg[1]);
  9832. new_spawn->SetWidgetID(id);
  9833. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9834. client->QueuePacket(ret);
  9835. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  9836. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  9837. if (packet2) {
  9838. packet2->setDataByName("spawn_index", index);
  9839. packet2->setDataByName("delete", 1);
  9840. EQ2Packet* app = packet2->serialize();
  9841. client->QueuePacket(app);
  9842. safe_delete(packet2);
  9843. }
  9844. }
  9845. }
  9846. else if (atoi(sep->arg[0]) == 26) {
  9847. if (sep->IsSet(4)) {
  9848. Widget* new_spawn = new Widget();
  9849. int32 id = atoul(sep->arg[1]);
  9850. new_spawn->SetWidgetID(id);
  9851. float x = atof(sep->arg[2]);
  9852. float y = atof(sep->arg[3]);
  9853. float z = atof(sep->arg[4]);
  9854. new_spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9855. new_spawn->SetWidgetX(x);
  9856. new_spawn->SetWidgetY(y);
  9857. new_spawn->SetWidgetZ(z);
  9858. new_spawn->SetX(x);
  9859. new_spawn->SetY(y);
  9860. new_spawn->SetZ(z);
  9861. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9862. client->QueuePacket(ret);
  9863. }
  9864. }
  9865. else if (atoi(sep->arg[0]) == 27) {
  9866. Spawn* target = client->GetPlayer()->GetTarget();
  9867. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  9868. if (packet2 && target && sep->IsSet(2)) {
  9869. packet2->setSubstructDataByName("header", "defender", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9870. packet2->setSubstructDataByName("header", "defender_proxy", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9871. packet2->setSubstructDataByName("header", "attacker", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  9872. packet2->setArrayLengthByName("num_dmg", 1);
  9873. packet2->setArrayDataByName("damage_type", atoi(sep->arg[1]));
  9874. packet2->setArrayDataByName("damage", atoi(sep->arg[2]));
  9875. packet2->setDataByName("spell", 1);
  9876. packet2->setDataByName("spell_name", "Testing");
  9877. EQ2Packet* app = packet2->serialize();
  9878. if (sep->IsSet(4)) {
  9879. int16 offset = atoi(sep->arg[3]);
  9880. uchar* ptr2 = app->pBuffer;
  9881. ptr2 += offset;
  9882. if (sep->IsNumber(4)) {
  9883. int32 value1 = atol(sep->arg[4]);
  9884. if (value1 > 0xFFFF)
  9885. memcpy(ptr2, (uchar*)&value1, 4);
  9886. else if (value1 > 0xFF)
  9887. memcpy(ptr2, (uchar*)&value1, 2);
  9888. else
  9889. memcpy(ptr2, (uchar*)&value1, 1);
  9890. }
  9891. else {
  9892. int8 len = strlen(sep->arg[4]);
  9893. memcpy(ptr2, (uchar*)&len, 1);
  9894. ptr2 += 1;
  9895. memcpy(ptr2, sep->arg[4], len);
  9896. }
  9897. }
  9898. if (sep->IsSet(6)) {
  9899. int16 offset = atoi(sep->arg[5]);
  9900. uchar* ptr2 = app->pBuffer;
  9901. ptr2 += offset;
  9902. if (sep->IsNumber(6)) {
  9903. int32 value1 = atol(sep->arg[6]);
  9904. if (value1 > 0xFFFF)
  9905. memcpy(ptr2, (uchar*)&value1, 4);
  9906. else if (value1 > 0xFF)
  9907. memcpy(ptr2, (uchar*)&value1, 2);
  9908. else
  9909. memcpy(ptr2, (uchar*)&value1, 1);
  9910. }
  9911. else {
  9912. int8 len = strlen(sep->arg[6]);
  9913. memcpy(ptr2, (uchar*)&len, 1);
  9914. ptr2 += 1;
  9915. memcpy(ptr2, sep->arg[6], len);
  9916. }
  9917. }
  9918. DumpPacket(app);
  9919. client->QueuePacket(app);
  9920. safe_delete(packet2);
  9921. }
  9922. }
  9923. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  9924. World::newValue = strtoull(sep->arg[1], NULL, 0);
  9925. }
  9926. }
  9927. else {
  9928. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  9929. if (packet2) {
  9930. packet2->setSubstructDataByName("info_header", "show_name", 1);
  9931. packet2->setSubstructDataByName("info_header", "unknown", 7);
  9932. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  9933. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  9934. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  9935. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  9936. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  9937. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  9938. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  9939. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  9940. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  9941. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  9942. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  9943. packet2->setSubstructDataByName("info_header", "packettype", 3);
  9944. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  9945. packet2->setSubstructDataByName("spell_info", "level", 19);
  9946. packet2->setSubstructDataByName("spell_info", "tier", 1);
  9947. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  9948. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  9949. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  9950. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  9951. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  9952. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  9953. packet2->setSubstructDataByName("spell_info", "recast", 280);
  9954. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  9955. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  9956. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  9957. packet2->setSubstructDataByName("spell_info", "quality", 3);
  9958. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  9959. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  9960. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  9961. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  9962. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  9963. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  9964. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  9965. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  9966. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  9967. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  9968. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  9969. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  9970. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  9971. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  9972. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  9973. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  9974. packet2->setArrayDataByName("reagent", "Alcohol");
  9975. packet2->setArrayDataByName("consumed", "123");
  9976. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  9977. packet2->setSubstructDataByName("spell_info", "id", 8308);
  9978. packet2->setSubstructDataByName("spell_info", "icon", 303);
  9979. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  9980. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  9981. packet2->setSubstructDataByName("spell_info", "type", 2);
  9982. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  9983. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  9984. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  9985. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  9986. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  9987. EQ2Packet* outapp = packet2->serialize();
  9988. DumpPacket(outapp);
  9989. client->QueuePacket(outapp);
  9990. safe_delete(packet2);
  9991. }
  9992. }
  9993. return;
  9994. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  9995. if (!p) return;
  9996. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9997. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  9998. //}
  9999. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10000. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  10001. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  10002. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  10003. if (packet) {
  10004. client->QueuePacket(packet->serialize());
  10005. safe_delete(packet);
  10006. }
  10007. }*/
  10008. /*if (client->GetCurrentZone()->Grid != nullptr) {
  10009. int32 numFaces = 0;
  10010. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  10011. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  10012. map<int32, vector<Face*> >::iterator itr;
  10013. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  10014. numFaces += (*itr).second.size();
  10015. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  10016. }*/
  10017. //uchar blah[] = {
  10018. // 1208 - OP_EQUpdateStoreCmd
  10019. // /*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
  10020. // /*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
  10021. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  10022. // /*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
  10023. /*};
  10024. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10025. int8 val = 0;
  10026. int16 pos = 0;
  10027. int idx = 0;
  10028. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  10029. pos = atoi(sep2->arg[idx]);
  10030. val = atoi(sep2->arg[idx+1]);
  10031. memset(blah+pos, val, 1);
  10032. idx+=2;
  10033. }
  10034. DumpPacket(blah, sizeof(blah));
  10035. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  10036. if (client->GetPlayer()->GetTarget()) {
  10037. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  10038. if (packet) {
  10039. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10040. packet->setDataByName("size", 0);
  10041. packet->setDataByName("unknown2", 0);
  10042. EQ2Packet* app = packet->serialize();
  10043. client->QueuePacket(app);
  10044. safe_delete(packet);
  10045. }
  10046. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  10047. if (set_pov) {
  10048. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10049. EQ2Packet* app_pov = set_pov->serialize();
  10050. client->QueuePacket(app_pov);
  10051. safe_delete(set_pov);
  10052. }
  10053. }
  10054. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10055. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  10056. if (packet) {
  10057. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  10058. packet->setDataByName("Type", atoi(sep2->arg[0]));
  10059. else
  10060. packet->setDataByName("Type", 2);
  10061. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  10062. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  10063. else
  10064. packet->setDataByName("race_id", 0);
  10065. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  10066. packet->setDataByName("gender", atoi(sep2->arg[2]));
  10067. else
  10068. packet->setDataByName("gender", 2);
  10069. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  10070. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  10071. else
  10072. packet->setDataByName("unknown", 0, 0);
  10073. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  10074. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  10075. else
  10076. packet->setDataByName("unknown", 0, 1);
  10077. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  10078. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  10079. else
  10080. packet->setDataByName("unknown", 0, 2);
  10081. client->QueuePacket(packet->serialize());
  10082. }
  10083. safe_delete(packet);
  10084. safe_delete(sep2);
  10085. }
  10086. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  10087. const char *channel_name;
  10088. if (sep == NULL || !sep->IsSet(0)) {
  10089. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  10090. PrintSep(sep);
  10091. return;
  10092. }
  10093. channel_name = sep->arg[0];
  10094. if (!chat.IsInChannel(client, channel_name))
  10095. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  10096. else if (!chat.LeaveChannel(client, channel_name))
  10097. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  10098. }
  10099. /*
  10100. Function:
  10101. Purpose :
  10102. Params :
  10103. Dev :
  10104. Example :
  10105. */
  10106. void Commands::Command_WeaponStats(Client* client)
  10107. {
  10108. Player* player = client->GetPlayer();
  10109. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10110. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10111. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10112. client->SimpleMessage(0, "Primary:");
  10113. if (primary) {
  10114. client->Message(0, "Name: %s", primary->name.c_str());
  10115. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  10116. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  10117. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  10118. client->Message(0, "Proc Percent: %d%%", 0);
  10119. client->Message(0, "Procs Per Minute: %d", 0);
  10120. }
  10121. else {
  10122. client->SimpleMessage(0, "Name: fist");
  10123. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  10124. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  10125. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  10126. client->Message(0, "Proc Percent: %d%%", 0);
  10127. client->Message(0, "Procs Per Minute: %d", 0);
  10128. }
  10129. client->SimpleMessage(0, " ");
  10130. client->SimpleMessage(0, " ");
  10131. if (secondary) {
  10132. client->SimpleMessage(0, "Secondary:");
  10133. client->Message(0, "Name: %s", secondary->name.c_str());
  10134. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  10135. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  10136. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  10137. client->Message(0, "Proc Percent: %d%%", 0);
  10138. client->Message(0, "Procs Per Minute: %d", 0);
  10139. client->SimpleMessage(0, " ");
  10140. client->SimpleMessage(0, " ");
  10141. }
  10142. client->SimpleMessage(0, "Ranged:");
  10143. if (ranged) {
  10144. client->Message(0, "Name: %s", ranged->name.c_str());
  10145. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  10146. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  10147. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  10148. client->Message(0, "Proc Percent: %d%%", 0);
  10149. client->Message(0, "Procs Per Minute: %d", 0);
  10150. }
  10151. else
  10152. client->SimpleMessage(0, "None");
  10153. }
  10154. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  10155. const char *channel_name;
  10156. if (sep == NULL || !sep->IsSet(0)) {
  10157. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  10158. return;
  10159. }
  10160. channel_name = sep->arg[0];
  10161. if (!chat.ChannelExists(channel_name))
  10162. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  10163. else
  10164. chat.SendChannelUserList(client, channel_name);
  10165. }
  10166. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  10167. {
  10168. ZoneServer* zone = 0;
  10169. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  10170. if (zone_id > 0)
  10171. {
  10172. zone = zone_list.Get(zone_id, false);
  10173. if (zone)
  10174. {
  10175. zone->SetSafeX(client->GetPlayer()->GetX());
  10176. zone->SetSafeY(client->GetPlayer()->GetY());
  10177. zone->SetSafeZ(client->GetPlayer()->GetZ());
  10178. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  10179. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  10180. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  10181. else
  10182. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  10183. }
  10184. }
  10185. }
  10186. /*
  10187. Function:
  10188. Purpose :
  10189. Params :
  10190. Dev :
  10191. Example :
  10192. */
  10193. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  10194. {
  10195. ZoneInfo* zone_info = new ZoneInfo;
  10196. if (sep && sep->arg[0])
  10197. {
  10198. if (sep->IsNumber(0))
  10199. zone_info->id = atoi(sep->arg[0]);
  10200. else
  10201. zone_info->id = database.GetZoneID(sep->arg[0]);
  10202. if (zone_info->id > 0)
  10203. {
  10204. database.LoadZoneInfo(zone_info);
  10205. 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);
  10206. 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);
  10207. 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);
  10208. 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);
  10209. 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);
  10210. 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);
  10211. 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);
  10212. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  10213. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  10214. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  10215. }
  10216. else
  10217. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10218. }
  10219. else
  10220. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  10221. safe_delete(zone_info);
  10222. }
  10223. /*
  10224. Function:
  10225. Purpose :
  10226. Params :
  10227. Dev :
  10228. Example :
  10229. */
  10230. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  10231. {
  10232. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  10233. {
  10234. ZoneServer* zone = 0;
  10235. int32 zone_id = 0;
  10236. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  10237. {
  10238. zone_id = atoi(sep->arg[0]);
  10239. zone = zone_list.Get(atoi(sep->arg[0]), false);
  10240. }
  10241. else
  10242. {
  10243. zone_id = database.GetZoneID(sep->arg[0]);
  10244. if (zone_id > 0)
  10245. zone = zone_list.Get(sep->arg[0], false);
  10246. }
  10247. if (zone_id > 0)
  10248. {
  10249. if (zone_set_values.count(string(sep->arg[1])) > 0)
  10250. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  10251. else
  10252. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  10253. }
  10254. else
  10255. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10256. }
  10257. else
  10258. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  10259. }
  10260. void Commands::Command_Rain(Client* client, Seperator* sep) {
  10261. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10262. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  10263. return;
  10264. }
  10265. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  10266. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  10267. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  10268. }
  10269. void Commands::Command_Wind(Client* client, Seperator* sep) {
  10270. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10271. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  10272. return;
  10273. }
  10274. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  10275. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  10276. }
  10277. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  10278. Spawn* spawn = client->GetPlayer()->GetTarget();
  10279. if(spawn) {
  10280. client->SetMerchantTransaction(spawn);
  10281. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  10282. client->SendHailCommand(spawn);
  10283. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  10284. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  10285. client->SendBuyMerchantList(sell);
  10286. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  10287. client->SendSellMerchantList(sell);
  10288. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  10289. client->SendBuyBackList(sell);
  10290. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10291. if (packet) {
  10292. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  10293. packet->setDataByName("type", 16);
  10294. EQ2Packet* outapp = packet->serialize();
  10295. if (outapp)
  10296. client->QueuePacket(outapp);
  10297. safe_delete(packet);
  10298. }
  10299. }
  10300. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  10301. client->SendRepairList();
  10302. }
  10303. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  10304. }
  10305. void Commands::Command_Weather(Client* client, Seperator* sep)
  10306. {
  10307. //PrintSep(sep, "Weather");
  10308. if( sep && sep->arg[0] )
  10309. {
  10310. ZoneServer* zsZone = client->GetCurrentZone();
  10311. const char* value = sep->arg[0];
  10312. // process single-param commands first
  10313. if( strncasecmp(value, "details", strlen(value)) == 0 )
  10314. {
  10315. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  10316. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  10317. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  10318. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  10319. }
  10320. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  10321. {
  10322. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10323. zsZone->ProcessWeather();
  10324. }
  10325. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  10326. {
  10327. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  10328. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  10329. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  10330. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  10331. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  10332. zsZone->SetWeatherPattern(1);
  10333. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  10334. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  10335. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  10336. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10337. zsZone->ProcessWeather();
  10338. }
  10339. // process commands with params
  10340. if( sep->arg[1] )
  10341. {
  10342. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  10343. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  10344. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  10345. zsZone->SetWeatherType(atoi(sep->arg[1]));
  10346. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  10347. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  10348. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  10349. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  10350. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  10351. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  10352. }
  10353. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  10354. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  10355. zsZone->SetRain(zsZone->GetCurrentWeather());
  10356. }
  10357. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  10358. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  10359. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  10360. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  10361. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10362. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  10363. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10364. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  10365. }
  10366. }
  10367. else
  10368. {
  10369. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  10370. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  10371. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  10372. return;
  10373. }
  10374. }
  10375. void Commands::Command_Select(Client* client, Seperator* sep) {
  10376. if (sep && sep->arg[1]) {
  10377. Spawn* spawn = client->GetPlayer()->GetTarget();
  10378. if (spawn && strlen(sep->arg[1]) > 0)
  10379. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  10380. }
  10381. }
  10382. /*
  10383. Function: Command_ConsumeFood()
  10384. Purpose : Consume Food/Drink and apply mods
  10385. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  10386. Dev : Zcoretri
  10387. Example : /consume_food 22
  10388. */
  10389. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  10390. if (sep && sep->arg[0] && sep->IsNumber(0))
  10391. {
  10392. Player* player = client->GetPlayer();
  10393. int8 slot = atoi(sep->arg[0]);
  10394. Item* item = player->GetEquipmentList()->GetItem(slot);
  10395. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  10396. {
  10397. client->Message(CHANNEL_NARRATIVE, "If you ate anymore you would explode!");
  10398. return;
  10399. }
  10400. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  10401. {
  10402. client->Message(CHANNEL_NARRATIVE, "If you drank anymore you would explode!");
  10403. return;
  10404. }
  10405. client->ConsumeFoodDrink(item, slot);
  10406. }
  10407. }
  10408. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  10409. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10410. if (atoi(sep->arg[0]) == 1) {
  10411. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  10412. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  10413. client->GetPlayer()->SetCharSheetChanged(true);
  10414. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  10415. }
  10416. else {
  10417. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  10418. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  10419. client->GetPlayer()->SetCharSheetChanged(true);
  10420. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  10421. }
  10422. }
  10423. else
  10424. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  10425. }
  10426. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  10427. {
  10428. if(sep)
  10429. {
  10430. string data;
  10431. if(sep->arg[0]){
  10432. data = string(sep->arg[0]);
  10433. }
  10434. for(int i=1;i<sep->GetMaxArgNum();i++){
  10435. if(sep->arg[i])
  10436. data.append(" ").append(sep->arg[i]);
  10437. }
  10438. const char* target_name = 0;
  10439. int32 spawn_id = 0;
  10440. if(client->GetPlayer()->GetTarget())
  10441. {
  10442. target_name = client->GetPlayer()->GetTarget()->GetName();
  10443. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10444. }
  10445. else
  10446. target_name = "N/A";
  10447. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  10448. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  10449. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  10450. else
  10451. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  10452. }
  10453. }
  10454. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  10455. PrintSep(sep, "Command_Attune_Inv");
  10456. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10457. // Get the item index from the first parameter
  10458. int16 index = atoi(sep->arg[0]);
  10459. // Check to see if this is a valid item index for the player, if not exit out of the function
  10460. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  10461. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  10462. return;
  10463. }
  10464. // Get the item
  10465. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  10466. if(item) {
  10467. // Valid item lets check to make sure this item is attunable, if not return out
  10468. if (!item->CheckFlag(ATTUNEABLE)) {
  10469. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  10470. return;
  10471. }
  10472. // Remove the attunable flag
  10473. item->generic_info.item_flags -= ATTUNEABLE;
  10474. // Set the attuned flag
  10475. item->generic_info.item_flags += ATTUNED;
  10476. // Flag this item for saving
  10477. item->save_needed = true;
  10478. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  10479. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  10480. EQ2Packet* outapp = 0;
  10481. for (int32 i=0;i<packets.size();i++) {
  10482. outapp = packets[i];
  10483. if(outapp)
  10484. client->QueuePacket(outapp);
  10485. }
  10486. }
  10487. }
  10488. }
  10489. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  10490. PrintSep(sep, "Command_Reset_Zone_Timer");
  10491. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10492. int32 db_id = atoul(sep->arg[0]);
  10493. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  10494. if (data) {
  10495. // TODO: add a check to timers to ensure it can be reset
  10496. // Delete the character from the instance
  10497. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  10498. data->instance_id = 0;
  10499. // Update the success time and set to 0 so the player can enter it again
  10500. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  10501. data->last_success_timestamp = 0;
  10502. }
  10503. }*/
  10504. }
  10505. void Commands::Command_Player(Client* client, Seperator* sep) {
  10506. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  10507. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  10508. }
  10509. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  10510. // /player coins add 10
  10511. // /player coins add plat 10
  10512. Player* player = client->GetPlayer();
  10513. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  10514. player = (Player*)player->GetTarget();
  10515. if (sep && sep->arg[0] && sep->arg[1]) {
  10516. const char* action = sep->arg[0];
  10517. int64 value = 0;
  10518. if (strncasecmp(action, "add", strlen(action)) == 0) {
  10519. if (sep->IsNumber(1)) {
  10520. value = atoi64(sep->arg[1]);
  10521. player->AddCoins(value);
  10522. if (client->GetPlayer() == player)
  10523. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10524. else {
  10525. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10526. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10527. }
  10528. return;
  10529. }
  10530. else if (sep->arg[2] && sep->IsNumber(2)) {
  10531. const char* type = sep->arg[1];
  10532. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  10533. value = atoi64(sep->arg[2]);
  10534. }
  10535. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  10536. value = atoi64(sep->arg[2]) * 100;
  10537. }
  10538. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  10539. value = atoi64(sep->arg[2]) * 10000;
  10540. }
  10541. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  10542. value = atoi64(sep->arg[2]) * 1000000;
  10543. }
  10544. player->AddCoins(value);
  10545. if (client->GetPlayer() == player)
  10546. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10547. else {
  10548. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10549. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10550. }
  10551. return;
  10552. }
  10553. }
  10554. }
  10555. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  10556. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  10557. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  10558. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  10559. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  10560. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  10561. }
  10562. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  10563. PrintSep(sep, "ACHIEVEMENT_ADD");
  10564. if (sep && sep->IsSet(0)) {
  10565. int32 spell_id = atoul(sep->arg[1]);
  10566. int8 spell_tier = 0;
  10567. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10568. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10569. // addspellbookentry here
  10570. if (spell_tier >= data->maxRank) {
  10571. return;
  10572. }
  10573. if (!spell_tier) {
  10574. spell_tier = 1;
  10575. }
  10576. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10577. {
  10578. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10579. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10580. client->GetPlayer()->UnlockSpell(spell);
  10581. client->SendSpellUpdate(spell);
  10582. }
  10583. else
  10584. {
  10585. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  10586. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10587. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10588. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10589. client->GetPlayer()->UnlockSpell(spell);
  10590. client->SendSpellUpdate(spell);
  10591. }
  10592. // cast spell here
  10593. if (!spell_tier)
  10594. spell_tier = 1;
  10595. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10596. if (spell) {
  10597. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10598. }
  10599. }
  10600. else {
  10601. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10602. }
  10603. master_aa_list.DisplayAA(client, 0, 0);
  10604. }
  10605. void Commands::Command_Editor(Client* client, Seperator* sep) {
  10606. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  10607. if (packet) {
  10608. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  10609. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  10610. char command[255];
  10611. url = "browser " + url;
  10612. int32 spawn_id = 0;
  10613. int32 zone_id = 0;
  10614. string type;
  10615. if (client->GetCurrentZone())
  10616. zone_id = client->GetCurrentZone()->GetZoneID();
  10617. if (client->GetPlayer()->GetTarget()) {
  10618. Spawn* target = client->GetPlayer()->GetTarget();
  10619. if (target->IsWidget())
  10620. type = "widgets";
  10621. else if (target->IsSign())
  10622. type = "signs";
  10623. else if (target->IsObject())
  10624. type = "objects";
  10625. else if (target->IsNPC())
  10626. type = "npcs";
  10627. else if (target->IsGroundSpawn())
  10628. type = "ground";
  10629. else
  10630. type = "spawn";
  10631. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10632. }
  10633. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  10634. packet->setDataByName("accept_command", command);
  10635. }
  10636. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  10637. char command[255];
  10638. url = "browser " + url;
  10639. if (client->GetPlayer()->GetTarget())
  10640. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  10641. packet->setDataByName("accept_command", command);
  10642. }
  10643. else {
  10644. string command = "browser " + url;
  10645. packet->setDataByName("accept_command", command.c_str());
  10646. }
  10647. packet->setDataByName("text", "Open the web editor?");
  10648. packet->setDataByName("accept_text", "Open");
  10649. packet->setDataByName("cancel_text", "Cancel");
  10650. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  10651. packet->setDataByName("unknown2", 50);
  10652. packet->setDataByName("unknown4", 1);
  10653. client->QueuePacket(packet->serialize());
  10654. safe_delete(packet);
  10655. }
  10656. }
  10657. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  10658. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10659. return;
  10660. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10661. if(client->GetCurrentRez()->active)
  10662. client->AcceptResurrection();
  10663. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10664. }
  10665. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  10666. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10667. return;
  10668. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10669. if(client->GetCurrentRez()->active)
  10670. client->GetCurrentRez()->should_delete = true;
  10671. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10672. }
  10673. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  10674. PrintSep(sep, "Switch_AA_Profile");
  10675. if (sep && sep->IsSet(0)) {
  10676. string type = sep->arg[0];
  10677. int8 newtemplate = atoul(sep->arg[1]);
  10678. master_aa_list.DisplayAA(client, newtemplate, 1);
  10679. }
  10680. }
  10681. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  10682. PrintSep(sep, "Get_AA_Xml");
  10683. if (sep && sep->IsSet(0)) {
  10684. string tabnum = sep->arg[0];
  10685. string spellid = sep->arg[1];
  10686. }
  10687. }
  10688. void Commands::Add_AA(Client* client, Seperator* sep) {
  10689. PrintSep(sep, "Add_AA");
  10690. if (sep && sep->IsSet(0)) {
  10691. int32 spell_id = atoul(sep->arg[1]);
  10692. int8 spell_tier = 0;
  10693. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10694. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10695. // addspellbookentry here
  10696. if(!data) {
  10697. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  10698. return;
  10699. }
  10700. if (spell_tier >= data->maxRank) {
  10701. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  10702. return;
  10703. }
  10704. if (!spell_tier) {
  10705. spell_tier = 1;
  10706. }
  10707. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10708. {
  10709. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10710. if(spell)
  10711. {
  10712. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10713. client->GetPlayer()->UnlockSpell(spell);
  10714. client->SendSpellUpdate(spell);
  10715. }
  10716. }
  10717. else
  10718. {
  10719. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10720. if(spell)
  10721. {
  10722. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10723. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10724. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10725. client->GetPlayer()->UnlockSpell(spell);
  10726. client->SendSpellUpdate(spell);
  10727. }
  10728. }
  10729. // cast spell here
  10730. if (!spell_tier)
  10731. spell_tier = 1;
  10732. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10733. if (spell) {
  10734. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10735. }
  10736. }
  10737. else {
  10738. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10739. }
  10740. master_aa_list.DisplayAA(client, 0, 0);
  10741. }
  10742. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  10743. PrintSep(sep, "Commit_AA_Profile");
  10744. if (sep && sep->IsSet(0)) {
  10745. }
  10746. }
  10747. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  10748. PrintSep(sep, "Begin_AA_Profile");
  10749. if (sep && sep->IsSet(0)) {
  10750. master_aa_list.DisplayAA(client, 100, 2);
  10751. }
  10752. }
  10753. void Commands::Back_AA(Client* client, Seperator* sep) {
  10754. if (sep && sep->IsSet(0)) {
  10755. PrintSep(sep, "Back_AA");
  10756. }
  10757. }
  10758. void Commands::Remove_AA(Client* client, Seperator* sep) {
  10759. if (sep && sep->IsSet(0)) {
  10760. PrintSep(sep, "Remove_AA");
  10761. }
  10762. }
  10763. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  10764. MasterAAList master_aa_list;
  10765. PrintSep(sep, "Cancel_AA_Profile");
  10766. master_aa_list.DisplayAA(client, 0, 0);
  10767. }
  10768. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  10769. if (sep && sep->IsSet(0)) {
  10770. PrintSep(sep, "Save_AA_Profile");
  10771. }
  10772. }
  10773. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  10774. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  10775. if (!sep->IsNumber(0)) return;
  10776. int32 request_id = atoul(sep->arg[0]);
  10777. if (!sep->IsNumber(1)) return;
  10778. sint32 item_id = atoi(sep->arg[1]);
  10779. if (client->IsCurrentTransmuteID(request_id)) {
  10780. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  10781. }
  10782. else if (client->IsCurrentTransmuteID(item_id)) {
  10783. if (!sep->IsSet(2)) return;
  10784. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  10785. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  10786. }
  10787. }
  10788. }
  10789. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  10790. if(sep)
  10791. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  10792. }
  10793. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  10794. if(sep && sep->arg[0][0] && sep->arg[1][0])
  10795. {
  10796. char* name = sep->arg[0];
  10797. char* zoneName = sep->arg[1];
  10798. char query[256];
  10799. 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);
  10800. if (database.RunQuery(query, strnlen(query, 256)))
  10801. {
  10802. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  10803. }
  10804. else
  10805. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  10806. }
  10807. }
  10808. void Commands::Command_Mood(Client* client, Seperator* sep) {
  10809. Player* player = client->GetPlayer();
  10810. if( sep && sep->arg[0] )
  10811. {
  10812. const char* value = sep->arg[0];
  10813. InfoStruct* info = player->GetInfoStruct();
  10814. int32 cid = client->GetCharacterID();
  10815. char* characterName = database.GetCharacterName(cid);
  10816. char tmp[1024]; // our emote string "xyz appears zyx"
  10817. //char properties vals
  10818. char* pname = "mood";
  10819. char* pval; // mood value
  10820. bool pt; //used to verify return from DB.
  10821. //This should never be seen.
  10822. sprintf(tmp, " ");
  10823. if( strncasecmp(value, "angry", strlen(value)) == 0 )
  10824. {
  10825. sprintf(tmp, "%s appears angry", characterName);
  10826. pval = "11852";
  10827. player->SetMoodState(11852, 1);
  10828. info->set_mood(11852);
  10829. pt = database.insertCharacterProperty(client, pname, pval);
  10830. }
  10831. else if( strncasecmp(value, "afraid", strlen(value)) == 0 )
  10832. {
  10833. sprintf(tmp, "%s appears afraid", characterName);
  10834. pval = "11851";
  10835. player->SetMoodState(11851, 1);
  10836. info->set_mood(11851);
  10837. pt = database.insertCharacterProperty(client, pname, pval);
  10838. }
  10839. else if( strncasecmp(value, "happy", strlen(value)) == 0 )
  10840. {
  10841. sprintf(tmp, "%s appears happy", characterName);
  10842. pval = "11854";
  10843. player->SetMoodState(11854, 1);
  10844. info->set_mood(11854);
  10845. pt = database.insertCharacterProperty(client, pname, pval);
  10846. }
  10847. else if( strncasecmp(value, "sad", strlen(value)) == 0 ) {
  10848. sprintf(tmp, "%s appears sad", characterName);
  10849. pval = "11856";
  10850. player->SetMoodState(11856, 1);
  10851. info->set_mood(11856);
  10852. pt = database.insertCharacterProperty(client, pname, pval);
  10853. }
  10854. else if( strncasecmp(value, "tired", strlen(value)) == 0 )
  10855. {
  10856. sprintf(tmp, "%s appears tired", characterName);
  10857. pval = "11857";
  10858. player->SetMoodState(11857, 1);
  10859. info->set_mood(11857);
  10860. pt = database.insertCharacterProperty(client, pname, pval);
  10861. }
  10862. else if( strncasecmp(value, "none", strlen(value)) == 0 )
  10863. {
  10864. //using 11855 mood_idle for none, I assume thats what its for?
  10865. pval = "11855";
  10866. player->SetMoodState(11855, 1);
  10867. info->set_mood(11855);
  10868. pt = database.insertCharacterProperty(client, pname, pval);
  10869. //return since we have nothing left to do. No emote for none.
  10870. return;
  10871. }else{
  10872. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  10873. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  10874. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  10875. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  10876. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  10877. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  10878. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  10879. return;
  10880. }
  10881. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, tmp);
  10882. return;
  10883. }
  10884. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  10885. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  10886. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  10887. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  10888. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  10889. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  10890. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  10891. return;
  10892. }
  10893. /*
  10894. Function: Command_CancelEffect()
  10895. Purpose : Cancels (good) effect spells
  10896. Example : /cancel_effect spell_id - would cancel the spell with the <spell_id> value in spell effects list
  10897. */
  10898. void Commands::Command_CancelEffect(Client* client, Seperator* sep)
  10899. {
  10900. if (sep && sep->arg[0] && sep->IsNumber(0))
  10901. {
  10902. int32 spell_id = atoul(sep->arg[0]);
  10903. SpellEffects* effect = client->GetPlayer()->GetSpellEffect(spell_id);
  10904. if(!effect || effect->spell->spell->GetSpellData()->det_type) {
  10905. return;
  10906. }
  10907. MaintainedEffects* meffect = effect->caster->GetMaintainedSpell(spell_id);
  10908. if (!meffect || !meffect->spell || !meffect->spell->caster ||
  10909. !meffect->spell->caster->GetZone()->GetSpellProcess()->DeleteCasterSpell(meffect->spell, "canceled", false, true, client->GetPlayer()))
  10910. client->Message(CHANNEL_COLOR_RED, "The spell effect could not be cancelled.");
  10911. }
  10912. }
  10913. /*
  10914. Function: Command_CurePlayer()
  10915. Purpose : Identifies spell to cast for cure based on type
  10916. Example : /cureplayer ??
  10917. https://eq2.fandom.com/wiki/Update:58
  10918. New command /cureplayer [playername|group or raid position][trauma|arcane|noxious|elemental|curse] optional [spell|potion]
  10919. Example: /cureplayer g0 noxious spell
  10920. Will attempt to cure yourself of a noxious detriment with only spells and without using potions (even if you have them).
  10921. Example: /cureplayer r4 noxious
  10922. Will attempt to cure the character in raid slot 4 of a noxious detriment using a spell or potion (whichever is available).
  10923. */
  10924. void Commands::Command_CurePlayer(Client* client, Seperator* sep)
  10925. {
  10926. Entity* target = nullptr;
  10927. bool use_spells = true;
  10928. bool use_potions = true;
  10929. if (sep && sep->arg[0] && sep->arg[1]) {
  10930. if(sep->arg[2]) {
  10931. std::string type(sep->arg[2]);
  10932. boost::algorithm::to_lower(type);
  10933. if(type == "potion")
  10934. use_spells = false;
  10935. else if(type == "spell")
  10936. use_potions = false;
  10937. }
  10938. if(strlen(sep->arg[0]) > 1 && isdigit(sep->arg[0][1])) {
  10939. int32 mapped_position = (int32)(sep->arg[0][1]) - 48;
  10940. // TODO: RAID Support ('r' argument)
  10941. if(sep->arg[0][0] == 'g' && !mapped_position) {
  10942. target = (Entity*)client->GetPlayer();
  10943. }
  10944. else {
  10945. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  10946. if (gmi && gmi->group_id) {
  10947. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  10948. if(group) {
  10949. target = group->GetGroupMemberByPosition(client->GetPlayer(), mapped_position);
  10950. }
  10951. }
  10952. }
  10953. }
  10954. else {
  10955. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  10956. if(target_client && target_client->GetPlayer() && target_client->GetPlayer()->GetZone() == client->GetPlayer()->GetZone()) {
  10957. target = (Entity*)target_client->GetPlayer();
  10958. }
  10959. }
  10960. ItemEffectType type = EFFECT_CURE_TYPE_ALL;
  10961. bool successful_spell = false;
  10962. bool successful_potion = false;
  10963. if(target) {
  10964. SpellBookEntry* entry = nullptr;
  10965. std::string str(sep->arg[1]);
  10966. boost::algorithm::to_lower(str);
  10967. if(str == "arcane") {
  10968. type = EFFECT_CURE_TYPE_ARCANE;
  10969. // cure arcane spell missing in DB?
  10970. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()) {
  10971. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()); // cure noxious
  10972. }
  10973. }
  10974. else if(str == "trauma") {
  10975. type = EFFECT_CURE_TYPE_TRAUMA;
  10976. // cure trauma spell missing in DB?
  10977. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()) {
  10978. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()); // cure noxious
  10979. }
  10980. }
  10981. else if(str == "noxious") {
  10982. type = EFFECT_CURE_TYPE_NOXIOUS;
  10983. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()) {
  10984. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()); // cure noxious
  10985. }
  10986. }
  10987. else if(str == "curse") {
  10988. type = EFFECT_CURE_TYPE_CURSE;
  10989. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()) {
  10990. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()); // cure curse
  10991. }
  10992. }
  10993. else if(str == "magic") {
  10994. type = EFFECT_CURE_TYPE_MAGIC;
  10995. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()) {
  10996. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()); // cure magic
  10997. }
  10998. }
  10999. if(use_spells) {
  11000. // check if any of the specific cure types are available, if not then check the base cures
  11001. if(!entry && rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()) {
  11002. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()); // cure
  11003. }
  11004. if(entry) {
  11005. Spell* spell = master_spell_list.GetSpell(entry->spell_id, entry->tier);
  11006. target->GetZone()->ProcessSpell(spell, (Entity*)client->GetPlayer(), target, true, false);
  11007. successful_spell = true;
  11008. }
  11009. }
  11010. }
  11011. if(!successful_spell && use_potions && target && type != NO_EFFECT_TYPE) {
  11012. vector<Item*>* potential_items = client->GetItemsByEffectType(type, EFFECT_CURE_TYPE_ALL);
  11013. if (potential_items && potential_items->size() > 0) {
  11014. vector<Item*>::iterator itr;
  11015. for (itr = potential_items->begin(); itr != potential_items->end(); itr++)
  11016. {
  11017. Item* item = *itr;
  11018. if(client->UseItem(item, target)) {
  11019. successful_potion = true;
  11020. break;
  11021. }
  11022. }
  11023. }
  11024. safe_delete(potential_items);
  11025. }
  11026. }
  11027. }